qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] e55250: qmp-shell: fix pretty printing of JSO


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] e55250: qmp-shell: fix pretty printing of JSON responses
Date: Sun, 06 Mar 2016 05:00:05 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: e55250c6cb4cf836f9188095a21c85f663aac06b
      
https://github.com/qemu/qemu/commit/e55250c6cb4cf836f9188095a21c85f663aac06b
  Author: Daniel P. Berrange <address@hidden>
  Date:   2016-03-04 (Fri, 04 Mar 2016)

  Changed paths:
    M scripts/qmp/qmp-shell

  Log Message:
  -----------
  qmp-shell: fix pretty printing of JSON responses

Pretty printing of JSON responses is important to be able to understand
large responses from query commands in particular. Unfortunately this
was broken during the addition of the verbose flag in

  commit 1ceca07e48ead0dd2e41576c81d40e6a91cafefd
  Author: John Snow <address@hidden>
  Date:   Wed Apr 29 15:14:04 2015 -0400

    scripts: qmp-shell: Add verbose flag

This is because that change turned the python data structure into a
formatted JSON string before the pretty print was given it. So we're
just pretty printing a string, which is a no-op.

The original pretty printer would output python objects.

(QEMU) query-chardev
{   u'return': [   {   u'filename': u'vc',
                 u'frontend-open': False,
                 u'label': u'parallel0'},
             {   u'filename': u'vc',
                 u'frontend-open': True,
                 u'label': u'serial0'},
             {   u'filename': u'unix:/tmp/qemp,server',
                 u'frontend-open': True,
                 u'label': u'compat_monitor0'}]}

This fixes the problem by switching to outputting pretty formatted JSON
text instead. This has the added benefit that the pretty printed output
is now valid JSON text. Due to the way the verbose flag was handled, the
pretty printing now applies to the command sent, as well as its response:

(QEMU) query-chardev
{
    "execute": "query-chardev",
    "arguments": {}
}
{
    "return": [
  {
      "frontend-open": false,
      "label": "parallel0",
      "filename": "vc"
  },
  {
      "frontend-open": true,
      "label": "serial0",
      "filename": "vc"
  },
  {
      "frontend-open": true,
      "label": "compat_monitor0",
      "filename": "unix:/tmp/qmp,server"
  }
    ]
}

Signed-off-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Tested-by: Kashyap Chamarthy <address@hidden>
Reviewed-by: John Snow <address@hidden>
[Bonus fix: multiple -p now work]
Signed-off-by: Markus Armbruster <address@hidden>


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

  Changed paths:
    M hw/acpi/core.c
    M net/net.c
    M numa.c
    M tests/test-opts-visitor.c

  Log Message:
  -----------
  qapi-dealloc: Reduce use outside of generated code

No need to roll our own use of the dealloc visitors when we can
just directly use the qapi_free_FOO() functions that do what we
want in one line.

In net.c, inline net_visit() into its remaining lone caller.

After this patch, test-visitor-serialization.c is the only
non-generated file that needs to use a dealloc visitor, because
it is testing low level aspects of the visitor interface.

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


  Commit: 14f00c6c492488381a513c3816b15794446231a0
      
https://github.com/qemu/qemu/commit/14f00c6c492488381a513c3816b15794446231a0
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

  Changed paths:
    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 tests/qapi-schema/qapi-schema-test.json

  Log Message:
  -----------
  qapi: Rename 'fields' to 'members' in generator

C types and JSON objects don't have fields, but members.  We
shouldn't gratuitously invent terminology.  This patch is a
strict renaming of generator code internals (including testsuite
comments), before later patches rename C interfaces.

No change to generated code with this patch.

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: c81200b01422783cd29796ef4ccc275d05f9ce67
      
https://github.com/qemu/qemu/commit/c81200b01422783cd29796ef4ccc275d05f9ce67
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

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

  Log Message:
  -----------
  qapi: Rename 'fields' to 'members' in generated C code

C types and JSON objects don't have fields, but members.  We
shouldn't gratuitously invent terminology.  This patch is a
strict renaming of static genarated functions, plus the naming
of the dummy filler member for empty structs, before the next
patch exposes some of that naming to the rest of the code base.

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: 4d91e9115cc6700113e772b19d1f39bbcf345977
      
