Received: from eggs.gnu.org ([2001:4830:134:3::10]:40826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba4Ax-0005g0-KK for qemu-devel@nongnu.org; Wed, 17 Aug 2016 12:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ba4Aw-0002c3-N1 for qemu-devel@nongnu.org; Wed, 17 Aug 2016 12:58:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba4Aw-0002br-HT for qemu-devel@nongnu.org; Wed, 17 Aug 2016 12:58:46 -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 0FA4C85547 for ; Wed, 17 Aug 2016 16:58:46 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 17 Aug 2016 20:57:50 +0400 Message-Id: <20160817165757.23486-14-marcandre.lureau@redhat.com> In-Reply-To: <20160817165757.23486-1-marcandre.lureau@redhat.com> References: <20160817165757.23486-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 v5 13/20] monitor: implement 'qmp_query_commands' without qmp_cmds 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?= One step towards getting rid of the static qmp_cmds table. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- monitor.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/monitor.c b/monitor.c index e72804a..dad49b6 100644 --- a/monitor.c +++ b/monitor.c @@ -957,21 +957,28 @@ static void hmp_info_help(Monitor *mon, const QDict= *qdict) help_cmd(mon, "info"); } =20 -CommandInfoList *qmp_query_commands(Error **errp) +static void query_commands_cb(QmpCommand *cmd, void *opaque) { - CommandInfoList *info, *cmd_list =3D NULL; - const mon_cmd_t *cmd; - - for (cmd =3D qmp_cmds; cmd->name !=3D NULL; cmd++) { - info =3D g_malloc0(sizeof(*info)); - info->value =3D g_malloc0(sizeof(*info->value)); - info->value->name =3D g_strdup(cmd->name); + CommandInfoList *info, **list =3D opaque; =20 - info->next =3D cmd_list; - cmd_list =3D info; + if (!cmd->enabled) { + return; } =20 - return cmd_list; + info =3D g_malloc0(sizeof(*info)); + info->value =3D g_malloc0(sizeof(*info->value)); + info->value->name =3D g_strdup(cmd->name); + info->next =3D *list; + *list =3D info; +} + +CommandInfoList *qmp_query_commands(Error **errp) +{ + CommandInfoList *list =3D NULL; + + qmp_for_each_command(query_commands_cb, &list); + + return list; } =20 EventInfoList *qmp_query_events(Error **errp) --=20 2.9.0