qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 291928: qapi: Use Python 2.6 "except E as ...


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 291928: qapi: Use Python 2.6 "except E as ..." syntax
Date: Tue, 09 Feb 2016 05:30:06 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 291928a80f39670929fcce222acd5e21d1434692
      
https://github.com/qemu/qemu/commit/291928a80f39670929fcce222acd5e21d1434692
  Author: Markus Armbruster <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Use Python 2.6 "except E as ..." syntax

PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec2103).

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


  Commit: cf6c63456b47118a7f0fbb917c220c0a483db6de
      
https://github.com/qemu/qemu/commit/cf6c63456b47118a7f0fbb917c220c0a483db6de
  Author: Markus Armbruster <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/qmp/qemu-ga-client
    M scripts/qmp/qmp
    M scripts/qmp/qmp-shell
    M scripts/qmp/qmp.py

  Log Message:
  -----------
  scripts/qmp: Use Python 2.6 "except E as ..." syntax

PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec2103).

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


  Commit: 86b227d984fde7069c49ceb92828a965baa11186
      
https://github.com/qemu/qemu/commit/86b227d984fde7069c49ceb92828a965baa11186
  Author: Markus Armbruster <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/tracetool.py

  Log Message:
  -----------
  Revert "tracetool: use Python 2.4-compatible exception handling syntax"

This reverts commit 662da3854e3f490223373b40afdcfcc339d14aa5.

We require Python 2.6 now (commit fec2103).

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


  Commit: 03e188102ca8d2eab16a8d0e7818c533a93bb799
      
https://github.com/qemu/qemu/commit/03e188102ca8d2eab16a8d0e7818c533a93bb799
  Author: Markus Armbruster <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M tests/image-fuzzer/runner.py
    M tests/qemu-iotests/qed.py

  Log Message:
  -----------
  tests: Use Python 2.6 "except E as ..." syntax

PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec2103).

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


  Commit: 6e8e5cb9aa663ba59d4ca0f4cb8307d75163e31a
      
https://github.com/qemu/qemu/commit/6e8e5cb9aa663ba59d4ca0f4cb8307d75163e31a
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qobject/json-parser.c
    M qobject/qjson.c

  Log Message:
  -----------
  qobject: Document more shortcomings in our number handling

We've already documented that our JSON parsing is locale dependent;
but we should also document that our JSON output has the same
problem.  Additionally, JSON requires finite values (you have to
upgrade to JSON5 to get support for Inf or NaN), and our output
truncates floating point numbers to the point of losing significant
precision that could cause the receiver to read a different value.

Sadly, this series is not going to be the one that addresses these
problems.

Fix some trailing whitespace I noticed in the vicinity.

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


  Commit: d7bea75d35a44023efc9d481d3a1a2600677b2ef
      
https://github.com/qemu/qemu/commit/d7bea75d35a44023efc9d481d3a1a2600677b2ef
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/opts-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c

  Log Message:
  -----------
  qapi: Avoid use of misnamed DO_UPCAST()

The macro DO_UPCAST() is incorrectly named: it converts from a
parent class to a derived class (which is a downcast).  Better,
and more consistent with some of the other qapi visitors, is
to use the container_of() macro through a to_FOO() helper.  Names
like 'to_ov()' may be a bit short, but for a static helper it
doesn't hurt too much, and matches existing practice in files
like qmp-input-visitor.c.

Our current definition of container_of() is weaker than
DO_UPCAST(), in that it does not require the derived class to
have Visitor as its first member, but this does not hurt our
usage patterns in qapi visitors.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 77577cb8d6ec9d787e22c5e4ab17ee85fa3f753d
      
https://github.com/qemu/qemu/commit/77577cb8d6ec9d787e22c5e4ab17ee85fa3f753d
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/qapi-dealloc-visitor.c

  Log Message:
  -----------
  qapi: Drop dead dealloc visitor variable

Commit 0b9d8542 added StackEntry.is_list_head, but forgot to
delete the now-unused QapiDeallocVisitor.is_list_head.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 4894b00b27926223bafc8cc993ab7b8ebe160bc0
      
https://github.com/qemu/qemu/commit/4894b00b27926223bafc8cc993ab7b8ebe160bc0
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/qapi-dealloc-visitor.c

  Log Message:
  -----------
  qapi: Dealloc visitor does not need a type_size()

