qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 29f6bd: qapi: Assert in places where variants


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 29f6bd: qapi: Assert in places where variants are not hand...
Date: Fri, 18 Mar 2016 11:30:08 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 29f6bd15eb8a55ed37b2a443f7275b3d134eb2b2
      
https://github.com/qemu/qemu/commit/29f6bd15eb8a55ed37b2a443f7275b3d134eb2b2
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-commands.py
    M scripts/qapi-event.py

  Log Message:
  -----------
  qapi: Assert in places where variants are not handled

We are getting closer to the point where we could use one union
as the base or variant type within another union type (as long
as there are no collisions between any possible combination of
member names allowed across all discriminator choices).  But
until we get to that point, it is worth asserting that variants
are not present in places where we are not prepared to handle
them: when exploding a type into a parameter list, we do not
expect variants.  The qapi.py code is already checking this,
via the older check_type() method; but someday we hope to get
rid of that and move checking into QAPISchema*.check().  The
two asserts added here make sure any refactoring still catches
problems, and makes it locally obvious why we can iterate over
only type.members without worrying about type.variants.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 972a110162677fe5155f68a718ec6e999cd059a7
      
https://github.com/qemu/qemu/commit/972a110162677fe5155f68a718ec6e999cd059a7
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-commands.py
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out
    M tests/test-qmp-commands.c

  Log Message:
  -----------
  qapi: Fix command with named empty argument type

The generator special-cased

 { 'command':'foo', 'data': {} }

