qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 4277f1: libqtest: Rename functions to send QM


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 4277f1: libqtest: Rename functions to send QMP messages
Date: Thu, 16 Aug 2018 02:49:28 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 4277f1ebd9b70ee38caddfe3c514d7a91e676bc1
      
https://github.com/qemu/qemu/commit/4277f1ebd9b70ee38caddfe3c514d7a91e676bc1
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/ahci-test.c
    M tests/libqos/ahci.c
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/qmp-test.c

  Log Message:
  -----------
  libqtest: Rename functions to send QMP messages

The functions to receive messages are called qtest_qmp_receive() and
qmp_receive(), qmp_fd_receive().  The ones to send messages are called
qtest_async_qmp(), qtest_async_qmpv(), qmp_async(), qmp_fd_send(),
qmp_fd_sendv().  Inconsistent.  Rename the *_async* ones to
qmp_send(), qtest_qmp_send(), qtest_qmp_vsend().  Rename
qmp_fd_sendv() to qmp_fd_vsend().

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: f94648fe3d298354d9b9fa03d8eaf622d92d781f
      
https://github.com/qemu/qemu/commit/f94648fe3d298354d9b9fa03d8eaf622d92d781f
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c

  Log Message:
  -----------
  libqtest: Clean up how we read device_del messages

qtest_qmp_device_del() still uses the qmp("") hack to receive a
message, even though we have qmp_receive() since commit 66e0c7b187e.
Put it to use.

Bonus: gets rid of empty format strings.  A step towards compile-time
format string checking without triggering -Wformat-zero-length.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: be62e1724f383c9e5012732af6c4dce587a917ee
      
https://github.com/qemu/qemu/commit/be62e1724f383c9e5012732af6c4dce587a917ee
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c

  Log Message:
  -----------
  libqtest: Clean up how we read the QMP greeting

qtest_init() still uses the qtest_qmp_discard_response(s, "") hack to
receive the greeting, even though we have qtest_qmp_receive() since
commit 66e0c7b187e.  Put it to use.

Bonus: gets rid of an empty format string.  A step towards
compile-time format string checking without triggering
-Wformat-zero-length.

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


  Commit: 055a1efc7c5a30ca0993720da57ba70179d28c7b
      
https://github.com/qemu/qemu/commit/055a1efc7c5a30ca0993720da57ba70179d28c7b
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/ahci-test.c
    M tests/boot-order-test.c
    M tests/drive_del-test.c
    M tests/fdc-test.c
    M tests/ide-test.c
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/migration-test.c
    M tests/test-filter-mirror.c
    M tests/test-filter-redirector.c
    M tests/virtio-blk-test.c

  Log Message:
  -----------
  libqtest: Remove qtest_qmp_discard_response() & friends