The intent of having the visitor type_size() callback differ
from type_uint64() is to allow special handling for sizes; the
visitor core gracefully falls back to type_uint64() if there is
no need for the distinction.  Since the dealloc visitor does
nothing for any of the int visits, drop the pointless size
handler.

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


  Commit: e408311546b633b232312450d9017f4db21df0dc
      
https://github.com/qemu/qemu/commit/e408311546b633b232312450d9017f4db21df0dc
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Drop dead parameter in gen_params()

Commit 5cdc8831 reworked gen_params() to be simpler, but forgot
to clean up a now-unused errp named argument.

No change to generated code.

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


  Commit: 7019738d4c9ce49b8fad09e9774393ad127b835d
      
https://github.com/qemu/qemu/commit/7019738d4c9ce49b8fad09e9774393ad127b835d
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hmp.c
    M vl.c

  Log Message:
  -----------
  hmp: Drop pointless allocation during qapi visit

The qapi visitor contract allows us to visit a virtual structure,
where we don't have any corresponding qapi struct.  Most such uses
pass NULL for @obj; but these two callers were passing a dummy
pointer, which then gets allocated to heap memory but then
immediately freed without use.  Clean this up to suppress unwanted
allocation, like we do elsewhere.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 9b65859d5e2e43fa89365224c5330e8c72ab760b
      
https://github.com/qemu/qemu/commit/9b65859d5e2e43fa89365224c5330e8c72ab760b
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hmp.c
    M vl.c

  Log Message:
  -----------
  hmp: Cache use of qapi visitor

Cache the visitor in a local variable instead of repeatedly
calling the accessor.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 014791b0df927226b794d14696724b9c9c0583d0
      
https://github.com/qemu/qemu/commit/014791b0df927226b794d14696724b9c9c0583d0
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M vl.c

  Log Message:
  -----------
  vl: Ensure qapi visitor properly ends struct visit

Guarantee that visit_end_struct() is called if
visit_start_struct() succeeded.  This matches the behavior of
most other uses of visitors, and is a step towards the possibility
of a future patch that adds and enforces some tighter semantics to
the visitor interface (namely, cleanup of the visitor would no
longer have to mop up as many leftovers from an aborted partial
visit).

The change to code here matches the flow of hmp.c:hmp_object_add();
a later patch will then further simplify the cleanup logic of both
places by refactoring visit_end_struct() to not require a second
local error object.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 9dbb8fa7eff6e5e4cfd83ea26dc67f8404b84aa2
      
https://github.com/qemu/qemu/commit/9dbb8fa7eff6e5e4cfd83ea26dc67f8404b84aa2
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hw/virtio/virtio-balloon.c

  Log Message:
  -----------
  balloon: Improve use of qapi visitor

Rework the control flow of balloon_stats_get_all() to make it
easier for a later patch to split visit_end_struct().  Also
switch to the uint64 visitor to match the data type.

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


  Commit: a16e3e5c5825c90887a863513916f93eeec16c55
      
https://github.com/qemu/qemu/commit/a16e3e5c5825c90887a863513916f93eeec16c55
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

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

  Log Message:
  -----------
  qapi: Improve generated event use of qapi visitor

All other successful clients of visit_start_struct() were paired
with an unconditional visit_end_struct(); but the generated
code for events was relying on qmp_output_visitor_cleanup() to
work on an incomplete visit.  Alter the code to guarantee that
the struct is completed, which will make a future patch to
split visit_end_struct() easier to reason about.  While at it,
drop some assertions and comments that are not present in other
uses of the qmp output visitor, and pass NULL rather than "" as
the 'kind' parameter (matching most other uses where obj is NULL).

The changes to the generated code look like:

