[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qapi: Fix error handling code on alternate c
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH v2] qapi: Fix error handling code on alternate conflict |
Date: |
Thu, 20 Jul 2017 14:52:23 -0300 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Thu, Jul 20, 2017 at 06:14:44PM +0200, Markus Armbruster wrote:
> Eduardo Habkost <address@hidden> writes:
>
> > The conflict check added by commit c0644771 ("qapi: Reject
> > alternates that can't work with keyval_parse()") doesn't work
> > with the following declaration:
> >
> > { 'alternate': 'Alt',
> > 'data': { 'one': 'bool',
> > 'two': 'str' } }
> >
> > It crashes with:
> >
> > Traceback (most recent call last):
> > File "./scripts/qapi-types.py", line 295, in <module>
> > schema = QAPISchema(input_file)
> > File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 1468, in
> > __init__
> > self.exprs = check_exprs(parser.exprs)
> > File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 958, in
> > check_exprs
> > check_alternate(expr, info)
> > File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 830, in
> > check_alternate
> > % (name, key, types_seen[qtype]))
> > KeyError: 'QTYPE_QSTRING'
> >
> > This happens because the previously-seen conflicting member
> > ('one') can't be found at types_seen[qtype], but at
> > types_seen['QTYPE_BOOL'].
> >
> > Fix the bug by moving the error check to the same loop that adds
> > new items to types_seen, raising an exception if types_seen[qt]
> > is already set.
> >
> > Add two additional test cases that can detect the bug.
> >
> > Signed-off-by: Eduardo Habkost <address@hidden>
> [...]
> > diff --git a/tests/qapi-schema/alternate-conflict-num-string.out
> > b/tests/qapi-schema/alternate-conflict-num-string.out
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/tests/qapi-schema/alternate-multi-conflict.json
> > b/tests/qapi-schema/alternate-multi-conflict.json
> > new file mode 100644
> > index 0000000..e69de29
>
> Accident? Can drop on commit.
Yes, sorry. Thanks for spotting it.
--
Eduardo