a0067da157
The generated marshal functions do not visit arguments from commands that take no arguments. Thus they fail to catch invalid members. Visit the arguments, if provided, to throw an error in case of invalid members. Currently, qmp_check_client_args() checks for invalid arguments and correctly catches this case. When switching to qmp_dispatch() we want to keep that behaviour. The commands using 'O' may have arbitrary arguments, and must have 'gen': false in the qapi schema to skip the generated checks. Old/new diff: void qmp_marshal_stop(QDict *args, QObject **ret, Error **errp) { Error *err = NULL; + Visitor *v = NULL; - (void)args; + if (args) { + v = qmp_input_visitor_new(QOBJECT(args), true); + visit_start_struct(v, NULL, NULL, 0, &err); + if (err) { + goto out; + } + + if (!err) { + visit_check_struct(v, &err); + } + visit_end_struct(v, NULL); + if (err) { + goto out; + } + } qmp_stop(&err); + +out: error_propagate(errp, err); + visit_free(v); + if (args) { + v = qapi_dealloc_visitor_new(); + visit_start_struct(v, NULL, NULL, 0, NULL); + + visit_end_struct(v, NULL); + visit_free(v); + } } The new code closely resembles code for a command with arguments. Differences: - the visit of the argument and its cleanup struct don't visit any members (because there are none). - the visit of the argument struct and its cleanup are conditional. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20160912091913.15831-14-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> |
||
---|---|---|
.. | ||
coccinelle | ||
kvm | ||
qemu-guest-agent | ||
qemugdb | ||
qmp | ||
tracetool | ||
analyse-9p-simpletrace.py | ||
analyze-inclusions | ||
analyze-migration.py | ||
check-qerror.sh | ||
checkpatch.pl | ||
clean-header-guards.pl | ||
clean-includes | ||
cleanup-trace-events.pl | ||
cocci-macro-file.h | ||
coverity-model.c | ||
create_config | ||
disas-objdump.pl | ||
dump-guest-memory.py | ||
extract-vsssdk-headers | ||
feature_to_c.sh | ||
get_maintainer.pl | ||
gtester-cat | ||
hxtool | ||
make_device_config.sh | ||
make-release | ||
ordereddict.py | ||
qapi-commands.py | ||
qapi-event.py | ||
qapi-introspect.py | ||
qapi-types.py | ||
qapi-visit.py | ||
qapi.py | ||
qemu-binfmt-conf.sh | ||
qemu-gdb.py | ||
qemu.py | ||
qtest.py | ||
refresh-pxe-roms.sh | ||
shaderinclude.pl | ||
signrom.py | ||
simpletrace.py | ||
switch-timer-api | ||
texi2pod.pl | ||
tracetool.py | ||
update-linux-headers.sh | ||
vmstate-static-checker.py |