From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Hu Tao <hutao@cn.fujitsu.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qapi: Fix crash with enum dealloc when kind is invalid
Date: Wed, 10 Sep 2014 22:17:11 -0600 [thread overview]
Message-ID: <54112247.40303@redhat.com> (raw)
In-Reply-To: <20140911005328.GB2554@fam-t430.nay.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]
On 09/10/2014 06:53 PM, Fam Zheng wrote:
> On Wed, 09/10 17:32, Paolo Bonzini wrote:
>> Il 10/09/2014 17:02, Fam Zheng ha scritto:
>>>> A bit hackish, but I don't have any better idea.
>>>>
>>>> Hmm... what about adding a new member to the visitors for "invalid enum"
>>>> value? The dealloc visitor could override it to do nothing, while the
>>>> default could abort or set an error. Would that work?
>>>
>>> The invalid state of enum still needs to be saved in the data. It is detected
>>> by the input visitor, but should be checked by other visitors (output, dealloc)
>>> later.
>>
>> Yes, that's fine. The only part where I'm not sure is the special
>> casing of the _MAX enum.
>>
>
> Yes, it is abusing. Let's add an _INVALID = 0 enum which is much clearer.
If I understand correctly, you mean that for:
{ 'enum': 'Foo', 'data': [ 'one', 'two' ] }
FOO_ONE would now be 1 instead of its current value of 0?
We just barely saw a case where Hu Tao's code was relying on the
implicit value 0 assigned to the first enum in the json file [1]
although I strongly argued that it should be nuked (and so it was fixed
in [2]). So I could live with reserving 0 for internal use for flagging
parse errors (such as attempting to pass the string 'three' where a Foo
value is expected).
[1] https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg01691.html
[2] https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg01938.html
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-09-11 4:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 12:30 [Qemu-devel] [PATCH] qapi: Fix crash with enum dealloc when kind is invalid Fam Zheng
2014-09-10 13:01 ` Paolo Bonzini
2014-09-10 15:02 ` Fam Zheng
2014-09-10 15:32 ` Paolo Bonzini
2014-09-11 0:53 ` Fam Zheng
2014-09-11 4:17 ` Eric Blake [this message]
2014-09-11 4:38 ` Fam Zheng
2014-09-11 14:26 ` Michael Roth
2014-09-11 14:35 ` Paolo Bonzini
2014-09-11 23:02 ` Michael Roth
2014-09-11 1:01 ` Michael Roth
2014-09-11 1:02 ` [Qemu-devel] [PATCH] tests: add QMP input visitor test for unions with no discriminator Michael Roth
2014-09-11 4:19 ` Eric Blake
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=54112247.40303@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=hutao@cn.fujitsu.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).