|     qmp = qmp_event_build_dict("DEVICE_TRAY_MOVED");
|
|     qov = qmp_output_visitor_new();
|-    g_assert(qov);
|-
|     v = qmp_output_get_visitor(qov);
|-    g_assert(v);
|
|-    /* Fake visit, as if all members are under a structure */
|-    visit_start_struct(v, NULL, "", "DEVICE_TRAY_MOVED", 0, &err);
|+    visit_start_struct(v, NULL, NULL, "DEVICE_TRAY_MOVED", 0, &err);
|     if (err) {
|         goto out;
|     }
|     visit_type_str(v, (char **)&device, "device", &err);
|     if (err) {
|-        goto out;
|+        goto out_obj;
|     }
|     visit_type_bool(v, &tray_open, "tray-open", &err);
|     if (err) {
|-        goto out;
|+        goto out_obj;
|     }
|-    visit_end_struct(v, &err);
|+out_obj:
|+    visit_end_struct(v, err ? NULL : &err);
|     if (err) {
|         goto out;
|     }
|
|     obj = qmp_output_get_qobject(qov);
|-    g_assert(obj != NULL);
|+    g_assert(obj);
|
|     qdict_put_obj(qmp, "data", obj);
|     emit(QAPI_EVENT_DEVICE_TRAY_MOVED, qmp, &err);

Note that the 'goto out_obj' with no intervening code before the
label, as well as the construct of 'err ? NULL : &err', are both
a bit unusual but also temporary; they get fixed in a later patch
that splits visit_end_struct() to drop its errp parameter by moving
some checking before the label.  But until that time, this was the
simplest way to avoid the appearance of passing a possibly-set
error to visit_end_struct(), even though actual code inspection
shows that visit_end_struct() for a QMP output visitor will never
set an error.

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
[Commit message's code diff tweaked]
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 92b09babc11b60458c28cfe37eaa314de50e6241
      
https://github.com/qemu/qemu/commit/92b09babc11b60458c28cfe37eaa314de50e6241
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/qapi-visit.py

  Log Message:
  -----------
  qapi: Track all failures between visit_start/stop

Inside the generated code between visit_start_struct() and
visit_end_struct(), we were blindly setting the error into
the caller's errp parameter.  But a future patch to split
visit_end_struct() will require that we take action based
on whether an error has occurred, which requires us to track
all actions through a local err.  Rewrite the visits to be
more in line with the other generated calls.

Generated code changes look like:

|     visit_start_struct(v, (void **)obj, "Abort", name, sizeof(Abort), &err);
|-    if (!err) {
|-        if (*obj) {
|-            visit_type_Abort_fields(v, obj, errp);
|-        }
|-        visit_end_struct(v, &err);
|+    if (err) {
|+        goto out;
|     }
|+    if (!*obj) {
|+        goto out_obj;
|+    }
|+    visit_type_Abort_fields(v, obj, &err);
|+    error_propagate(errp, err);
|+    err = NULL;
|+out_obj:
|+    visit_end_struct(v, &err);
|+out:
|     error_propagate(errp, err);
| }

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


  Commit: 7c91aabd8964cfdf637f302c579c95401f21ce92
      
https://github.com/qemu/qemu/commit/7c91aabd8964cfdf637f302c579c95401f21ce92
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M include/qapi/visitor-impl.h
    M include/qapi/visitor.h
    M qapi/qapi-visit-core.c
    M scripts/qapi-visit.py

  Log Message:
  -----------
  qapi-visit: Kill unused visit_end_union()

The generated code can call visit_end_union() without having called
visit_start_union().  Example:
   if (!*obj) {
      goto out_obj;
  }
  visit_type_CpuInfoBase_fields(v, (CpuInfoBase **)obj, &err);
  if (err) {
      goto out_obj; // if we go from here...
  }
  if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) {
      goto out_obj;
  }
  switch ((*obj)->arch) {
    [...]
  }
    out_obj:
  // ... then *obj is true, and ...
  error_propagate(errp, err);
  err = NULL;
  if (*obj) {
      // we end up here
      visit_end_union(v, !!(*obj)->u.data, &err);
  }
  error_propagate(errp, err);

Harmless only because no visitor implements end_union().  Clean it up
anyway, by deleting the function as useless.

Messed up since we have visit_end_union (commit cee2ded).

Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
[expand scope of patch to delete rather than repair]
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 4c40314a35816de635e7170eaacdc0c35be83a8a
      
https://github.com/qemu/qemu/commit/4c40314a35816de635e7170eaacdc0c35be83a8a
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M include/qapi/visitor-impl.h
    M qapi/opts-visitor.c
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c

  Log Message:
  -----------
  qapi: Prefer type_int64 over type_int in visitors

The qapi builtin type 'int' is basically shorthand for the type
'int64'.  In fact, since no visitor was providing the optional
type_int64() callback, visit_type_int64() was just always falling
back to type_int(), cementing the equivalence between the types.

