#
468866b8 |
| 07-May-2014 |
Markus Armbruster <armbru@redhat.com> |
qapi-visit.py: Clean up confusing push_indent() / pop_indent() use
Changing implicit indentation in the middle of generating a block makes following the code being generated unnecessarily hard.
Sig
qapi-visit.py: Clean up confusing push_indent() / pop_indent() use
Changing implicit indentation in the middle of generating a block makes following the code being generated unnecessarily hard.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
e2cd0f4f |
| 07-May-2014 |
Markus Armbruster <armbru@redhat.com> |
qapi: Replace start_optional()/end_optional() by optional()
Semantics of end_optional() differ subtly from the other end_FOO() callbacks: when start_FOO() succeeds, the matching end_FOO() gets calle
qapi: Replace start_optional()/end_optional() by optional()
Semantics of end_optional() differ subtly from the other end_FOO() callbacks: when start_FOO() succeeds, the matching end_FOO() gets called regardless of what happens in between. end_optional() gets called only when everything in between succeeds as well. Entirely undocumented, like all of the visitor API.
The only user of Visitor Callback end_optional() never did anything, and was removed in commit 9f9ab46.
I'm about to clean up error handling in the generated visitor code, and end_optional() is in my way. No users mean no test cases, and making non-trivial cleanup transformations without test cases doesn't strike me as a good idea.
Drop end_optional(), and rename start_optional() to optional(). We can always go back to a pair of callbacks when we have an actual need.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
33aaad52 |
| 02-May-2014 |
Lluís Vilanova <vilanova@ac.upc.edu> |
qapi: Use an explicit input file
Use an explicit input file on the command-line instead of reading from standard input.
It also outputs the proper file name when there's an error.
Signed-off-by: L
qapi: Use an explicit input file
Use an explicit input file on the command-line instead of reading from standard input.
It also outputs the proper file name when there's an error.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
bceae769 |
| 07-Mar-2014 |
Wenchao Xia <wenchaoqemu@gmail.com> |
qapi script: support enum type as discriminator in union
By default, any union will automatically generate a enum type as "[UnionName]Kind" in C code, and it is duplicated when the discriminator is
qapi script: support enum type as discriminator in union
By default, any union will automatically generate a enum type as "[UnionName]Kind" in C code, and it is duplicated when the discriminator is specified as a pre-defined enum type in schema. After this patch, the pre-defined enum type will be really used as the switch case condition in generated C code, if discriminator is an enum field.
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
b0b58195 |
| 05-Mar-2014 |
Wenchao Xia <wenchaoqemu@gmail.com> |
qapi script: use same function to generate enum string
Prior to this patch, qapi-visit.py used custom code to generate enum names used for handling a qapi union. Fix it to instead reuse common code,
qapi script: use same function to generate enum string
Prior to this patch, qapi-visit.py used custom code to generate enum names used for handling a qapi union. Fix it to instead reuse common code, with identical generated results, and allowing future updates to generation to only need to touch one place.
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
949ceeb3 |
| 01-Mar-2014 |
Markus Armbruster <armbru@redhat.com> |
qapi: Clean up null checking in generated visitors
Visitors get passed a pointer to the visited object. The generated visitors try to cope with this pointer being null in some places, for instance
qapi: Clean up null checking in generated visitors
Visitors get passed a pointer to the visited object. The generated visitors try to cope with this pointer being null in some places, for instance like this:
visit_start_optional(m, obj ? &(*obj)->has_name : NULL, "name", &err);
visit_start_optional() passes its second argument to Visitor method start_optional. Three out of three methods dereference it unconditionally.
I fail to see how this pointer could legitimately be null.
All this useless null checking is highly redundant, which Coverity duly reports. About 200 times.
Remove the useless null checks.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
a105acbc |
| 01-Mar-2014 |
Markus Armbruster <armbru@redhat.com> |
qapi: Drop nonsensical header guard in generated qapi-visit.c
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitu
qapi: Drop nonsensical header guard in generated qapi-visit.c
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
678e48a2 |
| 01-Mar-2014 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix licensing of scripts
The scripts carry this copyright notice:
# This work is licensed under the terms of the GNU GPLv2. # See the COPYING.LIB file in the top-level directory.
The
qapi: Fix licensing of scripts
The scripts carry this copyright notice:
# This work is licensed under the terms of the GNU GPLv2. # See the COPYING.LIB file in the top-level directory.
The sentences contradict each other, as COPYING.LIB contains the LGPL 2.1. Michael Roth says this was a simple pasto, and he meant to refer COPYING. Let's fix that.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
7b75d9d6 |
| 31-Oct-2013 |
Richard Henderson <rth@twiddle.net> |
Adjust qapi-visit for python-2.4.3
We say we support python 2.4, but python 2.4.3 does not support the "expr if test else expr" syntax used here.
This allows QEMU to compile on RHEL 5.3, the last r
Adjust qapi-visit for python-2.4.3
We say we support python 2.4, but python 2.4.3 does not support the "expr if test else expr" syntax used here.
This allows QEMU to compile on RHEL 5.3, the last release for ia64.
Signed-off-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
622f557f |
| 19-Sep-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi-types/visit.py: Inheritance for structs
This introduces a new 'base' key for struct definitions that refers to another struct type. On the JSON level, the fields of the base type are included d
qapi-types/visit.py: Inheritance for structs
This introduces a new 'base' key for struct definitions that refers to another struct type. On the JSON level, the fields of the base type are included directly into the same namespace as the fields of the defined type, like with unions. On the C level, a pointer to a struct of the base type is included.
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
#
14d36307 |
| 18-Sep-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi-types/visit.py: Pass whole expr dict for structs
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
|
#
69dd62df |
| 08-Jul-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi: Anonymous unions
The discriminator for anonymous unions is the data type. This allows to have a union type that allows both of these:
{ 'file': 'my_existing_block_device_id' } { 'file
qapi: Anonymous unions
The discriminator for anonymous unions is the data type. This allows to have a union type that allows both of these:
{ 'file': 'my_existing_block_device_id' } { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } }
Unions like this are specified in the schema with an empty dict as discriminator. For this example you could take:
{ 'union': 'BlockRef', 'discriminator': {}, 'data': { 'definition': 'BlockOptions', 'reference': 'str' } } { 'type': 'ExampleObject', 'data: { 'file': 'BlockRef' } }
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
#
50f2bdc7 |
| 03-Jul-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi: Flat unions with arbitrary discriminator
Instead of the rather verbose syntax that distinguishes base and subclass fields...
{ "type": "file", "read-only": true, "data": { "
qapi: Flat unions with arbitrary discriminator
Instead of the rather verbose syntax that distinguishes base and subclass fields...
{ "type": "file", "read-only": true, "data": { "filename": "test" } }
...we can now have both in the same namespace, allowing a more direct mapping of the command line, and moving fields between the common base and subclasses without breaking the API:
{ "driver": "file", "read-only": true, "filename": "test" }
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
#
0aef92b9 |
| 02-Jul-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi-visit.py: Implement 'base' for unions
This implements the visitor part of base types for unions. Parsed into QMP, this example schema definition...
{ 'type': 'BlockOptionsBase', 'data': {
qapi-visit.py: Implement 'base' for unions
This implements the visitor part of base types for unions. Parsed into QMP, this example schema definition...
{ 'type': 'BlockOptionsBase', 'data': { 'read-only': 'bool' } } { 'type': 'BlockOptionsQcow2, 'data': { 'lazy-refcounts': 'bool' } }
{ 'union': 'BlockOptions', 'base': 'BlockOptionsBase', 'data': { 'raw': 'BlockOptionsRaw' 'qcow2': 'BlockOptionsQcow2' } }
...would describe the following JSON object:
{ "type": "qcow2", "read-only": true, "data": { "lazy-refcounts": false } }
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
#
d131c897 |
| 02-Jul-2013 |
Kevin Wolf <kwolf@redhat.com> |
qapi-visit.py: Split off generate_visit_struct_fields()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
|
#
7c946bc4 |
| 10-May-2013 |
Michael Roth <mdroth@linux.vnet.ibm.com> |
qapi: qapi-visit.py, native list support
Teach visitor generators about native types so they can generate the appropriate visitor routines.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> R
qapi: qapi-visit.py, native list support
Teach visitor generators about native types so they can generate the appropriate visitor routines.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
c664aef5 |
| 10-May-2013 |
Michael Roth <mdroth@linux.vnet.ibm.com> |
qapi: qapi-visit.py, fix list handling for union types
Currently we assume non-list types when generating visitor routines for union types. This is broken, since values like ['Type'] need to mapped
qapi: qapi-visit.py, fix list handling for union types
Currently we assume non-list types when generating visitor routines for union types. This is broken, since values like ['Type'] need to mapped to 'TypeList'.
We already have a type_name() function to handle this that we use for generating struct visitors, so use that here as well.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
7b1b5d19 |
| 17-Dec-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: move include files to include/qobject/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
#
79ee7df8 |
| 06-Dec-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: move inclusions of qemu-common.h from headers to .c files
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
#
eda50a65 |
| 19-Sep-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: do not protect enum values from namespace pollution
Enum values are always preceded by the uppercase name of the enum, so they do not conflict with reserved words.
Signed-off-by: Paolo Bonzin
qapi: do not protect enum values from namespace pollution
Enum values are always preceded by the uppercase name of the enum, so they do not conflict with reserved words.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
227ccf6b |
| 01-Sep-2012 |
Stefan Weil <sw@weilnetz.de> |
qapi: Fix potential NULL pointer segfault
Report from smatch:
qapi-visit.c:1640 visit_type_BlockdevAction(8) error: we previously assumed 'obj' could be null (see line 1639) qapi-visit.c:2432 visi
qapi: Fix potential NULL pointer segfault
Report from smatch:
qapi-visit.c:1640 visit_type_BlockdevAction(8) error: we previously assumed 'obj' could be null (see line 1639) qapi-visit.c:2432 visit_type_NetClientOptions(8) error: we previously assumed 'obj' could be null (see line 2431)
Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
b9c4b48d |
| 31-Aug-2012 |
Amos Kong <akong@redhat.com> |
qapi: generate list struct and visit_list for enum
Currently, if we define an 'enum' and use it in one command's data, list struct for enum could not be generated, but it's used in qmp function.
Fo
qapi: generate list struct and visit_list for enum
Currently, if we define an 'enum' and use it in one command's data, list struct for enum could not be generated, but it's used in qmp function.
For example: KeyCodesList could not be generated. >>> qapi-schema.json: { 'enum': 'KeyCodes', 'data': [ 'shift', 'alt' ... ] } { 'command': 'sendkey', 'data': { 'keys': ['KeyCodes'], '*hold-time': 'int' } }
>>> qmp-command.h: void qmp_sendkey(KeyCodesList * keys, bool has_hold_time, int64_t hold_time, Error **errp);
This patch lets qapi generate list struct and visit_list for enum.
Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
d195325b |
| 17-Jul-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: fix error propagation
Don't overwrite / leak previously set errors. Make traversal cope with missing mandatory sub-structs. Don't try to end a container that could not be started.
v1->v2: - u
qapi: fix error propagation
Don't overwrite / leak previously set errors. Make traversal cope with missing mandatory sub-structs. Don't try to end a container that could not be started.
v1->v2: - unchanged
v2->v3: - instead of examining, assert that we never overwrite errors with error_set() - allow visitors to set a NULL struct pointer successfully, so traversal of incomplete objects can continue - check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a typo, "obj != NULL" implies "*obj != NULL" here) - fix start_struct / end_struct balance for unions as well
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
show more ...
|
#
3a86a0fa |
| 22-Mar-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: untangle next_list
Right now, the semantics of next_list are complicated. The caller must:
* call start_list
* call next_list for each element *including the first*
* on the first call to
qapi: untangle next_list
Right now, the semantics of next_list are complicated. The caller must:
* call start_list
* call next_list for each element *including the first*
* on the first call to next_list, the second argument should point to NULL and the result is the head of the list. On subsequent calls, the second argument should point to the last node (last result of next_list) and next_list itself tacks the element at the tail of the list.
This works for both input and output visitor, but having the visitor write memory when it is only reading the list is ugly. Plus, relying on *list to detect the first call is tricky and undocumented.
We can initialize so->entry in next_list instead of start_list, leaving it NULL in start_list. This way next_list sees clearly whether it is on the first call---as a bonus, it discriminates the cases based on internal state of the visitor rather than external state. We can also pull the assignment of the list head from generated code up to next_list.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|
#
69b50071 |
| 22-Mar-2012 |
Paolo Bonzini <pbonzini@redhat.com> |
qapi: allow freeing partially-allocated objects
Objects going through the dealloc visitor can be only partially allocated. Detect the situation and avoid a segfault. This also helps with the input
qapi: allow freeing partially-allocated objects
Objects going through the dealloc visitor can be only partially allocated. Detect the situation and avoid a segfault. This also helps with the input visitor, when there are errors.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
show more ...
|