qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com, armbru@redhat.com, qemu-stable@nongnu.org,
	lcapitulino@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union
Date: Thu, 11 Sep 2014 18:20:58 -0500	[thread overview]
Message-ID: <1410477659-9163-3-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1410477659-9163-1-git-send-email-mdroth@linux.vnet.ibm.com>

If the .data field of a QAPI Union is NULL, we don't need to free
any of the union fields..

Make use of the new visit_start_union interface to access this
information and instruct the generated code to not visit these
fields when this occurs.

Cc: qemu-stable@nongnu.org
Reported-by: Fam Zheng <famz@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qapi/qapi-dealloc-visitor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index dc53545..eb77078 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -162,6 +162,11 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[],
 {
 }
 
+static bool qapi_dealloc_start_union(Visitor *v, bool data_present, Error **errp)
+{
+    return data_present;
+}
+
 Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
 {
     return &v->visitor;
@@ -191,6 +196,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
     v->visitor.type_str = qapi_dealloc_type_str;
     v->visitor.type_number = qapi_dealloc_type_number;
     v->visitor.type_size = qapi_dealloc_type_size;
+    v->visitor.start_union = qapi_dealloc_start_union;
 
     QTAILQ_INIT(&v->stack);
 
-- 
1.9.1

  parent reply	other threads:[~2014-09-11 23:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 23:20 [Qemu-devel] [PATCH 0/3] qapi: fix crash in dealloc visitor for union types Michael Roth
2014-09-11 23:20 ` [Qemu-devel] [PATCH 1/3] qapi: add visit_start_union and visit_end_union Michael Roth
2014-09-12  2:29   ` Eric Blake
2014-09-12 15:22     ` Michael Roth
2014-09-12 10:17   ` Paolo Bonzini
2014-09-12 15:34     ` Michael Roth
2014-09-12 15:39       ` Paolo Bonzini
2014-09-12 16:17         ` Michael Roth
2014-09-12 16:29           ` Paolo Bonzini
2014-09-12 18:28             ` Michael Roth
2014-09-11 23:20 ` Michael Roth [this message]
2014-09-12  2:34   ` [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union Eric Blake
2014-09-11 23:20 ` [Qemu-devel] [PATCH 3/3] tests: add QMP input visitor test for unions with no discriminator Michael Roth
2014-09-12  3:04 ` [Qemu-devel] [PATCH 4/3] qemu-iotests: Test missing "driver" key for blockdev-add Fam Zheng
2014-09-12  4:17   ` Eric Blake
2014-09-12  3:06 ` [Qemu-devel] [PATCH 0/3] qapi: fix crash in dealloc visitor for union types Fam Zheng

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=1410477659-9163-3-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@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).