qtest_qmp_discard_response(...) is shorthand for
qobject_unref(qtest_qmp(...), except it's not actually shorter.
Moreover, the presence of these functions encourage sloppy testing.
Remove them from libqtest.  Add them as macros to the tests that use
them, with a TODO comment asking for cleanup.

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


  Commit: bb340eb2387edfc59098bde4caea387c369005b1
      
https://github.com/qemu/qemu/commit/bb340eb2387edfc59098bde4caea387c369005b1
  Author: Eric Blake <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.h

  Log Message:
  -----------
  libqtest: Document calling conventions

We have two flavors of vararg usage in qtest: qtest_hmp() etc. work
like sprintf(), and qtest_qmp() etc. work like qobject_from_jsonf().
Spell that out in the comments.

Also add GCC_FMT_ATTR() to qtest_hmp() etc. so that the compiler can
flag incorrect use.

We have some cleanup work to do before we can do the same for
qtest_qmp() etc.  This would get us the same better-than-nothing
checking we already have for qobject_from_jsonf(): common incorrect
uses of supported conversion specifications will be flagged
(e.g. passing a double for %d), but use of unsupported ones won't.

Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
[Rebased, comment wording tweaked, commit message rewritten]
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>


  Commit: 6ce80fd80355d29b3ed8c2fa14251a9b8276a86a
      
https://github.com/qemu/qemu/commit/6ce80fd80355d29b3ed8c2fa14251a9b8276a86a
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M include/qapi/qmp/qjson.h
    M qobject/qjson.c
    M tests/check-qjson.c
    M tests/libqtest.h

  Log Message:
  -----------
  qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail()

Commit ab45015a968 "qobject: Let qobject_from_jsonf() fail instead of
abort" fails to accomplish its stated aim: the function can still
abort due to its use of &error_abort.

Its rationale for letting it fail is that all remaining users cope
fine with failure.  Well, they're just fine with aborting, too; it's
what they do on failure.

Simply reverting the broken commit would bring back the unfortunate
asymmetry between qobject_from_jsonf() and qobject_from_jsonv(): one
aborts, the other returns null.  So also rename it to
qobject_from_jsonf_nofail().

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


  Commit: 4ff184689bf3d22b01c0d00c2bf6bf9595ff9b48
      
https://github.com/qemu/qemu/commit/4ff184689bf3d22b01c0d00c2bf6bf9595ff9b48
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M include/qapi/qmp/qjson.h
    M qobject/qjson.c

  Log Message:
  -----------
  qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail()

Every printf()-like function sooner or later needs its vprintf()-like
buddy.  The next commit will need qobject_from_jsonf_nofail()'s buddy,
and qdict_from_jsonf_nofail()'s buddy will be used later in this
series.  Add both.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 69f0cb661a9284045464619f24ceaa8771c0a212
      
https://github.com/qemu/qemu/commit/69f0cb661a9284045464619f24ceaa8771c0a212
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c

  Log Message:
  -----------
  libqtest: Simplify qmp_fd_vsend() a bit

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: eac78bd430f357b9d935afaa09355c6fc6a13e3d
      
https://github.com/qemu/qemu/commit/eac78bd430f357b9d935afaa09355c6fc6a13e3d
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/test-qobject-input-visitor.c

  Log Message:
  -----------
  test-qobject-input-visitor: Avoid format string ambiguity

When visitor_input_test_init_internal()'s argument @ap is null, then
@json_string is interpreted literally, else it's gets %-escapes
interpolated.  This is awkward.

One caller always passes null @ap, and the others never do.  Lift the
building of the QObject into the callers, where it can be done without
such ambiguity.

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


  Commit: 2d36e843042d2ef47f3bfc47a1a83401fdb07b84
      
https://github.com/qemu/qemu/commit/2d36e843042d2ef47f3bfc47a1a83401fdb07b84
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M include/qapi/qmp/qjson.h
    M qobject/qjson.c

  Log Message:
  -----------
  qobject: qobject_from_jsonv() is dangerous, hide it away

qobject_from_jsonv() takes ownership of %p arguments.  On failure, we
can't generally know whether we failed before or after %p, so
ownership becomes indeterminate.  To avoid leaks, callers passing %p
must terminate on error, e.g. by passing &error_abort.  Trap for the
unwary; document and give the function internal linkage.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 62fff696d56b90e5820d2c3c3085b778b23f0d93
      
https://github.com/qemu/qemu/commit/62fff696d56b90e5820d2c3c3085b778b23f0d93
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/ahci-test.c
    M tests/ide-test.c

  Log Message:
  -----------
  tests: Pass literal format strings directly to qmp_FOO()

The qmp_FOO() take a printf-like format string.  In a few places, we
assign a string literal to a variable and pass that instead of simply
passing the literal.  Clean that up.

Bonus: gets rid of non-literal format strings.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 015715f554f19a809cd80ff53a3881fddfda1336
      
https://github.com/qemu/qemu/commit/015715f554f19a809cd80ff53a3881fddfda1336
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqos/pci-pc.c
    M tests/libqtest.c
    M tests/migration-test.c
    M tests/test-qga.c
    M tests/tpm-util.c
    M tests/vhost-user-test.c

  Log Message:
  -----------
  tests: Clean up string interpolation into QMP input (simple cases)

When you build QMP input manually like this

    cmd = g_strdup_printf("{ 'execute': 'migrate',"
                    "'arguments': { 'uri': '%s' } }",
                    uri);
    rsp = qmp(cmd);
    g_free(cmd);

you're responsible for escaping the interpolated values for JSON.  Not
done here, and therefore works only for sufficiently nice @uri.  For
instance, if @uri contained a single "'", qobject_from_vjsonf_nofail()
would abort.  A sufficiently nasty @uri could even inject unwanted
members into the arguments object.

Leaving interpolation into JSON to qmp() is more robust:

    rsp = qmp("{ 'execute': 'migrate', 'arguments': { 'uri': %s } }", uri);

It's also more concise.

Clean up the simple cases where we interpolate exactly a JSON value.

Bonus: gets rid of non-literal format strings.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 530e79a822b9a0336705f2b262546e843c4bf90b
      
https://github.com/qemu/qemu/commit/530e79a822b9a0336705f2b262546e843c4bf90b
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/cpu-plug-test.c

  Log Message:
  -----------
  cpu-plug-test: Don't pass integers as strings to device_add

test_plug_with_device_add_x86() plugs Haswell-i386-cpu and
Haswell-x86_64-cpu with device_add.  It passes socket-id, core-id,
thread-id as JSON strings.  The properties are actually integers.

test_plug_with_device_add_coreid() plugs power8_v2.0-spapr-cpu-core
and qemu-s390x-cpu with device_add.  It passes core-id as JSON string.
The properties are actually integers.

Passing JSON string values to integer properties works only due to
device_add implementation accidents.  Fix the test to pass JSON
numbers.  While there, use %u rather than %i with unsigned int.

Cc: Thomas Huth <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 82cab70bd884a77fbe4e738725c32c88daca70d6
      
https://github.com/qemu/qemu/commit/82cab70bd884a77fbe4e738725c32c88daca70d6
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/cpu-plug-test.c
    M tests/e1000e-test.c
    M tests/ivshmem-test.c
    M tests/libqos/pci.c
    M tests/libqos/pci.h
    M tests/libqos/usb.c
    M tests/libqos/usb.h
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/usb-hcd-ehci-test.c
    M tests/usb-hcd-ohci-test.c
    M tests/usb-hcd-uhci-test.c
    M tests/usb-hcd-xhci-test.c
    M tests/virtio-blk-test.c
    M tests/virtio-net-test.c
    M tests/virtio-rng-test.c
    M tests/virtio-scsi-test.c
    M tests/virtio-serial-test.c

  Log Message:
  -----------
  tests: Clean up string interpolation around qtest_qmp_device_add()

Leaving interpolation into JSON to qmp() is more robust than building
QMP input manually, as explained in the commit before previous.

qtest_qmp_device_add() and its wrappers interpolate into JSON as
follows:

* qtest_qmp_device_add() interpolates members into a JSON object.

* So do its wrappers qpci_plug_device_test() and usb_test_hotplug().

* usb_test_hotplug() additionally interpolates strings and numbers
  into JSON strings.

Clean them up:

* Have qtest_qmp_device_add() take its extra device properties as
  arguments for qdict_from_jsonf_nofail() instead of a string
  containing JSON members.

* Drop qpci_plug_device_test(), use qtest_qmp_device_add()
  directly.

* Change usb_test_hotplug() parameter @port to string, to avoid
  interpolation.  Interpolate @hcd_id separately.

Bonus: gets rid of a non-literal format string.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

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


  Commit: e14541652486080a7bb38057f024a18143d111ed
      
https://github.com/qemu/qemu/commit/e14541652486080a7bb38057f024a18143d111ed
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/migration-test.c

  Log Message:
  -----------
  migration-test: Make wait_command() return the "return" member

All callers of wait_command() are only interested in the success
response's "return" member.  Lift its extraction into wait_command().

Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 3cd46d42fe632b4732eca23b15b99d1b26ee6f2c
      
https://github.com/qemu/qemu/commit/3cd46d42fe632b4732eca23b15b99d1b26ee6f2c
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/migration-test.c
    M tests/tpm-util.c

  Log Message:
  -----------
  tests: New helper qtest_qmp_receive_success()

Commit b21373d0713 copied wait_command() from tests/migration-test.c
to tests/tpm-util.c.  Replace both copies by new libqtest helper
qtest_qmp_receive_success().  Also use it to simplify
qtest_qmp_device_del().

Bonus: gets rid of a non-literal format string.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Cc: Thomas Huth <address@hidden>
Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Cc: Stefan Berger <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Stefan Berger <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 4399596b152f6c933a173b0e97ba4e3b6a57458f
      
https://github.com/qemu/qemu/commit/4399596b152f6c933a173b0e97ba4e3b6a57458f
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/migration-test.c

  Log Message:
  -----------
  migration-test: Make wait_command() cope with '%'

wait_command() passes its argument @command to qtest_qmp_send().
Falls apart if @command contain '%'.  Two ways to disarm this trap:
suppress interpretation of '%' by passing @command as argument to
format string "%s", or fix it by having wait_command() take the
variable arguments to go with @command.  Do the latter.

This is another step towards compile-time format string checking
without triggering -Wformat-nonliteral.

Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: b7281c6989c09a98670ea11c588b17737c846154
      
https://github.com/qemu/qemu/commit/b7281c6989c09a98670ea11c588b17737c846154
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/migration-test.c

  Log Message:
  -----------
  migration-test: Clean up string interpolation into QMP, part 1

Leaving interpolation into JSON to qmp() is more robust than building
QMP input manually, as explained in the recent commit "tests: Clean up
string interpolation into QMP input (simple cases)".

migrate_recover() builds QMP input manually because wait_command()
can't interpolate.  Well, it can since the previous commit.  Simplify
accordingly.

Bonus: gets rid of a non-literal format string.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: b5bbd3f315d686bd511f5be72e4aab3b2bd52de8
      
https://github.com/qemu/qemu/commit/b5bbd3f315d686bd511f5be72e4aab3b2bd52de8
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/migration-test.c

  Log Message:
  -----------
  migration-test: Clean up string interpolation into QMP, part 2

Leaving interpolation into JSON to qmp() is more robust than building
QMP input manually, as explained in the recent commit "tests: Clean up
string interpolation into QMP input (simple cases)".

migrate() interpolates members into a JSON object.  Change it to take
its extra QMP arguments as arguments for qdict_from_jsonf_nofail()
instead of a string containing JSON members.

Bonus: gets rid of a non-literal format string.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: c44a56d8ba1c13fea5c9d045ac178638807079cc
      
https://github.com/qemu/qemu/commit/c44a56d8ba1c13fea5c9d045ac178638807079cc
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/migration-test.c

  Log Message:
  -----------
  migration-test: Clean up string interpolation into QMP, part 3

Leaving interpolation into JSON to qmp() is more robust than building
QMP input manually, as explained in the recent commit "tests: Clean up
string interpolation into QMP input (simple cases)".

migration-test.c interpolates strings into JSON in a few places:

* migrate_set_parameter() interpolates string parameter @value as a
  JSON number.  Change it to long long.  This requires changing
  migrate_check_parameter() similarly.

* migrate_set_capability() interpolates string parameter @value as a
  JSON boolean.  Change it to bool.

* deprecated_set_speed() interpolates string parameter @value as a
  JSON number.  Change it to long long.

Bonus: gets rid of non-literal format strings.  A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.

Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: e3dc93be1ac46fdb58142383319b783b4c4ce8ca
      
https://github.com/qemu/qemu/commit/e3dc93be1ac46fdb58142383319b783b4c4ce8ca
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.h

  Log Message:
  -----------
  libqtest: Enable compile-time format string checking

qtest_qmp() & friends pass their format string and variable arguments
to qobject_from_vjsonf_nofail().  Unlike qobject_from_jsonv(), they
aren't decorated with GCC_FMT_ATTR().  Fix that to get compile-time
format string checking.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>


  Commit: 88b988c895e3c226e264502cec03e13c34bb8f61
      
https://github.com/qemu/qemu/commit/88b988c895e3c226e264502cec03e13c34bb8f61
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/boot-order-test.c
    M tests/boot-serial-test.c
    M tests/cdrom-test.c
    M tests/endianness-test.c
    M tests/ipmi-bt-test.c
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/m25p80-test.c
    M tests/m48t59-test.c
    M tests/machine-none-test.c
    M tests/numa-test.c
    M tests/pnv-xscom-test.c
    M tests/prom-env-test.c
    M tests/qmp-test.c
    M tests/sdhci-test.c
    M tests/tco-test.c
    M tests/test-filter-mirror.c
    M tests/test-filter-redirector.c
    M tests/virtio-balloon-test.c
    M tests/virtio-blk-test.c
    M tests/virtio-console-test.c
    M tests/virtio-serial-test.c
    M tests/vmgenid-test.c

  Log Message:
  -----------
  libqtest: Replace qtest_startf() by qtest_initf()

qtest_init() creates a new QTestState, and leaves @global_qtest alone.
qtest_start() additionally assigns it to @global_qtest, but
qtest_startf() additionally assigns NULL to @global_qtest.  This makes
no sense.  Replace it by qtest_initf() that works like qtest_init(),
i.e. leaves @global_qtest alone.

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


  Commit: 248eef02c5c59c6d48ae8e353dda4712e9c2bfdd
      
https://github.com/qemu/qemu/commit/248eef02c5c59c6d48ae8e353dda4712e9c2bfdd
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c
    M tests/libqtest.h

  Log Message:
  -----------
  libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency

13 of 13 C99 library function pairs taking ... or a va_list parameter
are called FOO() and vFOO().  In QEMU, we sometimes call the one
taking a va_list FOOv() instead.  Bad taste.  libqtest.h uses both
spellings.  Normalize it to the standard spelling.

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


  Commit: 71a268a5fd437e5beae0c931e5bb8afbfe7f3e53
      
https://github.com/qemu/qemu/commit/71a268a5fd437e5beae0c931e5bb8afbfe7f3e53
  Author: Eric Blake <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c

  Log Message:
  -----------
  tests/libqtest: Improve kill_qemu()

In kill_qemu() we have an assert that checks that the QEMU process
didn't dump core:
      assert(!WCOREDUMP(wstatus));

Unfortunately the WCOREDUMP macro here means the resulting message
is not very easy to comprehend on at least some systems:

ahci-test: tests/libqtest.c:113: kill_qemu: Assertion `!(((__extension__ 
(((union { __typeof(wstatus) __in; int __i; }) { .__in = (wstatus) }).__i))) & 
0x80)' failed.

and it doesn't identify what signal the process took. What's more,
WCOREDUMP is not reliable - in some cases, setrlimit() coupled with
kernel dump settings can result in the flag not being set.  It's
better to log ALL death by signal, instead of caring whether a core
dump was attempted (although once we know a signal happened, also
mentioning if a core dump is present can be helpful).

Furthermore, we are NOT detecting EINTR (while EINTR shouldn't be
happening if we didn't install signal handlers, it's still better
to always be robust).

Finally, even non-signal death with a non-zero status is suspicious,
since qemu's SIGINT handler is supposed to result in exit(0).

Instead of using a raw assert, print the information in an
easier to understand way:

/i386/ahci/sanity: tests/libqtest.c:129: kill_qemu() detected QEMU death from 
signal 11 (Segmentation fault) (core dumped)

(Of course, the really useful information would be why the QEMU
process dumped core in the first place, but we don't have that
by the time the test program has picked up the exit status.)

Suggested-by: Peter Maydell <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
[Core dump reporting and commit message tweaked]
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>


  Commit: f9e986d237881fda3ce599a89c26433531f5acbb
      
https://github.com/qemu/qemu/commit/f9e986d237881fda3ce599a89c26433531f5acbb
  Author: Markus Armbruster <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M tests/libqtest.c

  Log Message:
  -----------
  libqtest: Improve error reporting for bad read from QEMU

When read() from the qtest socket or the QMP socket fails or EOFs, we
report "Broken pipe" and exit(1).  This commonly happens when QEMU
crashes.  It also happens when QEMU refuses to run because the test
passed it bad arguments.  Sadly, we neglect to report either.

Improve this by calling abort() instead of exit(1), so kill_qemu()
runs, and reports how QEMU died.  This improves error reporting to
something like

    /x86_64/device/introspect/list: Broken pipe
    tests/libqtest.c:129: kill_qemu() detected QEMU death from signal 6 
(Aborted) (dumped core)

Three exit() remain in libqtest.c:

* In qmp_response(), when we can't parse a QMP reply read from the QMP
  socket.  Change to abort() for consistency.

* In qtest_qemu_binary(), when QTEST_QEMU_BINARY isn't in the
  environment.  This can only happen before we start QEMU.  Leave
  alone.

* In qtest_init_without_qmp_handshake(), when the fork()ed child fails
  to execlp().  Leave alone.

exit() elsewhere are unlikely due to QEMU dying on us.  If that should
turn out to be wrong, we can move kill_qemu() from @abrt_hooks to
atexit() or something.

Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
[Commit message tweaked slightly]


  Commit: c542a9f9794ec8e0bc3fcf5956d3cc8bce667789
      
https://github.com/qemu/qemu/commit/c542a9f9794ec8e0bc3fcf5956d3cc8bce667789
  Author: Peter Maydell <address@hidden>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M include/qapi/qmp/qjson.h
    M qobject/qjson.c
    M tests/ahci-test.c
    M tests/boot-order-test.c
    M tests/boot-serial-test.c
    M tests/cdrom-test.c
    M tests/check-qjson.c
    M tests/cpu-plug-test.c
    M tests/drive_del-test.c
    M tests/e1000e-test.c
    M tests/endianness-test.c
    M tests/fdc-test.c
    M tests/ide-test.c
    M tests/ipmi-bt-test.c
    M tests/ivshmem-test.c
    M tests/libqos/ahci.c
    M tests/libqos/pci-pc.c
    M tests/libqos/pci.c
    M tests/libqos/pci.h
    M tests/libqos/usb.c
    M tests/libqos/usb.h
    M tests/libqtest.c
    M tests/libqtest.h
    M tests/m25p80-test.c
    M tests/m48t59-test.c
    M tests/machine-none-test.c
    M tests/migration-test.c
    M tests/numa-test.c
    M tests/pnv-xscom-test.c
    M tests/prom-env-test.c
    M tests/qmp-test.c
    M tests/sdhci-test.c
    M tests/tco-test.c
    M tests/test-filter-mirror.c
    M tests/test-filter-redirector.c
    M tests/test-qga.c
    M tests/test-qobject-input-visitor.c
    M tests/tpm-util.c
    M tests/usb-hcd-ehci-test.c
    M tests/usb-hcd-ohci-test.c
    M tests/usb-hcd-uhci-test.c
    M tests/usb-hcd-xhci-test.c
    M tests/vhost-user-test.c
    M tests/virtio-balloon-test.c
    M tests/virtio-blk-test.c
    M tests/virtio-console-test.c
    M tests/virtio-net-test.c
    M tests/virtio-rng-test.c
    M tests/virtio-scsi-test.c
    M tests/virtio-serial-test.c
    M tests/vmgenid-test.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/armbru/tags/pull-tests-2018-08-16' into 
staging

Testing patches for 2018-08-16

# gpg: Signature made Thu 16 Aug 2018 09:34:43 BST
# gpg:                using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <address@hidden>"
# gpg:                 aka "Markus Armbruster <address@hidden>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-tests-2018-08-16: (25 commits)
  libqtest: Improve error reporting for bad read from QEMU
  tests/libqtest: Improve kill_qemu()
  libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency
  libqtest: Replace qtest_startf() by qtest_initf()
  libqtest: Enable compile-time format string checking
  migration-test: Clean up string interpolation into QMP, part 3
  migration-test: Clean up string interpolation into QMP, part 2
  migration-test: Clean up string interpolation into QMP, part 1
  migration-test: Make wait_command() cope with '%'
  tests: New helper qtest_qmp_receive_success()
  migration-test: Make wait_command() return the "return" member
  tests: Clean up string interpolation around qtest_qmp_device_add()
  cpu-plug-test: Don't pass integers as strings to device_add
  tests: Clean up string interpolation into QMP input (simple cases)
  tests: Pass literal format strings directly to qmp_FOO()
  qobject: qobject_from_jsonv() is dangerous, hide it away
  test-qobject-input-visitor: Avoid format string ambiguity
  libqtest: Simplify qmp_fd_vsend() a bit
  qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail()
  qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail()
  ...

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


Compare: https://github.com/qemu/qemu/compare/d3bd57d9f6a6...c542a9f9794e
      **NOTE:** This service has been marked for deprecation: 
https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.

reply via email to

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