However, some visitors are providing a type_uint64() callback.
For purposes of code consistency, it is nicer if all visitors
use the paired type_int64/type_uint64 names rather than the
mismatched type_int/type_uint64.  So this patch just renames
the signed int callbacks in place, dropping the type_int()
callback as redundant, and a later patch will focus on the
unsigned int callbacks.

Add some FIXMEs to questionable reuse of errp in code touched
by the rename, while at it (the reuse works as long as the
callbacks don't modify value when setting an error, but it's not
a good example to set) - a later patch will then fix those.

No change in functionality here, although further cleanups are
in the pipeline.

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


  Commit: f755dea79dc81b0d6a8f6414e0672e165e28d8ba
      
https://github.com/qemu/qemu/commit/f755dea79dc81b0d6a8f6414e0672e165e28d8ba
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M include/qapi/visitor-impl.h
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c

  Log Message:
  -----------
  qapi: Make all visitors supply uint64 callbacks

Our qapi visitor contract supports multiple integer visitors,
but left the type_uint64 visitor as optional (falling back on
type_int64); which in turn can lead to awkward behavior with
numbers larger than INT64_MAX (the user has to be aware of
twos complement, and deal with negatives).

This patch does not address the disparity in handling large
values as negatives.  It merely moves the fallback from uint64
to int64 from the visitor core to the visitors, where the issue
can actually be fixed, by implementing the missing type_uint64()
callbacks on top of the respective type_int64() callbacks, and
with a FIXME comment explaining why that's wrong.

With that done, we now have a type_uint64() callback in every
driver, so we can make it mandatory from the core.  And although
the type_int64() callback can cover the entire valid range of
type_uint{8,16,32} on valid user input, using type_uint64() to
avoid mixed signedness makes more sense.

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


  Commit: 04e070d217b4414f1f91aa8ad25fc0ae7ca0be93
      
https://github.com/qemu/qemu/commit/04e070d217b4414f1f91aa8ad25fc0ae7ca0be93
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M include/qapi/visitor-impl.h
    M qapi/qapi-visit-core.c

  Log Message:
  -----------
  qapi: Consolidate visitor small integer callbacks

Commit 4e27e819 introduced optional visitor callbacks for all
sorts of int types, but no visitor has supplied any of the
callbacks for sizes less than 64 bits.  In other words, the
generic implementation based on using type_[u]int64() followed
by bounds-checking works just fine. In the interest of
simplicity, it's easier to make the visitor callback interface
not have to worry about the other sizes.

Adding some helper functions minimizes the boilerplate required
to correct FIXMEs added earlier with regards to questionable
reuse of errp, particularly now that we can guarantee from a
single file audit that value is unchanged if an error is set.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 395a233f7c089f23e3c0d43ce34c709dc5acd7de
      
https://github.com/qemu/qemu/commit/395a233f7c089f23e3c0d43ce34c709dc5acd7de
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M scripts/qapi-visit.py

  Log Message:
  -----------
  qapi: Don't cast Enum* to int*

C compilers are allowed to represent enums as a smaller type
than int, if all enum values fit in the smaller type.  There
are even compiler flags that force the use of this smaller
representation, although using them changes the ABI of a
binary. Therefore, our generated code for visit_type_ENUM()
(for all qapi enums) was wrong for casting Enum* to int* when
calling visit_type_enum().

It appears that no one has been using compiler ABI switches
for qemu, because if they had, we are potentially dereferencing
beyond bounds or even risking a SIGBUS on platforms where
unaligned pointer dereferencing is fatal.  But it is still
better to avoid the practice entirely, and just use the correct
types.

This matches the fix for alternate qapi types, done earlier in
commit 0426d53 "qapi: Simplify visiting of alternate types",
with generated code changing as:

| void visit_type_QType(Visitor *v, QType *obj, const char *name, Error **errp)
| {
|-    visit_type_enum(v, (int *)obj, QType_lookup, "QType", name, errp);
|+    int value = *obj;
|+    visit_type_enum(v, &value, QType_lookup, "QType", name, errp);
|+    *obj = value;
| }

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 4fa45492c3387c0fa51e8e81160ac9a7814f44a2
      
