From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjNOx-0001vw-AY for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjNOv-0002pm-10 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjNOu-0002pe-PU for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 6CCF685546 for ; Mon, 12 Sep 2016 09:19:40 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 12 Sep 2016 13:19:02 +0400 Message-Id: <20160912091913.15831-8-marcandre.lureau@redhat.com> In-Reply-To: <20160912091913.15831-1-marcandre.lureau@redhat.com> References: <20160912091913.15831-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 v6 07/18] qmp: Hack to keep commands configuration-specific List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= We currently define QMP commands in two places: the QAPI schema and qmp-commands.hx. The latter is preprocessed, the former is not. We use the preprocessor to suppress configuration-specific commands. For instance, query-spice is only available #ifdef CONFIG_SPICE. QMP command dispatch and query-commands use the qmp-commands.hx definition, and thus obey the #ifdeffery there. Good, because it lets QMP clients probe for available features more easily. query-qmp-schema uses the QAPI schema, and thus lists the configuration-specific commands even when they're unavailable. Not so good. We're about to flip command dispatch and query-commands to the non-middle-mode command registry, which uses the QAPI schema, so we can ditch qmp-commands.hx. To avoid regressing query-commands, arrange for commands that are suppressed with the preprocessor now to be unregistered with that registry. This will keep them unavailable and out of query-commands when we flip command dispatch and query-commands to that registry, exactly as before. This is a hack. The proper solution is to support configuration-specific commands in the QAPI schema. Mark it FIXME. Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Markus Armbruster --- monitor.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/monitor.c b/monitor.c index b7ae552..18d37f7 100644 --- a/monitor.c +++ b/monitor.c @@ -1008,6 +1008,38 @@ static void qmp_query_qmp_schema(QDict *qdict, QOb= ject **ret_data, *ret_data =3D qobject_from_json(qmp_schema_json); } =20 +/* + * Note: right now, this function is never called. It will be called + * shortly when we stop using QAPI 'middle mode'. The rest of this + * comment is written as if that was the case already. + * + * We used to define commands in qmp-commands.hx in addition to the + * QAPI schema. This permitted defining some of them only in certain + * configurations. query-commands has always reflected that (good, + * because it lets QMP clients figure out what's actually available), + * while query-qmp-schema never did (not so good). This function is a + * hack to keep the configuration-specific commands defined exactly as + * before, even though qmp-commands.hx is gone. + * + * FIXME Educate the QAPI schema on configuration-specific commands, + * and drop this hack. + */ +static void qmp_unregister_commands_hack(void) +{ +#ifndef CONFIG_SPICE + qmp_unregister_command("query-spice"); +#endif +#ifndef TARGET_I386 + qmp_unregister_command("rtc-reset-reinjection"); +#endif +#ifndef TARGET_S390X + qmp_unregister_command("dump-skeys"); +#endif +#ifndef TARGET_ARM + qmp_unregister_command("query-gic-capabilities"); +#endif +} + static void qmp_init_marshal(void) { qmp_register_command("query-qmp-schema", qmp_query_qmp_schema, @@ -1016,6 +1048,9 @@ static void qmp_init_marshal(void) QCO_NO_OPTIONS); qmp_register_command("netdev_add", qmp_netdev_add, QCO_NO_OPTIONS); + + /* call it after the rest of qapi_init() */ + register_module_init(qmp_unregister_commands_hack, MODULE_INIT_QAPI)= ; } =20 qapi_init(qmp_init_marshal); --=20 2.10.0