qapi: Support multiple command registries per program

The command registry encapsulates a single command list.  Give the
functions using it a parameter instead.  Define suitable command lists
in monitor, guest agent and test-qmp-commands.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1488544368-30622-6-git-send-email-armbru@redhat.com>
[Debugging turds buried]
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Markus Armbruster 2017-03-03 13:32:25 +01:00
parent 0587568780
commit 1527badb95
9 changed files with 84 additions and 66 deletions

View file

@ -8,6 +8,8 @@
#include "tests/test-qapi-types.h"
#include "tests/test-qapi-visit.h"
static QmpCommandList qmp_commands;
void qmp_user_def_cmd(Error **errp)
{
}
@ -94,7 +96,7 @@ static void test_dispatch_cmd(void)
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));
resp = qmp_dispatch(QOBJECT(req));
resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp != NULL);
assert(!qdict_haskey(qobject_to_qdict(resp), "error"));
@ -111,7 +113,7 @@ static void test_dispatch_cmd_failure(void)
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
resp = qmp_dispatch(QOBJECT(req));
resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp != NULL);
assert(qdict_haskey(qobject_to_qdict(resp), "error"));
@ -125,7 +127,7 @@ static void test_dispatch_cmd_failure(void)
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));
resp = qmp_dispatch(QOBJECT(req));
resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp != NULL);
assert(qdict_haskey(qobject_to_qdict(resp), "error"));
@ -139,7 +141,7 @@ static QObject *test_qmp_dispatch(QDict *req)
QDict *resp;
QObject *ret;
resp_obj = qmp_dispatch(QOBJECT(req));
resp_obj = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp_obj);
resp = qobject_to_qdict(resp_obj);
assert(resp && !qdict_haskey(resp, "error"));
@ -273,7 +275,7 @@ int main(int argc, char **argv)
g_test_add_func("/0.15/dealloc_types", test_dealloc_types);
g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial);
qmp_init_marshal();
test_qmp_init_marshal(&qmp_commands);
g_test_run();
return 0;