https://github.com/qemu/qemu/commit/4fa45492c3387c0fa51e8e81160ac9a7814f44a2
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hw/misc/edu.c
    M hw/virtio/virtio-balloon.c
    M include/qom/object.h
    M qom/object.c
    M target-i386/cpu.c

  Log Message:
  -----------
  qom: Use typedef for Visitor

No need to repeat 'struct Visitor' when we already have it in
typedefs.h.  Omitting the redundant 'struct' also makes a later
patch easier to search for all object property callbacks that
are associated with a Visitor.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 51e72bc1dd6ace6e91d675f41a1f09bd00ab8043
      
https://github.com/qemu/qemu/commit/51e72bc1dd6ace6e91d675f41a1f09bd00ab8043
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M backends/hostmem.c
    M block/qapi.c
    M blockdev.c
    M bootdevice.c
    M hmp.c
    M hw/acpi/core.c
    M hw/acpi/ich9.c
    M hw/core/machine.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev-properties.c
    M hw/core/qdev.c
    M hw/i386/pc.c
    M hw/ide/qdev.c
    M hw/intc/xics.c
    M hw/isa/lpc_ich9.c
    M hw/mem/pc-dimm.c
    M hw/misc/edu.c
    M hw/misc/tmp105.c
    M hw/net/ne2000-isa.c
    M hw/pci-host/piix.c
    M hw/pci-host/q35.c
    M hw/ppc/spapr_drc.c
    M hw/usb/dev-storage.c
    M hw/virtio/virtio-balloon.c
    M include/qapi/visitor.h
    M memory.c
    M net/dump.c
    M net/filter-buffer.c
    M net/net.c
    M numa.c
    M qapi/qapi-visit-core.c
    M qemu-img.c
    M qom/object.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 target-i386/cpu.c
    M target-ppc/translate_init.c
    M tests/test-opts-visitor.c
    M tests/test-qdev-global-props.c
    M tests/test-qmp-commands.c
    M tests/test-qmp-input-strict.c
    M tests/test-qmp-input-visitor.c
    M tests/test-qmp-output-visitor.c
    M tests/test-string-input-visitor.c
    M tests/test-string-output-visitor.c
    M tests/test-visitor-serialization.c
    M util/qemu-sockets.c
    M vl.c

  Log Message:
  -----------
  qapi: Swap visit_* arguments for consistent 'name' placement

JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp).  This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order.  It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.

Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.

Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.

Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
 $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings').  The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.

    // Part 1: Swap declaration order
    @@
    type TV, TErr, TObj, T1, T2;
    identifier OBJ, ARG1, ARG2;
    @@
     void visit_start_struct
    -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
    +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
     { ... }

    @@
    type bool, TV, T1;
    identifier ARG1;
    @@
     bool visit_optional
    -(TV v, T1 ARG1, const char *name)
    +(TV v, const char *name, T1 ARG1)
     { ... }

    @@
    type TV, TErr, TObj, T1;
    identifier OBJ, ARG1;
    @@
     void visit_get_next_type
    -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
    +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
     { ... }

    @@
    type TV, TErr, TObj, T1, T2;
    identifier OBJ, ARG1, ARG2;
    @@
     void visit_type_enum
    -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
    +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
     { ... }

    @@
    type TV, TErr, TObj;
    identifier OBJ;
    identifier VISIT_TYPE =~ "^visit_type_";
    @@
     void VISIT_TYPE
    -(TV v, TObj OBJ, const char *name, TErr errp)
    +(TV v, const char *name, TObj OBJ, TErr errp)
     { ... }

    // Part 2: swap caller order
    @@
    expression V, NAME, OBJ, ARG1, ARG2, ERR;
    identifier VISIT_TYPE =~ "^visit_type_";
    @@
    (
    -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
    +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
    |
    -visit_optional(V, ARG1, NAME)
    +visit_optional(V, NAME, ARG1)
    |
    -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
    +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
    |
    -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
    +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
    |
    -VISIT_TYPE(V, OBJ, NAME, ERR)
    +VISIT_TYPE(V, NAME, OBJ, ERR)
    )

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: d7bce9999df85c56c8cb1fcffd944d51bff8ff48
      
