From nobody Mon Feb 9 02:07:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1665129815; cv=none; d=zohomail.com; s=zohoarc; b=MGBZ11oPmdy0LqNcXY+ew/I1pWwcJXa6O9kilndV2uXc7/X+qJCeLt4YgTvUnL9IPTqh5Oxoic6FLm3UW8Sg4pYJMmg75Y5JOcxkvJXVla3iOy7AZ9+LV8CDvUyFnsj/oDZAmWL1akJ2TYVH4iGceCBLd3y1oTtXY8mCbaD7nyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665129815; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Q5oo2EE1aR6vAJpWUcWBc+5YaEwUZ1JDqmWGdrHM6Os=; b=VnyXhIZsnjfOsEqJuLXspIORexIcais3atV/SzprbFA02Kj/GHYHJBsXXyF4zaBheFbZHhK2oqIJxgNH006B9dhGEUE+SIQCKCmfhqVTzSt7+9NFWNpqLINzWEerVSbqN9KmS4TTYZE+SQuxRM5bDozmFP3eZsatU2oaRTGBiAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665129814804602.5115106995731; Fri, 7 Oct 2022 01:03:34 -0700 (PDT) Received: from localhost ([::1]:39034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogiKT-0005pU-2g for importer@patchew.org; Fri, 07 Oct 2022 04:03:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogiHA-0004v2-6j for qemu-devel@nongnu.org; Fri, 07 Oct 2022 04:00:09 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]:34650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogiGy-0004Yt-5c for qemu-devel@nongnu.org; Fri, 07 Oct 2022 03:59:59 -0400 Received: from iva4-f06c35e68a0a.qloud-c.yandex.net (iva4-f06c35e68a0a.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:152e:0:640:f06c:35e6]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id F1D0460038; Fri, 7 Oct 2022 10:52:16 +0300 (MSK) Received: from den-plotnikov-w.yandex-team.ru (unknown [2a02:6b8:b081:16::1:1f]) by iva4-f06c35e68a0a.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 9pXW8lgM7E-qFOesB7T; Fri, 07 Oct 2022 10:52:15 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1665129136; bh=Q5oo2EE1aR6vAJpWUcWBc+5YaEwUZ1JDqmWGdrHM6Os=; h=Message-Id:Date:Cc:Subject:To:From; b=aLJEdeHo9uCQDBNDqLaCN9N5dbqN5PjcncQecKRZZTpk+oNI7246w6zCGO0decMUL C6o3uKHGXSWwdgCNfFx6xbOsZwosPzp0XVLrkNk0Ryctz4uOwx1xHyMo4/dxSJvZ5P YRkllPrSoUOv9o/+CQtb0nd+Gd5eiljBAbCMFx00= Authentication-Results: iva4-f06c35e68a0a.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Denis Plotnikov To: qemu-devel@nongnu.org Cc: yc-core@yandex-team.ru, armbru@redhat.com, michael.roth@amd.com, vsementsov@yandex-team.ru Subject: [PATCH v1] qapi/qmp: Add timestamps to qmp command responses Date: Fri, 7 Oct 2022 10:52:08 +0300 Message-Id: <20221007075208.175614-1-den-plotnikov@yandex-team.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.200; envelope-from=den-plotnikov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1665129817133100001 Content-Type: text/plain; charset="utf-8" Add "start" & "end" time values to qmp command responses. These time values are added to let the qemu management layer get the exact command execution time without any other time variance which might be broug= ht by other parts of management layer or qemu internals. This is particulary usef= ul for the management layer logging for later problems resolving. Example of result: ./qemu/scripts/qmp/qmp-shell /tmp/qmp.socket (QEMU) query-status {"end": {"seconds": 1650367305, "microseconds": 831032}, "start": {"seconds": 1650367305, "microseconds": 831012}, "return": {"status": "running", "singlestep": false, "running": true}} The responce of the qmp command contains the start & end time of the qmp command processing. Suggested-by: Andrey Ryabinin Signed-off-by: Denis Plotnikov --- v0->v1: - remove interface to control "start" and "end" time values: return timest= amps unconditionally - add description to qmp specification - leave the same timestamp format in "seconds", "microseconds" to be consi= stent with events timestamp - fix patch description docs/interop/qmp-spec.txt | 20 ++++++++++++++++++-- qapi/qmp-dispatch.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/interop/qmp-spec.txt b/docs/interop/qmp-spec.txt index b0e8351d5b261..d1cca8bc447ce 100644 --- a/docs/interop/qmp-spec.txt +++ b/docs/interop/qmp-spec.txt @@ -158,7 +158,9 @@ responses that have an unknown "id" field. =20 The format of a success response is: =20 -{ "return": json-value, "id": json-value } +{ "return": json-value, "id": json-value, + "start": {"seconds": json-value, "microseconds": json-value}, + "end": {"seconds": json-value, "microseconds": json-value} } =20 Where, =20 @@ -169,13 +171,21 @@ The format of a success response is: command does not return data - The "id" member contains the transaction identification associated with the command execution if issued by the Client +- The "start" member contains the exact time of when the command has been + stated to be processed. It is a fixed json-object with time in + seconds and microseconds relative to the Unix Epoch (1 Jan 1970) +- The "end" member contains the exact time of when the command has been + finished to be processed. It is a fixed json-object with time in + seconds and microseconds relative to the Unix Epoch (1 Jan 1970) =20 2.4.2 error ----------- =20 The format of an error response is: =20 -{ "error": { "class": json-string, "desc": json-string }, "id": json-value= } +{ "error": { "class": json-string, "desc": json-string }, "id": json-value + "start": {"seconds": json-value, "microseconds": json-value}, + "end": {"seconds": json-value, "microseconds": json-value} } =20 Where, =20 @@ -184,6 +194,12 @@ The format of an error response is: not attempt to parse this message. - The "id" member contains the transaction identification associated with the command execution if issued by the Client +- The "start" member contains the exact time of when the command has been + stated to be processed. It is a fixed json-object with time in + seconds and microseconds relative to the Unix Epoch (1 Jan 1970) +- The "end" member contains the exact time of when the command has been + finished to be processed. It is a fixed json-object with time in + seconds and microseconds relative to the Unix Epoch (1 Jan 1970) =20 NOTE: Some errors can occur before the Server is able to read the "id" mem= ber, in these cases the "id" member will not be part of the error response, even diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 0990873ec8ec1..fce87416f2128 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -130,6 +130,22 @@ static void do_qmp_dispatch_bh(void *opaque) aio_co_wake(data->co); } =20 +static void add_timestamps(QDict *qdict, uint64_t start_ms, uint64_t end_m= s) +{ + QDict *start_dict, *end_dict; + + start_dict =3D qdict_new(); + qdict_put_int(start_dict, "seconds", start_ms / G_USEC_PER_SEC); + qdict_put_int(start_dict, "microseconds", start_ms % G_USEC_PER_SEC); + + end_dict =3D qdict_new(); + qdict_put_int(end_dict, "seconds", end_ms / G_USEC_PER_SEC); + qdict_put_int(end_dict, "microseconds", end_ms % G_USEC_PER_SEC); + + qdict_put_obj(qdict, "start", QOBJECT(start_dict)); + qdict_put_obj(qdict, "end", QOBJECT(end_dict)); +} + /* * Runs outside of coroutine context for OOB commands, but in coroutine * context for everything else. @@ -146,6 +162,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject= *request, QObject *id; QObject *ret =3D NULL; QDict *rsp =3D NULL; + uint64_t ts_start =3D g_get_real_time(); =20 dict =3D qobject_to(QDict, request); if (!dict) { @@ -270,5 +287,6 @@ out: qdict_put_obj(rsp, "id", qobject_ref(id)); } =20 + add_timestamps(rsp, ts_start, g_get_real_time()); return rsp; } --=20 2.25.1