qemu-e2k/scripts
Marc-André Lureau a0067da157 qapi: check invalid arguments on no-args commands
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>
2016-09-19 17:32:22 +02:00
..
coccinelle coccinelle: add a script to remove useless casts 2016-09-15 15:32:22 +03:00
kvm vmxcap: Add TSC scaling bit 2016-09-13 19:08:46 +02:00
qemu-guest-agent
qemugdb
qmp scripts: ensure monitor socket has SO_REUSEADDR set 2016-07-22 13:23:35 +05:30
tracetool trace: add syslog tracing backend 2016-09-05 13:47:01 -04:00
analyse-9p-simpletrace.py
analyze-inclusions
analyze-migration.py
check-qerror.sh
checkpatch.pl checkpatch: Fix whitespace checks for documentation code blocks 2016-09-13 19:09:44 +02:00
clean-header-guards.pl scripts: New clean-header-guards.pl 2016-07-12 16:19:16 +02:00
clean-includes os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
cleanup-trace-events.pl
cocci-macro-file.h
coverity-model.c
create_config build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} 2016-09-19 17:32:21 +02:00
disas-objdump.pl
dump-guest-memory.py exec: hide mr->ram_addr from qemu_get_ram_ptr users 2016-05-29 09:11:12 +02:00
extract-vsssdk-headers
feature_to_c.sh scripts: Use $(..) instead of deprecated .. 2016-06-07 18:19:23 +03:00
get_maintainer.pl
gtester-cat
hxtool
make_device_config.sh scripts: Use $(..) instead of deprecated .. 2016-06-07 18:19:23 +03:00
make-release
ordereddict.py
qapi-commands.py qapi: check invalid arguments on no-args commands 2016-09-19 17:32:22 +02:00
qapi-event.py qapi: Implement boxed types for commands/events 2016-07-19 13:21:08 +02:00
qapi-introspect.py qapi: Plumb in 'boxed' to qapi generator lower levels 2016-07-19 13:21:08 +02:00
qapi-types.py qapi: Add type.is_empty() helper 2016-07-19 13:21:08 +02:00
qapi-visit.py qapi: Drop useless gen_err_check() 2016-07-19 13:21:08 +02:00
qapi.py qapi: Implement boxed types for commands/events 2016-07-19 13:21:08 +02:00
qemu-binfmt-conf.sh scripts: Use $(..) instead of deprecated .. 2016-06-07 18:19:23 +03:00
qemu-gdb.py
qemu.py iotest: fix python based IO tests 2016-07-26 18:28:40 +02:00
qtest.py iotest: fix python based IO tests 2016-07-26 18:28:40 +02:00
refresh-pxe-roms.sh
shaderinclude.pl
signrom.py linuxboot_dma: avoid guest ABI breakage on gcc vs. clang compilation 2016-08-09 22:57:36 +02:00
simpletrace.py
switch-timer-api
texi2pod.pl
tracetool.py
update-linux-headers.sh scripts: Use $(..) instead of deprecated .. 2016-06-07 18:19:23 +03:00
vmstate-static-checker.py vmstate-static-checker: fix size mismatch detection in unused fields 2016-06-17 18:24:33 +05:30