https://github.com/qemu/qemu/commit/d7bce9999df85c56c8cb1fcffd944d51bff8ff48
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M backends/hostmem.c
    M bootdevice.c
    M hw/acpi/ich9.c
    M hw/core/machine.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev-properties.c
    M hw/core/qdev.c
    M hw/i386/pc.c
    M hw/ide/qdev.c
    M hw/intc/xics.c
    M hw/isa/lpc_ich9.c
    M hw/mem/pc-dimm.c
    M hw/misc/edu.c
    M hw/misc/tmp105.c
    M hw/net/ne2000-isa.c
    M hw/pci-host/piix.c
    M hw/pci-host/q35.c
    M hw/ppc/spapr_drc.c
    M hw/usb/dev-storage.c
    M hw/virtio/virtio-balloon.c
    M include/qom/object.h
    M memory.c
    M net/dump.c
    M net/filter-buffer.c
    M qom/object.c
    M target-i386/cpu.c
    M target-ppc/translate_init.c
    M tests/test-qdev-global-props.c

  Log Message:
  -----------
  qom: Swap 'name' next to visitor in ObjectPropertyAccessor

Similar to the previous patch, it's nice to have all functions
in the tree that involve a visitor and a name for conversion to
or from QAPI to consistently stick the 'name' parameter next
to the Visitor parameter.

