All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com, famz@redhat.com, qemu-stable@nongnu.org,
	lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] qapi: add visit_start_union and visit_end_union
Date: Fri, 12 Sep 2014 18:29:46 +0200	[thread overview]
Message-ID: <54131F7A.3000809@redhat.com> (raw)
In-Reply-To: <20140912161720.19243.93082@loki>

Il 12/09/2014 18:17, Michael Roth ha scritto:
> Quoting Paolo Bonzini (2014-09-12 10:39:49)
>> Il 12/09/2014 17:34, Michael Roth ha scritto:
>>>
>>> { 'union': 'UserDefUnion',
>>>   'base': 'UserDefZero',
>>>   'data': { 'a' : 'int', 'b' : 'UserDefB' } }
>>>
>>> If UserDefUnion.a is 0, UserDefUnion.data will cast it to a NULL value and
>>> cause the output visitor to bail, when really it should just be left to
>>> continue on serializing the integer.
>>
>> In the case of dealloc, that'd be okay because the dealloc visit would
>> do nothing for KIND_A, right?
> 
> Yup that should be fine for the dealloc visitor. With this series we never
> actually visit the int in this case though due to this quirk. But that's
> okay because it's not an allocated type and the dealloc visitor doesn't need
> to do anything anyway. (It's a bit wonky, but since that reliance on
> implementation details now lives in the visitor implementation of
> visit_start_union it's reasonably contained at least)
> 
> But if we're looking at extending visit_start_union for use in something like
> an output visitor, this would need to be addressed some other way, since
> skipping scalar fields because they're 0 is a bug there.

I guess it would be something like

   has_data = (kind < KIND_MAX) && (is_scalar[kind] || !!data)

That could be done in qapi-visit.py if we were so inclined...

Paolo

  reply	other threads:[~2014-09-12 16:30 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 [this message]
2014-09-12 18:28             ` Michael Roth
2014-09-11 23:20 ` [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union Michael Roth
2014-09-12  2:34   ` 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=54131F7A.3000809@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.