https://github.com/qemu/qemu/commit/4d91e9115cc6700113e772b19d1f39bbcf345977
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

  Changed paths:
    M scripts/qapi-visit.py

  Log Message:
  -----------
  qapi-visit: Expose visit_type_FOO_members()

Dan Berrange reported a case where he needs to work with a
QCryptoBlockOptions union type using the OptsVisitor, but only
visit one of the branches of that type (the discriminator is not
visited directly, but learned externally).  When things were
boxed, it was easy: just visit the variant directly, which took
care of both allocating the variant and visiting its members, then
store that pointer in the union type.  But now that things are
unboxed, we need a way to visit the members without allocation,
done by exposing visit_type_FOO_members() to the user.

Before the patch, we had quite a bit of code associated with
object_members_seen to make sure that a declaration of the helper
was in scope before any use of the function.  But now that the
helper is public and declared in the header, the .c file no
longer needs to worry about topological sorting (the helper is
always in scope), which leads to some nice cleanups.

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


  Commit: 9ee86b852673fd9ec807b1ff3c3a1337351dac0a
      
https://github.com/qemu/qemu/commit/9ee86b852673fd9ec807b1ff3c3a1337351dac0a
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

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

  Log Message:
  -----------
  qapi: Update docs to match recent generator changes

Several commits have been changing the generator, but not updating
the docs to match:
- The implicit tag member is named "type", not "kind".  Screwed up in
commit 39a1815.
- Commit 9f08c8ec made list types lazy, and thereby dropped
UserDefOneList if nothing explicitly uses the list type.
- Commit 51e72bc1 switched the parameter order with 'name' occurring
earlier.
- Commit e65d89bf changed the layout of UserDefOneList.
- Prefer the term 'member' over 'field'.
- We now expose visit_type_FOO_members() for objects.
- etc.

