]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi: Fix QemuOpts visitor regression on unvisited input
authorEric Blake <eblake@redhat.com>
Wed, 22 Mar 2017 14:45:25 +0000 (09:45 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 30 Mar 2017 17:35:02 +0000 (12:35 -0500)
An off-by-one in commit 15c2f669e meant that we were failing to
check for unparsed input in all QemuOpts visitors.  Recent testsuite
additions show that fixing the obvious bug with bogus fields will
also fix the case of an incomplete list visit; update the tests to
match the new behavior.

Simple testcase:

./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio -numa node,size=1g

failed to diagnose that 'size' is not a valid argument to -numa, and
now once again reports:

qemu-system-x86_64: -numa node,size=1g: Invalid parameter 'size'

See also https://bugzilla.redhat.com/show_bug.cgi?id=1434666

CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20170322144525.18964-4-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
(cherry picked from commit 21f88d021d0d2b4ecee8f6cd6ca63a943a3ce71d)
 Conflicts:
qapi/opts-visitor.c
tests/test-opts-visitor.c
 * drop changes related to 9cb8ef36 and a9416dc6 tests
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qapi/opts-visitor.c
tests/test-opts-visitor.c

index 1048bbc84e1232c1615d002d5cc28704108a2922..1453cf6de03c2cb0c77613c6f80bf56bc66f8bd5 100644 (file)
@@ -164,7 +164,7 @@ opts_check_struct(Visitor *v, Error **errp)
     GHashTableIter iter;
     GQueue *any;
 
-    if (ov->depth > 0) {
+    if (ov->depth > 1) {
         return;
     }
 
index 8befe8291860ce0cbc3e783cec422007b0615cc0..2886a722e4b2fee19631cb18822a1fdbe480064d 100644 (file)
@@ -175,6 +175,7 @@ expect_u64_max(OptsVisitorFixture *f, gconstpointer test_data)
 static void
 test_opts_dict_unvisited(void)
 {
+    Error *err = NULL;
     QemuOpts *opts;
     Visitor *v;
     UserDefOptions *userdef;
@@ -183,11 +184,11 @@ test_opts_dict_unvisited(void)
                            &error_abort);
 
     v = opts_visitor_new(opts);
-    /* BUG: bogus should be diagnosed */
-    visit_type_UserDefOptions(v, NULL, &userdef, &error_abort);
+    visit_type_UserDefOptions(v, NULL, &userdef, &err);
+    error_free_or_abort(&err);
     visit_free(v);
     qemu_opts_del(opts);
-    qapi_free_UserDefOptions(userdef);
+    g_assert(!userdef);
 }
 
 int