Commit 9e812b6a authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Markus Armbruster
Browse files

monitor: implement 'qmp_query_commands' without qmp_cmds



One step towards getting rid of the static qmp_cmds table.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <20160912091913.15831-11-marcandre.lureau@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent c823501e
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -957,21 +957,28 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)
    help_cmd(mon, "info");
}

CommandInfoList *qmp_query_commands(Error **errp)
static void query_commands_cb(QmpCommand *cmd, void *opaque)
{
    CommandInfoList *info, *cmd_list = NULL;
    const mon_cmd_t *cmd;
    CommandInfoList *info, **list = opaque;

    if (!cmd->enabled) {
        return;
    }

    for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
    info = g_malloc0(sizeof(*info));
    info->value = g_malloc0(sizeof(*info->value));
    info->value->name = g_strdup(cmd->name);

        info->next = cmd_list;
        cmd_list = info;
    info->next = *list;
    *list = info;
}

    return cmd_list;
CommandInfoList *qmp_query_commands(Error **errp)
{
    CommandInfoList *list = NULL;

    qmp_for_each_command(query_commands_cb, &list);

    return list;
}

EventInfoList *qmp_query_events(Error **errp)