Received: from eggs.gnu.org ([2001:4830:134:3::10]:41615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVckF-0006LP-UF for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVckD-0007Kd-Sl for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:52:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVckD-0007KS-KY for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:52:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 F1F9CC05678E for ; Fri, 5 Aug 2016 10:52:48 +0000 (UTC) From: Markus Armbruster References: <20160721140030.28383-1-marcandre.lureau@redhat.com> <20160721140030.28383-2-marcandre.lureau@redhat.com> Date: Fri, 05 Aug 2016 12:52:46 +0200 In-Reply-To: <20160721140030.28383-2-marcandre.lureau@redhat.com> (marcandre lureau's message of "Thu, 21 Jul 2016 18:00:19 +0400") Message-ID: <87lh0b32td.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 01/12] qapi-schema: use generated marshaller for 'qmp_capabilities' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com Cc: qemu-devel@nongnu.org marcandre.lureau@redhat.com writes: > From: Marc-Andr=C3=A9 Lureau > > qapi'fy the 'qmp_capabilities' command. > > Signed-off-by: Marc-Andr=C3=A9 Lureau > Reviewed-by: Eric Blake > --- > monitor.c | 4 ++-- > qapi-schema.json | 21 +++++++++++++++++++++ > qmp-commands.hx | 2 +- > 3 files changed, 24 insertions(+), 3 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 5d68a5d..cb1a0c7 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -617,7 +617,7 @@ static void monitor_qapi_event_init(void) > qmp_event_set_func_emit(monitor_qapi_event_queue); > } >=20=20 > -static void qmp_capabilities(QDict *params, QObject **ret_data, Error **= errp) > +void qmp_qmp_capabilities(Error **errp) > { > cur_mon->qmp.in_command_mode =3D true; > } > @@ -3649,7 +3649,7 @@ static int monitor_can_read(void *opaque) > static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd, > Error **errp) > { > - bool is_cap =3D cmd->mhandler.cmd_new =3D=3D qmp_capabilities; > + bool is_cap =3D cmd->mhandler.cmd_new =3D=3D qmp_marshal_qmp_capabil= ities; >=20=20 > if (is_cap && mon->qmp.in_command_mode) { > error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, > diff --git a/qapi-schema.json b/qapi-schema.json > index 5658723..03c15d8 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -20,6 +20,27 @@ > # QAPI introspection > { 'include': 'qapi/introspect.json' } >=20=20 > +## > +# @qmp_capabilities: > +# > +# Enable QMP capabilities. > +# > +# Arguments: None. > +# > +# Example: > +# > +# -> { "execute": "qmp_capabilities" } > +# <- { "return": {} } > +# > +# Notes: This command is valid exactly when first connecting: it must be > +# issued before any other command will be accepted, and will fail once t= he > +# monitor is accepting other commands. Pointer to docs/qmp-spec.txt wouldn't hurt. > +# > +# Since: 0.13 > +# > +## > +{ 'command': 'qmp_capabilities' } > + > ## > # @LostTickPolicy: > # > diff --git a/qmp-commands.hx b/qmp-commands.hx > index c8d360a..13707ac 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -2209,7 +2209,7 @@ EQMP > .args_type =3D "", > .params =3D "", > .help =3D "enable QMP capabilities", > - .mhandler.cmd_new =3D qmp_capabilities, > + .mhandler.cmd_new =3D qmp_marshal_qmp_capabilities, > }, >=20=20 > SQMP According to docs/qmp-spec.txt section 4, the command is for negotiating capabilities: Clients should use the qmp_capabilities command to enable capabilities advertised in the Server's greeting (section '2.2 Server Greeting') they support. It neglects to specify how that might be done, though. Section 2.2 specifies the greeting's member "capabilities" as json-array, without saying anything about its members. Section 2.2.1 seems to imply the members are strings, which makes some sense. To actually support capabilities negotiation, the command needs an argument matching the greeting's capabilities array. The argument must be optional, defaulting to the empty array. No need to add that now. Clarifying the docs would be nice, but it's not this patch's job. Reviewed-by: Markus Armbruster