to avoid emitting a visitor variable, but failed to see that

 { 'struct':'NamedEmptyType, 'data': {} }
 { 'command':'foo', 'data':'NamedEmptyType' }

needs the same treatment.  There, the generator happily generates a
visitor to get no arguments, and a visitor to destroy no arguments;
and the compiler isn't happy with that, as demonstrated by the updated
qapi-schema-test.json:

  tests/test-qmp-marshal.c: In function ‘qmp_marshal_user_def_cmd0’:
  tests/test-qmp-marshal.c:264:14: error: variable ‘v’ set but not used 
[-Werror=unused-but-set-variable]
       Visitor *v;
          ^

No change to generated code except for the testsuite addition.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 4040d995e49c5b818be79e50a18c1bf8d2354d12
      
https://github.com/qemu/qemu/commit/4040d995e49c5b818be79e50a18c1bf8d2354d12
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-types.py
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Make c_type() more OO-like

QAPISchemaType.c_type() is a bit awkward: it takes two optional
boolean flags is_param and is_unboxed, and they should never both
be True.

Add a new method for each of the flags, and drop the flags from
c_type().

Most callers pass no flags; they remain unchanged.

One caller passes is_param=True; call the new .c_param_type()
instead.

One caller passes is_unboxed=True, except for simple union types.
This is actually an ugly special case that will go away soon, so
until then, we now have to call either .c_type() or the new
.c_unboxed_type().  Tolerable in the interim.

It requires slightly more Python, but is arguably easier to read.

Suggested-by: Markus Armbruster <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 7599697c66d22ff4c859ba6ccea30e6a9aae6b9b
      
https://github.com/qemu/qemu/commit/7599697c66d22ff4c859ba6ccea30e6a9aae6b9b
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M docs/qapi-code-gen.txt
    M scripts/qapi.py
    M tests/qapi-schema/comments.out
    M tests/qapi-schema/empty.out
    M tests/qapi-schema/event-case.out
    M tests/qapi-schema/ident-with-escape.out
    M tests/qapi-schema/include-relpath.out
    M tests/qapi-schema/include-repetition.out
    M tests/qapi-schema/include-simple.out
    M tests/qapi-schema/indented-expr.out
    M tests/qapi-schema/qapi-schema-test.out

  Log Message:
  -----------
  qapi: Adjust names of implicit types

The original choice of ':obj-' as the prefix for implicit types
made it obvious that we weren't going to clash with any user-defined
names, which cannot contain ':'.  But now we want to create structs
for implicit types, to get rid of special cases in the generators,
and our use of ':' in implicit names needs a tweak to produce valid
C code.

We could transliterate ':' to '_', except that C99 mandates that
"identifiers that begin with an underscore are always reserved for
use as identifiers with file scope in both the ordinary and tag name
spaces".  So it's time to change our naming convention: we can
instead use the 'q_' prefix that we reserved for ourselves back in
commit 9fb081e0.  Technically, since we aren't planning on exposing
the empty type in generated code, we could keep the name ':empty',
but renaming it to 'q_empty' makes the check for startswith('q_')
cover all implicit types, whether or not code is generated for them.

As long as we don't declare 'empty' or 'obj' ticklish, it shouldn't
clash with c_name() prepending 'q_' to the user's ticklish names.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 7ce106a96feee4d46bfcdb47127b0935804c9357
      
https://github.com/qemu/qemu/commit/7ce106a96feee4d46bfcdb47127b0935804c9357
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-types.py
    M scripts/qapi-visit.py
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Emit implicit structs in generated C

We already have several places that want to visit all the members
of an implicit object within a larger context (simple union variant,
event with anonymous data, command with anonymous arguments struct);
and will be adding another one soon (the ability to declare an
anonymous base for a flat union).  Having a C struct declared for
these implicit types, along with a visit_type_FOO_members() helper
function, will make for fewer special cases in our generator.

We do not, however, need qapi_free_FOO() or visit_type_FOO()
functions for implicit types, because they should not be used
directly outside of the generated code.  This is done by adding a
conditional in visit_object_type() for both qapi-types.py and
qapi-visit.py based on the object name.  The comparison of
"name.startswith('q_')" is a bit hacky (it's basically duplicating
what .is_implicit() already uses), but beats changing the signature
of the visit_object_type() callback to pass a new 'implicit' flag.
The hack should be temporary: we are considering adding a future
patch that consolidates the narrow visit_object_type(..., base,
local_members, variants) and visit_object_type_flat(...,
all_members, variants) [where different sets of information are
already broken out, and the QAPISchemaObjectType is no longer
available] into a broader visit_object_type(obj_type) [where the
visitor can query the needed fields from obj_type directly].

Also, now that we WANT to output C code for implicits, we no longer
need the visit_needed() filter, leaving 'q_empty' as the only object
still needing a special case.  Remember, 'q_empty' is the only
built-in generated object, which means that without a special case
it would be emitted in multiple files (the main qapi-types.h and in
qga-qapi-types.h) causing compilation failure due to redefinition.
But since it has no members, it's easier to just avoid an attempt to
visit that particular type; since gen_object() is called recursively,
we also prime the objects_seen set to cover any recursion into the
empty type.

The patch relies on the changed naming of implicit types in the
previous patch.  It is a bit unfortunate that the generated struct
names and visit_type_FOO_members() don't match normal naming
conventions, but it's not too bad, since they will only be used in
generated code.

The generated code grows substantially in size: the implicit
'-wrapper' types must be emitted in qapi-types.h before any union
can include an unboxed member of that type.  Arguably, the '-args'
types could be emitted in a private header for just qapi-visit.c
and qmp-marshal.c, rather than polluting qapi-types.h; but adding
complexity to the generator to split the output location according
to role doesn't seem worth the maintenance costs.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 8df59565d2c27dec8c96a2090f0eb73303efce14
      
https://github.com/qemu/qemu/commit/8df59565d2c27dec8c96a2090f0eb73303efce14
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-event.py

  Log Message:
  -----------
  qapi-event: Drop qmp_output_get_qobject() null check

qmp_output_get_qobject() was changed never to return null some time
ago (in commit 6c2f9a15), but the qapi_event_send_FOO() functions
still check.  Clean that up:

|@@ -28,7 +28,6 @@ void qapi_event_send_acpi_device_ost(ACP
|     QMPEventFuncEmit emit;
|     QmpOutputVisitor *qov;
|     Visitor *v;
|-    QObject *obj;
|
|     emit = qmp_event_get_func_emit();
|     if (!emit) {
|@@ -54,10 +53,7 @@ out_obj:
|         goto out;
|     }
|
|-    obj = qmp_output_get_qobject(qov);
|-    g_assert(obj);
|-
|-    qdict_put_obj(qmp, "data", obj);
|+    qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
|     emit(QAPI_EVENT_ACPI_DEVICE_OST, qmp, &err);
|
| out:

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 0949e95b48e30715e157cabbc59dcb0ed912d3ff
      
https://github.com/qemu/qemu/commit/0949e95b48e30715e157cabbc59dcb0ed912d3ff
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-event.py

  Log Message:
  -----------
  qapi-event: Utilize implicit struct visits

Rather than generate inline per-member visits, take advantage
of the 'visit_type_FOO_members()' function for emitting events.
This is possible now that implicit structs can be visited like
any other.  Generated code shrinks accordingly; by initializing
a struct based on parameters, through a new gen_param_var()
helper, like:

|@@ -338,6 +250,9 @@ void qapi_event_send_block_job_error(con
|     QMPEventFuncEmit emit = qmp_event_get_func_emit();
|     QmpOutputVisitor *qov;
|     Visitor *v;
|+    q_obj_BLOCK_JOB_ERROR_arg param = {
|+        (char *)device, operation, action
|+    };
|
|     if (!emit) {
|         return;
@@ -351,19 +266,7 @@ void qapi_event_send_block_job_error(con
|     if (err) {
|         goto out;
|     }
|-    visit_type_str(v, "device", (char **)&device, &err);
|-    if (err) {
|-        goto out_obj;
|-    }
|-    visit_type_IoOperationType(v, "operation", &operation, &err);
|-    if (err) {
|-        goto out_obj;
|-    }
|-    visit_type_BlockErrorAction(v, "action", &action, &err);
|-    if (err) {
|-        goto out_obj;
|-    }
|-out_obj:
|+    visit_type_q_obj_BLOCK_JOB_ERROR_arg_members(v, &param, &err);
|     visit_end_struct(v, err ? NULL : &err);

Notice that the initialization of 'param' has to cast away const
(just as the old gen_visit_members() had to do): we can't change
the signature of the user function (which uses 'const char *'), but
have to assign it to a non-const QAPI object (which requires
'char *').

While touching this, document with a FIXME comment that there is
still a potential collision between QMP members and our choice of
local variable names within qapi_event_send_FOO().

This patch also paves the way for some followup simplifications
in the generator, in subsequent patches.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 386230a249ca6ed0204d8616dfc30c5ea95a809c
      
https://github.com/qemu/qemu/commit/386230a249ca6ed0204d8616dfc30c5ea95a809c
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-commands.py

  Log Message:
  -----------
  qapi-commands: Utilize implicit struct visits

Rather than generate inline per-member visits, take advantage
of the 'visit_type_FOO_members()' function for command
marshalling.  This is possible now that implicit structs can be
visited like any other.  Generate call arguments from a stack-
allocated struct, rather than a list of local variables:

|@@ -57,26 +57,15 @@ void qmp_marshal_add_fd(QDict *args, QOb
|     QmpInputVisitor *qiv = qmp_input_visitor_new_strict(QOBJECT(args));
|     QapiDeallocVisitor *qdv;
|     Visitor *v;
|-    bool has_fdset_id = false;
|-    int64_t fdset_id = 0;
|-    bool has_opaque = false;
|-    char *opaque = NULL;
|+    q_obj_add_fd_arg arg = {0};
|
|     v = qmp_input_get_visitor(qiv);
|-    if (visit_optional(v, "fdset-id", &has_fdset_id)) {
|-        visit_type_int(v, "fdset-id", &fdset_id, &err);
|-        if (err) {
|-            goto out;
|-        }
|-    }
|-    if (visit_optional(v, "opaque", &has_opaque)) {
|-        visit_type_str(v, "opaque", &opaque, &err);
|-        if (err) {
|-            goto out;
|-        }
|+    visit_type_q_obj_add_fd_arg_members(v, &arg, &err);
|+    if (err) {
|+        goto out;
|     }
|
|-    retval = qmp_add_fd(has_fdset_id, fdset_id, has_opaque, opaque, &err);
|+    retval = qmp_add_fd(arg.has_fdset_id, arg.fdset_id, arg.has_opaque, 
arg.opaque, &err);
|     if (err) {
|         goto out;
|     }
|@@ -88,12 +77,7 @@ out:
|     qmp_input_visitor_cleanup(qiv);
|     qdv = qapi_dealloc_visitor_new();
|     v = qapi_dealloc_get_visitor(qdv);
|-    if (visit_optional(v, "fdset-id", &has_fdset_id)) {
|-        visit_type_int(v, "fdset-id", &fdset_id, NULL);
|-    }
|-    if (visit_optional(v, "opaque", &has_opaque)) {
|-        visit_type_str(v, "opaque", &opaque, NULL);
|-    }
|+    visit_type_q_obj_add_fd_arg_members(v, &arg, NULL);
|     qapi_dealloc_visitor_cleanup(qdv);
| }

This also has the nice side effect of eliminating a chance of
collision between argument QMP names and local variables.

This patch also paves the way for some followup simplifications
in the generator, in subsequent patches.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: c1ff0e6c853111496a3c5ae392b9adae5043c7be
      
https://github.com/qemu/qemu/commit/c1ff0e6c853111496a3c5ae392b9adae5043c7be
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-commands.py

  Log Message:
  -----------
  qapi-commands: Inline single-use helpers of gen_marshal()

Originally, gen_marshal_input_visit() (or gen_visitor_input_block()
before commit f1538019) was factored out to make it easy to do two
passes of a visit to each member of a (possibly-implicit) object,
without duplicating lots of code.  But after recent changes, those
visits now occupy a single line of emitted code, and the helper
method has become a series of conditionals both before and after
the one important line, making it rather awkward to see at a glance
what gets emitted on the first (parsing) or second (deallocation)
pass.  It's a lot easier to read the generator code if we just
inline both uses directly into gen_marshal(), without all the
conditionals.

Once we've done that, it's easy to notice that gen_marshal_vars()
is used only once, and inlining it too lets us consolidate some
mcgen() calls that used to be split across helpers.

gen_call() remains a single-use helper function, but it has
enough indentation and complexity that inlining it would hamper
legibility.

No change to generated output.  The fact that the diffstat shows
a net reduction in lines is an argument in favor of this cleanup.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 12f254fd5f98717d17f079c73500123303b232da
      
https://github.com/qemu/qemu/commit/12f254fd5f98717d17f079c73500123303b232da
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi-visit.py
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Inline gen_visit_members() into lone caller

Commit 82ca8e46 noticed that we had multiple implementations of
visiting every member of a struct, and consolidated it into
gen_visit_fields() (now gen_visit_members()) with enough
parameters to cater to slight differences between the clients.
But recent exposure of implicit types has meant that we are now
down to a single use of that method, so we can clean up the
unused conditionals and just inline it into the remaining
caller: gen_visit_object_members().

Likewise, gen_err_check() no longer needs optional parameters,
as the lone use of non-defaults was via gen_visit_members().

No change to generated code.

Suggested-by: Markus Armbruster <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 861877a0dd0a8e1bdbcc9743530f4dc9745a736a
      
https://github.com/qemu/qemu/commit/861877a0dd0a8e1bdbcc9743530f4dc9745a736a
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Drop unused c_null()

Now that we are always bulk-initializing a QAPI C struct to 0
(whether by g_malloc0() or by 'Type arg = {0};'), we no longer
have any clients of c_null() in the generator for per-element
initialization.  This patch is easy enough to revert if we find
a use in the future, but in the present, get rid of the dead code.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
      
https://github.com/qemu/qemu/commit/32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M backends/baum.c
    M backends/msmouse.c
    M block/nbd.c
    M block/qcow2.c
    M block/vmdk.c
    M blockdev.c
    M hmp.c
    M hw/char/escc.c
    M hw/input/hid.c
    M hw/input/ps2.c
    M hw/input/virtio-input-hid.c
    M hw/mem/pc-dimm.c
    M net/dump.c
    M net/hub.c
    M net/l2tpv3.c
    M net/net.c
    M net/netmap.c
    M net/slirp.c
    M net/socket.c
    M net/tap-win32.c
    M net/tap.c
    M net/vde.c
    M net/vhost-user.c
    M numa.c
    M qemu-char.c
    M qemu-nbd.c
    M replay/replay-input.c
    M scripts/qapi-types.py
    M scripts/qapi-visit.py
    M scripts/qapi.py
    M spice-qemu-char.c
    M tests/test-io-channel-socket.c
    M tests/test-qmp-commands.c
    M tests/test-qmp-input-visitor.c
    M tests/test-qmp-output-visitor.c
    M tpm.c
    M ui/console.c
    M ui/input-keymap.c
    M ui/input-legacy.c
    M ui/input.c
    M ui/vnc-auth-sasl.c
    M ui/vnc.c
    M util/qemu-sockets.c

  Log Message:
  -----------
  qapi: Don't special-case simple union wrappers

Simple unions were carrying a special case that hid their 'data'
QMP member from the resulting C struct, via the hack method
QAPISchemaObjectTypeVariant.simple_union_type().  But by using
the work we started by unboxing flat union and alternate
branches, coupled with the ability to visit the members of an
implicit type, we can now expose the simple union's implicit
type in qapi-types.h:

| struct q_obj_ImageInfoSpecificQCow2_wrapper {
|     ImageInfoSpecificQCow2 *data;
| };
|
| struct q_obj_ImageInfoSpecificVmdk_wrapper {
|     ImageInfoSpecificVmdk *data;
| };
...
| struct ImageInfoSpecific {
|     ImageInfoSpecificKind type;
|     union { /* union tag is @type */
|         void *data;
|-        ImageInfoSpecificQCow2 *qcow2;
|-        ImageInfoSpecificVmdk *vmdk;
|+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
|+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
|     } u;
| };

Doing this removes asymmetry between QAPI's QMP side and its
C side (both sides now expose 'data'), and means that the
treatment of a simple union as sugar for a flat union is now
equivalent in both languages (previously the two approaches used
a different layer of dereferencing, where the simple union could
be converted to a flat union with equivalent C layout but
different {} on the wire, or to an equivalent QMP wire form
but with different C representation).  Using the implicit type
also lets us get rid of the simple_union_type() hack.

Of course, now all clients of simple unions have to adjust from
using su->u.member to using su->u.member.data; while this touches
a number of files in the tree, some earlier cleanup patches
helped minimize the change to the initialization of a temporary
variable rather than every single member access.  The generated
qapi-visit.c code is also affected by the layout change:

|@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
|     }
|     switch (obj->type) {
|     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
|-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
|+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, 
&obj->u.qcow2, &err);
|         break;
|     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
|-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
|+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, 
&obj->u.vmdk, &err);
|         break;
|     default:
|         abort();

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: bd59adce692cbb70e5639c0f5611b45a0d107167
      
https://github.com/qemu/qemu/commit/bd59adce692cbb70e5639c0f5611b45a0d107167
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M docs/qapi-code-gen.txt

  Log Message:
  -----------
  qapi: Make BlockdevOptions doc example closer to reality

Although we don't want to repeat the entire BlockdevOptions
QMP command in the example, it helps if we aren't needlessly
diverging (the initial example was written before we had
committed the actual QMP interface).  Use names that match what
is found in qapi/block-core.json, such as '*read-only' rather
than 'readonly', or 'BlockdevRef' rather than 'BlockRef'.

For the simple union example, invent BlockdevOptionsSimple so
that later text is unambiguous which of the two union forms is
meant (telling the user to refer back to two 'BlockdevOptions'
wasn't nice, and QMP has only the flat union form).

Also, mention that the discriminator of a flat union is
non-optional.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: ac4338f8eb783fd421aae492ca262a586918471e
      
https://github.com/qemu/qemu/commit/ac4338f8eb783fd421aae492ca262a586918471e
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M docs/qapi-code-gen.txt
    M scripts/qapi-types.py
    M scripts/qapi.py
    M tests/qapi-schema/flat-union-bad-base.err
    M tests/qapi-schema/flat-union-bad-base.json
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out

  Log Message:
  -----------
  qapi: Allow anonymous base for flat union

Rather than requiring all flat unions to explicitly create
a separate base struct, we can allow the qapi schema to specify
the common members via an inline dictionary. This is similar to
how commands can specify an inline anonymous type for its 'data'.
We already have several struct types that only exist to serve as
a single flat union's base; the next commit will clean them up.
In particular, this patch's change to the BlockdevOptions example
in qapi-code-gen.txt will actually be done in the real QAPI schema.

Now that anonymous bases are legal, we need to rework the
flat-union-bad-base negative test (as previously written, it
forms what is now valid QAPI; tweak it to now provide coverage
of a new error message path), and add a positive test in
qapi-schema-test to use an anonymous base (making the integer
argument optional, for even more coverage).

Note that this patch only allows anonymous bases for flat unions;
simple unions are already enough syntactic sugar that we do not
want to burden them further.  Meanwhile, while it would be easy
to also allow an anonymous base for structs, that would be quite
redundant, as the members can be put right into the struct
instead.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 3666a97f78704b941c360dc917acb14c8774eca7
      
https://github.com/qemu/qemu/commit/3666a97f78704b941c360dc917acb14c8774eca7
  Author: Eric Blake <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M qapi-schema.json
    M qapi/block-core.json
    M qapi/introspect.json
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Use anonymous bases in QMP flat unions

Now that the generator supports it, we might as well use an
anonymous base rather than breaking out a single-use Base
structure, for all three of our current QMP flat unions.

Oddly enough, this change does not affect the resulting
introspection output (because we already inline the members of
a base type into an object, and had no independent use of the
base type reachable from a command).

The case_whitelist now has to list the name of an implicit
type; which is not too bad (consider it a feature if it makes
it harder for developers to make the whitelist grow :)

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 4829e0378dfb91d55af9dfd741bd09e8f2c4f91a
      
https://github.com/qemu/qemu/commit/4829e0378dfb91d55af9dfd741bd09e8f2c4f91a
  Author: Peter Maydell <address@hidden>
  Date:   2016-03-18 (Fri, 18 Mar 2016)

  Changed paths:
    M backends/baum.c
    M backends/msmouse.c
    M block/nbd.c
    M block/qcow2.c
    M block/vmdk.c
    M blockdev.c
    M docs/qapi-code-gen.txt
    M hmp.c
    M hw/char/escc.c
    M hw/input/hid.c
    M hw/input/ps2.c
    M hw/input/virtio-input-hid.c
    M hw/mem/pc-dimm.c
    M net/dump.c
    M net/hub.c
    M net/l2tpv3.c
    M net/net.c
    M net/netmap.c
    M net/slirp.c
    M net/socket.c
    M net/tap-win32.c
    M net/tap.c
    M net/vde.c
    M net/vhost-user.c
    M numa.c
    M qapi-schema.json
    M qapi/block-core.json
    M qapi/introspect.json
    M qemu-char.c
    M qemu-nbd.c
    M replay/replay-input.c
    M scripts/qapi-commands.py
    M scripts/qapi-event.py
    M scripts/qapi-types.py
    M scripts/qapi-visit.py
    M scripts/qapi.py
    M spice-qemu-char.c
    M tests/qapi-schema/comments.out
    M tests/qapi-schema/empty.out
    M tests/qapi-schema/event-case.out
    M tests/qapi-schema/flat-union-bad-base.err
    M tests/qapi-schema/flat-union-bad-base.json
    M tests/qapi-schema/ident-with-escape.out
    M tests/qapi-schema/include-relpath.out
    M tests/qapi-schema/include-repetition.out
    M tests/qapi-schema/include-simple.out
    M tests/qapi-schema/indented-expr.out
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out
    M tests/test-io-channel-socket.c
    M tests/test-qmp-commands.c
    M tests/test-qmp-input-visitor.c
    M tests/test-qmp-output-visitor.c
    M tpm.c
    M ui/console.c
    M ui/input-keymap.c
    M ui/input-legacy.c
    M ui/input.c
    M ui/vnc-auth-sasl.c
    M ui/vnc.c
    M util/qemu-sockets.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-03-18' into 
staging

QAPI patches for 2016-03-18

# gpg: Signature made Fri 18 Mar 2016 09:54:57 GMT using RSA key ID EB918653
# gpg: Good signature from "Markus Armbruster <address@hidden>"
# gpg:                 aka "Markus Armbruster <address@hidden>"

* remotes/armbru/tags/pull-qapi-2016-03-18:
  qapi: Use anonymous bases in QMP flat unions
  qapi: Allow anonymous base for flat union
  qapi: Make BlockdevOptions doc example closer to reality
  qapi: Don't special-case simple union wrappers
  qapi: Drop unused c_null()
  qapi: Inline gen_visit_members() into lone caller
  qapi-commands: Inline single-use helpers of gen_marshal()
  qapi-commands: Utilize implicit struct visits
  qapi-event: Utilize implicit struct visits
  qapi-event: Drop qmp_output_get_qobject() null check
  qapi: Emit implicit structs in generated C
  qapi: Adjust names of implicit types
  qapi: Make c_type() more OO-like
  qapi: Fix command with named empty argument type
  qapi: Assert in places where variants are not handled

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/879c26fb9fd9...4829e0378dfb

reply via email to

[Prev in Thread] Current Thread [Next in Thread]