From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1dZ-0006K4-S9 for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bm1dX-0008NQ-Ni for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1dX-0008My-H8 for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:43 -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 0B28731B30F for ; Mon, 19 Sep 2016 16:41:43 +0000 (UTC) From: Markus Armbruster Date: Mon, 19 Sep 2016 18:41:26 +0200 Message-Id: <1474303294-13952-11-git-send-email-armbru@redhat.com> In-Reply-To: <1474303294-13952-1-git-send-email-armbru@redhat.com> References: <1474303294-13952-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 10/18] 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau One step towards getting rid of the static qmp_cmds table. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Message-Id: <20160912091913.15831-11-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- monitor.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/monitor.c b/monitor.c index 6e0ae81..f50aa6e 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 +static void query_commands_cb(QmpCommand *cmd, void *opaque) +{ + CommandInfoList *info, **list =3D opaque; + + if (!cmd->enabled) { + return; + } + + 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 *info, *cmd_list =3D NULL; - const mon_cmd_t *cmd; + CommandInfoList *list =3D NULL; =20 - 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); + qmp_for_each_command(query_commands_cb, &list); =20 - info->next =3D cmd_list; - cmd_list =3D info; - } - - return cmd_list; + return list; } =20 EventInfoList *qmp_query_events(Error **errp) --=20 2.5.5