Rework the examples to show slightly more output (we don't want to
show too much; that's what the testsuite is for), and regenerate the
output to match all recent changes.  Also, rearrange output to show
.h files before .c (understanding the interface first often makes
the implementation easier to follow).

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


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

  Changed paths:
    M qemu-char.c

  Log Message:
  -----------
  chardev: Shorten references into ChardevBackend

An upcoming patch will alter how simple unions, like ChardevBackend,
are laid out, which will impact all lines of the form 'backend->u.XXX'
(expanding it to the longer 'backend->u.XXX.data').  For better
legibility in that patch, and less need for line wrapping, it's better
to use a temporary variable to reduce the effect of a layout change to
just the variable initializations, rather than every reference within
a ChardevBackend.  It doesn't hurt that this also makes the code more
consistent: some clients touched here already had a temporary variable
but weren't using it.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-By: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 0399293e5b9e5443b82103fa8e2c97deadef9825
      
https://github.com/qemu/qemu/commit/0399293e5b9e5443b82103fa8e2c97deadef9825
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

  Changed paths:
    M block/nbd.c
    M qemu-char.c
    M qemu-nbd.c
    M tests/test-io-channel-socket.c
    M ui/vnc.c
    M util/qemu-sockets.c

  Log Message:
  -----------
  util: Shorten references into SocketAddress

An upcoming patch will alter how simple unions, like SocketAddress,
are laid out, which will impact all lines of the form 'addr->u.XXX'
(expanding it to the longer 'addr->u.XXX.data').  For better
legibility in that patch, and less need for line wrapping, it's better
to use a temporary variable to reduce the effect of a layout change to
just the variable initializations, rather than every reference within
a SocketAddress.  Also, take advantage of some C99 initialization where
it makes sense (simplifying g_new0() to g_new()).

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


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

  Changed paths:
    M hw/char/escc.c
    M hw/input/hid.c
    M hw/input/ps2.c
    M hw/input/virtio-input-hid.c
    M replay/replay-input.c
    M ui/input-legacy.c
    M ui/input.c

  Log Message:
  -----------
  ui: Shorten references into InputEvent

An upcoming patch will alter how simple unions, like InputEvent, are
laid out, which will impact all lines of the form 'evt->u.XXX'
(expanding it to the longer 'evt->u.XXX.data').  For better
legibility in that patch, and less need for line wrapping, it's better
to use a temporary variable to reduce the effect of a layout change to
just the variable initializations, rather than every reference within
an InputEvent.

There was one instance in hid.c:hid_pointer_event() where the code
was referring to evt->u.rel inside the case label where evt->u.abs
is the correct name; thankfully, both members of the union have the
same type, so it happened to work, but it is now cleaner.

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


  Commit: 10f759079e616a1cc4701fc26ab5e2a048ce912c
      
https://github.com/qemu/qemu/commit/10f759079e616a1cc4701fc26ab5e2a048ce912c
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

  Changed paths:
    M blockdev.c
    M ui/input.c

  Log Message:
  -----------
  qapi: Avoid use of 'data' member of QAPI unions

QAPI code generators currently create a 'void *data' member as
part of the anonymous union embedded in the C struct corresponding
to a QAPI union.  However, directly assigning to this member of
the union feels a bit fishy, when we can assign to another member
of the struct instead.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


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

  Changed paths:
    M backends/baum.c
    M backends/msmouse.c
    M qapi-schema.json
    M qemu-char.c

  Log Message:
  -----------
  chardev: Drop useless ChardevDummy type

Commit d0d7708b made ChardevDummy be an empty wrapper type around
ChardevCommon.  But there is no technical reason for this indirection,
so simplify the code by directly using the base type.

Also change the fallback assignment to assign u.null rather than
u.data, since a future patch will remove the data member of the C
struct generated for QAPI unions.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 48eb62a74fc2d6b0ae9e5f414304a85cfbf33066
      
https://github.com/qemu/qemu/commit/48eb62a74fc2d6b0ae9e5f414304a85cfbf33066
  Author: Eric Blake <address@hidden>
  Date:   2016-03-05 (Sat, 05 Mar 2016)

  Changed paths:
    M scripts/qapi-types.py
    M tests/Makefile
    R tests/qapi-schema/union-clash-data.err
    R tests/qapi-schema/union-clash-data.exit
    R tests/qapi-schema/union-clash-data.json
    R tests/qapi-schema/union-clash-data.out

  Log Message:
  -----------
  qapi: Drop useless 'data' member of unions

We started moving away from the use of the 'void *data' member
in the C union corresponding to a QAPI union back in commit
544a373; recent commits have gotten rid of other uses.  Now
that it is completely unused, we can remove the member itself
as well as the FIXME comment.  Update the testsuite to drop the
negative test union-clash-data.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>


  Commit: 1464ad45cd6cdeb0b5c1a54d3d3791396e47e52f
      
https://github.com/qemu/qemu/commit/1464ad45cd6cdeb0b5c1a54d3d3791396e47e52f
  Author: Peter Maydell <address@hidden>
  Date:   2016-03-06 (Sun, 06 Mar 2016)

  Changed paths:
    M backends/baum.c
    M backends/msmouse.c
    M block/nbd.c
    M blockdev.c
    M docs/qapi-code-gen.txt
    M docs/qmp-spec.txt
    M hw/acpi/core.c
    M hw/char/escc.c
    M hw/input/hid.c
    M hw/input/ps2.c
    M hw/input/virtio-input-hid.c
    M net/net.c
    M numa.c
    M qapi-schema.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 scripts/qmp/qmp-shell
    M tests/Makefile
    M tests/qapi-schema/qapi-schema-test.json
    R tests/qapi-schema/union-clash-data.err
    R tests/qapi-schema/union-clash-data.exit
    R tests/qapi-schema/union-clash-data.json
    R tests/qapi-schema/union-clash-data.out
    M tests/test-io-channel-socket.c
    M tests/test-opts-visitor.c
    M ui/input-legacy.c
    M ui/input.c
    M ui/vnc.c
    M util/qemu-sockets.c

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

QAPI patches for 2016-03-04

# gpg: Signature made Sat 05 Mar 2016 09:47:19 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-04:
  qapi: Drop useless 'data' member of unions
  chardev: Drop useless ChardevDummy type
  qapi: Avoid use of 'data' member of QAPI unions
  ui: Shorten references into InputEvent
  util: Shorten references into SocketAddress
  chardev: Shorten references into ChardevBackend
  qapi: Update docs to match recent generator changes
  qapi-visit: Expose visit_type_FOO_members()
  qapi: Rename 'fields' to 'members' in generated C code
  qapi: Rename 'fields' to 'members' in generator
  qapi-dealloc: Reduce use outside of generated code
  qmp-shell: fix pretty printing of JSON responses

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


Compare: https://github.com/qemu/qemu/compare/3c0f12df65da...1464ad45cd6c

reply via email to

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