Received: from eggs.gnu.org ([2001:4830:134:3::10]:56490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWoN-0002Uo-KH for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btWoL-0003R7-L5 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWoL-0003Qq-EZ for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:53 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0730922028 for ; Mon, 10 Oct 2016 09:23:53 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 10 Oct 2016 13:22:50 +0400 Message-Id: <20161010092301.14974-14-marcandre.lureau@redhat.com> In-Reply-To: <20161010092301.14974-1-marcandre.lureau@redhat.com> References: <20161010092301.14974-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 13/24] monitor: add 'async' capability List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, berrange@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Declare that the server supports async. Check if the client supports it: the following patch will suspend the qmp monitor if an async command is ongoing. Signed-off-by: Marc-Andr=C3=A9 Lureau --- monitor.c | 20 +++++++++++++++++--- qapi-schema.json | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/monitor.c b/monitor.c index d7baa86..4a20d81 100644 --- a/monitor.c +++ b/monitor.c @@ -173,6 +173,7 @@ typedef struct { * mode. */ bool in_command_mode; /* are we in command mode? */ + bool has_async; /* the client has async capability */ QmpClient client; } MonitorQMP; =20 @@ -570,9 +571,22 @@ static void monitor_qapi_event_init(void) qmp_event_set_func_emit(monitor_qapi_event_queue); } =20 -void qmp_qmp_capabilities(Error **errp) +void qmp_qmp_capabilities(bool has_capabilities, + QMPCapabilityList *capabilities, Error **errp) { + bool has_async =3D false; + + if (has_capabilities) { + while (capabilities) { + if (capabilities->value =3D=3D QMP_CAPABILITY_ASYNC) { + has_async =3D true; + } + capabilities =3D capabilities->next; + } + } + cur_mon->qmp.in_command_mode =3D true; + cur_mon->qmp.has_async =3D has_async; } =20 static void handle_hmp_command(Monitor *mon, const char *cmdline); @@ -3852,8 +3866,8 @@ static QObject *get_qmp_greeting(void) =20 qmp_marshal_query_version(NULL, &ver, NULL); =20 - return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': [= ]}}", - ver); + return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': [= " + "'async']}}", ver); } =20 static void monitor_qmp_event(void *opaque, int event) diff --git a/qapi-schema.json b/qapi-schema.json index 93b2929..95d3c72 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -37,7 +37,7 @@ # # Enable QMP capabilities. # -# Arguments: None. +# @capabilities: #optional an array of QMPCapability (since 2.8) # # Example: # @@ -51,7 +51,7 @@ # Since: 0.13 # ## -{ 'command': 'qmp_capabilities' } +{ 'command': 'qmp_capabilities', 'data': { '*capabilities': ['QMPCapabil= ity'] } } =20 ## # @LostTickPolicy: --=20 2.10.0