qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eric Blake <eblake@redhat.com>, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PULL for-2.9 17/17] qapi: Fix QemuOpts visitor regression on unvisited input
Date: Wed, 22 Mar 2017 17:05:48 +0100	[thread overview]
Message-ID: <1490198748-4753-18-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1490198748-4753-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

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>
---
 qapi/opts-visitor.c       |  6 +++---
 tests/test-opts-visitor.c | 13 ++++++++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 026d25b..324b197 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -164,7 +164,7 @@ opts_check_struct(Visitor *v, Error **errp)
     GHashTableIter iter;
     GQueue *any;
 
-    if (ov->depth > 0) {
+    if (ov->depth > 1) {
         return;
     }
 
@@ -276,8 +276,8 @@ static void
 opts_check_list(Visitor *v, Error **errp)
 {
     /*
-     * FIXME should set error when unvisited elements remain.  Mostly
-     * harmless, as the generated visits always visit all elements.
+     * Unvisited list elements will be reported later when checking
+     * whether unvisited struct members remain.
      */
 }
 
diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c
index 8e0dda5..23e8970 100644
--- a/tests/test-opts-visitor.c
+++ b/tests/test-opts-visitor.c
@@ -175,6 +175,7 @@ expect_u64_max(OptsVisitorFixture *f, gconstpointer test_data)
 static void
 test_opts_range_unvisited(void)
 {
+    Error *err = NULL;
     intList *list = NULL;
     intList *tail;
     QemuOpts *opts;
@@ -199,10 +200,11 @@ test_opts_range_unvisited(void)
     g_assert_cmpint(tail->value, ==, 1);
     tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
     g_assert(tail);
-    visit_check_list(v, &error_abort); /* BUG: unvisited tail not reported */
+    visit_check_list(v, &error_abort); /* unvisited tail ignored until... */
     visit_end_list(v, (void **)&list);
 
-    visit_check_struct(v, &error_abort);
+    visit_check_struct(v, &err); /* ...here */
+    error_free_or_abort(&err);
     visit_end_struct(v, NULL);
 
     qapi_free_intList(list);
@@ -250,6 +252,7 @@ test_opts_range_beyond(void)
 static void
 test_opts_dict_unvisited(void)
 {
+    Error *err = NULL;
     QemuOpts *opts;
     Visitor *v;
     UserDefOptions *userdef;
@@ -258,11 +261,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
-- 
2.7.4

      parent reply	other threads:[~2017-03-22 16:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 16:05 [Qemu-devel] [PULL for-2.9 00/17] QAPI patches for 2017-03-22 Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 01/17] test-keyval: Tweaks to improve list coverage Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 02/17] keyval: Improve some comments Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 03/17] test-keyval: Cover alternate and 'any' type Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 04/17] keyval: Document issues with 'any' and alternate types Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 05/17] MAINTAINERS: Add myself for files I touched recently Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 06/17] qapi: Drop excessive Make dependencies on qapi2texi.py Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 07/17] qapi2texi: Fix to actually fail when 'doc-required' is false Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 08/17] qapi: Drop unused QAPIDoc member optional Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 09/17] tests/qapi-schema: Make test-qapi.py print docs again Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 10/17] tests/qapi-schema: Systematic positive doc comment tests Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 11/17] qapi2texi: Fix translation of *strong* and _emphasized_ Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 12/17] qapi: Fix string input visitor regression for empty lists Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 13/17] Revert "hostmem: fix QEMU crash by 'info memdev'" Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 14/17] test-qobject-input-visitor: Cover visit_type_uint64() Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 15/17] tests: Expose regression in QemuOpts visitor Markus Armbruster
2017-03-22 16:05 ` [Qemu-devel] [PULL for-2.9 16/17] qom: Avoid unvisited 'id'/'qom-type' in user_creatable_add_opts Markus Armbruster
2017-03-22 17:28   ` Eric Blake
2017-03-22 16:05 ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490198748-4753-18-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).