Done by manually changing include/qom/object.h and qom/object.c,
then running this Coccinelle script and touching up the fallout
(Coccinelle insisted on adding some trailing whitespace).

    @ rule1 @
    identifier fn;
    typedef Object, Visitor, Error;
    identifier obj, v, opaque, name, errp;
    @@
     void fn
    - (Object *obj, Visitor *v, void *opaque, const char *name,
    + (Object *obj, Visitor *v, const char *name, void *opaque,
       Error **errp) { ... }

    @@
    identifier rule1.fn;
    expression obj, v, opaque, name, errp;
    @@
     fn(obj, v,
    -   opaque, name,
    +   name, opaque,
  errp)

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 0b2a0d6bb2446060944061e53e87d0c7addede79
      
https://github.com/qemu/qemu/commit/0b2a0d6bb2446060944061e53e87d0c7addede79
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M include/qapi/visitor-impl.h
    M qapi/opts-visitor.c
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c

  Log Message:
  -----------
  qapi: Swap 'name' in visit_* callbacks to match public API

As explained in the previous patches, matching argument order of
'name, &value' to JSON's "name":value makes sense.  However,
while the last two patches were easy with Coccinelle, I ended up
doing this one all by hand.  Now all the visitor callbacks match
the main interface.

The compiler is able to enforce that all clients match the changed
interface in visitor-impl.h, even where two pointers are being
swapped, because only one of the two pointers is const (if that
were not the case, then C's looseness on treating 'char *' like
'void *' would have made review a bit harder).

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 337283dffbb5ad5860ed00408a5fd0665c21be07
      
https://github.com/qemu/qemu/commit/337283dffbb5ad5860ed00408a5fd0665c21be07
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hmp.c
    M hw/core/qdev-properties.c
    M hw/ppc/spapr_drc.c
    M hw/virtio/virtio-balloon.c
    M include/qapi/visitor-impl.h
    M include/qapi/visitor.h
    M qapi/opts-visitor.c
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qom/object.c
    M scripts/qapi-event.py
    M scripts/qapi-visit.py
    M vl.c

  Log Message:
  -----------
  qapi: Drop unused 'kind' for struct/enum visit

visit_start_struct() and visit_type_enum() had a 'kind' argument
that was usually set to either the stringized version of the
corresponding qapi type name, or to NULL (although some clients
didn't even get that right).  But nothing ever used the argument.
It's even hard to argue that it would be useful in a debugger,
as a stack backtrace also tells which type is being visited.

Therefore, drop the 'kind' argument as dead.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
[Harmless rebase mistake cleaned up]
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: bdd8e6b5d8a9def83d491a3f41c10424fc366258
      
https://github.com/qemu/qemu/commit/bdd8e6b5d8a9def83d491a3f41c10424fc366258
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/qmp-input-visitor.c

  Log Message:
  -----------
  qapi: Tighten qmp_input_end_list()

The only way that qmp_input_pop() will set errp is if a dictionary
was the most recent thing pushed.  Since we don't have any
push(struct)/pop(list) or push(list)/pop(struct) mismatches (such
a mismatch is a programming bug), we therefore cannot set errp
inside qmp_input_end_list().  Make this obvious by
using &error_abort.  A later patch will then remove the errp
parameter of qmp_input_pop(), but that will first require the
larger task of splitting visit_end_struct().

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


  Commit: 08f9541dec51700abef0c37994213164ca4e4fc9
      
https://github.com/qemu/qemu/commit/08f9541dec51700abef0c37994213164ca4e4fc9
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M hw/ppc/spapr_drc.c
    M include/qapi/visitor-impl.h
    M include/qapi/visitor.h
    M qapi/opts-visitor.c
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c
    M scripts/qapi-visit.py

  Log Message:
  -----------
  qapi: Drop unused error argument for list and implicit struct

No backend was setting an error when ending the visit of a list or
implicit struct, or when moving to the next list node.  Make the
callers a bit easier to follow by making this a part of the contract,
and removing the errp argument - callers can then unconditionally end
an object as part of cleanup without having to think about whether a
second error is dominated by a first, because there is no second
error.

A later patch will then tackle the larger task of splitting
visit_end_struct(), which can indeed set an error.

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


  Commit: a86156401559cb4401cf9ecc704faeab6fc8bb19
      
https://github.com/qemu/qemu/commit/a86156401559cb4401cf9ecc704faeab6fc8bb19
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/qmp-output-visitor.c
    M tests/test-qmp-output-visitor.c

  Log Message:
  -----------
  qmp: Fix reference-counting of qnull on empty output visit

Commit 6c2f9a15 ensured that we would not return NULL when the
caller used an output visitor but had nothing to visit. But
in doing so, it added a FIXME about a reference count leak
that could abort qemu in the (unlikely) case of SIZE_MAX such
visits (more plausible on 32-bit).  (Although that commit
suggested we might fix it in time for 2.5, we ran out of time;
fortunately, it is unlikely enough to bite that it was not
worth worrying about during the 2.5 release.)

This fixes things by documenting the internal contracts, and
explaining why the internal function can return NULL and only
the public facing interface needs to worry about qnull(),
thus avoiding over-referencing the qnull_ global object.

It does not, however, fix the stupidity of the stack mixing
up two separate pieces of information; add a FIXME to explain
that issue, which will be fixed shortly in a future patch.

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


  Commit: 455ba08afde784466420449d01c6458f88349d55
      
https://github.com/qemu/qemu/commit/455ba08afde784466420449d01c6458f88349d55
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M qapi/qmp-output-visitor.c

  Log Message:
  -----------
  qmp: Don't abuse stack to track qmp-output root

The previous commit documented an inconsistency in how we are
using the stack of qmp-output-visitor.  Normally, pushing a
single top-level object puts the object on the stack twice:
once as the root, and once as the current container being
appended to; but popping that struct only pops once.  However,
qmp_ouput_add() was trying to either set up the added object
as the new root (works if you parse two top-level scalars in a
row: the second replaces the first as the root) or as a member
of the current container (works as long as you have an open
container on the stack; but if you have popped the first
top-level container, it then resolves to the root and still
tries to add into that existing container).

Fix the stupidity by not tracking two separate things in the
stack.  Drop the now-useless qmp_output_first() and
qmp_output_last() while at it.

Saved for a later patch: we still are rather sloppy in that
qmp_output_get_object() can be called in the middle of a parse,
rather than requiring that a visit is complete.

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


  Commit: 86ae191163d48ff4ff9d9996868e6cfe92a82449
      
https://github.com/qemu/qemu/commit/86ae191163d48ff4ff9d9996868e6cfe92a82449
  Author: Eric Blake <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M cpus.c
    M hmp.c
    M scripts/qapi.py

  Log Message:
  -----------
  qapi: Fix compilation failure on MIPS and SPARC

Commit 86f4b687 broke compilation on MIPS and SPARC, which have a
preprocessor pollution of '#define mips 1' and '#define sparc 1',
respectively.  Treat it the same way as we do for the pollution with
'unix', so that QMP remains backwards compatible and only the C code
needs to use the alternative 'q_mips', 'q_sparc' spelling.

CC: James Hogan <address@hidden>
CC: Peter Maydell <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Tested-by: James Hogan <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 423aeaf219890e8a7311dbeef1a925020027c2ea
      
https://github.com/qemu/qemu/commit/423aeaf219890e8a7311dbeef1a925020027c2ea
  Author: Lluís Vilanova <address@hidden>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M Makefile

  Log Message:
  -----------
  qapi: Add missing JSON files in build dependencies

Forgotten in commit 1dde0f4 (trace.json) and commit fafa4d5
(rocker.json).

Signed-off-by: Lluís Vilanova <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: ac1be2ae6b2995b99430c48329eb971b0281acf1
      
https://github.com/qemu/qemu/commit/ac1be2ae6b2995b99430c48329eb971b0281acf1
  Author: Peter Maydell <address@hidden>
  Date:   2016-02-09 (Tue, 09 Feb 2016)

  Changed paths:
    M Makefile
    M backends/hostmem.c
    M block/qapi.c
    M blockdev.c
    M bootdevice.c
    M cpus.c
    M hmp.c
    M hw/acpi/core.c
    M hw/acpi/ich9.c
    M hw/core/machine.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev-properties.c
    M hw/core/qdev.c
    M hw/i386/pc.c
    M hw/ide/qdev.c
    M hw/intc/xics.c
    M hw/isa/lpc_ich9.c
    M hw/mem/pc-dimm.c
    M hw/misc/edu.c
    M hw/misc/tmp105.c
    M hw/net/ne2000-isa.c
    M hw/pci-host/piix.c
    M hw/pci-host/q35.c
    M hw/ppc/spapr_drc.c
    M hw/usb/dev-storage.c
    M hw/virtio/virtio-balloon.c
    M include/qapi/visitor-impl.h
    M include/qapi/visitor.h
    M include/qom/object.h
    M memory.c
    M net/dump.c
    M net/filter-buffer.c
    M net/net.c
    M numa.c
    M qapi/opts-visitor.c
    M qapi/qapi-dealloc-visitor.c
    M qapi/qapi-visit-core.c
    M qapi/qmp-input-visitor.c
    M qapi/qmp-output-visitor.c
    M qapi/string-input-visitor.c
    M qapi/string-output-visitor.c
    M qemu-img.c
    M qobject/json-parser.c
    M qobject/qjson.c
    M qom/object.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 scripts/qmp/qemu-ga-client
    M scripts/qmp/qmp
    M scripts/qmp/qmp-shell
    M scripts/qmp/qmp.py
    M scripts/tracetool.py
    M target-i386/cpu.c
    M target-ppc/translate_init.c
    M tests/image-fuzzer/runner.py
    M tests/qemu-iotests/qed.py
    M tests/test-opts-visitor.c
    M tests/test-qdev-global-props.c
    M tests/test-qmp-commands.c
    M tests/test-qmp-input-strict.c
    M tests/test-qmp-input-visitor.c
    M tests/test-qmp-output-visitor.c
    M tests/test-string-input-visitor.c
    M tests/test-string-output-visitor.c
    M tests/test-visitor-serialization.c
    M util/qemu-sockets.c
    M vl.c

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

QAPI patches for 2016-02-09

# gpg: Signature made Tue 09 Feb 2016 10:55:51 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-02-09: (31 commits)
  qapi: Add missing JSON files in build dependencies
  qapi: Fix compilation failure on MIPS and SPARC
  qmp: Don't abuse stack to track qmp-output root
  qmp: Fix reference-counting of qnull on empty output visit
  qapi: Drop unused error argument for list and implicit struct
  qapi: Tighten qmp_input_end_list()
  qapi: Drop unused 'kind' for struct/enum visit
  qapi: Swap 'name' in visit_* callbacks to match public API
  qom: Swap 'name' next to visitor in ObjectPropertyAccessor
  qapi: Swap visit_* arguments for consistent 'name' placement
  qom: Use typedef for Visitor
  qapi: Don't cast Enum* to int*
  qapi: Consolidate visitor small integer callbacks
  qapi: Make all visitors supply uint64 callbacks
  qapi: Prefer type_int64 over type_int in visitors
  qapi-visit: Kill unused visit_end_union()
  qapi: Track all failures between visit_start/stop
  qapi: Improve generated event use of qapi visitor
  balloon: Improve use of qapi visitor
  vl: Ensure qapi visitor properly ends struct visit
  ...

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


Compare: https://github.com/qemu/qemu/compare/74f30f153f42...ac1be2ae6b29

reply via email to

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