All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups
@ 2017-09-01 18:03 Eric Blake
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot Eric Blake
                   ` (29 more replies)
  0 siblings, 30 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Markus gave some good advice on my 'v4: Clean up around qmp() and hmp()'
series [1], but Paolo made the suggestion on v5 [2] that we are probably
better off avoiding dependence on a magic global variable, rather than
making such dependence even more prominent.  So, this round of patches
starts to head in the direction of more explicit use of a QTestState
object - particularly in all tests that have more than one test state
active at a given time.  There is still more work to do (patch 28 shows
how many tests still depend on global_qtest), and I'd still like to do
even more renaming (for example, rather than having qtest_inb(s, addr)
and inb(addr), I'd rather have a single inb(s, addr) once I get rid of
all dependence on global_qtest, but this series was getting long
enough that I want to get review started on the earlier parts that
might as well go in the tree now rather than waiting for the whole
conversion series to be complete.  (Or, by posting this alternative
that goes the opposite direction from v5, we may decide that depending
on global_qtest is not so bad after all, and just go with v5 instead
of this version.)

There's still more libqtest cleanups in my queue, in particular all
the work around making qmp("...") friendlier to use and compatible
with gcc -Wformat checking, but we'll take it one step at a time.

[1] https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg00595.html
[2] https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg03589.html

Since v5:
001/29:[down] 'tests: Improve .gitignore for tests/multiboot'
002/29:[down] 'tests: Sort .gitignore'
003/29:[----] [--] 'test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code'
004/29:[----] [--] 'qtest: Don't perform side effects inside assertion'
005/29:[----] [--] 'numa-test: Use hmp()'
006/29:[----] [-C] 'tests: Clean up wait for event'
007/29:[----] [--] 'libqtest: Remove dead qtest_instances variable'
008/29:[----] [--] 'libqtest: Let socket_send() compute length'
009/29:[----] [--] 'libqtest: Use qemu_strtoul()'
010/29:[----] [--] 'libqtest: Topologically sort functions'
011/29:[----] [--] 'libqtest: Inline qtest_query_target_endianness()'
012/29:[down] 'libqos: Track QTestState with QPCIBus'
013/29:[down] 'libqos: Use explicit QTestState for pci operations'
014/29:[down] 'libqos: Use explicit QTestState for fw_cfg operations'
015/29:[down] 'libqos: Use explicit QTestState for rtas operations'
016/29:[down] 'libqos: Use explicit QTestState for virtio operations'
017/29:[down] 'ahci-test: Drop dependence on global_qtest'
018/29:[down] 'ivshmem-test: Drop dependence on global_qtest'
019/29:[down] 'postcopy-test: Drop dependence on global_qtest'
020/29:[down] 'vhost-user-test: Drop dependence on global_qtest'
021/29:[down] 'qmp-test: Drop dependence on global_qtest'
022/29:[down] 'tests/boot-sector: Drop dependence on global_qtest'
023/29:[down] 'tests/acpi-utils: Drop dependence on global_qtest'
024/29:[down] 'bios-tables-test: Drop dependence on global_qtest'
025/29:[down] 'wdt_ib700-test: Drop dependence on global_qtest'
026/29:[down] 'fw_cfg-test: Drop dependence on global_qtest'
027/29:[down] 'libqtest: Make qtest_init() accept format string'
028/29:[down] 'libqtest: Remove qtest_start() and qtest_end() shortcuts'
029/29:[down] 'libqtest: Rename qtest_init() to qtest_start()'

Eric Blake (28):
  tests: Improve .gitignore for tests/multiboot
  tests: Sort .gitignore
  test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code
  qtest: Don't perform side effects inside assertion
  numa-test: Use hmp()
  libqtest: Remove dead qtest_instances variable
  libqtest: Let socket_send() compute length
  libqtest: Use qemu_strtoul()
  libqtest: Topologically sort functions
  libqtest: Inline qtest_query_target_endianness()
  libqos: Track QTestState with QPCIBus
  libqos: Use explicit QTestState for pci operations
  libqos: Use explicit QTestState for fw_cfg operations
  libqos: Use explicit QTestState for rtas operations
  libqos: Use explicit QTestState for virtio operations
  ahci-test: Drop dependence on global_qtest
  ivshmem-test: Drop dependence on global_qtest
  postcopy-test: Drop dependence on global_qtest
  vhost-user-test: Drop dependence on global_qtest
  qmp-test: Drop dependence on global_qtest
  tests/boot-sector: Drop dependence on global_qtest
  tests/acpi-utils: Drop dependence on global_qtest
  bios-tables-test: Drop dependence on global_qtest
  wdt_ib700-test: Drop dependence on global_qtest
  fw_cfg-test: Drop dependence on global_qtest
  libqtest: Make qtest_init() accept format string
  libqtest: Remove qtest_start() and qtest_end() shortcuts
  libqtest: Rename qtest_init() to qtest_start()

Markus Armbruster (1):
  tests: Clean up wait for event

 tests/libqtest.h               |  37 +-----
 tests/acpi-utils.h             |  65 ++++-----
 tests/boot-sector.h            |   6 +-
 tests/libqos/ahci.h            |   2 +-
 tests/libqos/fw_cfg.h          |  10 +-
 tests/libqos/libqos.h          |   5 +-
 tests/libqos/malloc-pc.h       |   4 +-
 tests/libqos/malloc-spapr.h    |   2 +-
 tests/libqos/malloc.h          |   1 +
 tests/libqos/pci-pc.h          |   2 +-
 tests/libqos/pci-spapr.h       |   2 +-
 tests/libqos/pci.h             |   1 +
 tests/libqos/rtas.h            |   9 +-
 tests/libqos/virtio-mmio.h     |   3 +-
 tests/libqos/virtio.h          |   5 +-
 tests/libqtest.c               | 293 +++++++++++++++++++++--------------------
 qtest.c                        |  80 +++++++----
 tests/ac97-test.c              |   4 +-
 tests/acpi-utils.c             |  19 +--
 tests/ahci-test.c              |  85 ++++++------
 tests/bios-tables-test.c       | 198 ++++++++++++++--------------
 tests/boot-order-test.c        |  19 ++-
 tests/boot-sector.c            |   8 +-
 tests/boot-serial-test.c       |  12 +-
 tests/device-introspect-test.c |  24 ++--
 tests/display-vga-test.c       |  18 +--
 tests/drive_del-test.c         |  17 +--
 tests/ds1338-test.c            |   2 +-
 tests/e1000-test.c             |  10 +-
 tests/e1000e-test.c            |  24 ++--
 tests/eepro100-test.c          |  11 +-
 tests/endianness-test.c        |  33 ++---
 tests/es1370-test.c            |   4 +-
 tests/fdc-test.c               |   4 +-
 tests/fw_cfg-test.c            |  13 +-
 tests/hd-geo-test.c            |  16 +--
 tests/i440fx-test.c            |  16 +--
 tests/i82801b11-test.c         |   5 +-
 tests/ide-test.c               |   8 +-
 tests/intel-hda-test.c         |  11 +-
 tests/ioh3420-test.c           |   7 +-
 tests/ipmi-bt-test.c           |  11 +-
 tests/ipmi-kcs-test.c          |   7 +-
 tests/ipoctal232-test.c        |   5 +-
 tests/ivshmem-test.c           |  22 +---
 tests/libqos/ahci.c            |  49 +++----
 tests/libqos/fw_cfg.c          |  14 +-
 tests/libqos/libqos-pc.c       |   2 +-
 tests/libqos/libqos.c          |  45 ++-----
 tests/libqos/malloc-pc.c       |   8 +-
 tests/libqos/malloc-spapr.c    |   4 +-
 tests/libqos/pci-pc.c          |  58 ++++----
 tests/libqos/pci-spapr.c       |  44 ++++---
 tests/libqos/rtas.c            |  21 +--
 tests/libqos/virtio-mmio.c     |  54 ++++----
 tests/libqos/virtio-pci.c      |   3 +
 tests/libqos/virtio.c          |  77 ++++++-----
 tests/m25p80-test.c            |   9 +-
 tests/m48t59-test.c            |   2 +-
 tests/ne2000-test.c            |   4 +-
 tests/numa-test.c              |  49 +++----
 tests/nvme-test.c              |   7 +-
 tests/pc-cpu-test.c            |  26 ++--
 tests/pcnet-test.c             |   4 +-
 tests/pnv-xscom-test.c         |  14 +-
 tests/postcopy-test.c          |  86 ++++++------
 tests/prom-env-test.c          |  13 +-
 tests/pvpanic-test.c           |   4 +-
 tests/pxe-test.c               |  16 +--
 tests/q35-test.c               |  12 +-
 tests/qmp-test.c               |  35 ++---
 tests/qom-test.c               |   7 +-
 tests/rtas-test.c              |   2 +-
 tests/rtc-test.c               |   2 +-
 tests/rtl8139-test.c           |   7 +-
 tests/spapr-phb-test.c         |   5 +-
 tests/tco-test.c               |  17 +--
 tests/test-arm-mptimer.c       |   4 +-
 tests/test-filter-mirror.c     |  16 +--
 tests/test-filter-redirector.c |  60 ++++-----
 tests/test-hmp.c               |   7 +-
 tests/test-netfilter.c         |   9 +-
 tests/test-qga.c               |  90 -------------
 tests/test-x86-cpuid-compat.c  |  13 +-
 tests/tmp105-test.c            |   7 +-
 tests/tpci200-test.c           |   4 +-
 tests/usb-hcd-ehci-test.c      |  27 ++--
 tests/usb-hcd-ohci-test.c      |   4 +-
 tests/usb-hcd-uhci-test.c      |   6 +-
 tests/usb-hcd-xhci-test.c      |  19 +--
 tests/vhost-user-test.c        | 105 ++++++---------
 tests/virtio-balloon-test.c    |   4 +-
 tests/virtio-blk-test.c        |  16 +--
 tests/virtio-console-test.c    |  12 +-
 tests/virtio-net-test.c        |   4 +-
 tests/virtio-rng-test.c        |   4 +-
 tests/virtio-serial-test.c     |   4 +-
 tests/vmgenid-test.c           |  49 +++----
 tests/vmxnet3-test.c           |   4 +-
 tests/wdt_ib700-test.c         |  84 ++++++------
 tests/.gitignore               |  30 +++--
 101 files changed, 1092 insertions(+), 1330 deletions(-)

-- 
2.13.5

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-04 14:03   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore Eric Blake
                   ` (28 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Right now, tests/multiboot is not run by default during 'make check';
but when it is run in-tree, it was leaving some junk behind that could
accidentally get checked in with a careless 'git add tests'.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/.gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index fed0189a5a..64ecd6683b 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -10,6 +10,8 @@ check-qnull
 check-qstring
 check-qom-interface
 check-qom-proplist
+multiboot/test.out
+multiboot/*.elf
 qht-bench
 rcutorture
 test-aio
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  7:20   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
                   ` (27 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

It doesn't matter if things are unsorted, but finding stuff in a list
is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
en_US.UTF-8).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/.gitignore | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/tests/.gitignore b/tests/.gitignore
index 64ecd6683b..8d35a58751 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,25 +1,27 @@
+*-test
 atomic_add-bench
 benchmark-crypto-cipher
 benchmark-crypto-hash
 benchmark-crypto-hmac
 check-qdict
-check-qnum
 check-qjson
 check-qlist
 check-qnull
-check-qstring
+check-qnum
 check-qom-interface
 check-qom-proplist
-multiboot/test.out
+check-qstring
 multiboot/*.elf
+multiboot/test.out
+qapi-schema/*.test.*
 qht-bench
 rcutorture
 test-aio
 test-aio-multithread
 test-arm-mptimer
 test-base64
-test-bitops
 test-bitcnt
+test-bitops
 test-blockjob
 test-blockjob-txn
 test-bufferiszero
@@ -35,18 +37,19 @@ test-crypto-ivgen
 test-crypto-pbkdf
 test-crypto-secret
 test-crypto-tlscredsx509
-test-crypto-tlscredsx509-work/
 test-crypto-tlscredsx509-certs/
+test-crypto-tlscredsx509-work/
 test-crypto-tlssession
-test-crypto-tlssession-work/
 test-crypto-tlssession-client/
 test-crypto-tlssession-server/
+test-crypto-tlssession-work/
 test-crypto-xts
 test-cutils
+test-filter-mirror
+test-filter-redirector
 test-hbitmap
 test-hmp
 test-int128
-test-iov
 test-io-channel-buffer
 test-io-channel-command
 test-io-channel-command.fifo
@@ -55,27 +58,29 @@ test-io-channel-file.txt
 test-io-channel-socket
 test-io-channel-tls
 test-io-task
+test-iov
 test-keyval
 test-logging
 test-mul64
+test-netfilter
 test-opts-visitor
 test-qapi-event.[ch]
 test-qapi-types.[ch]
 test-qapi-util
 test-qapi-visit.[ch]
 test-qdev-global-props
-test-qemu-opts
 test-qdist
+test-qemu-opts
 test-qga
 test-qht
 test-qht-par
 test-qmp-commands
 test-qmp-commands.h
 test-qmp-event
-test-qobject-input-strict
-test-qobject-input-visitor
 test-qmp-introspect.[ch]
 test-qmp-marshal.c
+test-qobject-input-strict
+test-qobject-input-visitor
 test-qobject-output-visitor
 test-rcu-list
 test-replication
@@ -92,8 +97,3 @@ test-write-threshold
 test-x86-cpuid
 test-x86-cpuid-compat
 test-xbzrle
-test-netfilter
-test-filter-mirror
-test-filter-redirector
-*-test
-qapi-schema/*.test.*
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot Eric Blake
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  7:43   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion Eric Blake
                   ` (26 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Back when the test was introduced, in commit 62c39b307, the
test was set up to run qemu-ga directly on the host performing
the test, and defaults to limiting itself to safe commands.  At
the time, it was envisioned that setting QGA_TEST_SIDE_EFFECTING
in the environment could cover a few more commands, while noting
the potential danger of those side effects running in the host.

But this has NEVER been tested: if you enable the environment
variable, the test WILL fail.  One obvious reason: if you are not
running as root, you'll probably get a permission failure when
trying to freeze the file systems, or when changing system time.
Less obvious: if you run the test as root (wow, you're brave), you
could end up hanging if the test tries to log things to a
temporarily frozen filesystem.  But the cutest reason of all: if
you get past the above hurdles, the test uses invalid JSON in
test_qga_fstrim() (missing '' around the dictionary key 'minimum'),
and will thus fail an assertion in qmp_fd().

Rather than leave this untested time-bomb in place, rip it out.
Hopefully, as originally envisioned, we can find an opportunity
to test an actual sandboxed guest where the guest-agent has
full permissions and will not unduly affect the host running
the test - if so, 'git revert' can be used if desired, for
salvaging any useful parts of this attempt.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-qga.c | 90 --------------------------------------------------------
 1 file changed, 90 deletions(-)

diff --git a/tests/test-qga.c b/tests/test-qga.c
index 06783e7585..fd6bc7690f 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -642,65 +642,6 @@ static void test_qga_get_time(gconstpointer fix)
     QDECREF(ret);
 }

-static void test_qga_set_time(gconstpointer fix)
-{
-    const TestFixture *fixture = fix;
-    QDict *ret;
-    int64_t current, time;
-    gchar *cmd;
-
-    /* get current time */
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    current = qdict_get_int(ret, "return");
-    g_assert_cmpint(current, >, 0);
-    QDECREF(ret);
-
-    /* set some old time */
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-set-time',"
-                 " 'arguments': { 'time': 1000 } }");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    QDECREF(ret);
-
-    /* check old time */
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    time = qdict_get_int(ret, "return");
-    g_assert_cmpint(time / 1000, <, G_USEC_PER_SEC * 10);
-    QDECREF(ret);
-
-    /* set back current time */
-    cmd = g_strdup_printf("{'execute': 'guest-set-time',"
-                          " 'arguments': { 'time': %" PRId64 " } }",
-                          current + time * 1000);
-    ret = qmp_fd(fixture->fd, cmd);
-    g_free(cmd);
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    QDECREF(ret);
-}
-
-static void test_qga_fstrim(gconstpointer fix)
-{
-    const TestFixture *fixture = fix;
-    QDict *ret;
-    QList *list;
-    const QListEntry *entry;
-
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-fstrim',"
-                 " arguments: { minimum: 4194304 } }");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    list = qdict_get_qlist(ret, "return");
-    entry = qlist_first(list);
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "paths"));
-
-    QDECREF(ret);
-}
-
 static void test_qga_blacklist(gconstpointer data)
 {
     TestFixture fix;
@@ -831,30 +772,6 @@ static void test_qga_fsfreeze_status(gconstpointer fix)
     QDECREF(ret);
 }

-static void test_qga_fsfreeze_and_thaw(gconstpointer fix)
-{
-    const TestFixture *fixture = fix;
-    QDict *ret;
-    const gchar *status;
-
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-freeze'}");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    QDECREF(ret);
-
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-status'}");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    status = qdict_get_try_str(ret, "return");
-    g_assert_cmpstr(status, ==, "frozen");
-    QDECREF(ret);
-
-    ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-thaw'}");
-    g_assert_nonnull(ret);
-    qmp_assert_no_error(ret);
-    QDECREF(ret);
-}
-
 static void test_qga_guest_exec(gconstpointer fix)
 {
     const TestFixture *fixture = fix;
@@ -1029,13 +946,6 @@ int main(int argc, char **argv)
     g_test_add_data_func("/qga/guest-get-osinfo", &fix,
                          test_qga_guest_get_osinfo);

-    if (g_getenv("QGA_TEST_SIDE_EFFECTING")) {
-        g_test_add_data_func("/qga/fsfreeze-and-thaw", &fix,
-                             test_qga_fsfreeze_and_thaw);
-        g_test_add_data_func("/qga/set-time", &fix, test_qga_set_time);
-        g_test_add_data_func("/qga/fstrim", &fix, test_qga_fstrim);
-    }
-
     ret = g_test_run();

     fixture_tear_down(&fix, NULL);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (2 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-04 14:06   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp() Eric Blake
                   ` (25 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Assertions should be separate from the side effects, since in
theory, g_assert() can be disabled (in practice, we can't really
ever do that).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 qtest.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 57 insertions(+), 23 deletions(-)

diff --git a/qtest.c b/qtest.c
index 88a09e9afc..cbbfb71114 100644
--- a/qtest.c
+++ b/qtest.c
@@ -332,10 +332,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
                strcmp(words[0], "outl") == 0) {
         unsigned long addr;
         unsigned long value;
+        int ret;

         g_assert(words[1] && words[2]);
-        g_assert(qemu_strtoul(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtoul(words[2], NULL, 0, &value) == 0);
+        ret = qemu_strtoul(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtoul(words[2], NULL, 0, &value);
+        g_assert(ret == 0);
         g_assert(addr <= 0xffff);

         if (words[0][3] == 'b') {
@@ -352,9 +355,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         strcmp(words[0], "inl") == 0) {
         unsigned long addr;
         uint32_t value = -1U;
+        int ret;

         g_assert(words[1]);
-        g_assert(qemu_strtoul(words[1], NULL, 0, &addr) == 0);
+        ret = qemu_strtoul(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
         g_assert(addr <= 0xffff);

         if (words[0][2] == 'b') {
@@ -372,10 +377,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
                strcmp(words[0], "writeq") == 0) {
         uint64_t addr;
         uint64_t value;
+        int ret;

         g_assert(words[1] && words[2]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &value) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &value);
+        g_assert(ret == 0);

         if (words[0][5] == 'b') {
             uint8_t data = value;
@@ -401,9 +409,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
                strcmp(words[0], "readq") == 0) {
         uint64_t addr;
         uint64_t value = UINT64_C(-1);
+        int ret;

         g_assert(words[1]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);

         if (words[0][4] == 'b') {
             uint8_t data;
@@ -427,10 +437,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         uint64_t addr, len, i;
         uint8_t *data;
         char *enc;
+        int ret;

         g_assert(words[1] && words[2]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &len);
+        g_assert(ret == 0);
         /* We'd send garbage to libqtest if len is 0 */
         g_assert(len);

@@ -451,10 +464,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         uint64_t addr, len;
         uint8_t *data;
         gchar *b64_data;
+        int ret;

         g_assert(words[1] && words[2]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &len);
+        g_assert(ret == 0);

         data = g_malloc(len);
         cpu_physical_memory_read(addr, data, len);
@@ -468,10 +484,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         uint64_t addr, len, i;
         uint8_t *data;
         size_t data_len;
+        int ret;

         g_assert(words[1] && words[2] && words[3]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &len);
+        g_assert(ret == 0);

         data_len = strlen(words[3]);
         if (data_len < 3) {
@@ -497,11 +516,15 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         uint64_t addr, len;
         uint8_t *data;
         unsigned long pattern;
+        int ret;

         g_assert(words[1] && words[2] && words[3]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);
-        g_assert(qemu_strtoul(words[3], NULL, 0, &pattern) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &len);
+        g_assert(ret == 0);
+        ret = qemu_strtoul(words[3], NULL, 0, &pattern);
+        g_assert(ret == 0);

         if (len) {
             data = g_malloc(len);
@@ -517,10 +540,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         uint8_t *data;
         size_t data_len;
         gsize out_len;
+        int ret;

         g_assert(words[1] && words[2] && words[3]);
-        g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);
-        g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);
+        ret = qemu_strtou64(words[1], NULL, 0, &addr);
+        g_assert(ret == 0);
+        ret = qemu_strtou64(words[2], NULL, 0, &len);
+        g_assert(ret == 0);

         data_len = strlen(words[3]);
         if (data_len < 3) {
@@ -551,11 +577,16 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
     } else if (strcmp(words[0], "rtas") == 0) {
         uint64_t res, args, ret;
         unsigned long nargs, nret;
+        int rc;

-        g_assert(qemu_strtoul(words[2], NULL, 0, &nargs) == 0);
-        g_assert(qemu_strtou64(words[3], NULL, 0, &args) == 0);
-        g_assert(qemu_strtoul(words[4], NULL, 0, &nret) == 0);
-        g_assert(qemu_strtou64(words[5], NULL, 0, &ret) == 0);
+        rc = qemu_strtoul(words[2], NULL, 0, &nargs);
+        g_assert(rc == 0);
+        rc = qemu_strtou64(words[3], NULL, 0, &args);
+        g_assert(rc == 0);
+        rc = qemu_strtoul(words[4], NULL, 0, &nret);
+        g_assert(rc == 0);
+        rc = qemu_strtou64(words[5], NULL, 0, &ret);
+        g_assert(rc == 0);
         res = qtest_rtas_call(words[1], nargs, args, nret, ret);

         qtest_send_prefix(chr);
@@ -565,7 +596,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         int64_t ns;

         if (words[1]) {
-            g_assert(qemu_strtoi64(words[1], NULL, 0, &ns) == 0);
+            int ret = qemu_strtoi64(words[1], NULL, 0, &ns);
+            g_assert(ret == 0);
         } else {
             ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
         }
@@ -575,9 +607,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
                     (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
     } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) {
         int64_t ns;
+        int ret;

         g_assert(words[1]);
-        g_assert(qemu_strtoi64(words[1], NULL, 0, &ns) == 0);
+        ret = qemu_strtoi64(words[1], NULL, 0, &ns);
+        g_assert(ret == 0);
         qtest_clock_warp(ns);
         qtest_send_prefix(chr);
         qtest_sendf(chr, "OK %"PRIi64"\n",
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp()
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (3 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  7:44   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 06/29] tests: Clean up wait for event Eric Blake
                   ` (24 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Don't open-code something that has a convenient helper available.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> 
---
 tests/numa-test.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/tests/numa-test.c b/tests/numa-test.c
index 3f636840b1..e1b6152244 100644
--- a/tests/numa-test.c
+++ b/tests/numa-test.c
@@ -17,21 +17,6 @@ static char *make_cli(const char *generic_cli, const char *test_cli)
     return g_strdup_printf("%s %s", generic_cli ? generic_cli : "", test_cli);
 }

-static char *hmp_info_numa(void)
-{
-    QDict *resp;
-    char *s;
-
-    resp = qmp("{ 'execute': 'human-monitor-command', 'arguments': "
-                      "{ 'command-line': 'info numa '} }");
-    g_assert(resp);
-    g_assert(qdict_haskey(resp, "return"));
-    s = g_strdup(qdict_get_str(resp, "return"));
-    g_assert(s);
-    QDECREF(resp);
-    return s;
-}
-
 static void test_mon_explicit(const void *data)
 {
     char *s;
@@ -42,7 +27,7 @@ static void test_mon_explicit(const void *data)
                    "-numa node,nodeid=1,cpus=4-7 ");
     qtest_start(cli);

-    s = hmp_info_numa();
+    s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
     g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
     g_free(s);
@@ -59,7 +44,7 @@ static void test_mon_default(const void *data)
     cli = make_cli(data, "-smp 8 -numa node -numa node");
     qtest_start(cli);

-    s = hmp_info_numa();
+    s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
     g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
     g_free(s);
@@ -78,7 +63,7 @@ static void test_mon_partial(const void *data)
                    "-numa node,nodeid=1,cpus=4-5 ");
     qtest_start(cli);

-    s = hmp_info_numa();
+    s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
     g_assert(strstr(s, "node 1 cpus: 4 5"));
     g_free(s);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 06/29] tests: Clean up wait for event
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (4 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp() Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable Eric Blake
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini, Gerd Hoffmann

From: Markus Armbruster <armbru@redhat.com>

We still use hacks like qmp("") to wait for an event, even though we
have qmp_eventwait() since commit 8fe941f, and qmp_eventwait_ref()
since commit 7ffe312.  Both commits neglected to convert all the
existing hacks.  Make up what they missed.

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 <armbru@redhat.com>
Message-Id: <1500645206-13559-8-git-send-email-armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>

---
v4: hoist earlier in series
---
 tests/boot-order-test.c   |  2 +-
 tests/libqos/pci-pc.c     |  6 +-----
 tests/tco-test.c          |  3 +--
 tests/usb-hcd-uhci-test.c |  6 +-----
 tests/usb-hcd-xhci-test.c | 12 ++----------
 tests/wdt_ib700-test.c    | 35 ++++++++++-------------------------
 6 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index fc1e7941f7..9d516830dd 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -43,7 +43,7 @@ static void test_a_boot_order(const char *machine,
      * system_reset only requests reset.  We get a RESET event after
      * the actual reset completes.  Need to wait for that.
      */
-    qmp_discard_response("");   /* HACK: wait for event */
+    qmp_eventwait("RESET");
     actual = read_boot_order();
     g_assert_cmphex(actual, ==, expected_reboot);
     qtest_quit(global_qtest);
diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index ded1c54c06..02ce49927a 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -173,9 +173,5 @@ void qpci_unplug_acpi_device_test(const char *id, uint8_t slot)

     outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);

-    response = qmp("");
-    g_assert(response);
-    g_assert(qdict_haskey(response, "event"));
-    g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
-    QDECREF(response);
+    qmp_eventwait("DEVICE_DELETED");
 }
diff --git a/tests/tco-test.c b/tests/tco-test.c
index c4c264eb3d..f2ed6ed91c 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -237,9 +237,8 @@ static void test_tco_max_timeout(void)

 static QDict *get_watchdog_action(void)
 {
-    QDict *ev = qmp("");
+    QDict *ev = qmp_eventwait_ref("WATCHDOG");
     QDict *data;
-    g_assert(!strcmp(qdict_get_str(ev, "event"), "WATCHDOG"));

     data = qdict_get_qdict(ev, "data");
     QINCREF(data);
diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
index 5b500fedb0..0fb7f8d223 100644
--- a/tests/usb-hcd-uhci-test.c
+++ b/tests/usb-hcd-uhci-test.c
@@ -68,11 +68,7 @@ static void test_usb_storage_hotplug(void)
     g_assert(!qdict_haskey(response, "error"));
     QDECREF(response);

-    response = qmp("");
-    g_assert(response);
-    g_assert(qdict_haskey(response, "event"));
-    g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
-    QDECREF(response);
+    qmp_eventwait("DEVICE_DELETED");
 }

 int main(int argc, char **argv)
diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
index 031764da6d..c05a339894 100644
--- a/tests/usb-hcd-xhci-test.c
+++ b/tests/usb-hcd-xhci-test.c
@@ -57,11 +57,7 @@ static void test_usb_uas_hotplug(void)
     g_assert(!qdict_haskey(response, "error"));
     QDECREF(response);

-    response = qmp("");
-    g_assert(qdict_haskey(response, "event"));
-    g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
-    QDECREF(response);
-
+    qmp_eventwait("DEVICE_DELETED");

     response = qmp("{'execute': 'device_del',"
                            " 'arguments': {"
@@ -71,11 +67,7 @@ static void test_usb_uas_hotplug(void)
     g_assert(!qdict_haskey(response, "error"));
     QDECREF(response);

-    response = qmp("");
-    g_assert(response);
-    g_assert(qdict_haskey(response, "event"));
-    g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
-    QDECREF(response);
+    qmp_eventwait("DEVICE_DELETED");
 }

 int main(int argc, char **argv)
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 49f4f0c221..4fc8eeae86 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -18,26 +18,10 @@ static void qmp_check_no_event(void)
     QDECREF(resp);
 }

-static QDict *qmp_get_event(const char *name)
-{
-    QDict *event = qmp("");
-    QDict *data;
-    g_assert(qdict_haskey(event, "event"));
-    g_assert(!strcmp(qdict_get_str(event, "event"), name));
-
-    if (qdict_haskey(event, "data")) {
-        data = qdict_get_qdict(event, "data");
-        QINCREF(data);
-    } else {
-        data = NULL;
-    }
-
-    QDECREF(event);
-    return data;
-}
-
 static QDict *ib700_program_and_wait(QTestState *s)
 {
+    QDict *event, *data;
+
     clock_step(NANOSECONDS_PER_SECOND * 40);
     qmp_check_no_event();

@@ -61,7 +45,11 @@ static QDict *ib700_program_and_wait(QTestState *s)
     clock_step(3 * NANOSECONDS_PER_SECOND);
     qmp_check_no_event();
     clock_step(2 * NANOSECONDS_PER_SECOND);
-    return qmp_get_event("WATCHDOG");
+    event = qmp_eventwait_ref("WATCHDOG");
+    data = qdict_get_qdict(event, "data");
+    QINCREF(data);
+    QDECREF(event);
+    return data;
 }


@@ -73,8 +61,7 @@ static void ib700_pause(void)
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
     QDECREF(d);
-    d = qmp_get_event("STOP");
-    QDECREF(d);
+    qmp_eventwait("STOP");
     qtest_end();
 }

@@ -86,8 +73,7 @@ static void ib700_reset(void)
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
-    d = qmp_get_event("RESET");
-    QDECREF(d);
+    qmp_eventwait("RESET");
     qtest_end();
 }

@@ -99,8 +85,7 @@ static void ib700_shutdown(void)
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
-    d = qmp_get_event("SHUTDOWN");
-    QDECREF(d);
+    qmp_eventwait("SHUTDOWN");
     qtest_end();
 }

-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (5 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 06/29] tests: Clean up wait for event Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-04 17:02   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length Eric Blake
                   ` (22 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Prior to commit 063c23d9, we were tracking a list of parallel
qtest objects, in order to safely clean up a SIGABRT handler
only after the last connection quits.  But when we switched to
more of glib's infrastructure, the list became dead code that
is never assigned to.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/libqtest.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index b9a1f180e1..3f956f09fc 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -42,7 +42,6 @@ struct QTestState
 };

 static GHookList abrt_hooks;
-static GList *qtest_instances;
 static struct sigaction sigact_old;

 #define g_assert_no_errno(ret) do { \
@@ -240,13 +239,10 @@ QTestState *qtest_init(const char *extra_args)

 void qtest_quit(QTestState *s)
 {
-    qtest_instances = g_list_remove(qtest_instances, s);
     g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s));

     /* Uninstall SIGABRT handler on last instance */
-    if (!qtest_instances) {
-        cleanup_sigabrt_handler();
-    }
+    cleanup_sigabrt_handler();

     kill_qemu(s);
     close(s->fd);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (6 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  8:12   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul() Eric Blake
                   ` (21 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Rather than make multiple callers call strlen(), it's easier if
socket_send() itself can compute a length via strlen() if none
was provided (caller passes -1).  Callers that can get at the
length more efficiently are left that way.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 3f956f09fc..a6ce21d7f9 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -251,10 +251,13 @@ void qtest_quit(QTestState *s)
     g_free(s);
 }

-static void socket_send(int fd, const char *buf, size_t size)
+static void socket_send(int fd, const char *buf, ssize_t size)
 {
     size_t offset;

+    if (size < 0) {
+        size = strlen(buf);
+    }
     offset = 0;
     while (offset < size) {
         ssize_t len;
@@ -274,9 +277,8 @@ static void socket_send(int fd, const char *buf, size_t size)
 static void socket_sendf(int fd, const char *fmt, va_list ap)
 {
     gchar *str = g_strdup_vprintf(fmt, ap);
-    size_t size = strlen(str);

-    socket_send(fd, str, size);
+    socket_send(fd, str, -1);
     g_free(str);
 }

@@ -858,7 +860,7 @@ void qtest_bufwrite(QTestState *s, uint64_t addr, const void *data, size_t size)

     bdata = g_base64_encode(data, size);
     qtest_sendf(s, "b64write 0x%" PRIx64 " 0x%zx ", addr, size);
-    socket_send(s->fd, bdata, strlen(bdata));
+    socket_send(s->fd, bdata, -1);
     socket_send(s->fd, "\n", 1);
     qtest_rsp(s, 0);
     g_free(bdata);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul()
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (7 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  9:11   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions Eric Blake
                   ` (20 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

This will keep checkpatch happy when the next patch does code motion.
Fix the include order to match HACKING when adding the needed header.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> 
---
 tests/libqtest.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index a6ce21d7f9..438a22678d 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -15,12 +15,13 @@
  *
  */
 #include "qemu/osdep.h"
-#include "libqtest.h"

 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <sys/un.h>

+#include "libqtest.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/json-streamer.h"
@@ -333,12 +334,14 @@ redo:
     g_string_free(line, TRUE);

     if (strcmp(words[0], "IRQ") == 0) {
-        int irq;
+        long irq;
+        int ret;

         g_assert(words[1] != NULL);
         g_assert(words[2] != NULL);

-        irq = strtoul(words[2], NULL, 0);
+        ret = qemu_strtol(words[2], NULL, 0, &irq);
+        g_assert(!ret);
         g_assert_cmpint(irq, >=, 0);
         g_assert_cmpint(irq, <, MAX_IRQ);

@@ -701,11 +704,13 @@ void qtest_outl(QTestState *s, uint16_t addr, uint32_t value)
 static uint32_t qtest_in(QTestState *s, const char *cmd, uint16_t addr)
 {
     gchar **args;
-    uint32_t value;
+    int ret;
+    unsigned long value;

     qtest_sendf(s, "%s 0x%x\n", cmd, addr);
     args = qtest_rsp(s, 2);
-    value = strtoul(args[1], NULL, 0);
+    ret = qemu_strtoul(args[1], NULL, 0, &value);
+    g_assert(!ret && value <= UINT32_MAX);
     g_strfreev(args);

     return value;
@@ -756,11 +761,13 @@ void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value)
 static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr)
 {
     gchar **args;
+    int ret;
     uint64_t value;

     qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr);
     args = qtest_rsp(s, 2);
-    value = strtoull(args[1], NULL, 0);
+    ret = qemu_strtou64(args[1], NULL, 0, &value);
+    g_assert(!ret);
     g_strfreev(args);

     return value;
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (8 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul() Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  9:22   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness() Eric Blake
                   ` (19 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Put static functions prior to public ones, in part so that
improvements to qtest_start() can benefit from the static
helpers without needing forward references.  Code motion, with
no semantic change.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.c | 263 +++++++++++++++++++++++++++----------------------------
 1 file changed, 131 insertions(+), 132 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 438a22678d..5d16351e24 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -49,7 +49,6 @@ static struct sigaction sigact_old;
     g_assert_cmpint(ret, !=, -1); \
 } while (0)

-static int qtest_query_target_endianness(QTestState *s);

 static int init_socket(const char *socket_path)
 {
@@ -128,6 +127,137 @@ static void setup_sigabrt_handler(void)
     sigaction(SIGABRT, &sigact, &sigact_old);
 }

+static void socket_send(int fd, const char *buf, ssize_t size)
+{
+    size_t offset;
+
+    if (size < 0) {
+        size = strlen(buf);
+    }
+    offset = 0;
+    while (offset < size) {
+        ssize_t len;
+
+        len = write(fd, buf + offset, size - offset);
+        if (len == -1 && errno == EINTR) {
+            continue;
+        }
+
+        g_assert_no_errno(len);
+        g_assert_cmpint(len, >, 0);
+
+        offset += len;
+    }
+}
+
+static void socket_sendf(int fd, const char *fmt, va_list ap)
+{
+    gchar *str = g_strdup_vprintf(fmt, ap);
+
+    socket_send(fd, str, -1);
+    g_free(str);
+}
+
+static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    socket_sendf(s->fd, fmt, ap);
+    va_end(ap);
+}
+
+static GString *qtest_recv_line(QTestState *s)
+{
+    GString *line;
+    size_t offset;
+    char *eol;
+
+    while ((eol = strchr(s->rx->str, '\n')) == NULL) {
+        ssize_t len;
+        char buffer[1024];
+
+        len = read(s->fd, buffer, sizeof(buffer));
+        if (len == -1 && errno == EINTR) {
+            continue;
+        }
+
+        if (len == -1 || len == 0) {
+            fprintf(stderr, "Broken pipe\n");
+            exit(1);
+        }
+
+        g_string_append_len(s->rx, buffer, len);
+    }
+
+    offset = eol - s->rx->str;
+    line = g_string_new_len(s->rx->str, offset);
+    g_string_erase(s->rx, 0, offset + 1);
+
+    return line;
+}
+
+static gchar **qtest_rsp(QTestState *s, int expected_args)
+{
+    GString *line;
+    gchar **words;
+    int i;
+
+redo:
+    line = qtest_recv_line(s);
+    words = g_strsplit(line->str, " ", 0);
+    g_string_free(line, TRUE);
+
+    if (strcmp(words[0], "IRQ") == 0) {
+        long irq;
+        int ret;
+
+        g_assert(words[1] != NULL);
+        g_assert(words[2] != NULL);
+
+        ret = qemu_strtol(words[2], NULL, 0, &irq);
+        g_assert(!ret);
+        g_assert_cmpint(irq, >=, 0);
+        g_assert_cmpint(irq, <, MAX_IRQ);
+
+        if (strcmp(words[1], "raise") == 0) {
+            s->irq_level[irq] = true;
+        } else {
+            s->irq_level[irq] = false;
+        }
+
+        g_strfreev(words);
+        goto redo;
+    }
+
+    g_assert(words[0] != NULL);
+    g_assert_cmpstr(words[0], ==, "OK");
+
+    if (expected_args) {
+        for (i = 0; i < expected_args; i++) {
+            g_assert(words[i] != NULL);
+        }
+    } else {
+        g_strfreev(words);
+    }
+
+    return words;
+}
+
+static int qtest_query_target_endianness(QTestState *s)
+{
+    gchar **args;
+    int big_endian;
+
+    qtest_sendf(s, "endianness\n");
+    args = qtest_rsp(s, 1);
+    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
+    big_endian = strcmp(args[1], "big") == 0;
+    g_strfreev(args);
+
+    return big_endian;
+}
+
 static void cleanup_sigabrt_handler(void)
 {
     sigaction(SIGABRT, &sigact_old, NULL);
@@ -252,137 +382,6 @@ void qtest_quit(QTestState *s)
     g_free(s);
 }

-static void socket_send(int fd, const char *buf, ssize_t size)
-{
-    size_t offset;
-
-    if (size < 0) {
-        size = strlen(buf);
-    }
-    offset = 0;
-    while (offset < size) {
-        ssize_t len;
-
-        len = write(fd, buf + offset, size - offset);
-        if (len == -1 && errno == EINTR) {
-            continue;
-        }
-
-        g_assert_no_errno(len);
-        g_assert_cmpint(len, >, 0);
-
-        offset += len;
-    }
-}
-
-static void socket_sendf(int fd, const char *fmt, va_list ap)
-{
-    gchar *str = g_strdup_vprintf(fmt, ap);
-
-    socket_send(fd, str, -1);
-    g_free(str);
-}
-
-static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    socket_sendf(s->fd, fmt, ap);
-    va_end(ap);
-}
-
-static GString *qtest_recv_line(QTestState *s)
-{
-    GString *line;
-    size_t offset;
-    char *eol;
-
-    while ((eol = strchr(s->rx->str, '\n')) == NULL) {
-        ssize_t len;
-        char buffer[1024];
-
-        len = read(s->fd, buffer, sizeof(buffer));
-        if (len == -1 && errno == EINTR) {
-            continue;
-        }
-
-        if (len == -1 || len == 0) {
-            fprintf(stderr, "Broken pipe\n");
-            exit(1);
-        }
-
-        g_string_append_len(s->rx, buffer, len);
-    }
-
-    offset = eol - s->rx->str;
-    line = g_string_new_len(s->rx->str, offset);
-    g_string_erase(s->rx, 0, offset + 1);
-
-    return line;
-}
-
-static gchar **qtest_rsp(QTestState *s, int expected_args)
-{
-    GString *line;
-    gchar **words;
-    int i;
-
-redo:
-    line = qtest_recv_line(s);
-    words = g_strsplit(line->str, " ", 0);
-    g_string_free(line, TRUE);
-
-    if (strcmp(words[0], "IRQ") == 0) {
-        long irq;
-        int ret;
-
-        g_assert(words[1] != NULL);
-        g_assert(words[2] != NULL);
-
-        ret = qemu_strtol(words[2], NULL, 0, &irq);
-        g_assert(!ret);
-        g_assert_cmpint(irq, >=, 0);
-        g_assert_cmpint(irq, <, MAX_IRQ);
-
-        if (strcmp(words[1], "raise") == 0) {
-            s->irq_level[irq] = true;
-        } else {
-            s->irq_level[irq] = false;
-        }
-
-        g_strfreev(words);
-        goto redo;
-    }
-
-    g_assert(words[0] != NULL);
-    g_assert_cmpstr(words[0], ==, "OK");
-
-    if (expected_args) {
-        for (i = 0; i < expected_args; i++) {
-            g_assert(words[i] != NULL);
-        }
-    } else {
-        g_strfreev(words);
-    }
-
-    return words;
-}
-
-static int qtest_query_target_endianness(QTestState *s)
-{
-    gchar **args;
-    int big_endian;
-
-    qtest_sendf(s, "endianness\n");
-    args = qtest_rsp(s, 1);
-    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
-    big_endian = strcmp(args[1], "big") == 0;
-    g_strfreev(args);
-
-    return big_endian;
-}
-
 typedef struct {
     JSONMessageParser parser;
     QDict *response;
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness()
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (9 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-02  0:10   ` Philippe Mathieu-Daudé
  2017-09-05  9:25   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
                   ` (18 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

There was only one caller; it's easier to inline things.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 5d16351e24..b6dd26e54a 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -244,20 +244,6 @@ redo:
     return words;
 }

-static int qtest_query_target_endianness(QTestState *s)
-{
-    gchar **args;
-    int big_endian;
-
-    qtest_sendf(s, "endianness\n");
-    args = qtest_rsp(s, 1);
-    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
-    big_endian = strcmp(args[1], "big") == 0;
-    g_strfreev(args);
-
-    return big_endian;
-}
-
 static void cleanup_sigabrt_handler(void)
 {
     sigaction(SIGABRT, &sigact_old, NULL);
@@ -288,6 +274,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     gchar *qmp_socket_path;
     gchar *command;
     const char *qemu_binary;
+    gchar **args;

     qemu_binary = getenv("QTEST_QEMU_BINARY");
     if (!qemu_binary) {
@@ -351,8 +338,11 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     }

     /* ask endianness of the target */
-
-    s->big_endian = qtest_query_target_endianness(s);
+    qtest_sendf(s, "endianness\n");
+    args = qtest_rsp(s, 1);
+    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
+    s->big_endian = strcmp(args[1], "big") == 0;
+    g_strfreev(args);

     return s;
 }
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (10 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness() Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 19:20   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations Eric Blake
                   ` (17 subsequent siblings)
  29 siblings, 3 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, John Snow, David Gibson, Alexander Graf,
	Gerd Hoffmann, open list:IDE, open list:sPAPR

When initializing a QPCIBus, track which QTestState the bus is
associated with (so that a later patch can then explicitly use
that test state for all communication on the bus, rather than
blindly relying on global_qtest).  Update the initialization
functions to take another parameter, and update all callers to
pass in state (for now, most callers get away with passing the
current global_qtest as the current state, although this required
fixing the order of initialization to ensure qtest_start() is
called before qpci_init*() in rtl8139-test, and provided an
opportunity to pass in the allocator in e1000e-test).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/ahci.h       | 2 +-
 tests/libqos/libqos.h     | 2 +-
 tests/libqos/pci-pc.h     | 2 +-
 tests/libqos/pci-spapr.h  | 2 +-
 tests/libqos/pci.h        | 1 +
 tests/ahci-test.c         | 2 +-
 tests/e1000e-test.c       | 6 +++---
 tests/i440fx-test.c       | 2 +-
 tests/ide-test.c          | 2 +-
 tests/libqos/ahci.c       | 4 ++--
 tests/libqos/libqos.c     | 4 ++--
 tests/libqos/pci-pc.c     | 5 ++++-
 tests/libqos/pci-spapr.c  | 6 +++++-
 tests/q35-test.c          | 4 ++--
 tests/rtl8139-test.c      | 5 +++--
 tests/tco-test.c          | 2 +-
 tests/usb-hcd-ehci-test.c | 2 +-
 tests/vhost-user-test.c   | 4 ++--
 18 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index 5f9627bb0f..715ca1e226 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -571,7 +571,7 @@ void ahci_free(AHCIQState *ahci, uint64_t addr);
 void ahci_clean_mem(AHCIQState *ahci);

 /* Device management */
-QPCIDevice *get_ahci_device(uint32_t *fingerprint);
+QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint);
 void free_ahci_device(QPCIDevice *dev);
 void ahci_pci_enable(AHCIQState *ahci);
 void start_ahci_device(AHCIQState *ahci);
diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 231969766f..78e5c044a0 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -10,7 +10,7 @@ typedef struct QOSState QOSState;
 typedef struct QOSOps {
     QGuestAllocator *(*init_allocator)(QAllocOpts);
     void (*uninit_allocator)(QGuestAllocator *);
-    QPCIBus *(*qpci_init)(QGuestAllocator *alloc);
+    QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc);
     void (*qpci_free)(QPCIBus *bus);
     void (*shutdown)(QOSState *);
 } QOSOps;
diff --git a/tests/libqos/pci-pc.h b/tests/libqos/pci-pc.h
index 9479b51642..491eeac756 100644
--- a/tests/libqos/pci-pc.h
+++ b/tests/libqos/pci-pc.h
@@ -16,7 +16,7 @@
 #include "libqos/pci.h"
 #include "libqos/malloc.h"

-QPCIBus *qpci_init_pc(QGuestAllocator *alloc);
+QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc);
 void     qpci_free_pc(QPCIBus *bus);

 #endif
diff --git a/tests/libqos/pci-spapr.h b/tests/libqos/pci-spapr.h
index 4192126d86..387686dfc8 100644
--- a/tests/libqos/pci-spapr.h
+++ b/tests/libqos/pci-spapr.h
@@ -11,7 +11,7 @@
 #include "libqos/malloc.h"
 #include "libqos/pci.h"

-QPCIBus *qpci_init_spapr(QGuestAllocator *alloc);
+QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc);
 void     qpci_free_spapr(QPCIBus *bus);

 #endif
diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
index ed480614ff..429c382282 100644
--- a/tests/libqos/pci.h
+++ b/tests/libqos/pci.h
@@ -48,6 +48,7 @@ struct QPCIBus {
     void (*config_writel)(QPCIBus *bus, int devfn,
                           uint8_t offset, uint32_t value);

+    QTestState *qts;
     uint16_t pio_alloc_ptr;
     uint64_t mmio_alloc_ptr, mmio_limit;
 };
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 999121bb7c..c94d1bd712 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -160,7 +160,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)
     alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);

     /* Verify that we have an AHCI device present. */
-    s->dev = get_ahci_device(&s->fingerprint);
+    s->dev = get_ahci_device(s->parent->qts, &s->fingerprint);

     return s;
 }
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index c612dc64ec..d8085d944e 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -392,12 +392,12 @@ static void data_test_init(e1000e_device *d)
     qtest_start(cmdline);
     g_free(cmdline);

-    test_bus = qpci_init_pc(NULL);
-    g_assert_nonnull(test_bus);
-
     test_alloc = pc_alloc_init();
     g_assert_nonnull(test_alloc);

+    test_bus = qpci_init_pc(global_qtest, test_alloc);
+    g_assert_nonnull(test_bus);
+
     e1000e_device_init(test_bus, d);
 }

diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index e9d05c87d1..4390e5591e 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -38,7 +38,7 @@ static QPCIBus *test_start_get_bus(const TestData *s)
     cmdline = g_strdup_printf("-smp %d", s->num_cpus);
     qtest_start(cmdline);
     g_free(cmdline);
-    return qpci_init_pc(NULL);
+    return qpci_init_pc(global_qtest, NULL);
 }

 static void test_i440fx_defaults(gconstpointer opaque)
diff --git a/tests/ide-test.c b/tests/ide-test.c
index aa9de065fc..b2237b6158 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -143,7 +143,7 @@ static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, QPCIBar *ide_bar)
     uint16_t vendor_id, device_id;

     if (!pcibus) {
-        pcibus = qpci_init_pc(NULL);
+        pcibus = qpci_init_pc(global_qtest, NULL);
     }

     /* Find PCI device and verify it's the right one */
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 1ca7f456b5..790ef991b3 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -123,13 +123,13 @@ bool is_atapi(AHCIQState *ahci, uint8_t port)
 /**
  * Locate, verify, and return a handle to the AHCI device.
  */
-QPCIDevice *get_ahci_device(uint32_t *fingerprint)
+QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint)
 {
     QPCIDevice *ahci;
     uint32_t ahci_fingerprint;
     QPCIBus *pcibus;

-    pcibus = qpci_init_pc(NULL);
+    pcibus = qpci_init_pc(qts, NULL);

     /* Find the AHCI PCI device and verify it's the right one. */
     ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));
diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 6226546c28..c95428e1cb 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
         if (ops->init_allocator) {
             qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
         }
-        if (ops->qpci_init && qs->alloc) {
-            qs->pcibus = ops->qpci_init(qs->alloc);
+        if (ops->qpci_init) {
+            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
         }
     }

diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index 02ce49927a..85b34c6d13 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -115,11 +115,14 @@ static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint3
     outl(0xcfc, value);
 }

-QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
+QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
 {
     QPCIBusPC *ret;

+    assert(qts);
+
     ret = g_malloc(sizeof(*ret));
+    ret->bus.qts = qts;

     ret->bus.pio_readb = qpci_pc_pio_readb;
     ret->bus.pio_readw = qpci_pc_pio_readw;
diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
index 2043f1e123..cd9b8f52d2 100644
--- a/tests/libqos/pci-spapr.c
+++ b/tests/libqos/pci-spapr.c
@@ -154,11 +154,14 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
 #define SPAPR_PCI_MMIO32_WIN_SIZE    0x80000000 /* 2 GiB */
 #define SPAPR_PCI_IO_WIN_SIZE        0x10000

-QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
+QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc)
 {
     QPCIBusSPAPR *ret;

+    assert(qts);
+
     ret = g_malloc(sizeof(*ret));
+    ret->bus.qts = qts;

     ret->alloc = alloc;

@@ -201,6 +204,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
     ret->bus.mmio_alloc_ptr = ret->mmio32.pci_base;
     ret->bus.mmio_limit = ret->mmio32.pci_base + ret->mmio32.size;

+
     return &ret->bus;
 }

diff --git a/tests/q35-test.c b/tests/q35-test.c
index f98bed7a2d..e149c4c51d 100644
--- a/tests/q35-test.c
+++ b/tests/q35-test.c
@@ -86,7 +86,7 @@ static void test_smram_lock(void)

     qtest_start("-M q35");

-    pcibus = qpci_init_pc(NULL);
+    pcibus = qpci_init_pc(global_qtest, NULL);
     g_assert(pcibus != NULL);

     pcidev = qpci_device_find(pcibus, 0);
@@ -145,7 +145,7 @@ static void test_tseg_size(const void *data)
     g_free(cmdline);

     /* locate the DRAM controller */
-    pcibus = qpci_init_pc(NULL);
+    pcibus = qpci_init_pc(global_qtest, NULL);
     g_assert(pcibus != NULL);
     pcidev = qpci_device_find(pcibus, 0);
     g_assert(pcidev != NULL);
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index 7de7dc45ae..68bfc42178 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -35,7 +35,7 @@ static QPCIDevice *get_device(void)
 {
     QPCIDevice *dev;

-    pcibus = qpci_init_pc(NULL);
+    pcibus = qpci_init_pc(global_qtest, NULL);
     qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev);
     g_assert(dev != NULL);

@@ -197,11 +197,12 @@ int main(int argc, char **argv)
 {
     int ret;

+    qtest_start("-device rtl8139");
+
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/rtl8139/nop", nop);
     qtest_add_func("/rtl8139/timer", test_init);

-    qtest_start("-device rtl8139");
     ret = g_test_run();

     qtest_end();
diff --git a/tests/tco-test.c b/tests/tco-test.c
index f2ed6ed91c..0387971953 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -64,7 +64,7 @@ static void test_init(TestData *d)
     qtest_irq_intercept_in(qs, "ioapic");
     g_free(s);

-    d->bus = qpci_init_pc(NULL);
+    d->bus = qpci_init_pc(qs, NULL);
     d->dev = qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00));
     g_assert(d->dev != NULL);

diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index 944eb1c088..55d4743a2a 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -52,7 +52,7 @@ static void ehci_port_test(struct qhc *hc, int port, uint32_t expect)

 static void test_init(void)
 {
-    pcibus = qpci_init_pc(NULL);
+    pcibus = qpci_init_pc(global_qtest, NULL);
     g_assert(pcibus != NULL);

     qusb_pci_init_one(pcibus, &uhci1, QPCI_DEVFN(0x1d, 0), 4);
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index d4da09f147..ea7d38ea44 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -164,7 +164,7 @@ static void init_virtio_dev(TestServer *s)
     QVirtioPCIDevice *dev;
     uint32_t features;

-    s->bus = qpci_init_pc(NULL);
+    s->bus = qpci_init_pc(global_qtest, NULL);
     g_assert_nonnull(s->bus);

     dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
@@ -891,7 +891,7 @@ static void test_multiqueue(void)
     qtest_start(cmd);
     g_free(cmd);

-    bus = qpci_init_pc(NULL);
+    bus = qpci_init_pc(global_qtest, NULL);
     dev = virtio_net_pci_init(bus, PCI_SLOT);

     alloc = pc_alloc_init();
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (11 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 19:22   ` Philippe Mathieu-Daudé
  2017-09-05 10:03   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
                   ` (16 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, David Gibson, Alexander Graf, open list:sPAPR

Now that the QPCIBus tracks QTestState, use that state instead
of an implicit reliance on global_qtest.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/pci-pc.c    | 47 ++++++++++++++++++++++++-----------------------
 tests/libqos/pci-spapr.c | 20 ++++++++++----------
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index 85b34c6d13..9545f881ee 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -29,90 +29,91 @@ typedef struct QPCIBusPC

 static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr)
 {
-    return inb(addr);
+    return qtest_inb(bus->qts, addr);
 }

 static void qpci_pc_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
 {
-    outb(addr, val);
+    qtest_outb(bus->qts, addr, val);
 }

 static uint16_t qpci_pc_pio_readw(QPCIBus *bus, uint32_t addr)
 {
-    return inw(addr);
+    return qtest_inw(bus->qts, addr);
 }

 static void qpci_pc_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
 {
-    outw(addr, val);
+    qtest_outw(bus->qts, addr, val);
 }

 static uint32_t qpci_pc_pio_readl(QPCIBus *bus, uint32_t addr)
 {
-    return inl(addr);
+    return qtest_inl(bus->qts, addr);
 }

 static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
 {
-    outl(addr, val);
+    qtest_outl(bus->qts, addr, val);
 }

 static uint64_t qpci_pc_pio_readq(QPCIBus *bus, uint32_t addr)
 {
-    return (uint64_t)inl(addr) + ((uint64_t)inl(addr + 4) << 32);
+    return (uint64_t)qtest_inl(bus->qts, addr) +
+        ((uint64_t)qtest_inl(bus->qts, addr + 4) << 32);
 }

 static void qpci_pc_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
 {
-    outl(addr, val & 0xffffffff);
-    outl(addr + 4, val >> 32);
+    qtest_outl(bus->qts, addr, val & 0xffffffff);
+    qtest_outl(bus->qts, addr + 4, val >> 32);
 }

 static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len)
 {
-    memread(addr, buf, len);
+    qtest_memread(bus->qts, addr, buf, len);
 }

 static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr,
                              const void *buf, size_t len)
 {
-    memwrite(addr, buf, len);
+    qtest_memwrite(bus->qts, addr, buf, len);
 }

 static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    return inb(0xcfc);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    return qtest_inb(bus->qts, 0xcfc);
 }

 static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    return inw(0xcfc);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    return qtest_inw(bus->qts, 0xcfc);
 }

 static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    return inl(0xcfc);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    return qtest_inl(bus->qts, 0xcfc);
 }

 static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    outb(0xcfc, value);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    qtest_outb(bus->qts, 0xcfc, value);
 }

 static void qpci_pc_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16_t value)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    outw(0xcfc, value);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    qtest_outw(bus->qts, 0xcfc, value);
 }

 static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value)
 {
-    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
-    outl(0xcfc, value);
+    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
+    qtest_outl(bus->qts, 0xcfc, value);
 }

 QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
index cd9b8f52d2..d7b2aa75e6 100644
--- a/tests/libqos/pci-spapr.c
+++ b/tests/libqos/pci-spapr.c
@@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR {
 static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    return readb(s->pio_cpu_base + addr);
+    return qtest_readb(bus->qts, s->pio_cpu_base + addr);
 }

 static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    writeb(s->pio_cpu_base + addr, val);
+    qtest_writeb(bus->qts, s->pio_cpu_base + addr, val);
 }

 static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    return bswap16(readw(s->pio_cpu_base + addr));
+    return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr));
 }

 static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    writew(s->pio_cpu_base + addr, bswap16(val));
+    qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val));
 }

 static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    return bswap32(readl(s->pio_cpu_base + addr));
+    return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr));
 }

 static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    writel(s->pio_cpu_base + addr, bswap32(val));
+    qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val));
 }

 static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    return bswap64(readq(s->pio_cpu_base + addr));
+    return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr));
 }

 static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    writeq(s->pio_cpu_base + addr, bswap64(val));
+    qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(val));
 }

 static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr,
                                void *buf, size_t len)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    memread(s->mmio32_cpu_base + addr, buf, len);
+    qtest_memread(bus->qts, s->mmio32_cpu_base + addr, buf, len);
 }

 static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr,
                                 const void *buf, size_t len)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
-    memwrite(s->mmio32_cpu_base + addr, buf, len);
+    qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len);
 }

 static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (12 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 19:21   ` [Qemu-devel] [PATCH v6 14.5/29] fixup! " Eric Blake
                     ` (3 more replies)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations Eric Blake
                   ` (15 subsequent siblings)
  29 siblings, 4 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, John Snow, David Gibson, Alexander Graf,
	open list:IDE, open list:sPAPR

Drop one more client of global_qtest by teaching all fw_cfg test
functionality (invoked through alloc-pc) to pass in an explicit
QTestState, adjusting all callers.  In particular, fw_cfg-test
had to reorder things to create the test state prior to creating
the fw_cfg.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/fw_cfg.h       | 10 ++++++----
 tests/libqos/libqos.h       |  2 +-
 tests/libqos/malloc-pc.h    |  4 ++--
 tests/libqos/malloc-spapr.h |  2 +-
 tests/libqos/malloc.h       |  1 +
 tests/boot-order-test.c     |  6 +++---
 tests/e1000e-test.c         |  2 +-
 tests/fw_cfg-test.c         | 14 ++++++--------
 tests/ide-test.c            |  2 +-
 tests/libqos/fw_cfg.c       | 14 ++++++++------
 tests/libqos/libqos.c       |  2 +-
 tests/libqos/malloc-pc.c    |  8 ++++----
 tests/libqos/malloc-spapr.c |  4 ++--
 tests/vhost-user-test.c     |  2 +-
 14 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index e8371b2317..396dd4ee1e 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -15,10 +15,12 @@


 typedef struct QFWCFG QFWCFG;
+typedef struct QTestState QTestState;

 struct QFWCFG
 {
     uint64_t base;
+    QTestState *qts;
     void (*select)(QFWCFG *fw_cfg, uint16_t key);
     void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
 };
@@ -30,12 +32,12 @@ uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
 uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);

-QFWCFG *mm_fw_cfg_init(uint64_t base);
-QFWCFG *io_fw_cfg_init(uint16_t base);
+QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
+QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);

-static inline QFWCFG *pc_fw_cfg_init(void)
+static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
 {
-    return io_fw_cfg_init(0x510);
+    return io_fw_cfg_init(qts, 0x510);
 }

 #endif
diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 78e5c044a0..07d4b93d1d 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -8,7 +8,7 @@
 typedef struct QOSState QOSState;

 typedef struct QOSOps {
-    QGuestAllocator *(*init_allocator)(QAllocOpts);
+    QGuestAllocator *(*init_allocator)(QTestState *qts, QAllocOpts);
     void (*uninit_allocator)(QGuestAllocator *);
     QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc);
     void (*qpci_free)(QPCIBus *bus);
diff --git a/tests/libqos/malloc-pc.h b/tests/libqos/malloc-pc.h
index 86ab9f0429..10f3da6cf2 100644
--- a/tests/libqos/malloc-pc.h
+++ b/tests/libqos/malloc-pc.h
@@ -15,8 +15,8 @@

 #include "libqos/malloc.h"

-QGuestAllocator *pc_alloc_init(void);
-QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags);
+QGuestAllocator *pc_alloc_init(QTestState *qts);
+QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags);
 void pc_alloc_uninit(QGuestAllocator *allocator);

 #endif
diff --git a/tests/libqos/malloc-spapr.h b/tests/libqos/malloc-spapr.h
index 64d0e770d1..52a9346a26 100644
--- a/tests/libqos/malloc-spapr.h
+++ b/tests/libqos/malloc-spapr.h
@@ -11,7 +11,7 @@
 #include "libqos/malloc.h"

 QGuestAllocator *spapr_alloc_init(void);
-QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags);
+QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags);
 void spapr_alloc_uninit(QGuestAllocator *allocator);

 #endif
diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h
index ae9dac8f61..828fddabdb 100644
--- a/tests/libqos/malloc.h
+++ b/tests/libqos/malloc.h
@@ -14,6 +14,7 @@
 #define LIBQOS_MALLOC_H

 #include "qemu/queue.h"
+#include "libqtest.h"

 typedef enum {
     ALLOC_NO_FLAGS    = 0x00,
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 9d516830dd..5fc2ca8e9e 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -135,7 +135,7 @@ static void test_prep_boot_order(void)

 static uint64_t read_boot_order_pmac(void)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(0xf0000510);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf0000510);

     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -160,7 +160,7 @@ static void test_pmac_newworld_boot_order(void)

 static uint64_t read_boot_order_sun4m(void)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(0xd00000510ULL);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd00000510ULL);

     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -172,7 +172,7 @@ static void test_sun4m_boot_order(void)

 static uint64_t read_boot_order_sun4u(void)
 {
-    QFWCFG *fw_cfg = io_fw_cfg_init(0x510);
+    QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510);

     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index d8085d944e..32aa738b72 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -392,7 +392,7 @@ static void data_test_init(e1000e_device *d)
     qtest_start(cmdline);
     g_free(cmdline);

-    test_alloc = pc_alloc_init();
+    test_alloc = pc_alloc_init(global_qtest);
     g_assert_nonnull(test_alloc);

     test_bus = qpci_init_pc(global_qtest, test_alloc);
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 688342bed5..47596c57a1 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -107,7 +107,11 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    fw_cfg = pc_fw_cfg_init();
+    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
+    s = qtest_start(cmdline);
+    g_free(cmdline);
+
+    fw_cfg = pc_fw_cfg_init(s);

     qtest_add_func("fw_cfg/signature", test_fw_cfg_signature);
     qtest_add_func("fw_cfg/id", test_fw_cfg_id);
@@ -125,15 +129,9 @@ int main(int argc, char **argv)
     qtest_add_func("fw_cfg/numa", test_fw_cfg_numa);
     qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);

-    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
-    s = qtest_start(cmdline);
-    g_free(cmdline);
-
     ret = g_test_run();

-    if (s) {
-        qtest_quit(s);
-    }
+    qtest_quit(s);

     return ret;
 }
diff --git a/tests/ide-test.c b/tests/ide-test.c
index b2237b6158..084f6a5f96 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -125,7 +125,7 @@ static void ide_test_start(const char *cmdline_fmt, ...)
     va_end(ap);

     qtest_start(cmdline);
-    guest_malloc = pc_alloc_init();
+    guest_malloc = pc_alloc_init(global_qtest);

     g_free(cmdline);
 }
diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index 4d9dc3fd0b..d0889d1e22 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -56,7 +56,7 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)

 static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
 {
-    writew(fw_cfg->base, key);
+    qtest_writew(fw_cfg->qts, fw_cfg->base, key);
 }

 static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
@@ -65,15 +65,16 @@ static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
     int i;

     for (i = 0; i < len; i++) {
-        ptr[i] = readb(fw_cfg->base + 2);
+        ptr[i] = qtest_readb(fw_cfg->qts, fw_cfg->base + 2);
     }
 }

-QFWCFG *mm_fw_cfg_init(uint64_t base)
+QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base)
 {
     QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));

     fw_cfg->base = base;
+    fw_cfg->qts = qts;
     fw_cfg->select = mm_fw_cfg_select;
     fw_cfg->read = mm_fw_cfg_read;

@@ -82,7 +83,7 @@ QFWCFG *mm_fw_cfg_init(uint64_t base)

 static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
 {
-    outw(fw_cfg->base, key);
+    qtest_outw(fw_cfg->qts, fw_cfg->base, key);
 }

 static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
@@ -91,15 +92,16 @@ static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
     int i;

     for (i = 0; i < len; i++) {
-        ptr[i] = inb(fw_cfg->base + 1);
+        ptr[i] = qtest_inb(fw_cfg->qts, fw_cfg->base + 1);
     }
 }

-QFWCFG *io_fw_cfg_init(uint16_t base)
+QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base)
 {
     QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));

     fw_cfg->base = base;
+    fw_cfg->qts = qts;
     fw_cfg->select = io_fw_cfg_select;
     fw_cfg->read = io_fw_cfg_read;

diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index c95428e1cb..62d2f39b93 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -24,7 +24,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
     qs->ops = ops;
     if (ops) {
         if (ops->init_allocator) {
-            qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
+            qs->alloc = ops->init_allocator(qs->qts, ALLOC_NO_FLAGS);
         }
         if (ops->qpci_init) {
             qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index dd2b900c5f..634b9c288a 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -29,11 +29,11 @@ void pc_alloc_uninit(QGuestAllocator *allocator)
     alloc_uninit(allocator);
 }

-QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
+QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags)
 {
     QGuestAllocator *s;
     uint64_t ram_size;
-    QFWCFG *fw_cfg = pc_fw_cfg_init();
+    QFWCFG *fw_cfg = pc_fw_cfg_init(qts);

     ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
     s = alloc_init_flags(flags, 1 << 20, MIN(ram_size, 0xE0000000));
@@ -45,7 +45,7 @@ QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
     return s;
 }

-inline QGuestAllocator *pc_alloc_init(void)
+inline QGuestAllocator *pc_alloc_init(QTestState *qts)
 {
-    return pc_alloc_init_flags(ALLOC_NO_FLAGS);
+    return pc_alloc_init_flags(qts, ALLOC_NO_FLAGS);
 }
diff --git a/tests/libqos/malloc-spapr.c b/tests/libqos/malloc-spapr.c
index 006404af33..1c359cea6c 100644
--- a/tests/libqos/malloc-spapr.c
+++ b/tests/libqos/malloc-spapr.c
@@ -22,7 +22,7 @@ void spapr_alloc_uninit(QGuestAllocator *allocator)
     alloc_uninit(allocator);
 }

-QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags)
+QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags)
 {
     QGuestAllocator *s;

@@ -34,5 +34,5 @@ QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags)

 QGuestAllocator *spapr_alloc_init(void)
 {
-    return spapr_alloc_init_flags(ALLOC_NO_FLAGS);
+    return spapr_alloc_init_flags(NULL, ALLOC_NO_FLAGS);
 }
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index ea7d38ea44..562bfaefd2 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -894,7 +894,7 @@ static void test_multiqueue(void)
     bus = qpci_init_pc(global_qtest, NULL);
     dev = virtio_net_pci_init(bus, PCI_SLOT);

-    alloc = pc_alloc_init();
+    alloc = pc_alloc_init(global_qtest);
     for (i = 0; i < queues * 2; i++) {
         vq[i] = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, i);
     }
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (13 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:16   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations Eric Blake
                   ` (14 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, David Gibson, Alexander Graf, open list:sPAPR

Drop one more client of global_qtest by teaching all rtas test
functionality to pass in an explicit QTestState, adjusting all
callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/rtas.h      |  9 ++++++---
 tests/libqos/pci-spapr.c | 18 ++++++++++++------
 tests/libqos/rtas.c      | 21 ++++++++++++---------
 tests/rtas-test.c        |  2 +-
 4 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/tests/libqos/rtas.h b/tests/libqos/rtas.h
index 498eb19230..e3d0f850a7 100644
--- a/tests/libqos/rtas.h
+++ b/tests/libqos/rtas.h
@@ -7,9 +7,12 @@
 #define LIBQOS_RTAS_H
 #include "libqos/malloc.h"

-int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns);
-uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
+int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc,
+                          struct tm *tm, uint32_t *ns);
+uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc,
+                                   uint64_t buid,
                                    uint32_t addr, uint32_t size);
-int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
+int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc,
+                               uint64_t buid,
                                uint32_t addr, uint32_t size, uint32_t val);
 #endif /* LIBQOS_RTAS_H */
diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
index d7b2aa75e6..b7199501b4 100644
--- a/tests/libqos/pci-spapr.c
+++ b/tests/libqos/pci-spapr.c
@@ -108,21 +108,24 @@ static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 1);
+    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
+                                     config_addr, 1);
 }

 static uint16_t qpci_spapr_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 2);
+    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
+                                     config_addr, 2);
 }

 static uint32_t qpci_spapr_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 4);
+    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
+                                     config_addr, 4);
 }

 static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,
@@ -130,7 +133,8 @@ static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 1, value);
+    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
+                               config_addr, 1, value);
 }

 static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offset,
@@ -138,7 +142,8 @@ static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offset,
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 2, value);
+    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
+                               config_addr, 2, value);
 }

 static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
@@ -146,7 +151,8 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
 {
     QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
     uint32_t config_addr = (devfn << 8) | offset;
-    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 4, value);
+    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
+                               config_addr, 4, value);
 }

 #define SPAPR_PCI_BASE               (1ULL << 45)
diff --git a/tests/libqos/rtas.c b/tests/libqos/rtas.c
index 0269803ce0..fb25f91723 100644
--- a/tests/libqos/rtas.c
+++ b/tests/libqos/rtas.c
@@ -26,7 +26,8 @@ static void qrtas_copy_ret(uint64_t target_ret, uint32_t nret, uint32_t *ret)
     }
 }

-static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
+static uint64_t qrtas_call(QTestState *qts, QGuestAllocator *alloc,
+                           const char *name,
                            uint32_t nargs, uint32_t *args,
                            uint32_t nret, uint32_t *ret)
 {
@@ -37,8 +38,7 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
     target_ret = guest_alloc(alloc, nret * sizeof(uint32_t));

     qrtas_copy_args(target_args, nargs, args);
-    res = qtest_rtas_call(global_qtest, name,
-                          nargs, target_args, nret, target_ret);
+    res = qtest_rtas_call(qts, name, nargs, target_args, nret, target_ret);
     qrtas_copy_ret(target_ret, nret, ret);

     guest_free(alloc, target_ret);
@@ -47,12 +47,13 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
     return res;
 }

-int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns)
+int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc,
+                          struct tm *tm, uint32_t *ns)
 {
     int res;
     uint32_t ret[8];

-    res = qrtas_call(alloc, "get-time-of-day", 0, NULL, 8, ret);
+    res = qrtas_call(qts, alloc, "get-time-of-day", 0, NULL, 8, ret);
     if (res != 0) {
         return res;
     }
@@ -70,7 +71,8 @@ int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns)
     return res;
 }

-uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
+uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc,
+                                   uint64_t buid,
                                    uint32_t addr, uint32_t size)
 {
     int res;
@@ -80,7 +82,7 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
     args[1] = buid >> 32;
     args[2] = buid & 0xffffffff;
     args[3] = size;
-    res = qrtas_call(alloc, "ibm,read-pci-config", 4, args, 2, ret);
+    res = qrtas_call(qts, alloc, "ibm,read-pci-config", 4, args, 2, ret);
     if (res != 0) {
         return -1;
     }
@@ -92,7 +94,8 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
     return ret[1];
 }

-int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
+int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc,
+                               uint64_t buid,
                                uint32_t addr, uint32_t size, uint32_t val)
 {
     int res;
@@ -103,7 +106,7 @@ int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
     args[2] = buid & 0xffffffff;
     args[3] = size;
     args[4] = val;
-    res = qrtas_call(alloc, "ibm,write-pci-config", 5, args, 1, ret);
+    res = qrtas_call(qts, alloc, "ibm,write-pci-config", 5, args, 1, ret);
     if (res != 0) {
         return -1;
     }
diff --git a/tests/rtas-test.c b/tests/rtas-test.c
index 276c87ef84..34a692163f 100644
--- a/tests/rtas-test.c
+++ b/tests/rtas-test.c
@@ -16,7 +16,7 @@ static void test_rtas_get_time_of_day(void)
     qs = qtest_spapr_boot("-machine pseries");

     t1 = time(NULL);
-    ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);
+    ret = qrtas_get_time_of_day(qs->qts, qs->alloc, &tm, &ns);
     g_assert_cmpint(ret, ==, 0);
     t2 = mktimegm(&tm);
     g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (14 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:26   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest Eric Blake
                   ` (13 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini, Stefan Hajnoczi, open list:virtio-blk

Drop one more client of global_qtest by teaching all virtio test
functionality to pass in an explicit QTestState in constructors,
where it is then reused for later access.  Adjust all callers.
This gets us one step closer to eliminating implicit use of
global_qtest.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/virtio-mmio.h |  3 +-
 tests/libqos/virtio.h      |  5 ++-
 tests/libqos/virtio-mmio.c | 54 +++++++++++++++++---------------
 tests/libqos/virtio-pci.c  |  3 ++
 tests/libqos/virtio.c      | 77 ++++++++++++++++++++++++++--------------------
 tests/virtio-blk-test.c    |  3 +-
 6 files changed, 84 insertions(+), 61 deletions(-)

diff --git a/tests/libqos/virtio-mmio.h b/tests/libqos/virtio-mmio.h
index e3e52b9ce1..bd01386054 100644
--- a/tests/libqos/virtio-mmio.h
+++ b/tests/libqos/virtio-mmio.h
@@ -41,6 +41,7 @@ typedef struct QVirtioMMIODevice {

 extern const QVirtioBus qvirtio_mmio;

-QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size);
+QVirtioMMIODevice *qvirtio_mmio_init_device(QTestState *qts, uint64_t addr,
+                                            uint32_t page_size);

 #endif
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 8fbcd1869c..d180d54fc4 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -19,6 +19,7 @@ typedef struct QVirtioBus QVirtioBus;

 typedef struct QVirtioDevice {
     const QVirtioBus *bus;
+    QTestState *qts;
     /* Device type */
     uint16_t device_type;
 } QVirtioDevice;
@@ -35,12 +36,14 @@ typedef struct QVirtQueue {
     uint16_t last_used_idx;
     bool indirect;
     bool event;
+    QTestState *qts;
 } QVirtQueue;

 typedef struct QVRingIndirectDesc {
     uint64_t desc; /* This points to an array fo struct vring_desc */
     uint16_t index;
     uint16_t elem;
+    QTestState *qts;
 } QVRingIndirectDesc;

 struct QVirtioBus {
@@ -93,7 +96,7 @@ struct QVirtioBus {
 static inline bool qvirtio_is_big_endian(QVirtioDevice *d)
 {
     /* FIXME: virtio 1.0 is always little-endian */
-    return qtest_big_endian(global_qtest);
+    return qtest_big_endian(d->qts);
 }

 static inline uint32_t qvring_size(uint32_t num, uint32_t align)
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c
index 7aa8383338..d151209d8e 100644
--- a/tests/libqos/virtio-mmio.c
+++ b/tests/libqos/virtio-mmio.c
@@ -18,40 +18,40 @@
 static uint8_t qvirtio_mmio_config_readb(QVirtioDevice *d, uint64_t off)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return readb(dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
+    return qtest_readb(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
 }

 static uint16_t qvirtio_mmio_config_readw(QVirtioDevice *d, uint64_t off)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return readw(dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
+    return qtest_readw(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
 }

 static uint32_t qvirtio_mmio_config_readl(QVirtioDevice *d, uint64_t off)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return readl(dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
+    return qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
 }

 static uint64_t qvirtio_mmio_config_readq(QVirtioDevice *d, uint64_t off)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return readq(dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
+    return qtest_readq(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_SPECIFIC + off);
 }

 static uint32_t qvirtio_mmio_get_features(QVirtioDevice *d)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    writel(dev->addr + QVIRTIO_MMIO_HOST_FEATURES_SEL, 0);
-    return readl(dev->addr + QVIRTIO_MMIO_HOST_FEATURES);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_HOST_FEATURES_SEL, 0);
+    return qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_HOST_FEATURES);
 }

 static void qvirtio_mmio_set_features(QVirtioDevice *d, uint32_t features)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
     dev->features = features;
-    writel(dev->addr + QVIRTIO_MMIO_GUEST_FEATURES_SEL, 0);
-    writel(dev->addr + QVIRTIO_MMIO_GUEST_FEATURES, features);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_GUEST_FEATURES_SEL, 0);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_GUEST_FEATURES, features);
 }

 static uint32_t qvirtio_mmio_get_guest_features(QVirtioDevice *d)
@@ -63,13 +63,14 @@ static uint32_t qvirtio_mmio_get_guest_features(QVirtioDevice *d)
 static uint8_t qvirtio_mmio_get_status(QVirtioDevice *d)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return (uint8_t)readl(dev->addr + QVIRTIO_MMIO_DEVICE_STATUS);
+    return (uint8_t)qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_STATUS);
 }

 static void qvirtio_mmio_set_status(QVirtioDevice *d, uint8_t status)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    writel(dev->addr + QVIRTIO_MMIO_DEVICE_STATUS, (uint32_t)status);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_DEVICE_STATUS,
+                 (uint32_t)status);
 }

 static bool qvirtio_mmio_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
@@ -77,9 +78,9 @@ static bool qvirtio_mmio_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
     uint32_t isr;

-    isr = readl(dev->addr + QVIRTIO_MMIO_INTERRUPT_STATUS) & 1;
+    isr = qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_INTERRUPT_STATUS) & 1;
     if (isr != 0) {
-        writel(dev->addr + QVIRTIO_MMIO_INTERRUPT_ACK, 1);
+        qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_INTERRUPT_ACK, 1);
         return true;
     }

@@ -91,9 +92,9 @@ static bool qvirtio_mmio_get_config_isr_status(QVirtioDevice *d)
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
     uint32_t isr;

-    isr = readl(dev->addr + QVIRTIO_MMIO_INTERRUPT_STATUS) & 2;
+    isr = qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_INTERRUPT_STATUS) & 2;
     if (isr != 0) {
-        writel(dev->addr + QVIRTIO_MMIO_INTERRUPT_ACK, 2);
+        qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_INTERRUPT_ACK, 2);
         return true;
     }

@@ -103,21 +104,23 @@ static bool qvirtio_mmio_get_config_isr_status(QVirtioDevice *d)
 static void qvirtio_mmio_queue_select(QVirtioDevice *d, uint16_t index)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    writel(dev->addr + QVIRTIO_MMIO_QUEUE_SEL, (uint32_t)index);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_SEL, (uint32_t)index);

-    g_assert_cmphex(readl(dev->addr + QVIRTIO_MMIO_QUEUE_PFN), ==, 0);
+    g_assert_cmphex(qtest_readl(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_PFN),
+                    ==, 0);
 }

 static uint16_t qvirtio_mmio_get_queue_size(QVirtioDevice *d)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    return (uint16_t)readl(dev->addr + QVIRTIO_MMIO_QUEUE_NUM_MAX);
+    return (uint16_t)qtest_readl(d->qts,
+                                 dev->addr + QVIRTIO_MMIO_QUEUE_NUM_MAX);
 }

 static void qvirtio_mmio_set_queue_address(QVirtioDevice *d, uint32_t pfn)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    writel(dev->addr + QVIRTIO_MMIO_QUEUE_PFN, pfn);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_PFN, pfn);
 }

 static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d,
@@ -128,8 +131,9 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d,
     uint64_t addr;

     vq = g_malloc0(sizeof(*vq));
+    vq->qts = d->qts;
     qvirtio_mmio_queue_select(d, index);
-    writel(dev->addr + QVIRTIO_MMIO_QUEUE_ALIGN, dev->page_size);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_ALIGN, dev->page_size);

     vq->index = index;
     vq->size = qvirtio_mmio_get_queue_size(d);
@@ -139,7 +143,7 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d,
     vq->indirect = (dev->features & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0;
     vq->event = (dev->features & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0;

-    writel(dev->addr + QVIRTIO_MMIO_QUEUE_NUM, vq->size);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_NUM, vq->size);

     /* Check different than 0 */
     g_assert_cmpint(vq->size, !=, 0);
@@ -164,7 +168,7 @@ static void qvirtio_mmio_virtqueue_cleanup(QVirtQueue *vq,
 static void qvirtio_mmio_virtqueue_kick(QVirtioDevice *d, QVirtQueue *vq)
 {
     QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d;
-    writel(dev->addr + QVIRTIO_MMIO_QUEUE_NOTIFY, vq->index);
+    qtest_writel(d->qts, dev->addr + QVIRTIO_MMIO_QUEUE_NOTIFY, vq->index);
 }

 const QVirtioBus qvirtio_mmio = {
@@ -187,21 +191,23 @@ const QVirtioBus qvirtio_mmio = {
     .virtqueue_kick = qvirtio_mmio_virtqueue_kick,
 };

-QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size)
+QVirtioMMIODevice *qvirtio_mmio_init_device(QTestState *qts, uint64_t addr,
+                                            uint32_t page_size)
 {
     QVirtioMMIODevice *dev;
     uint32_t magic;
     dev = g_malloc0(sizeof(*dev));

-    magic = readl(addr + QVIRTIO_MMIO_MAGIC_VALUE);
+    magic = qtest_readl(qts, addr + QVIRTIO_MMIO_MAGIC_VALUE);
     g_assert(magic == ('v' | 'i' << 8 | 'r' << 16 | 't' << 24));

     dev->addr = addr;
     dev->page_size = page_size;
     dev->vdev.device_type = readl(addr + QVIRTIO_MMIO_DEVICE_ID);
     dev->vdev.bus = &qvirtio_mmio;
+    dev->vdev.qts = qts;

-    writel(addr + QVIRTIO_MMIO_GUEST_PAGE_SIZE, page_size);
+    qtest_writel(qts, addr + QVIRTIO_MMIO_GUEST_PAGE_SIZE, page_size);

     return dev;
 }
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 7ac15c04e1..f15971220c 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -240,6 +240,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
     vqpci->vq.align = VIRTIO_PCI_VRING_ALIGN;
     vqpci->vq.indirect = (feat & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0;
     vqpci->vq.event = (feat & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0;
+    vqpci->vq.qts = d->qts;

     vqpci->msix_entry = -1;
     vqpci->msix_addr = 0;
@@ -316,6 +317,7 @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
                         qvirtio_pci_assign_device, &dev);

     dev->vdev.bus = &qvirtio_pci;
+    dev->vdev.qts = bus->qts;

     return dev;
 }
@@ -329,6 +331,7 @@ QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus,
                         qvirtio_pci_assign_device, &dev);

     dev->vdev.bus = &qvirtio_pci;
+    dev->vdev.qts = bus->qts;

     return dev;
 }
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 9880a6964e..064a82f0f3 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -87,7 +87,7 @@ void qvirtio_wait_queue_isr(QVirtioDevice *d,
     gint64 start_time = g_get_monotonic_time();

     for (;;) {
-        clock_step(100);
+        qtest_clock_step(d->qts, 100);
         if (d->bus->get_queue_isr_status(d, vq)) {
             return;
         }
@@ -109,7 +109,7 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
     uint8_t val;

     while ((val = readb(addr)) == 0xff) {
-        clock_step(100);
+        qtest_clock_step(d->qts, 100);
         g_assert(!d->bus->get_queue_isr_status(d, vq));
         g_assert(g_get_monotonic_time() - start_time <= timeout_us);
     }
@@ -133,7 +133,7 @@ void qvirtio_wait_used_elem(QVirtioDevice *d,
     for (;;) {
         uint32_t got_desc_idx;

-        clock_step(100);
+        qtest_clock_step(d->qts, 100);

         if (d->bus->get_queue_isr_status(d, vq) &&
             qvirtqueue_get_buf(vq, &got_desc_idx)) {
@@ -150,7 +150,7 @@ void qvirtio_wait_config_isr(QVirtioDevice *d, gint64 timeout_us)
     gint64 start_time = g_get_monotonic_time();

     for (;;) {
-        clock_step(100);
+        qtest_clock_step(d->qts, 100);
         if (d->bus->get_config_isr_status(d)) {
             return;
         }
@@ -169,22 +169,23 @@ void qvring_init(const QGuestAllocator *alloc, QVirtQueue *vq, uint64_t addr)

     for (i = 0; i < vq->size - 1; i++) {
         /* vq->desc[i].addr */
-        writeq(vq->desc + (16 * i), 0);
+        qtest_writeq(vq->qts, vq->desc + (16 * i), 0);
         /* vq->desc[i].next */
-        writew(vq->desc + (16 * i) + 14, i + 1);
+        qtest_writew(vq->qts, vq->desc + (16 * i) + 14, i + 1);
     }

     /* vq->avail->flags */
-    writew(vq->avail, 0);
+    qtest_writew(vq->qts, vq->avail, 0);
     /* vq->avail->idx */
-    writew(vq->avail + 2, 0);
+    qtest_writew(vq->qts, vq->avail + 2, 0);
     /* vq->avail->used_event */
-    writew(vq->avail + 4 + (2 * vq->size), 0);
+    qtest_writew(vq->qts, vq->avail + 4 + (2 * vq->size), 0);

     /* vq->used->flags */
-    writew(vq->used, 0);
+    qtest_writew(vq->qts, vq->used, 0);
     /* vq->used->avail_event */
-    writew(vq->used + 2 + sizeof(struct vring_used_elem) * vq->size, 0);
+    qtest_writew(vq->qts,
+                 vq->used + 2 + sizeof(struct vring_used_elem) * vq->size, 0);
 }

 QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
@@ -196,14 +197,15 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
     indirect->index = 0;
     indirect->elem = elem;
     indirect->desc = guest_alloc(alloc, sizeof(struct vring_desc) * elem);
+    indirect->qts = d->qts;

     for (i = 0; i < elem - 1; ++i) {
         /* indirect->desc[i].addr */
-        writeq(indirect->desc + (16 * i), 0);
+        qtest_writeq(d->qts, indirect->desc + (16 * i), 0);
         /* indirect->desc[i].flags */
-        writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
+        qtest_writew(d->qts, indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
         /* indirect->desc[i].next */
-        writew(indirect->desc + (16 * i) + 14, i + 1);
+        qtest_writew(d->qts, indirect->desc + (16 * i) + 14, i + 1);
     }

     return indirect;
@@ -216,18 +218,21 @@ void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data,

     g_assert_cmpint(indirect->index, <, indirect->elem);

-    flags = readw(indirect->desc + (16 * indirect->index) + 12);
+    flags = qtest_readw(indirect->qts,
+                        indirect->desc + (16 * indirect->index) + 12);

     if (write) {
         flags |= VRING_DESC_F_WRITE;
     }

     /* indirect->desc[indirect->index].addr */
-    writeq(indirect->desc + (16 * indirect->index), data);
+    qtest_writeq(indirect->qts, indirect->desc + (16 * indirect->index), data);
     /* indirect->desc[indirect->index].len */
-    writel(indirect->desc + (16 * indirect->index) + 8, len);
+    qtest_writel(indirect->qts,
+                 indirect->desc + (16 * indirect->index) + 8, len);
     /* indirect->desc[indirect->index].flags */
-    writew(indirect->desc + (16 * indirect->index) + 12, flags);
+    qtest_writew(indirect->qts,
+                 indirect->desc + (16 * indirect->index) + 12, flags);

     indirect->index++;
 }
@@ -247,11 +252,11 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write,
     }

     /* vq->desc[vq->free_head].addr */
-    writeq(vq->desc + (16 * vq->free_head), data);
+    qtest_writeq(vq->qts, vq->desc + (16 * vq->free_head), data);
     /* vq->desc[vq->free_head].len */
-    writel(vq->desc + (16 * vq->free_head) + 8, len);
+    qtest_writel(vq->qts, vq->desc + (16 * vq->free_head) + 8, len);
     /* vq->desc[vq->free_head].flags */
-    writew(vq->desc + (16 * vq->free_head) + 12, flags);
+    qtest_writew(vq->qts, vq->desc + (16 * vq->free_head) + 12, flags);

     return vq->free_head++; /* Return and increase, in this order */
 }
@@ -265,12 +270,13 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
     vq->num_free--;

     /* vq->desc[vq->free_head].addr */
-    writeq(vq->desc + (16 * vq->free_head), indirect->desc);
+    qtest_writeq(vq->qts, vq->desc + (16 * vq->free_head), indirect->desc);
     /* vq->desc[vq->free_head].len */
-    writel(vq->desc + (16 * vq->free_head) + 8,
-           sizeof(struct vring_desc) * indirect->elem);
+    qtest_writel(vq->qts, vq->desc + (16 * vq->free_head) + 8,
+                 sizeof(struct vring_desc) * indirect->elem);
     /* vq->desc[vq->free_head].flags */
-    writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT);
+    qtest_writew(vq->qts,
+                 vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT);

     return vq->free_head++; /* Return and increase, in this order */
 }
@@ -278,21 +284,23 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
 void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head)
 {
     /* vq->avail->idx */
-    uint16_t idx = readw(vq->avail + 2);
+    uint16_t idx = qtest_readw(d->qts, vq->avail + 2);
     /* vq->used->flags */
     uint16_t flags;
     /* vq->used->avail_event */
     uint16_t avail_event;

+    assert(d->qts == vq->qts);
+
     /* vq->avail->ring[idx % vq->size] */
-    writew(vq->avail + 4 + (2 * (idx % vq->size)), free_head);
+    qtest_writew(d->qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head);
     /* vq->avail->idx */
-    writew(vq->avail + 2, idx + 1);
+    qtest_writew(d->qts, vq->avail + 2, idx + 1);

     /* Must read after idx is updated */
-    flags = readw(vq->avail);
-    avail_event = readw(vq->used + 4 +
-                                sizeof(struct vring_used_elem) * vq->size);
+    flags = qtest_readw(d->qts, vq->avail);
+    avail_event = qtest_readw(d->qts, vq->used + 4 +
+                              sizeof(struct vring_used_elem) * vq->size);

     /* < 1 because we add elements to avail queue one by one */
     if ((flags & VRING_USED_F_NO_NOTIFY) == 0 &&
@@ -313,7 +321,7 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx)
 {
     uint16_t idx;

-    idx = readw(vq->used + offsetof(struct vring_used, idx));
+    idx = qtest_readw(vq->qts, vq->used + offsetof(struct vring_used, idx));
     if (idx == vq->last_used_idx) {
         return false;
     }
@@ -325,7 +333,8 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx)
                     offsetof(struct vring_used, ring) +
                     (vq->last_used_idx % vq->size) *
                     sizeof(struct vring_used_elem);
-        *desc_idx = readl(elem_addr + offsetof(struct vring_used_elem, id));
+        *desc_idx = qtest_readl(vq->qts, elem_addr +
+                                offsetof(struct vring_used_elem, id));
     }

     vq->last_used_idx++;
@@ -337,5 +346,5 @@ void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx)
     g_assert(vq->event);

     /* vq->avail->used_event */
-    writew(vq->avail + 4 + (2 * vq->size), idx);
+    qtest_writew(vq->qts, vq->avail + 4 + (2 * vq->size), idx);
 }
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 0576cb16ba..26d0a7e9af 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -687,7 +687,8 @@ static void mmio_basic(void)

     arm_test_start();

-    dev = qvirtio_mmio_init_device(MMIO_DEV_BASE_ADDR, MMIO_PAGE_SIZE);
+    dev = qvirtio_mmio_init_device(global_qtest, MMIO_DEV_BASE_ADDR,
+                                   MMIO_PAGE_SIZE);
     g_assert(dev != NULL);
     g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK);

-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (15 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 23:11   ` John Snow
  2017-09-05 10:32   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 18/29] ivshmem-test: " Eric Blake
                   ` (12 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini, John Snow, open list:IDE

Managing parallel connections to two different monitors via
the implicit global_qtest makes it hard to copy-and-paste code
to tests that are not aware of the implicit state; the
management of global_qtest is even harder to follow because
it was masked behind set_context().

Instead, explicitly pass QTestState* around (generally, by
reusing the member already present in ahci->parent QOSState),
and call explicit qtest_* functions on all places that
interact with a monitor.

We can assert that the conversion is correct by checking that
global_qtest remains NULL throughout the test (a later patch
that changes global_qtest to not be a public global variable
will drop the assertions).

Bonus: there were several spots that were constructing a JSON
string, then passing that through qmp() as the format, rather
than directly using qmp() to construct the JSON.  Fixing that
gets us one step closer to enabling -Wformat checking on
constructed JSON.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqos/libqos.h    |  1 -
 tests/ahci-test.c        | 83 +++++++++++++++++++++++-------------------------
 tests/libqos/ahci.c      | 45 +++++++++++++-------------
 tests/libqos/libqos-pc.c |  2 +-
 tests/libqos/libqos.c    | 37 ++++++---------------
 5 files changed, 73 insertions(+), 95 deletions(-)

diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 07d4b93d1d..9e020efb10 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -29,7 +29,6 @@ void qtest_shutdown(QOSState *qs);
 bool have_qemu_img(void);
 void mkimg(const char *file, const char *fmt, unsigned size_mb);
 void mkqcow2(const char *file, unsigned size_mb);
-void set_context(QOSState *s);
 void migrate(QOSState *from, QOSState *to, const char *uri);
 void prepare_blkdebug_script(const char *debug_fn, const char *event);
 void generate_pattern(void *buffer, size_t len, size_t cycle_len);
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index c94d1bd712..ba3f643d09 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -157,6 +157,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)

     s = g_malloc0(sizeof(AHCIQState));
     s->parent = qtest_pc_vboot(cli, ap);
+    global_qtest = NULL;
     alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);

     /* Verify that we have an AHCI device present. */
@@ -196,7 +197,7 @@ static void ahci_shutdown(AHCIQState *ahci)
 {
     QOSState *qs = ahci->parent;

-    set_context(qs);
+    assert(!global_qtest);
     ahci_clean_mem(ahci);
     free_ahci_device(ahci->dev);
     g_free(ahci);
@@ -869,15 +870,15 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,

     /* Write some indicative pattern to our buffer. */
     generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE);
-    bufwrite(ptr, tx, bufsize);
+    qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize);

     /* Write this buffer to disk, then read it back to the DMA buffer. */
     ahci_guest_io(ahci, port, write_cmd, ptr, bufsize, sector);
-    qmemset(ptr, 0x00, bufsize);
+    qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize);
     ahci_guest_io(ahci, port, read_cmd, ptr, bufsize, sector);

     /*** Read back the Data ***/
-    bufread(ptr, rx, bufsize);
+    qtest_bufread(ahci->parent->qts, ptr, rx, bufsize);
     g_assert_cmphex(memcmp(tx, rx, bufsize), ==, 0);

     ahci_free(ahci, ptr);
@@ -918,7 +919,7 @@ static void ahci_test_max(AHCIQState *ahci)
     }

     port = ahci_test_nondata(ahci, cmd);
-    memread(ahci->port[port].fb + 0x40, d2h, 0x20);
+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20);
     nsect = (uint64_t)d2h->lba_hi[2] << 40 |
         (uint64_t)d2h->lba_hi[1] << 32 |
         (uint64_t)d2h->lba_hi[0] << 24 |
@@ -1036,7 +1037,7 @@ static void test_dma_fragmented(void)
     /* Create a DMA buffer in guest memory, and write our pattern to it. */
     ptr = guest_alloc(ahci->parent->alloc, bufsize);
     g_assert(ptr);
-    bufwrite(ptr, tx, bufsize);
+    qtest_bufwrite(ahci->parent->qts, ptr, tx, bufsize);

     cmd = ahci_command_create(CMD_WRITE_DMA);
     ahci_command_adjust(cmd, 0, ptr, bufsize, 32);
@@ -1053,7 +1054,7 @@ static void test_dma_fragmented(void)
     ahci_command_free(cmd);

     /* Read back the guest's receive buffer into local memory */
-    bufread(ptr, rx, bufsize);
+    qtest_bufread(ahci->parent->qts, ptr, rx, bufsize);
     guest_free(ahci->parent->alloc, ptr);

     g_assert_cmphex(memcmp(tx, rx, bufsize), ==, 0);
@@ -1164,8 +1165,6 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
                     "-drive if=ide,format=%s,file=%s "
                     "-incoming %s", imgfmt, tmp_path, uri);

-    set_context(src->parent);
-
     /* initialize */
     px = ahci_port_select(src);
     ahci_port_clear(src, px);
@@ -1233,7 +1232,7 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write)
     generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE);
     ptr = ahci_alloc(ahci, bufsize);
     g_assert(ptr);
-    memwrite(ptr, tx, bufsize);
+    qtest_memwrite(ahci->parent->qts, ptr, tx, bufsize);

     /* Attempt to write (and fail) */
     cmd = ahci_guest_io_halt(ahci, port, cmd_write,
@@ -1299,8 +1298,6 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
                     "-incoming %s",
                     tmp_path, imgfmt, uri);

-    set_context(src->parent);
-
     /* Initialize and prepare */
     port = ahci_port_select(src);
     ahci_port_clear(src, port);
@@ -1309,7 +1306,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
     /* create DMA source buffer and write pattern */
     ptr = ahci_alloc(src, bufsize);
     g_assert(ptr);
-    memwrite(ptr, tx, bufsize);
+    qtest_memwrite(src->parent->qts, ptr, tx, bufsize);

     /* Write, trigger the VM to stop, migrate, then resume. */
     cmd = ahci_guest_io_halt(src, port, cmd_write,
@@ -1350,7 +1347,6 @@ static void test_flush_migrate(void)
     AHCIQState *src, *dst;
     AHCICommand *cmd;
     uint8_t px;
-    const char *s;
     char *uri = g_strdup_printf("unix:%s", mig_socket);

     prepare_blkdebug_script(debug_path, "flush_to_disk");
@@ -1368,8 +1364,6 @@ static void test_flush_migrate(void)
                     "-device ide-hd,drive=drive0 "
                     "-incoming %s", tmp_path, imgfmt, uri);

-    set_context(src->parent);
-
     px = ahci_port_select(src);
     ahci_port_clear(src, px);

@@ -1380,15 +1374,14 @@ static void test_flush_migrate(void)
     cmd = ahci_command_create(CMD_FLUSH_CACHE);
     ahci_command_commit(src, cmd, px);
     ahci_command_issue_async(src, cmd);
-    qmp_eventwait("STOP");
+    qtest_qmp_eventwait(src->parent->qts, "STOP");

     /* Migrate over */
     ahci_migrate(src, dst, uri);

     /* Complete the command */
-    s = "{'execute':'cont' }";
-    qmp_async(s);
-    qmp_eventwait("RESUME");
+    qtest_async_qmp(dst->parent->qts, "{'execute':'cont'}");
+    qtest_qmp_eventwait(dst->parent->qts, "RESUME");
     ahci_command_wait(dst, cmd);
     ahci_command_verify(dst, cmd);

@@ -1480,7 +1473,7 @@ static int ahci_cb_cmp_buff(AHCIQState *ahci, AHCICommand *cmd,
     }

     rx = g_malloc0(opts->size);
-    bufread(opts->buffer, rx, opts->size);
+    qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size);
     g_assert_cmphex(memcmp(tx, rx, opts->size), ==, 0);
     g_free(rx);

@@ -1555,9 +1548,10 @@ static void test_atapi_bcl(void)
 }


-static void atapi_wait_tray(bool open)
+static void atapi_wait_tray(AHCIQState *ahci, bool open)
 {
-    QDict *rsp = qmp_eventwait_ref("DEVICE_TRAY_MOVED");
+    QDict *rsp = qtest_qmp_eventwait_ref(ahci->parent->qts,
+                                         "DEVICE_TRAY_MOVED");
     QDict *data = qdict_get_qdict(rsp, "data");
     if (open) {
         g_assert(qdict_get_bool(data, "tray-open"));
@@ -1584,43 +1578,46 @@ static void test_atapi_tray(void)
     port = ahci_port_select(ahci);

     ahci_atapi_eject(ahci, port);
-    atapi_wait_tray(true);
+    atapi_wait_tray(ahci, true);

     ahci_atapi_load(ahci, port);
-    atapi_wait_tray(false);
+    atapi_wait_tray(ahci, false);

     /* Remove media */
-    qmp_async("{'execute': 'blockdev-open-tray', "
-               "'arguments': {'device': 'drive0'}}");
-    atapi_wait_tray(true);
-    rsp = qmp_receive();
+    qtest_async_qmp(ahci->parent->qts, "{'execute': 'blockdev-open-tray', "
+                    "'arguments': {'device': 'drive0'}}");
+    atapi_wait_tray(ahci, true);
+    rsp = qtest_qmp_receive(ahci->parent->qts);
     QDECREF(rsp);

-    qmp_discard_response("{'execute': 'x-blockdev-remove-medium', "
-                         "'arguments': {'device': 'drive0'}}");
+    qtest_qmp_discard_response(ahci->parent->qts,
+                               "{'execute': 'x-blockdev-remove-medium', "
+                               "'arguments': {'device': 'drive0'}}");

     /* Test the tray without a medium */
     ahci_atapi_load(ahci, port);
-    atapi_wait_tray(false);
+    atapi_wait_tray(ahci, false);

     ahci_atapi_eject(ahci, port);
-    atapi_wait_tray(true);
+    atapi_wait_tray(ahci, true);

     /* Re-insert media */
-    qmp_discard_response("{'execute': 'blockdev-add', "
-                          "'arguments': {'node-name': 'node0', "
+    qtest_qmp_discard_response(ahci->parent->qts,
+                               "{'execute': 'blockdev-add', "
+                               "'arguments': {'node-name': 'node0', "
                                         "'driver': 'raw', "
                                         "'file': { 'driver': 'file', "
                                                   "'filename': %s }}}", iso);
-    qmp_discard_response("{'execute': 'x-blockdev-insert-medium',"
-                          "'arguments': { 'device': 'drive0', "
+    qtest_qmp_discard_response(ahci->parent->qts,
+                               "{'execute': 'x-blockdev-insert-medium',"
+                               "'arguments': { 'device': 'drive0', "
                                          "'node-name': 'node0' }}");

     /* Again, the event shows up first */
-    qmp_async("{'execute': 'blockdev-close-tray', "
-               "'arguments': {'device': 'drive0'}}");
-    atapi_wait_tray(false);
-    rsp = qmp_receive();
+    qtest_async_qmp(ahci->parent->qts, "{'execute': 'blockdev-close-tray', "
+                    "'arguments': {'device': 'drive0'}}");
+    atapi_wait_tray(ahci, false);
+    rsp = qtest_qmp_receive(ahci->parent->qts);
     QDECREF(rsp);

     /* Now, to convince ATAPI we understand the media has changed... */
@@ -1640,10 +1637,10 @@ static void test_atapi_tray(void)

     /* Final tray test. */
     ahci_atapi_eject(ahci, port);
-    atapi_wait_tray(true);
+    atapi_wait_tray(ahci, true);

     ahci_atapi_load(ahci, port);
-    atapi_wait_tray(false);
+    atapi_wait_tray(ahci, false);

     /* Cleanup */
     g_free(tx);
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 790ef991b3..ba79cd77a0 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -283,7 +283,8 @@ void ahci_hba_enable(AHCIQState *ahci)
         /* Allocate Memory for the Command List Buffer & FIS Buffer */
         /* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */
         ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20);
-        qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20);
+        qtest_memset(ahci->parent->qts, ahci->port[i].clb, 0x00,
+                     num_cmd_slots * 0x20);
         g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb);
         ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb);
         g_assert_cmphex(ahci->port[i].clb, ==,
@@ -291,7 +292,7 @@ void ahci_hba_enable(AHCIQState *ahci)

         /* PxFB space ... 0x100, as in 4.2.1 p 35 */
         ahci->port[i].fb = ahci_alloc(ahci, 0x100);
-        qmemset(ahci->port[i].fb, 0x00, 0x100);
+        qtest_memset(ahci->parent->qts, ahci->port[i].fb, 0x00, 0x100);
         g_test_message("FB: 0x%08" PRIx64, ahci->port[i].fb);
         ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb);
         g_assert_cmphex(ahci->port[i].fb, ==,
@@ -397,7 +398,7 @@ void ahci_port_clear(AHCIQState *ahci, uint8_t port)
     g_assert_cmphex(ahci_px_rreg(ahci, port, AHCI_PX_IS), ==, 0);

     /* Wipe the FIS-Receive Buffer */
-    qmemset(ahci->port[port].fb, 0x00, 0x100);
+    qtest_memset(ahci->parent->qts, ahci->port[port].fb, 0x00, 0x100);
 }

 /**
@@ -466,7 +467,7 @@ void ahci_port_check_d2h_sanity(AHCIQState *ahci, uint8_t port, uint8_t slot)
     RegD2HFIS *d2h = g_malloc0(0x20);
     uint32_t reg;

-    memread(ahci->port[port].fb + 0x40, d2h, 0x20);
+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x40, d2h, 0x20);
     g_assert_cmphex(d2h->fis_type, ==, 0x34);

     reg = ahci_px_rreg(ahci, port, AHCI_PX_TFD);
@@ -484,7 +485,7 @@ void ahci_port_check_pio_sanity(AHCIQState *ahci, uint8_t port,
     /* We cannot check the Status or E_Status registers, because
      * the status may have again changed between the PIO Setup FIS
      * and the conclusion of the command with the D2H Register FIS. */
-    memread(ahci->port[port].fb + 0x20, pio, 0x20);
+    qtest_memread(ahci->parent->qts, ahci->port[port].fb + 0x20, pio, 0x20);
     g_assert_cmphex(pio->fis_type, ==, 0x5f);

     /* BUG: PIO Setup FIS as utilized by QEMU tries to fit the entire
@@ -516,7 +517,7 @@ void ahci_get_command_header(AHCIQState *ahci, uint8_t port,
 {
     uint64_t ba = ahci->port[port].clb;
     ba += slot * sizeof(AHCICommandHeader);
-    memread(ba, cmd, sizeof(AHCICommandHeader));
+    qtest_memread(ahci->parent->qts, ba, cmd, sizeof(AHCICommandHeader));

     cmd->flags = le16_to_cpu(cmd->flags);
     cmd->prdtl = le16_to_cpu(cmd->prdtl);
@@ -537,7 +538,7 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t port,
     tmp.prdbc = cpu_to_le32(cmd->prdbc);
     tmp.ctba = cpu_to_le64(cmd->ctba);

-    memwrite(ba, &tmp, sizeof(AHCICommandHeader));
+    qtest_memwrite(ahci->parent->qts, ba, &tmp, sizeof(AHCICommandHeader));
 }

 void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot)
@@ -575,7 +576,7 @@ void ahci_write_fis(AHCIQState *ahci, AHCICommand *cmd)
         tmp.count = cpu_to_le16(tmp.count);
     }

-    memwrite(addr, &tmp, sizeof(tmp));
+    qtest_memwrite(ahci->parent->qts, addr, &tmp, sizeof(tmp));
 }

 unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port)
@@ -636,7 +637,7 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,
     if (opts->size && !opts->buffer) {
         opts->buffer = ahci_alloc(ahci, opts->size);
         g_assert(opts->buffer);
-        qmemset(opts->buffer, 0x00, opts->size);
+        qtest_memset(ahci->parent->qts, opts->buffer, 0x00, opts->size);
     }

     /* Command creation */
@@ -661,15 +662,15 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,
     ahci_command_commit(ahci, cmd, port);
     ahci_command_issue_async(ahci, cmd);
     if (opts->error) {
-        qmp_eventwait("STOP");
+        qtest_qmp_eventwait(ahci->parent->qts, "STOP");
     }
     if (opts->mid_cb) {
         rc = opts->mid_cb(ahci, cmd, opts);
         g_assert_cmpint(rc, ==, 0);
     }
     if (opts->error) {
-        qmp_async("{'execute':'cont' }");
-        qmp_eventwait("RESUME");
+        qtest_async_qmp(ahci->parent->qts, "{'execute':'cont' }");
+        qtest_qmp_eventwait(ahci->parent->qts, "RESUME");
     }

     /* Wait for command to complete and verify sanity */
@@ -697,7 +698,7 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port,
     ahci_command_adjust(cmd, sector, buffer, bufsize, 0);
     ahci_command_commit(ahci, cmd, port);
     ahci_command_issue_async(ahci, cmd);
-    qmp_eventwait("STOP");
+    qtest_qmp_eventwait(ahci->parent->qts, "STOP");

     return cmd;
 }
@@ -706,8 +707,8 @@ AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port,
 void ahci_guest_io_resume(AHCIQState *ahci, AHCICommand *cmd)
 {
     /* Complete the command */
-    qmp_async("{'execute':'cont' }");
-    qmp_eventwait("RESUME");
+    qtest_async_qmp(ahci->parent->qts, "{'execute':'cont' }");
+    qtest_qmp_eventwait(ahci->parent->qts, "RESUME");
     ahci_command_wait(ahci, cmd);
     ahci_command_verify(ahci, cmd);
     ahci_command_free(cmd);
@@ -754,16 +755,16 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
     g_assert(props);
     ptr = ahci_alloc(ahci, bufsize);
     g_assert(!bufsize || ptr);
-    qmemset(ptr, 0x00, bufsize);
+    qtest_memset(ahci->parent->qts, ptr, 0x00, bufsize);

     if (bufsize && props->write) {
-        bufwrite(ptr, buffer, bufsize);
+        qtest_bufwrite(ahci->parent->qts, ptr, buffer, bufsize);
     }

     ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize, sector);

     if (bufsize && props->read) {
-        bufread(ptr, buffer, bufsize);
+        qtest_bufread(ahci->parent->qts, ptr, buffer, bufsize);
     }

     ahci_free(ahci, ptr);
@@ -901,7 +902,7 @@ static int copy_buffer(AHCIQState *ahci, AHCICommand *cmd,
                         const AHCIOpts *opts)
 {
     unsigned char *rx = opts->opaque;
-    bufread(opts->buffer, rx, opts->size);
+    qtest_bufread(ahci->parent->qts, opts->buffer, rx, opts->size);
     return 0;
 }

@@ -1141,7 +1142,7 @@ void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port)
     ahci_write_fis(ahci, cmd);
     /* Then ATAPI CMD, if needed */
     if (cmd->props->atapi) {
-        memwrite(table_ptr + 0x40, cmd->atapi_cmd, 16);
+        qtest_memwrite(ahci->parent->qts, table_ptr + 0x40, cmd->atapi_cmd, 16);
     }

     /* Construct and write the PRDs to the command table */
@@ -1162,8 +1163,8 @@ void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port)
         prd.dbc |= cpu_to_le32(0x80000000); /* Request DPS Interrupt */

         /* Commit the PRD entry to the Command Table */
-        memwrite(table_ptr + 0x80 + (i * sizeof(PRD)),
-                 &prd, sizeof(PRD));
+        qtest_memwrite(ahci->parent->qts, table_ptr + 0x80 + (i * sizeof(PRD)),
+                       &prd, sizeof(PRD));
     }

     /* Bookmark the PRDTL and CTBA values */
diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c
index b554758802..a9c1aceaa7 100644
--- a/tests/libqos/libqos-pc.c
+++ b/tests/libqos/libqos-pc.c
@@ -25,7 +25,7 @@ QOSState *qtest_pc_boot(const char *cmdline_fmt, ...)
     qs = qtest_vboot(&qos_ops, cmdline_fmt, ap);
     va_end(ap);

-    qtest_irq_intercept_in(global_qtest, "ioapic");
+    qtest_irq_intercept_in(qs->qts, "ioapic");

     return qs;
 }
diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 62d2f39b93..24e8156fe2 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -79,34 +79,19 @@ void qtest_shutdown(QOSState *qs)
     }
 }

-void set_context(QOSState *s)
+static QDict *qmp_execute(QTestState *qts, const char *command)
 {
-    global_qtest = s->qts;
-}
-
-static QDict *qmp_execute(const char *command)
-{
-    char *fmt;
-    QDict *rsp;
-
-    fmt = g_strdup_printf("{ 'execute': '%s' }", command);
-    rsp = qmp(fmt);
-    g_free(fmt);
-
-    return rsp;
+    return qtest_qmp(qts, "{ 'execute': %s }", command);
 }

 void migrate(QOSState *from, QOSState *to, const char *uri)
 {
     const char *st;
-    char *s;
     QDict *rsp, *sub;
     bool running;

-    set_context(from);
-
     /* Is the machine currently running? */
-    rsp = qmp_execute("query-status");
+    rsp = qmp_execute(from->qts, "query-status");
     g_assert(qdict_haskey(rsp, "return"));
     sub = qdict_get_qdict(rsp, "return");
     g_assert(qdict_haskey(sub, "running"));
@@ -114,30 +99,27 @@ void migrate(QOSState *from, QOSState *to, const char *uri)
     QDECREF(rsp);

     /* Issue the migrate command. */
-    s = g_strdup_printf("{ 'execute': 'migrate',"
-                        "'arguments': { 'uri': '%s' } }",
-                        uri);
-    rsp = qmp(s);
-    g_free(s);
+    rsp = qtest_qmp(from->qts,
+                    "{ 'execute': 'migrate', 'arguments': { 'uri': %s }}",
+                    uri);
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

     /* Wait for STOP event, but only if we were running: */
     if (running) {
-        qmp_eventwait("STOP");
+        qtest_qmp_eventwait(from->qts, "STOP");
     }

     /* If we were running, we can wait for an event. */
     if (running) {
         migrate_allocator(from->alloc, to->alloc);
-        set_context(to);
-        qmp_eventwait("RESUME");
+        qtest_qmp_eventwait(to->qts, "RESUME");
         return;
     }

     /* Otherwise, we need to wait: poll until migration is completed. */
     while (1) {
-        rsp = qmp_execute("query-migrate");
+        rsp = qmp_execute(from->qts, "query-migrate");
         g_assert(qdict_haskey(rsp, "return"));
         sub = qdict_get_qdict(rsp, "return");
         g_assert(qdict_haskey(sub, "status"));
@@ -160,7 +142,6 @@ void migrate(QOSState *from, QOSState *to, const char *uri)
     }

     migrate_allocator(from->alloc, to->alloc);
-    set_context(to);
 }

 bool have_qemu_img(void)
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 18/29] ivshmem-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (16 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:36   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 19/29] postcopy-test: " Eric Blake
                   ` (11 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Managing parallel connections to two different monitors via
the implicit global_qtest makes it hard to copy-and-paste code
to tests that are not aware of the implicit state.  Since we
have already fixed qpci to avoid global_qtest, we can now
simplify by not using global_qtest anywhere in ivshmem-test.

We can assert that the conversion is correct by checking that
global_qtest remains NULL throughout the test (a later patch
that changes global_qtest to not be a public global variable
will drop the assertions).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/ivshmem-test.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index 37763425ee..b9e0f573f6 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) {
 static inline unsigned in_reg(IVState *s, enum Reg reg)
 {
     const char *name = reg2str(reg);
-    QTestState *qtest = global_qtest;
     unsigned res;

-    global_qtest = s->qs->qts;
     res = qpci_io_readl(s->dev, s->reg_bar, reg);
     g_test_message("*%s -> %x\n", name, res);
-    global_qtest = qtest;

     return res;
 }
@@ -85,35 +82,25 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)
 static inline void out_reg(IVState *s, enum Reg reg, unsigned v)
 {
     const char *name = reg2str(reg);
-    QTestState *qtest = global_qtest;

-    global_qtest = s->qs->qts;
     g_test_message("%x -> *%s\n", v, name);
     qpci_io_writel(s->dev, s->reg_bar, reg, v);
-    global_qtest = qtest;
 }

 static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
 {
-    QTestState *qtest = global_qtest;
-
-    global_qtest = s->qs->qts;
     qpci_memread(s->dev, s->mem_bar, off, buf, len);
-    global_qtest = qtest;
 }

 static inline void write_mem(IVState *s, uint64_t off,
                              const void *buf, size_t len)
 {
-    QTestState *qtest = global_qtest;
-
-    global_qtest = s->qs->qts;
     qpci_memwrite(s->dev, s->mem_bar, off, buf, len);
-    global_qtest = qtest;
 }

 static void cleanup_vm(IVState *s)
 {
+    assert(!global_qtest);
     g_free(s->dev);
     qtest_shutdown(s->qs);
 }
@@ -131,6 +118,7 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
         g_printerr("ivshmem-test tests are only available on x86 or ppc64\n");
         exit(EXIT_FAILURE);
     }
+    global_qtest = NULL;
     s->dev = get_device(s->qs->pcibus);

     s->reg_bar = qpci_iomap(s->dev, 0, &barsize);
@@ -353,7 +341,6 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpint(vm1, !=, vm2);

     /* check number of MSI-X vectors */
-    global_qtest = s1->qs->qts;
     if (msi) {
         ret = qpci_msix_table_size(s1->dev);
         g_assert_cmpuint(ret, ==, nvectors);
@@ -376,7 +363,6 @@ static void test_ivshmem_server(bool msi)
     g_assert_cmpuint(ret, !=, 0);

     /* ping vm1 -> vm2 on vector 1 */
-    global_qtest = s2->qs->qts;
     if (msi) {
         ret = qpci_msix_pending(s2->dev, 1);
         g_assert_cmpuint(ret, ==, 0);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 19/29] postcopy-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (17 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 18/29] ivshmem-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:41   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 20/29] vhost-user-test: " Eric Blake
                   ` (10 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Managing parallel connections to two different monitors via
the implicit global_qtest makes it hard to copy-and-paste code
to tests that are not aware of the implicit state.  We are
already half-using the explicit APIs, so fix the remaining
spots to also be explicit about which connection is in use,
and avoid global_qtest.

We can assert that the conversion is correct by checking that
global_qtest remains NULL throughout the test (a later patch
that changes global_qtest to not be a public global variable
will drop the assertions).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/postcopy-test.c | 84 ++++++++++++++++++++++++---------------------------
 1 file changed, 40 insertions(+), 44 deletions(-)

diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 8142f2ab90..0e5fe20a83 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -223,7 +223,7 @@ static void wait_for_serial(const char *side)
 /*
  * Events can get in the way of responses we are actually waiting for.
  */
-static QDict *return_or_event(QDict *response)
+static QDict *return_or_event(QTestState *qts, QDict *response)
 {
     const char *event_string;
     if (!qdict_haskey(response, "event")) {
@@ -236,7 +236,7 @@ static QDict *return_or_event(QDict *response)
         got_stop = true;
     }
     QDECREF(response);
-    return return_or_event(qtest_qmp_receive(global_qtest));
+    return return_or_event(qts, qtest_qmp_receive(qts));
 }


@@ -247,12 +247,13 @@ static QDict *return_or_event(QDict *response)
  * going postcopy.
  */

-static uint64_t get_migration_pass(void)
+static uint64_t get_migration_pass(QTestState *qts)
 {
     QDict *rsp, *rsp_return, *rsp_ram;
     uint64_t result;

-    rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
+    rsp = return_or_event(qts,
+                          qtest_qmp(qts, "{ 'execute': 'query-migrate' }"));
     rsp_return = qdict_get_qdict(rsp, "return");
     if (!qdict_haskey(rsp_return, "ram")) {
         /* Still in setup */
@@ -265,7 +266,7 @@ static uint64_t get_migration_pass(void)
     return result;
 }

-static void wait_for_migration_complete(void)
+static void wait_for_migration_complete(QTestState *qts)
 {
     QDict *rsp, *rsp_return;
     bool completed;
@@ -273,7 +274,8 @@ static void wait_for_migration_complete(void)
     do {
         const char *status;

-        rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
+        rsp = return_or_event(qts,
+                              qtest_qmp(qts, "{ 'execute': 'query-migrate' }"));
         rsp_return = qdict_get_qdict(rsp, "return");
         status = qdict_get_str(rsp_return, "status");
         completed = strcmp(status, "completed") == 0;
@@ -283,14 +285,14 @@ static void wait_for_migration_complete(void)
     } while (!completed);
 }

-static void wait_for_migration_pass(void)
+static void wait_for_migration_pass(QTestState *qts)
 {
-    uint64_t initial_pass = get_migration_pass();
+    uint64_t initial_pass = get_migration_pass(qts);
     uint64_t pass;

     /* Wait for the 1st sync */
     do {
-        initial_pass = get_migration_pass();
+        initial_pass = get_migration_pass(qts);
         if (got_stop || initial_pass) {
             break;
         }
@@ -299,11 +301,11 @@ static void wait_for_migration_pass(void)

     do {
         usleep(1000 * 100);
-        pass = get_migration_pass();
+        pass = get_migration_pass(qts);
     } while (pass == initial_pass && !got_stop);
 }

-static void check_guests_ram(void)
+static void check_guests_ram(QTestState *qts)
 {
     /* Our ASM test will have been incrementing one byte from each page from
      * 1MB to <100MB in order.
@@ -318,13 +320,13 @@ static void check_guests_ram(void)
     bool hit_edge = false;
     bool bad = false;

-    qtest_memread(global_qtest, start_address, &first_byte, 1);
+    qtest_memread(qts, start_address, &first_byte, 1);
     last_byte = first_byte;

     for (address = start_address + 4096; address < end_address; address += 4096)
     {
         uint8_t b;
-        qtest_memread(global_qtest, address, &b, 1);
+        qtest_memread(qts, address, &b, 1);
         if (b != last_byte) {
             if (((b + 1) % 256) == last_byte && !hit_edge) {
                 /* This is OK, the guest stopped at the point of
@@ -356,9 +358,9 @@ static void cleanup(const char *filename)
 static void test_migrate(void)
 {
     char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
-    QTestState *global = global_qtest, *from, *to;
+    QTestState *from, *to;
     unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
-    gchar *cmd, *cmd_src, *cmd_dst;
+    gchar *cmd_src, *cmd_dst;
     QDict *rsp;

     char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
@@ -401,24 +403,24 @@ static void test_migrate(void)

     g_free(bootpath);

-    from = qtest_start(cmd_src);
+    from = qtest_init(cmd_src);
     g_free(cmd_src);

     to = qtest_init(cmd_dst);
     g_free(cmd_dst);

-    global_qtest = from;
-    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
-                  "'arguments': { "
+    assert(!global_qtest);
+
+    rsp = qtest_qmp(from, "{ 'execute': 'migrate-set-capabilities',"
+                    "'arguments': { "
                       "'capabilities': [ {"
                           "'capability': 'postcopy-ram',"
                           "'state': true } ] } }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

-    global_qtest = to;
-    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
-                  "'arguments': { "
+    rsp = qtest_qmp(to, "{ 'execute': 'migrate-set-capabilities',"
+                    "'arguments': { "
                       "'capabilities': [ {"
                           "'capability': 'postcopy-ram',"
                           "'state': true } ] } }");
@@ -429,15 +431,14 @@ static void test_migrate(void)
      * quickly, but that it doesn't complete precopy even on a slow
      * machine, so also set the downtime.
      */
-    global_qtest = from;
-    rsp = qmp("{ 'execute': 'migrate_set_speed',"
-              "'arguments': { 'value': 100000000 } }");
+    rsp = qtest_qmp(from, "{ 'execute': 'migrate_set_speed',"
+                    "'arguments': { 'value': 100000000 } }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

     /* 1ms downtime - it should never finish precopy */
-    rsp = qmp("{ 'execute': 'migrate_set_downtime',"
-              "'arguments': { 'value': 0.001 } }");
+    rsp = qtest_qmp(from, "{ 'execute': 'migrate_set_downtime',"
+                    "'arguments': { 'value': 0.001 } }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

@@ -445,35 +446,30 @@ static void test_migrate(void)
     /* Wait for the first serial output from the source */
     wait_for_serial("src_serial");

-    cmd = g_strdup_printf("{ 'execute': 'migrate',"
-                          "'arguments': { 'uri': '%s' } }",
-                          uri);
-    rsp = qmp(cmd);
-    g_free(cmd);
+    rsp = qtest_qmp(from,
+                    "{'execute': 'migrate', 'arguments': { 'uri': %s}}", uri);
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

-    wait_for_migration_pass();
+    wait_for_migration_pass(from);

-    rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
+    rsp = return_or_event(from,
+                          qtest_qmp(from,
+                                    "{ 'execute': 'migrate-start-postcopy' }"));
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

     if (!got_stop) {
-        qmp_eventwait("STOP");
+        qtest_qmp_eventwait(from, "STOP");
     }

-    global_qtest = to;
-    qmp_eventwait("RESUME");
+    qtest_qmp_eventwait(to, "RESUME");

     wait_for_serial("dest_serial");
-    global_qtest = from;
-    wait_for_migration_complete();
+    wait_for_migration_complete(from);

     qtest_quit(from);

-    global_qtest = to;
-
     qtest_memread(to, start_address, &dest_byte_a, 1);

     /* Destination still running, wait for a byte to change */
@@ -482,19 +478,19 @@ static void test_migrate(void)
         usleep(10 * 1000);
     } while (dest_byte_a == dest_byte_b);

-    qmp_discard_response("{ 'execute' : 'stop'}");
+    qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}");
     /* With it stopped, check nothing changes */
     qtest_memread(to, start_address, &dest_byte_c, 1);
     sleep(1);
     qtest_memread(to, start_address, &dest_byte_d, 1);
     g_assert_cmpint(dest_byte_c, ==, dest_byte_d);

-    check_guests_ram();
+    check_guests_ram(to);

     qtest_quit(to);
     g_free(uri);

-    global_qtest = global;
+    assert(!global_qtest);

     cleanup("bootsect");
     cleanup("migsocket");
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 20/29] vhost-user-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (18 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 19/29] postcopy-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:49   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 21/29] qmp-test: " Eric Blake
                   ` (9 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Managing parallel connections to two different monitors via
the implicit global_qtest makes it hard to copy-and-paste code
to tests that are not aware of the implicit state.  Now that
libqos is fully-explicit, it is easy to expand the rest of
vhost-user-test to also use explicit state everywhere.

We can assert that the conversion is correct by checking that
global_qtest remains NULL throughout the test (a later patch
that changes global_qtest to not be a public global variable
will drop the assertions).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/vhost-user-test.c | 68 ++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 38 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 562bfaefd2..1e0c50d12a 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -139,6 +139,7 @@ enum {
 };

 typedef struct TestServer {
+    QTestState *qts;
     QPCIBus *bus;
     gchar *socket_path;
     gchar *mig_path;
@@ -164,7 +165,7 @@ static void init_virtio_dev(TestServer *s)
     QVirtioPCIDevice *dev;
     uint32_t features;

-    s->bus = qpci_init_pc(global_qtest, NULL);
+    s->bus = qpci_init_pc(s->qts, NULL);
     g_assert_nonnull(s->bus);

     dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
@@ -236,8 +237,11 @@ static void read_guest_mem(const void *data)
         guest_mem += (s->memory.regions[i].mmap_offset / sizeof(*guest_mem));

         for (j = 0; j < 256; j++) {
-            uint32_t a = readl(s->memory.regions[i].guest_phys_addr + j*4);
-            uint32_t b = guest_mem[j];
+            uint32_t a, b;
+
+            a = qtest_readl(s->qts,
+                            s->memory.regions[i].guest_phys_addr + j * 4);
+            b = guest_mem[j];

             g_assert_cmpint(a, ==, b);
         }
@@ -515,6 +519,12 @@ static gboolean _test_server_free(TestServer *server)

 static void test_server_free(TestServer *server)
 {
+    assert(!global_qtest);
+    if (server->qts) {
+        qtest_quit(server->qts);
+        server->qts = NULL;
+    }
+
     g_idle_add((GSourceFunc)_test_server_free, server);
 }

@@ -626,7 +636,6 @@ static void test_migrate(void)
     TestServer *s = test_server_new("src");
     TestServer *dest = test_server_new("dest");
     char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
-    QTestState *global = global_qtest, *from, *to;
     GSource *source;
     gchar *cmd;
     QDict *rsp;
@@ -637,7 +646,7 @@ static void test_migrate(void)
     test_server_listen(dest);

     cmd = GET_QEMU_CMDE(s, 2, "", "");
-    from = qtest_start(cmd);
+    s->qts = qtest_init(cmd);
     g_free(cmd);

     init_virtio_dev(s);
@@ -646,7 +655,7 @@ static void test_migrate(void)
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));

     cmd = GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri);
-    to = qtest_init(cmd);
+    dest->qts = qtest_init(cmd);
     g_free(cmd);

     source = g_source_new(&test_migrate_source_funcs,
@@ -657,16 +666,13 @@ static void test_migrate(void)

     /* slow down migration to have time to fiddle with log */
     /* TODO: qtest could learn to break on some places */
-    rsp = qmp("{ 'execute': 'migrate_set_speed',"
-              "'arguments': { 'value': 10 } }");
+    rsp = qtest_qmp(s->qts, "{ 'execute': 'migrate_set_speed',"
+                    "'arguments': { 'value': 10 } }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

-    cmd = g_strdup_printf("{ 'execute': 'migrate',"
-                          "'arguments': { 'uri': '%s' } }",
-                          uri);
-    rsp = qmp(cmd);
-    g_free(cmd);
+    rsp = qtest_qmp(s->qts,
+                    "{'execute': 'migrate', 'arguments': { 'uri': %s}}", uri);
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

@@ -681,28 +687,23 @@ static void test_migrate(void)
     munmap(log, size);

     /* speed things up */
-    rsp = qmp("{ 'execute': 'migrate_set_speed',"
-              "'arguments': { 'value': 0 } }");
+    rsp = qtest_qmp(s->qts, "{ 'execute': 'migrate_set_speed',"
+                    "'arguments': { 'value': 0 } }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);

-    qmp_eventwait("STOP");
+    qtest_qmp_eventwait(s->qts, "STOP");

-    global_qtest = to;
-    qmp_eventwait("RESUME");
+    qtest_qmp_eventwait(dest->qts, "RESUME");

     read_guest_mem(dest);

     g_source_destroy(source);
     g_source_unref(source);

-    qtest_quit(to);
     test_server_free(dest);
-    qtest_quit(from);
     test_server_free(s);
     g_free(uri);
-
-    global_qtest = global;
 }

 static void wait_for_rings_started(TestServer *s, size_t count)
@@ -752,7 +753,7 @@ static void test_reconnect_subprocess(void)

     g_thread_new("connect", connect_thread, s);
     cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    qtest_start(cmd);
+    s->qts = qtest_init(cmd);
     g_free(cmd);

     init_virtio_dev(s);
@@ -766,7 +767,6 @@ static void test_reconnect_subprocess(void)
     wait_for_fds(s);
     wait_for_rings_started(s, 2);

-    qtest_end();
     test_server_free(s);
     return;
 }
@@ -788,14 +788,13 @@ static void test_connect_fail_subprocess(void)
     s->test_fail = true;
     g_thread_new("connect", connect_thread, s);
     cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    qtest_start(cmd);
+    s->qts = qtest_init(cmd);
     g_free(cmd);

     init_virtio_dev(s);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);

-    qtest_end();
     test_server_free(s);
 }

@@ -816,14 +815,13 @@ static void test_flags_mismatch_subprocess(void)
     s->test_flags = TEST_FLAGS_DISCONNECT;
     g_thread_new("connect", connect_thread, s);
     cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    qtest_start(cmd);
+    s->qts = qtest_init(cmd);
     g_free(cmd);

     init_virtio_dev(s);
     wait_for_fds(s);
     wait_for_rings_started(s, 2);

-    qtest_end();
     test_server_free(s);
 }

@@ -888,13 +886,13 @@ static void test_multiqueue(void)
                           512, 512, root, s->chr_name,
                           s->socket_path, "", s->chr_name,
                           queues, queues * 2 + 2);
-    qtest_start(cmd);
+    s->qts = qtest_init(cmd);
     g_free(cmd);

-    bus = qpci_init_pc(global_qtest, NULL);
+    bus = qpci_init_pc(s->qts, NULL);
     dev = virtio_net_pci_init(bus, PCI_SLOT);

-    alloc = pc_alloc_init(global_qtest);
+    alloc = pc_alloc_init(s->qts);
     for (i = 0; i < queues * 2; i++) {
         vq[i] = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, i);
     }
@@ -911,14 +909,12 @@ static void test_multiqueue(void)
     g_free(dev->pdev);
     g_free(dev);
     qpci_free_pc(bus);
-    qtest_end();

     test_server_free(s);
 }

 int main(int argc, char **argv)
 {
-    QTestState *s = NULL;
     TestServer *server = NULL;
     const char *hugefs;
     char *qemu_cmd = NULL;
@@ -955,7 +951,7 @@ int main(int argc, char **argv)

     qemu_cmd = GET_QEMU_CMD(server);

-    s = qtest_start(qemu_cmd);
+    server->qts = qtest_init(qemu_cmd);
     g_free(qemu_cmd);
     init_virtio_dev(server);

@@ -976,10 +972,6 @@ int main(int argc, char **argv)

     ret = g_test_run();

-    if (s) {
-        qtest_quit(s);
-    }
-
     /* cleanup */
     test_server_free(server);

-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 21/29] qmp-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (19 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 20/29] vhost-user-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  7:11   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: " Eric Blake
                   ` (8 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Although qmp-test does not
maintain parallel qtest connections, it was the last test
assigning to global_qtest.  It's just as easy to be explicit
about the state; once all tests have been cleaned up, a later
patch can then get rid of global_qtest and a layer of wrappers
in libqtest.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/qmp-test.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index 5d0260b2be..cf523b325e 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -40,32 +40,32 @@ static void test_version(QObject *version)
     visit_free(v);
 }

-static void test_malformed(void)
+static void test_malformed(QTestState *qts)
 {
     QDict *resp;

     /* Not even a dictionary */
-    resp = qmp("null");
+    resp = qtest_qmp(qts, "null");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     QDECREF(resp);

     /* No "execute" key */
-    resp = qmp("{}");
+    resp = qtest_qmp(qts, "{}");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     QDECREF(resp);

     /* "execute" isn't a string */
-    resp = qmp("{ 'execute': true }");
+    resp = qtest_qmp(qts, "{ 'execute': true }");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     QDECREF(resp);

     /* "arguments" isn't a dictionary */
-    resp = qmp("{ 'execute': 'no-such-cmd', 'arguments': [] }");
+    resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'arguments': [] }");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     QDECREF(resp);

     /* extra key */
-    resp = qmp("{ 'execute': 'no-such-cmd', 'extra': true }");
+    resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'extra': true }");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     QDECREF(resp);
 }
@@ -74,11 +74,12 @@ static void test_qmp_protocol(void)
 {
     QDict *resp, *q, *ret;
     QList *capabilities;
+    QTestState *qts;

-    global_qtest = qtest_init_without_qmp_handshake(common_args);
+    qts = qtest_init_without_qmp_handshake(common_args);

     /* Test greeting */
-    resp = qmp_receive();
+    resp = qtest_qmp_receive(qts);
     q = qdict_get_qdict(resp, "QMP");
     g_assert(q);
     test_version(qdict_get(q, "version"));
@@ -87,46 +88,46 @@ static void test_qmp_protocol(void)
     QDECREF(resp);

     /* Test valid command before handshake */
-    resp = qmp("{ 'execute': 'query-version' }");
+    resp = qtest_qmp(qts, "{ 'execute': 'query-version' }");
     g_assert_cmpstr(get_error_class(resp), ==, "CommandNotFound");
     QDECREF(resp);

     /* Test malformed commands before handshake */
-    test_malformed();
+    test_malformed(qts);

     /* Test handshake */
-    resp = qmp("{ 'execute': 'qmp_capabilities' }");
+    resp = qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }");
     ret = qdict_get_qdict(resp, "return");
     g_assert(ret && !qdict_size(ret));
     QDECREF(resp);

     /* Test repeated handshake */
-    resp = qmp("{ 'execute': 'qmp_capabilities' }");
+    resp = qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }");
     g_assert_cmpstr(get_error_class(resp), ==, "CommandNotFound");
     QDECREF(resp);

     /* Test valid command */
-    resp = qmp("{ 'execute': 'query-version' }");
+    resp = qtest_qmp(qts, "{ 'execute': 'query-version' }");
     test_version(qdict_get(resp, "return"));
     QDECREF(resp);

     /* Test malformed commands */
-    test_malformed();
+    test_malformed(qts);

     /* Test 'id' */
-    resp = qmp("{ 'execute': 'query-name', 'id': 'cookie#1' }");
+    resp = qtest_qmp(qts, "{ 'execute': 'query-name', 'id': 'cookie#1' }");
     ret = qdict_get_qdict(resp, "return");
     g_assert(ret);
     g_assert_cmpstr(qdict_get_try_str(resp, "id"), ==, "cookie#1");
     QDECREF(resp);

     /* Test command failure with 'id' */
-    resp = qmp("{ 'execute': 'human-monitor-command', 'id': 2 }");
+    resp = qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2 }");
     g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
     g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
     QDECREF(resp);

-    qtest_end();
+    qtest_quit(qts);
 }

 int main(int argc, char *argv[])
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (20 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 21/29] qmp-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05  7:04   ` Thomas Huth
  2017-09-08 12:48   ` Michael S. Tsirkin
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: " Eric Blake
                   ` (7 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, Michael S. Tsirkin, Igor Mammedov, Ben Warren

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Adjust the helper code to
use explicit state instead, and update all callers.

Fix some trailing whitespace while touching the file.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/boot-sector.h      | 6 ++++--
 tests/bios-tables-test.c | 2 +-
 tests/boot-sector.c      | 8 ++++----
 tests/pxe-test.c         | 2 +-
 tests/vmgenid-test.c     | 2 +-
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/tests/boot-sector.h b/tests/boot-sector.h
index 35d61c7e2b..6ee6bb4d97 100644
--- a/tests/boot-sector.h
+++ b/tests/boot-sector.h
@@ -5,7 +5,7 @@
  *
  * Authors:
  *  Michael S. Tsirkin <mst@redhat.com>
- *  Victor Kaplansky <victork@redhat.com>    
+ *  Victor Kaplansky <victork@redhat.com>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -14,11 +14,13 @@
 #ifndef TEST_BOOT_SECTOR_H
 #define TEST_BOOT_SECTOR_H

+#include "libqtest.h"
+
 /* Create boot disk file. fname must be a suitable string for mkstemp() */
 int boot_sector_init(char *fname);

 /* Loop until signature in memory is OK.  */
-void boot_sector_test(void);
+void boot_sector_test(QTestState *qts);

 /* unlink boot disk file.  */
 void boot_sector_cleanup(const char *fname);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 564da45f65..bde62bf1cf 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -632,7 +632,7 @@ static void test_acpi_one(const char *params, test_data *data)

     qtest_start(args);

-    boot_sector_test();
+    boot_sector_test(global_qtest);

     test_acpi_rsdp_address(data);
     test_acpi_rsdp_table(data);
diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index 9ee85370b0..8c8ac7f124 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -5,7 +5,7 @@
  *
  * Authors:
  *  Michael S. Tsirkin <mst@redhat.com>
- *  Victor Kaplansky <victork@redhat.com>    
+ *  Victor Kaplansky <victork@redhat.com>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -130,7 +130,7 @@ int boot_sector_init(char *fname)
 }

 /* Loop until signature in memory is OK.  */
-void boot_sector_test(void)
+void boot_sector_test(QTestState *qts)
 {
     uint8_t signature_low;
     uint8_t signature_high;
@@ -146,8 +146,8 @@ void boot_sector_test(void)
      * instruction.
      */
     for (i = 0; i < TEST_CYCLES; ++i) {
-        signature_low = readb(SIGNATURE_ADDR);
-        signature_high = readb(SIGNATURE_ADDR + 1);
+        signature_low = qtest_readb(qts, SIGNATURE_ADDR);
+        signature_high = qtest_readb(qts, SIGNATURE_ADDR + 1);
         signature = (signature_high << 8) | signature_low;
         if (signature == SIGNATURE) {
             break;
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index 0d70afccd6..e2d3853534 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -31,7 +31,7 @@ static void test_pxe_one(const char *params, bool ipv6)
                            ipv6 ? "on" : "off", params);

     qtest_start(args);
-    boot_sector_test();
+    boot_sector_test(global_qtest);
     qtest_quit(global_qtest);
     g_free(args);
 }
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index 3d5c1c3615..4bdc8a15e7 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -47,7 +47,7 @@ static uint32_t acpi_find_vgia(void)
     int i;

     /* Wait for guest firmware to finish and start the payload. */
-    boot_sector_test();
+    boot_sector_test(global_qtest);

     /* Tables should be initialized now. */
     rsdp_offset = acpi_find_rsdp_address();
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (21 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:57   ` Thomas Huth
  2017-09-08 12:48   ` Michael S. Tsirkin
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 24/29] bios-tables-test: " Eric Blake
                   ` (6 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, Michael S. Tsirkin, Igor Mammedov, Ben Warren

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Adjust the helper code to
use explicit state instead, and update all callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/acpi-utils.h       |  65 +++++++++----------
 tests/acpi-utils.c       |  19 +++---
 tests/bios-tables-test.c | 161 ++++++++++++++++++++++++-----------------------
 tests/vmgenid-test.c     |  18 +++---
 4 files changed, 133 insertions(+), 130 deletions(-)

diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index f8d87236c6..8ec83f71b1 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -28,20 +28,20 @@ typedef struct {
     bool tmp_files_retain;   /* do not delete the temp asl/aml */
 } AcpiSdtTable;

-#define ACPI_READ_FIELD(field, addr)           \
+#define ACPI_READ_FIELD(qts, field, addr)      \
     do {                                       \
         switch (sizeof(field)) {               \
         case 1:                                \
-            field = readb(addr);               \
+            field = qtest_readb(qts, addr);    \
             break;                             \
         case 2:                                \
-            field = readw(addr);               \
+            field = qtest_readw(qts, addr);    \
             break;                             \
         case 4:                                \
-            field = readl(addr);               \
+            field = qtest_readl(qts, addr);    \
             break;                             \
         case 8:                                \
-            field = readq(addr);               \
+            field = qtest_readq(qts, addr);    \
             break;                             \
         default:                               \
             g_assert(false);                   \
@@ -49,28 +49,28 @@ typedef struct {
         addr += sizeof(field);                  \
     } while (0);

-#define ACPI_READ_ARRAY_PTR(arr, length, addr)  \
-    do {                                        \
-        int idx;                                \
-        for (idx = 0; idx < length; ++idx) {    \
-            ACPI_READ_FIELD(arr[idx], addr);    \
-        }                                       \
+#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr)      \
+    do {                                                 \
+        int idx;                                         \
+        for (idx = 0; idx < length; ++idx) {             \
+            ACPI_READ_FIELD(qts, arr[idx], addr);        \
+        }                                                \
     } while (0);

-#define ACPI_READ_ARRAY(arr, addr)                               \
-    ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr)
+#define ACPI_READ_ARRAY(qts, arr, addr)                                 \
+    ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr)

-#define ACPI_READ_TABLE_HEADER(table, addr)                      \
+#define ACPI_READ_TABLE_HEADER(qts, table, addr)                 \
     do {                                                         \
-        ACPI_READ_FIELD((table)->signature, addr);               \
-        ACPI_READ_FIELD((table)->length, addr);                  \
-        ACPI_READ_FIELD((table)->revision, addr);                \
-        ACPI_READ_FIELD((table)->checksum, addr);                \
-        ACPI_READ_ARRAY((table)->oem_id, addr);                  \
-        ACPI_READ_ARRAY((table)->oem_table_id, addr);            \
-        ACPI_READ_FIELD((table)->oem_revision, addr);            \
-        ACPI_READ_ARRAY((table)->asl_compiler_id, addr);         \
-        ACPI_READ_FIELD((table)->asl_compiler_revision, addr);   \
+        ACPI_READ_FIELD(qts, (table)->signature, addr);          \
+        ACPI_READ_FIELD(qts, (table)->length, addr);             \
+        ACPI_READ_FIELD(qts, (table)->revision, addr);           \
+        ACPI_READ_FIELD(qts, (table)->checksum, addr);           \
+        ACPI_READ_ARRAY(qts, (table)->oem_id, addr);             \
+        ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr);       \
+        ACPI_READ_FIELD(qts, (table)->oem_revision, addr);       \
+        ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr);    \
+        ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr);     \
     } while (0);

 #define ACPI_ASSERT_CMP(actual, expected) do { \
@@ -87,18 +87,19 @@ typedef struct {
     g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
 } while (0)

-#define ACPI_READ_GENERIC_ADDRESS(field, addr)       \
-    do {                                             \
-        ACPI_READ_FIELD((field).space_id, addr);     \
-        ACPI_READ_FIELD((field).bit_width, addr);    \
-        ACPI_READ_FIELD((field).bit_offset, addr);   \
-        ACPI_READ_FIELD((field).access_width, addr); \
-        ACPI_READ_FIELD((field).address, addr);      \
+#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr)       \
+    do {                                                  \
+        ACPI_READ_FIELD(qts, (field).space_id, addr);     \
+        ACPI_READ_FIELD(qts, (field).bit_width, addr);    \
+        ACPI_READ_FIELD(qts, (field).bit_offset, addr);   \
+        ACPI_READ_FIELD(qts, (field).access_width, addr); \
+        ACPI_READ_FIELD(qts, (field).address, addr);      \
     } while (0);


 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
-uint32_t acpi_find_rsdp_address(void);
-void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table);
+uint32_t acpi_find_rsdp_address(QTestState *qts);
+void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
+                           AcpiRsdpDescriptor *rsdp_table);

 #endif  /* TEST_ACPI_UTILS_H */
diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
index 41dc1ea9b4..6dc8ca1a8c 100644
--- a/tests/acpi-utils.c
+++ b/tests/acpi-utils.c
@@ -32,7 +32,7 @@ uint8_t acpi_calc_checksum(const uint8_t *data, int len)
     return sum;
 }

-uint32_t acpi_find_rsdp_address(void)
+uint32_t acpi_find_rsdp_address(QTestState *qts)
 {
     uint32_t off;

@@ -42,7 +42,7 @@ uint32_t acpi_find_rsdp_address(void)
         int i;

         for (i = 0; i < sizeof sig - 1; ++i) {
-            sig[i] = readb(off + i);
+            sig[i] = qtest_readb(qts, off + i);
         }

         if (!memcmp(sig, "RSD PTR ", sizeof sig)) {
@@ -52,14 +52,15 @@ uint32_t acpi_find_rsdp_address(void)
     return off;
 }

-void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table)
+void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
+                           AcpiRsdpDescriptor *rsdp_table)
 {
-    ACPI_READ_FIELD(rsdp_table->signature, addr);
+    ACPI_READ_FIELD(qts, rsdp_table->signature, addr);
     ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR ");

-    ACPI_READ_FIELD(rsdp_table->checksum, addr);
-    ACPI_READ_ARRAY(rsdp_table->oem_id, addr);
-    ACPI_READ_FIELD(rsdp_table->revision, addr);
-    ACPI_READ_FIELD(rsdp_table->rsdt_physical_address, addr);
-    ACPI_READ_FIELD(rsdp_table->length, addr);
+    ACPI_READ_FIELD(qts, rsdp_table->checksum, addr);
+    ACPI_READ_ARRAY(qts, rsdp_table->oem_id, addr);
+    ACPI_READ_FIELD(qts, rsdp_table->revision, addr);
+    ACPI_READ_FIELD(qts, rsdp_table->rsdt_physical_address, addr);
+    ACPI_READ_FIELD(qts, rsdp_table->length, addr);
 }
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index bde62bf1cf..75b29df493 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -77,7 +77,7 @@ static void free_test_data(test_data *data)

 static void test_acpi_rsdp_address(test_data *data)
 {
-    uint32_t off = acpi_find_rsdp_address();
+    uint32_t off = acpi_find_rsdp_address(global_qtest);
     g_assert_cmphex(off, <, 0x100000);
     data->rsdp_addr = off;
 }
@@ -87,7 +87,7 @@ static void test_acpi_rsdp_table(test_data *data)
     AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
     uint32_t addr = data->rsdp_addr;

-    acpi_parse_rsdp_table(addr, rsdp_table);
+    acpi_parse_rsdp_table(global_qtest, addr, rsdp_table);

     /* rsdp checksum is not for the whole table, but for the first 20 bytes */
     g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
@@ -102,7 +102,7 @@ static void test_acpi_rsdt_table(test_data *data)
     uint8_t checksum;

     /* read the header */
-    ACPI_READ_TABLE_HEADER(rsdt_table, addr);
+    ACPI_READ_TABLE_HEADER(global_qtest, rsdt_table, addr);
     ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");

     /* compute the table entries in rsdt */
@@ -112,7 +112,7 @@ static void test_acpi_rsdt_table(test_data *data)

     /* get the addresses of the tables pointed by rsdt */
     tables = g_new0(uint32_t, tables_nr);
-    ACPI_READ_ARRAY_PTR(tables, tables_nr, addr);
+    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, addr);

     checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
                acpi_calc_checksum((uint8_t *)tables,
@@ -128,63 +128,64 @@ static void test_acpi_fadt_table(test_data *data)
 {
     AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
     uint32_t addr;
+    QTestState *qts = global_qtest;

     /* FADT table comes first */
     addr = data->rsdt_tables_addr[0];
-    ACPI_READ_TABLE_HEADER(fadt_table, addr);
+    ACPI_READ_TABLE_HEADER(qts, fadt_table, addr);

-    ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
-    ACPI_READ_FIELD(fadt_table->dsdt, addr);
-    ACPI_READ_FIELD(fadt_table->model, addr);
-    ACPI_READ_FIELD(fadt_table->reserved1, addr);
-    ACPI_READ_FIELD(fadt_table->sci_int, addr);
-    ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
-    ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
-    ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
-    ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
-    ACPI_READ_FIELD(fadt_table->reserved2, addr);
-    ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
-    ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
-    ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
-    ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
-    ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
-    ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
-    ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
-    ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
-    ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
-    ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
-    ACPI_READ_FIELD(fadt_table->reserved3, addr);
-    ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
-    ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
-    ACPI_READ_FIELD(fadt_table->flush_size, addr);
-    ACPI_READ_FIELD(fadt_table->flush_stride, addr);
-    ACPI_READ_FIELD(fadt_table->duty_offset, addr);
-    ACPI_READ_FIELD(fadt_table->duty_width, addr);
-    ACPI_READ_FIELD(fadt_table->day_alrm, addr);
-    ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
-    ACPI_READ_FIELD(fadt_table->century, addr);
-    ACPI_READ_FIELD(fadt_table->boot_flags, addr);
-    ACPI_READ_FIELD(fadt_table->reserved, addr);
-    ACPI_READ_FIELD(fadt_table->flags, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr);
-    ACPI_READ_FIELD(fadt_table->reset_value, addr);
-    ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr);
-    ACPI_READ_FIELD(fadt_table->minor_revision, addr);
-    ACPI_READ_FIELD(fadt_table->x_facs, addr);
-    ACPI_READ_FIELD(fadt_table->x_dsdt, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr);
-    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr);
+    ACPI_READ_FIELD(qts, fadt_table->firmware_ctrl, addr);
+    ACPI_READ_FIELD(qts, fadt_table->dsdt, addr);
+    ACPI_READ_FIELD(qts, fadt_table->model, addr);
+    ACPI_READ_FIELD(qts, fadt_table->reserved1, addr);
+    ACPI_READ_FIELD(qts, fadt_table->sci_int, addr);
+    ACPI_READ_FIELD(qts, fadt_table->smi_cmd, addr);
+    ACPI_READ_FIELD(qts, fadt_table->acpi_enable, addr);
+    ACPI_READ_FIELD(qts, fadt_table->acpi_disable, addr);
+    ACPI_READ_FIELD(qts, fadt_table->S4bios_req, addr);
+    ACPI_READ_FIELD(qts, fadt_table->reserved2, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1a_evt_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1b_evt_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1a_cnt_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1b_cnt_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1_evt_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm1_cnt_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk_len, addr);
+    ACPI_READ_FIELD(qts, fadt_table->gpe1_base, addr);
+    ACPI_READ_FIELD(qts, fadt_table->reserved3, addr);
+    ACPI_READ_FIELD(qts, fadt_table->plvl2_lat, addr);
+    ACPI_READ_FIELD(qts, fadt_table->plvl3_lat, addr);
+    ACPI_READ_FIELD(qts, fadt_table->flush_size, addr);
+    ACPI_READ_FIELD(qts, fadt_table->flush_stride, addr);
+    ACPI_READ_FIELD(qts, fadt_table->duty_offset, addr);
+    ACPI_READ_FIELD(qts, fadt_table->duty_width, addr);
+    ACPI_READ_FIELD(qts, fadt_table->day_alrm, addr);
+    ACPI_READ_FIELD(qts, fadt_table->mon_alrm, addr);
+    ACPI_READ_FIELD(qts, fadt_table->century, addr);
+    ACPI_READ_FIELD(qts, fadt_table->boot_flags, addr);
+    ACPI_READ_FIELD(qts, fadt_table->reserved, addr);
+    ACPI_READ_FIELD(qts, fadt_table->flags, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->reset_register, addr);
+    ACPI_READ_FIELD(qts, fadt_table->reset_value, addr);
+    ACPI_READ_FIELD(qts, fadt_table->arm_boot_flags, addr);
+    ACPI_READ_FIELD(qts, fadt_table->minor_revision, addr);
+    ACPI_READ_FIELD(qts, fadt_table->x_facs, addr);
+    ACPI_READ_FIELD(qts, fadt_table->x_dsdt, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_event_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_event_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm2_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm_timer_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe0_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe1_block, addr);

     ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
     g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
@@ -195,13 +196,13 @@ static void test_acpi_facs_table(test_data *data)
     AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
     uint32_t addr = data->fadt_table.firmware_ctrl;

-    ACPI_READ_FIELD(facs_table->signature, addr);
-    ACPI_READ_FIELD(facs_table->length, addr);
-    ACPI_READ_FIELD(facs_table->hardware_signature, addr);
-    ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr);
-    ACPI_READ_FIELD(facs_table->global_lock, addr);
-    ACPI_READ_FIELD(facs_table->flags, addr);
-    ACPI_READ_ARRAY(facs_table->resverved3, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->signature, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->length, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->hardware_signature, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->firmware_waking_vector, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->global_lock, addr);
+    ACPI_READ_FIELD(global_qtest, facs_table->flags, addr);
+    ACPI_READ_ARRAY(global_qtest, facs_table->resverved3, addr);

     ACPI_ASSERT_CMP(facs_table->signature, "FACS");
 }
@@ -210,11 +211,11 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
 {
     uint8_t checksum;

-    ACPI_READ_TABLE_HEADER(&sdt_table->header, addr);
+    ACPI_READ_TABLE_HEADER(global_qtest, &sdt_table->header, addr);

     sdt_table->aml_len = sdt_table->header.length - sizeof(AcpiTableHeader);
     sdt_table->aml = g_malloc0(sdt_table->aml_len);
-    ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
+    ACPI_READ_ARRAY_PTR(global_qtest, sdt_table->aml, sdt_table->aml_len, addr);

     checksum = acpi_calc_checksum((uint8_t *)sdt_table,
                                   sizeof(AcpiTableHeader)) +
@@ -492,32 +493,32 @@ static bool smbios_ep_table_ok(test_data *data)
     struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
     uint32_t addr = data->smbios_ep_addr;

-    ACPI_READ_ARRAY(ep_table->anchor_string, addr);
+    ACPI_READ_ARRAY(global_qtest, ep_table->anchor_string, addr);
     if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
         return false;
     }
-    ACPI_READ_FIELD(ep_table->checksum, addr);
-    ACPI_READ_FIELD(ep_table->length, addr);
-    ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
-    ACPI_READ_FIELD(ep_table->smbios_minor_version, addr);
-    ACPI_READ_FIELD(ep_table->max_structure_size, addr);
-    ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
-    ACPI_READ_ARRAY(ep_table->formatted_area, addr);
-    ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->checksum, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->length, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->smbios_major_version, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->smbios_minor_version, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->max_structure_size, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->entry_point_revision, addr);
+    ACPI_READ_ARRAY(global_qtest, ep_table->formatted_area, addr);
+    ACPI_READ_ARRAY(global_qtest, ep_table->intermediate_anchor_string, addr);
     if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
         return false;
     }
-    ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
-    ACPI_READ_FIELD(ep_table->structure_table_length, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->intermediate_checksum, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_length, addr);
     if (ep_table->structure_table_length == 0) {
         return false;
     }
-    ACPI_READ_FIELD(ep_table->structure_table_address, addr);
-    ACPI_READ_FIELD(ep_table->number_of_structures, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_address, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->number_of_structures, addr);
     if (ep_table->number_of_structures == 0) {
         return false;
     }
-    ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
+    ACPI_READ_FIELD(global_qtest, ep_table->smbios_bcd_revision, addr);
     if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
         acpi_calc_checksum((uint8_t *)ep_table + 0x10,
                            sizeof *ep_table - 0x10)) {
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index 4bdc8a15e7..73473162d0 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -50,15 +50,15 @@ static uint32_t acpi_find_vgia(void)
     boot_sector_test(global_qtest);

     /* Tables should be initialized now. */
-    rsdp_offset = acpi_find_rsdp_address();
+    rsdp_offset = acpi_find_rsdp_address(global_qtest);

     g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);

-    acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
+    acpi_parse_rsdp_table(global_qtest, rsdp_offset, &rsdp_table);

     rsdt = rsdp_table.rsdt_physical_address;
     /* read the header */
-    ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
+    ACPI_READ_TABLE_HEADER(global_qtest, &rsdt_table, rsdt);
     ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");

     /* compute the table entries in rsdt */
@@ -68,21 +68,21 @@ static uint32_t acpi_find_vgia(void)

     /* get the addresses of the tables pointed by rsdt */
     tables = g_new0(uint32_t, tables_nr);
-    ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
+    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, rsdt);

     for (i = 0; i < tables_nr; i++) {
-        ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]);
+        ACPI_READ_TABLE_HEADER(global_qtest, &ssdt_table, tables[i]);
         if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
             /* the first entry in the table should be VGIA
              * That's all we need
              */
-            ACPI_READ_FIELD(vgid_table.name_op, tables[i]);
+            ACPI_READ_FIELD(global_qtest, vgid_table.name_op, tables[i]);
             g_assert(vgid_table.name_op == 0x08);  /* name */
-            ACPI_READ_ARRAY(vgid_table.vgia, tables[i]);
+            ACPI_READ_ARRAY(global_qtest, vgid_table.vgia, tables[i]);
             g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
-            ACPI_READ_FIELD(vgid_table.val_op, tables[i]);
+            ACPI_READ_FIELD(global_qtest, vgid_table.val_op, tables[i]);
             g_assert(vgid_table.val_op == 0x0C);  /* dword */
-            ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]);
+            ACPI_READ_FIELD(global_qtest, vgid_table.vgia_val, tables[i]);
             /* The GUID is written at a fixed offset into the fw_cfg file
              * in order to implement the "OVMF SDT Header probe suppressor"
              * see docs/specs/vmgenid.txt for more details
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 24/29] bios-tables-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (22 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 10:59   ` Thomas Huth
  2017-09-08 12:49   ` Michael S. Tsirkin
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: " Eric Blake
                   ` (5 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini, Michael S. Tsirkin, Igor Mammedov

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Although bios-tables-test does
not maintain parallel qtest connections, it's just as easy to be
explicit about the state; once all tests have been cleaned up, a
later patch can then get rid of global_qtest and a layer of
wrappers in libqtest.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/bios-tables-test.c | 78 +++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 75b29df493..976792f2c5 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -38,6 +38,7 @@ typedef struct {
     struct smbios_21_entry_point smbios_ep_table;
     uint8_t *required_struct_types;
     int required_struct_types_len;
+    QTestState *qts;
 } test_data;

 static char disk[] = "tests/acpi-test-disk-XXXXXX";
@@ -77,7 +78,7 @@ static void free_test_data(test_data *data)

 static void test_acpi_rsdp_address(test_data *data)
 {
-    uint32_t off = acpi_find_rsdp_address(global_qtest);
+    uint32_t off = acpi_find_rsdp_address(data->qts);
     g_assert_cmphex(off, <, 0x100000);
     data->rsdp_addr = off;
 }
@@ -87,7 +88,7 @@ static void test_acpi_rsdp_table(test_data *data)
     AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
     uint32_t addr = data->rsdp_addr;

-    acpi_parse_rsdp_table(global_qtest, addr, rsdp_table);
+    acpi_parse_rsdp_table(data->qts, addr, rsdp_table);

     /* rsdp checksum is not for the whole table, but for the first 20 bytes */
     g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
@@ -102,7 +103,7 @@ static void test_acpi_rsdt_table(test_data *data)
     uint8_t checksum;

     /* read the header */
-    ACPI_READ_TABLE_HEADER(global_qtest, rsdt_table, addr);
+    ACPI_READ_TABLE_HEADER(data->qts, rsdt_table, addr);
     ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");

     /* compute the table entries in rsdt */
@@ -112,7 +113,7 @@ static void test_acpi_rsdt_table(test_data *data)

     /* get the addresses of the tables pointed by rsdt */
     tables = g_new0(uint32_t, tables_nr);
-    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, addr);
+    ACPI_READ_ARRAY_PTR(data->qts, tables, tables_nr, addr);

     checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
                acpi_calc_checksum((uint8_t *)tables,
@@ -128,7 +129,7 @@ static void test_acpi_fadt_table(test_data *data)
 {
     AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
     uint32_t addr;
-    QTestState *qts = global_qtest;
+    QTestState *qts = data->qts;

     /* FADT table comes first */
     addr = data->rsdt_tables_addr[0];
@@ -196,26 +197,27 @@ static void test_acpi_facs_table(test_data *data)
     AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
     uint32_t addr = data->fadt_table.firmware_ctrl;

-    ACPI_READ_FIELD(global_qtest, facs_table->signature, addr);
-    ACPI_READ_FIELD(global_qtest, facs_table->length, addr);
-    ACPI_READ_FIELD(global_qtest, facs_table->hardware_signature, addr);
-    ACPI_READ_FIELD(global_qtest, facs_table->firmware_waking_vector, addr);
-    ACPI_READ_FIELD(global_qtest, facs_table->global_lock, addr);
-    ACPI_READ_FIELD(global_qtest, facs_table->flags, addr);
-    ACPI_READ_ARRAY(global_qtest, facs_table->resverved3, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->signature, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->length, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->hardware_signature, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->firmware_waking_vector, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->global_lock, addr);
+    ACPI_READ_FIELD(data->qts, facs_table->flags, addr);
+    ACPI_READ_ARRAY(data->qts, facs_table->resverved3, addr);

     ACPI_ASSERT_CMP(facs_table->signature, "FACS");
 }

-static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
+static void test_dst_table(test_data *data, AcpiSdtTable *sdt_table,
+                           uint32_t addr)
 {
     uint8_t checksum;

-    ACPI_READ_TABLE_HEADER(global_qtest, &sdt_table->header, addr);
+    ACPI_READ_TABLE_HEADER(data->qts, &sdt_table->header, addr);

     sdt_table->aml_len = sdt_table->header.length - sizeof(AcpiTableHeader);
     sdt_table->aml = g_malloc0(sdt_table->aml_len);
-    ACPI_READ_ARRAY_PTR(global_qtest, sdt_table->aml, sdt_table->aml_len, addr);
+    ACPI_READ_ARRAY_PTR(data->qts, sdt_table->aml, sdt_table->aml_len, addr);

     checksum = acpi_calc_checksum((uint8_t *)sdt_table,
                                   sizeof(AcpiTableHeader)) +
@@ -232,7 +234,7 @@ static void test_acpi_dsdt_table(test_data *data)
     memset(&dsdt_table, 0, sizeof(dsdt_table));
     data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));

-    test_dst_table(&dsdt_table, addr);
+    test_dst_table(data, &dsdt_table, addr);
     ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT");

     /* Place DSDT first */
@@ -249,7 +251,7 @@ static void test_acpi_tables(test_data *data)

         memset(&ssdt_table, 0, sizeof(ssdt_table));
         uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
-        test_dst_table(&ssdt_table, addr);
+        test_dst_table(data, &ssdt_table, addr);
         g_array_append_val(data->tables, ssdt_table);
     }
 }
@@ -493,32 +495,32 @@ static bool smbios_ep_table_ok(test_data *data)
     struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
     uint32_t addr = data->smbios_ep_addr;

-    ACPI_READ_ARRAY(global_qtest, ep_table->anchor_string, addr);
+    ACPI_READ_ARRAY(data->qts, ep_table->anchor_string, addr);
     if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
         return false;
     }
-    ACPI_READ_FIELD(global_qtest, ep_table->checksum, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->length, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->smbios_major_version, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->smbios_minor_version, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->max_structure_size, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->entry_point_revision, addr);
-    ACPI_READ_ARRAY(global_qtest, ep_table->formatted_area, addr);
-    ACPI_READ_ARRAY(global_qtest, ep_table->intermediate_anchor_string, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->checksum, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->length, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->smbios_major_version, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->smbios_minor_version, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->max_structure_size, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->entry_point_revision, addr);
+    ACPI_READ_ARRAY(data->qts, ep_table->formatted_area, addr);
+    ACPI_READ_ARRAY(data->qts, ep_table->intermediate_anchor_string, addr);
     if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
         return false;
     }
-    ACPI_READ_FIELD(global_qtest, ep_table->intermediate_checksum, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_length, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->intermediate_checksum, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->structure_table_length, addr);
     if (ep_table->structure_table_length == 0) {
         return false;
     }
-    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_address, addr);
-    ACPI_READ_FIELD(global_qtest, ep_table->number_of_structures, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->structure_table_address, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->number_of_structures, addr);
     if (ep_table->number_of_structures == 0) {
         return false;
     }
-    ACPI_READ_FIELD(global_qtest, ep_table->smbios_bcd_revision, addr);
+    ACPI_READ_FIELD(data->qts, ep_table->smbios_bcd_revision, addr);
     if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
         acpi_calc_checksum((uint8_t *)ep_table + 0x10,
                            sizeof *ep_table - 0x10)) {
@@ -537,7 +539,7 @@ static void test_smbios_entry_point(test_data *data)
         int i;

         for (i = 0; i < sizeof sig - 1; ++i) {
-            sig[i] = readb(off + i);
+            sig[i] = qtest_readb(data->qts, off + i);
         }

         if (!memcmp(sig, "_SM_", sizeof sig)) {
@@ -580,9 +582,9 @@ static void test_smbios_structs(test_data *data)
     for (i = 0; i < ep_table->number_of_structures; i++) {

         /* grab type and formatted area length from struct header */
-        type = readb(addr);
+        type = qtest_readb(data->qts, addr);
         g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
-        len = readb(addr + 1);
+        len = qtest_readb(data->qts, addr + 1);

         /* single-instance structs must not have been encountered before */
         if (smbios_single_instance(type)) {
@@ -594,7 +596,7 @@ static void test_smbios_structs(test_data *data)
         prv = crt = 1;
         while (prv || crt) {
             prv = crt;
-            crt = readb(addr + len);
+            crt = qtest_readb(data->qts, addr + len);
             len++;
         }

@@ -631,9 +633,9 @@ static void test_acpi_one(const char *params, test_data *data)
                            data->machine, "kvm:tcg",
                            params ? params : "", disk);

-    qtest_start(args);
+    data->qts = qtest_init(args);

-    boot_sector_test(global_qtest);
+    boot_sector_test(data->qts);

     test_acpi_rsdp_address(data);
     test_acpi_rsdp_table(data);
@@ -654,7 +656,7 @@ static void test_acpi_one(const char *params, test_data *data)
     test_smbios_entry_point(data);
     test_smbios_structs(data);

-    qtest_quit(global_qtest);
+    qtest_quit(data->qts);
     g_free(args);
 }

-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (23 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 24/29] bios-tables-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 11:01   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: " Eric Blake
                   ` (4 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Improve this test to be
explicit about the state.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/wdt_ib700-test.c | 63 +++++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 4fc8eeae86..4bb8374011 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -11,9 +11,9 @@
 #include "libqtest.h"
 #include "qemu/timer.h"

-static void qmp_check_no_event(void)
+static void qmp_check_no_event(QTestState *s)
 {
-    QDict *resp = qmp("{'execute':'query-status'}");
+    QDict *resp = qtest_qmp(s, "{'execute':'query-status'}");
     g_assert(qdict_haskey(resp, "return"));
     QDECREF(resp);
 }
@@ -22,30 +22,30 @@ static QDict *ib700_program_and_wait(QTestState *s)
 {
     QDict *event, *data;

-    clock_step(NANOSECONDS_PER_SECOND * 40);
-    qmp_check_no_event();
+    qtest_clock_step(s, NANOSECONDS_PER_SECOND * 40);
+    qmp_check_no_event(s);

     /* 2 second limit */
-    outb(0x443, 14);
+    qtest_outb(s, 0x443, 14);

     /* Ping */
-    clock_step(NANOSECONDS_PER_SECOND);
-    qmp_check_no_event();
-    outb(0x443, 14);
+    qtest_clock_step(s, NANOSECONDS_PER_SECOND);
+    qmp_check_no_event(s);
+    qtest_outb(s, 0x443, 14);

     /* Disable */
-    clock_step(NANOSECONDS_PER_SECOND);
-    qmp_check_no_event();
-    outb(0x441, 1);
-    clock_step(3 * NANOSECONDS_PER_SECOND);
-    qmp_check_no_event();
+    qtest_clock_step(s, NANOSECONDS_PER_SECOND);
+    qmp_check_no_event(s);
+    qtest_outb(s, 0x441, 1);
+    qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND);
+    qmp_check_no_event(s);

     /* Enable and let it fire */
-    outb(0x443, 13);
-    clock_step(3 * NANOSECONDS_PER_SECOND);
-    qmp_check_no_event();
-    clock_step(2 * NANOSECONDS_PER_SECOND);
-    event = qmp_eventwait_ref("WATCHDOG");
+    qtest_outb(s, 0x443, 13);
+    qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND);
+    qmp_check_no_event(s);
+    qtest_clock_step(s, 2 * NANOSECONDS_PER_SECOND);
+    event = qtest_qmp_eventwait_ref(s, "WATCHDOG");
     data = qdict_get_qdict(event, "data");
     QINCREF(data);
     QDECREF(event);
@@ -56,48 +56,53 @@ static QDict *ib700_program_and_wait(QTestState *s)
 static void ib700_pause(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action pause -device ib700");
+    QTestState *s = qtest_init("-watchdog-action pause -device ib700");
+
     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
     QDECREF(d);
-    qmp_eventwait("STOP");
-    qtest_end();
+    qtest_qmp_eventwait(s, "STOP");
+    qtest_quit(s);
 }

 static void ib700_reset(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action reset -device ib700");
+    QTestState *s = qtest_init("-watchdog-action reset -device ib700");
+
     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
-    qmp_eventwait("RESET");
-    qtest_end();
+    qtest_qmp_eventwait(s, "RESET");
+    qtest_quit(s);
 }

 static void ib700_shutdown(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action reset -no-reboot -device ib700");
+    QTestState *s;
+
+    s = qtest_init("-watchdog-action reset -no-reboot -device ib700");
     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
     QDECREF(d);
-    qmp_eventwait("SHUTDOWN");
-    qtest_end();
+    qtest_qmp_eventwait(s, "SHUTDOWN");
+    qtest_quit(s);
 }

 static void ib700_none(void)
 {
     QDict *d;
-    QTestState *s = qtest_start("-watchdog-action none -device ib700");
+    QTestState *s = qtest_init("-watchdog-action none -device ib700");
+
     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "none"));
     QDECREF(d);
-    qtest_end();
+    qtest_quit(s);
 }

 int main(int argc, char **argv)
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (24 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-02  0:07   ` Philippe Mathieu-Daudé
  2017-09-05 11:05   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string Eric Blake
                   ` (3 subsequent siblings)
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  It turns out that with the
recent changes to libqos, fw_cfg-test was not even using
global_qtest any more.  Avoid a pointless strdup while at it.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/fw_cfg-test.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 47596c57a1..3a8dc7a2cd 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
 int main(int argc, char **argv)
 {
     QTestState *s;
-    char *cmdline;
     int ret;

     g_test_init(&argc, &argv, NULL);

-    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
-    s = qtest_start(cmdline);
-    g_free(cmdline);
+    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");

     fw_cfg = pc_fw_cfg_init(s);

-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (25 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: " Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-05 12:46   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts Eric Blake
                   ` (2 subsequent siblings)
  29 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini, Michael S. Tsirkin, Igor Mammedov

Several callers were formatting a string into a temporary
variable before calling qtest_init(); factor that into the
common code.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.h         |  7 ++++---
 tests/libqtest.c         | 13 ++++++++++--
 tests/bios-tables-test.c |  7 +------
 tests/postcopy-test.c    |  4 ++--
 tests/vhost-user-test.c  | 51 ++++++++++++++----------------------------------
 5 files changed, 33 insertions(+), 49 deletions(-)

diff --git a/tests/libqtest.h b/tests/libqtest.h
index 3ae570927a..d338de3e22 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -25,11 +25,12 @@ extern QTestState *global_qtest;

 /**
  * qtest_init:
- * @extra_args: other arguments to pass to QEMU.
+ * @extra_args...: other arguments to pass to QEMU, formatted as if by
+ * sprintf().
  *
  * Returns: #QTestState instance.
  */
-QTestState *qtest_init(const char *extra_args);
+QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);

 /**
  * qtest_init_without_qmp_handshake:
@@ -518,7 +519,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);
  */
 static inline QTestState *qtest_start(const char *args)
 {
-    global_qtest = qtest_init(args);
+    global_qtest = qtest_init("%s", args);
     return global_qtest;
 }

diff --git a/tests/libqtest.c b/tests/libqtest.c
index b6dd26e54a..18facbf130 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -347,9 +347,18 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     return s;
 }

-QTestState *qtest_init(const char *extra_args)
+QTestState *qtest_init(const char *extra_args, ...)
 {
-    QTestState *s = qtest_init_without_qmp_handshake(extra_args);
+    va_list ap;
+    QTestState *s;
+    char *cmd;
+
+    va_start(ap, extra_args);
+    cmd = g_strdup_vprintf(extra_args, ap);
+    va_end(ap);
+
+    s = qtest_init_without_qmp_handshake(cmd);
+    g_free(cmd);

     /* Read the QMP greeting and then do the handshake */
     qtest_qmp_discard_response(s, "");
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 976792f2c5..f8a107499f 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -623,18 +623,14 @@ static void test_smbios_structs(test_data *data)

 static void test_acpi_one(const char *params, test_data *data)
 {
-    char *args;
-
     /* Disable kernel irqchip to be able to override apic irq0. */
-    args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+    data->qts = qtest_init("-machine %s,accel=%s,kernel-irqchip=off "
                            "-net none -display none %s "
                            "-drive id=hd0,if=none,file=%s,format=raw "
                            "-device ide-hd,drive=hd0 ",
                            data->machine, "kvm:tcg",
                            params ? params : "", disk);

-    data->qts = qtest_init(args);
-
     boot_sector_test(data->qts);

     test_acpi_rsdp_address(data);
@@ -657,7 +653,6 @@ static void test_acpi_one(const char *params, test_data *data)
     test_smbios_structs(data);

     qtest_quit(data->qts);
-    g_free(args);
 }

 static uint8_t base_required_struct_types[] = {
diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 0e5fe20a83..20cfb280f6 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -403,10 +403,10 @@ static void test_migrate(void)

     g_free(bootpath);

-    from = qtest_init(cmd_src);
+    from = qtest_init("%s", cmd_src);
     g_free(cmd_src);

-    to = qtest_init(cmd_dst);
+    to = qtest_init("%s", cmd_dst);
     g_free(cmd_dst);

     assert(!global_qtest);
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 1e0c50d12a..0dbed5a36a 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -482,12 +482,12 @@ static inline void test_server_connect(TestServer *server)
 }

 #define GET_QEMU_CMD(s)                                         \
-    g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name,  \
-                    (s)->socket_path, "", (s)->chr_name)
+    QEMU_CMD, 512, 512, (root), (s)->chr_name,                  \
+        (s)->socket_path, "", (s)->chr_name

 #define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...)                     \
-    g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \
-                    (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__)
+    QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name,                \
+        (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__

 static gboolean _test_server_free(TestServer *server)
 {
@@ -637,7 +637,6 @@ static void test_migrate(void)
     TestServer *dest = test_server_new("dest");
     char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
     GSource *source;
-    gchar *cmd;
     QDict *rsp;
     guint8 *log;
     guint64 size;
@@ -645,18 +644,14 @@ static void test_migrate(void)
     test_server_listen(s);
     test_server_listen(dest);

-    cmd = GET_QEMU_CMDE(s, 2, "", "");
-    s->qts = qtest_init(cmd);
-    g_free(cmd);
+    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, "", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));

-    cmd = GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri);
-    dest->qts = qtest_init(cmd);
-    g_free(cmd);
+    dest->qts = qtest_init(GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri));

     source = g_source_new(&test_migrate_source_funcs,
                           sizeof(TestMigrateSource));
@@ -749,12 +744,9 @@ connect_thread(gpointer data)
 static void test_reconnect_subprocess(void)
 {
     TestServer *s = test_server_new("reconnect");
-    char *cmd;

     g_thread_new("connect", connect_thread, s);
-    cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    s->qts = qtest_init(cmd);
-    g_free(cmd);
+    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -783,13 +775,10 @@ static void test_reconnect(void)
 static void test_connect_fail_subprocess(void)
 {
     TestServer *s = test_server_new("connect-fail");
-    char *cmd;

     s->test_fail = true;
     g_thread_new("connect", connect_thread, s);
-    cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    s->qts = qtest_init(cmd);
-    g_free(cmd);
+    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -810,13 +799,10 @@ static void test_connect_fail(void)
 static void test_flags_mismatch_subprocess(void)
 {
     TestServer *s = test_server_new("flags-mismatch");
-    char *cmd;

     s->test_flags = TEST_FLAGS_DISCONNECT;
     g_thread_new("connect", connect_thread, s);
-    cmd = GET_QEMU_CMDE(s, 2, ",server", "");
-    s->qts = qtest_init(cmd);
-    g_free(cmd);
+    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -875,19 +861,16 @@ static void test_multiqueue(void)
     QPCIBus *bus;
     QVirtQueuePCI *vq[queues * 2];
     QGuestAllocator *alloc;
-    char *cmd;
     int i;

     s->queues = queues;
     test_server_listen(s);

-    cmd = g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
-                          "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
-                          512, 512, root, s->chr_name,
-                          s->socket_path, "", s->chr_name,
-                          queues, queues * 2 + 2);
-    s->qts = qtest_init(cmd);
-    g_free(cmd);
+    s->qts = qtest_init(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
+                        "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
+                        512, 512, root, s->chr_name,
+                        s->socket_path, "", s->chr_name,
+                        queues, queues * 2 + 2);

     bus = qpci_init_pc(s->qts, NULL);
     dev = virtio_net_pci_init(bus, PCI_SLOT);
@@ -917,7 +900,6 @@ int main(int argc, char **argv)
 {
     TestServer *server = NULL;
     const char *hugefs;
-    char *qemu_cmd = NULL;
     int ret;
     char template[] = "/tmp/vhost-test-XXXXXX";
     GMainLoop *loop;
@@ -949,10 +931,7 @@ int main(int argc, char **argv)
     /* run the main loop thread so the chardev may operate */
     thread = g_thread_new(NULL, thread_function, loop);

-    qemu_cmd = GET_QEMU_CMD(server);
-
-    server->qts = qtest_init(qemu_cmd);
-    g_free(qemu_cmd);
+    server->qts = qtest_init(GET_QEMU_CMD(server));
     init_virtio_dev(server);

     qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (26 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 23:16   ` John Snow
  2017-09-05 13:06   ` Thomas Huth
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start() Eric Blake
  2017-09-01 18:31 ` [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups no-reply
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, Gerd Hoffmann, John Snow, Keith Busch,
	Thomas Huth, Andreas Färber, David Gibson, Alexander Graf,
	Dr. David Alan Gilbert, Michael S. Tsirkin, Stefan Hajnoczi,
	Amit Shah, Jason Wang, Ben Warren, open list:Floppy,
	open list:sPAPR

Remove the trivial wrappers qtest_start() and qtest_end(), to make
it obvious in the rest of the testsuite where we are still relying on
global_qtest.  Doing this makes it easier to see what remaining
cleanups will be needed if we don't want an implicit dependency
on global state.  Many tests can also take advantage of qtest_init()
doing formatting of args, avoiding a temporary local variable.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.h               | 26 ------------------
 tests/libqtest.c               |  4 +--
 tests/ac97-test.c              |  4 +--
 tests/boot-order-test.c        | 11 +++-----
 tests/boot-serial-test.c       | 12 +++------
 tests/device-introspect-test.c | 24 ++++++++---------
 tests/display-vga-test.c       | 18 +++++--------
 tests/drive_del-test.c         | 17 ++++++------
 tests/ds1338-test.c            |  2 +-
 tests/e1000-test.c             | 10 ++-----
 tests/e1000e-test.c            | 14 +++-------
 tests/eepro100-test.c          | 11 ++------
 tests/endianness-test.c        | 33 +++++++++--------------
 tests/es1370-test.c            |  4 +--
 tests/fdc-test.c               |  4 +--
 tests/hd-geo-test.c            | 16 +++++------
 tests/i440fx-test.c            | 16 +++++------
 tests/i82801b11-test.c         |  5 ++--
 tests/ide-test.c               |  4 +--
 tests/intel-hda-test.c         | 11 ++++----
 tests/ioh3420-test.c           |  7 ++---
 tests/ipmi-bt-test.c           | 11 +++-----
 tests/ipmi-kcs-test.c          |  5 +---
 tests/ipoctal232-test.c        |  5 ++--
 tests/ivshmem-test.c           |  4 +--
 tests/libqos/libqos.c          |  2 +-
 tests/m25p80-test.c            |  9 +++----
 tests/m48t59-test.c            |  2 +-
 tests/ne2000-test.c            |  4 +--
 tests/numa-test.c              | 28 ++++++++++----------
 tests/nvme-test.c              |  7 ++---
 tests/pc-cpu-test.c            | 26 +++++++-----------
 tests/pcnet-test.c             |  4 +--
 tests/pnv-xscom-test.c         | 14 ++--------
 tests/prom-env-test.c          | 13 ++++-----
 tests/pvpanic-test.c           |  4 +--
 tests/pxe-test.c               | 14 ++++------
 tests/q35-test.c               |  8 +++---
 tests/qom-test.c               |  7 ++---
 tests/rtc-test.c               |  2 +-
 tests/rtl8139-test.c           |  4 +--
 tests/spapr-phb-test.c         |  5 ++--
 tests/tco-test.c               | 12 ++++-----
 tests/test-arm-mptimer.c       |  4 +--
 tests/test-filter-mirror.c     | 16 +++++------
 tests/test-filter-redirector.c | 60 ++++++++++++++++++++----------------------
 tests/test-hmp.c               |  7 ++---
 tests/test-netfilter.c         |  9 +++----
 tests/test-x86-cpuid-compat.c  | 13 ++++-----
 tests/tmp105-test.c            |  2 +-
 tests/tpci200-test.c           |  4 +--
 tests/usb-hcd-ehci-test.c      | 25 +++++++++---------
 tests/usb-hcd-ohci-test.c      |  4 +--
 tests/usb-hcd-xhci-test.c      |  4 +--
 tests/virtio-balloon-test.c    |  4 +--
 tests/virtio-blk-test.c        | 13 ++++-----
 tests/virtio-console-test.c    |  8 +++---
 tests/virtio-net-test.c        |  4 +--
 tests/virtio-rng-test.c        |  4 +--
 tests/virtio-serial-test.c     |  4 +--
 tests/vmgenid-test.c           | 29 ++++++--------------
 tests/vmxnet3-test.c           |  4 +--
 62 files changed, 267 insertions(+), 394 deletions(-)

diff --git a/tests/libqtest.h b/tests/libqtest.h
index d338de3e22..0459526187 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -509,32 +509,6 @@ void qtest_add_data_func_full(const char *str, void *data,
 void qtest_add_abrt_handler(GHookFunc fn, const void *data);

 /**
- * qtest_start:
- * @args: other arguments to pass to QEMU
- *
- * Start QEMU and assign the resulting #QTestState to a global variable.
- * The global variable is used by "shortcut" functions documented below.
- *
- * Returns: #QTestState instance.
- */
-static inline QTestState *qtest_start(const char *args)
-{
-    global_qtest = qtest_init("%s", args);
-    return global_qtest;
-}
-
-/**
- * qtest_end:
- *
- * Shut down the QEMU process started by qtest_start().
- */
-static inline void qtest_end(void)
-{
-    qtest_quit(global_qtest);
-    global_qtest = NULL;
-}
-
-/**
  * qmp:
  * @fmt...: QMP message to send to qemu
  *
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 18facbf130..fa4e47c137 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -970,7 +970,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
     QString *qstr;
     const char *mname;

-    qtest_start("-machine none");
+    global_qtest = qtest_init("-machine none");
     response = qmp("{ 'execute': 'query-machines' }");
     g_assert(response);
     list = qdict_get_qlist(response, "return");
@@ -987,6 +987,6 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
         cb(mname);
     }

-    qtest_end();
+    qtest_quit(global_qtest);
     QDECREF(response);
 }
diff --git a/tests/ac97-test.c b/tests/ac97-test.c
index e0d177bd9c..6a1edaa85a 100644
--- a/tests/ac97-test.c
+++ b/tests/ac97-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ac97/nop", nop);

-    qtest_start("-device AC97");
+    global_qtest = qtest_init("-device AC97");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 5fc2ca8e9e..e6efea6852 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -28,14 +28,12 @@ static void test_a_boot_order(const char *machine,
                               uint64_t expected_boot,
                               uint64_t expected_reboot)
 {
-    char *args;
     uint64_t actual;

-    args = g_strdup_printf("-nodefaults%s%s %s",
-                           machine ? " -M " : "",
-                           machine ?: "",
-                           test_args);
-    qtest_start(args);
+    global_qtest = qtest_init("-nodefaults%s%s %s",
+                              machine ? " -M " : "",
+                              machine ?: "",
+                              test_args);
     actual = read_boot_order();
     g_assert_cmphex(actual, ==, expected_boot);
     qmp_discard_response("{ 'execute': 'system_reset' }");
@@ -47,7 +45,6 @@ static void test_a_boot_order(const char *machine,
     actual = read_boot_order();
     g_assert_cmphex(actual, ==, expected_reboot);
     qtest_quit(global_qtest);
-    g_free(args);
 }

 static void test_boot_orders(const char *machine,
diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index b95c5e74ea..d7c0c320d7 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -71,7 +71,6 @@ done:
 static void test_machine(const void *data)
 {
     const testdef_t *test = data;
-    char *args;
     char tmpname[] = "/tmp/qtest-boot-serial-XXXXXX";
     int fd;

@@ -82,18 +81,15 @@ static void test_machine(const void *data)
      * Make sure that this test uses tcg if available: It is used as a
      * fast-enough smoketest for that.
      */
-    args = g_strdup_printf("-M %s,accel=tcg:kvm "
-                           "-chardev file,id=serial0,path=%s "
-                           "-no-shutdown -serial chardev:serial0 %s",
-                           test->machine, tmpname, test->extra);
-
-    qtest_start(args);
+    global_qtest = qtest_init("-M %s,accel=tcg:kvm "
+                              "-chardev file,id=serial0,path=%s "
+                              "-no-shutdown -serial chardev:serial0 %s",
+                              test->machine, tmpname, test->extra);
     unlink(tmpname);

     check_guest_output(test, fd);
     qtest_quit(global_qtest);

-    g_free(args);
     close(fd);
 }

diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
index f7162c023f..1c23b71038 100644
--- a/tests/device-introspect-test.c
+++ b/tests/device-introspect-test.c
@@ -126,7 +126,7 @@ static void test_device_intro_list(void)
     QList *types;
     char *help;

-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);

     types = device_type_list(true);
     QDECREF(types);
@@ -134,7 +134,7 @@ static void test_device_intro_list(void)
     help = hmp("device_add help");
     g_free(help);

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 /*
@@ -167,7 +167,7 @@ static void test_qom_list_fields(void)
     QList *non_abstract;
     QListEntry *e;

-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);

     all_types = qom_list_types(NULL, true);
     non_abstract = qom_list_types(NULL, false);
@@ -189,21 +189,21 @@ static void test_qom_list_fields(void)

     QDECREF(all_types);
     QDECREF(non_abstract);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_device_intro_none(void)
 {
-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);
     test_one_device("nonexistent");
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_device_intro_abstract(void)
 {
-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);
     test_one_device("device");
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_device_intro_concrete(void)
@@ -212,7 +212,7 @@ static void test_device_intro_concrete(void)
     QListEntry *entry;
     const char *type;

-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);
     types = device_type_list(false);

     QLIST_FOREACH_ENTRY(types, entry) {
@@ -223,7 +223,7 @@ static void test_device_intro_concrete(void)
     }

     QDECREF(types);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_abstract_interfaces(void)
@@ -232,7 +232,7 @@ static void test_abstract_interfaces(void)
     QListEntry *e;
     QDict *index;

-    qtest_start(common_args);
+    global_qtest = qtest_init("%s", common_args);

     all_types = qom_list_types("interface", true);
     index = qom_type_index(all_types);
@@ -257,7 +257,7 @@ static void test_abstract_interfaces(void)

     QDECREF(all_types);
     QDECREF(index);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c
index 2d7d24eee0..51c6feaaf1 100644
--- a/tests/display-vga-test.c
+++ b/tests/display-vga-test.c
@@ -12,39 +12,33 @@

 static void pci_cirrus(void)
 {
-    qtest_start("-vga none -device cirrus-vga");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device cirrus-vga"));
 }

 static void pci_stdvga(void)
 {
-    qtest_start("-vga none -device VGA");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device VGA"));
 }

 static void pci_secondary(void)
 {
-    qtest_start("-vga none -device secondary-vga");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device secondary-vga"));
 }

 static void pci_multihead(void)
 {
-    qtest_start("-vga none -device VGA -device secondary-vga");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device VGA -device secondary-vga"));
 }

 static void pci_virtio_gpu(void)
 {
-    qtest_start("-vga none -device virtio-gpu-pci");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device virtio-gpu-pci"));
 }

 #ifdef CONFIG_VIRTIO_VGA
 static void pci_virtio_vga(void)
 {
-    qtest_start("-vga none -device virtio-vga");
-    qtest_end();
+    qtest_quit(qtest_init("-vga none -device virtio-vga"));
 }
 #endif

diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c
index 2175139abb..602ab062b4 100644
--- a/tests/drive_del-test.c
+++ b/tests/drive_del-test.c
@@ -45,7 +45,7 @@ static void device_del(void)
 static void test_drive_without_dev(void)
 {
     /* Start with an empty drive */
-    qtest_start("-drive if=none,id=drive0");
+    global_qtest = qtest_init("-drive if=none,id=drive0");

     /* Delete the drive */
     drive_del();
@@ -55,7 +55,7 @@ static void test_drive_without_dev(void)
      */
     drive_add();

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_after_failed_device_add(void)
@@ -63,7 +63,7 @@ static void test_after_failed_device_add(void)
     QDict *response;
     QDict *error;

-    qtest_start("-drive if=none,id=drive0");
+    global_qtest = qtest_init("-drive if=none,id=drive0");

     /* Make device_add fail.  If this leaks the virtio-blk-pci device then a
      * reference to drive0 will also be held (via qdev properties).
@@ -86,15 +86,16 @@ static void test_after_failed_device_add(void)
      */
     drive_add();

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_drive_del_device_del(void)
 {
     /* Start with a drive used by a device that unplugs instantaneously */
-    qtest_start("-drive if=none,id=drive0,file=null-co://,format=raw"
-                " -device virtio-scsi-pci"
-                " -device scsi-hd,drive=drive0,id=dev0");
+    global_qtest = qtest_init(
+        "-drive if=none,id=drive0,file=null-co://,format=raw"
+        " -device virtio-scsi-pci"
+        " -device scsi-hd,drive=drive0,id=dev0");

     /*
      * Delete the drive, and then the device
@@ -103,7 +104,7 @@ static void test_drive_del_device_del(void)
     drive_del();
     device_del();

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/ds1338-test.c b/tests/ds1338-test.c
index 26968bc82a..da5b852351 100644
--- a/tests/ds1338-test.c
+++ b/tests/ds1338-test.c
@@ -60,7 +60,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = qtest_start("-display none -machine imx25-pdk");
+    s = global_qtest = qtest_init("-display none -machine imx25-pdk");
     i2c = imx_i2c_create(IMX25_I2C_0_BASE);
     addr = DS1338_ADDR;

diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index 0c5fcdcc44..59bd8b781f 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -15,15 +15,9 @@ static void test_device(gconstpointer data)
 {
     const char *model = data;
     QTestState *s;
-    char *args;

-    args = g_strdup_printf("-device %s", model);
-    s = qtest_start(args);
-
-    if (s) {
-        qtest_quit(s);
-    }
-    g_free(args);
+    s = qtest_init("-device %s", model);
+    qtest_quit(s);
 }

 static const char *models[] = {
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 32aa738b72..6ef240dc8f 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -380,17 +380,11 @@ static void e1000e_device_clear(QPCIBus *bus, e1000e_device *d)

 static void data_test_init(e1000e_device *d)
 {
-    char *cmdline;
-
     int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, test_sockets);
     g_assert_cmpint(ret, != , -1);

-    cmdline = g_strdup_printf("-netdev socket,fd=%d,id=hs0 "
+    global_qtest = qtest_init("-netdev socket,fd=%d,id=hs0 "
                               "-device e1000e,netdev=hs0", test_sockets[1]);
-    g_assert_nonnull(cmdline);
-
-    qtest_start(cmdline);
-    g_free(cmdline);

     test_alloc = pc_alloc_init(global_qtest);
     g_assert_nonnull(test_alloc);
@@ -408,7 +402,7 @@ static void data_test_clear(e1000e_device *d)
     pc_alloc_uninit(test_alloc);
     g_free(d->pci_dev);
     qpci_free_pc(test_bus);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_e1000e_init(gconstpointer data)
@@ -458,12 +452,12 @@ static void test_e1000e_hotplug(gconstpointer data)
 {
     static const uint8_t slot = 0x06;

-    qtest_start("-device e1000e");
+    global_qtest = qtest_init("-device e1000e");

     qpci_plug_device_test("e1000e", "e1000e_net", slot, NULL);
     qpci_unplug_acpi_device_test("e1000e_net", slot);

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c
index bdc8a67d57..6f49ac2656 100644
--- a/tests/eepro100-test.c
+++ b/tests/eepro100-test.c
@@ -14,17 +14,10 @@ static void test_device(gconstpointer data)
 {
     const char *model = data;
     QTestState *s;
-    char *args;
-
-    args = g_strdup_printf("-device %s", model);
-    s = qtest_start(args);

     /* Tests only initialization so far. TODO: Implement functional tests */
-
-    if (s) {
-        qtest_quit(s);
-    }
-    g_free(args);
+    s = qtest_init("-device %s", model);
+    qtest_quit(s);
 }

 static const char *models[] = {
diff --git a/tests/endianness-test.c b/tests/endianness-test.c
index ed0bf52019..68d5dbcd14 100644
--- a/tests/endianness-test.c
+++ b/tests/endianness-test.c
@@ -114,13 +114,11 @@ static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value)
 static void test_endianness(gconstpointer data)
 {
     const TestCase *test = data;
-    char *args;

-    args = g_strdup_printf("-M %s%s%s -device pc-testdev",
-                           test->machine,
-                           test->superio ? " -device " : "",
-                           test->superio ?: "");
-    qtest_start(args);
+    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
+                              test->machine,
+                              test->superio ? " -device " : "",
+                              test->superio ?: "");
     isa_outl(test, 0xe0, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
@@ -183,19 +181,16 @@ static void test_endianness(gconstpointer data)
     g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
     g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
     qtest_quit(global_qtest);
-    g_free(args);
 }

 static void test_endianness_split(gconstpointer data)
 {
     const TestCase *test = data;
-    char *args;

-    args = g_strdup_printf("-M %s%s%s -device pc-testdev",
-                           test->machine,
-                           test->superio ? " -device " : "",
-                           test->superio ?: "");
-    qtest_start(args);
+    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
+                              test->machine,
+                              test->superio ? " -device " : "",
+                              test->superio ?: "");
     isa_outl(test, 0xe8, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
@@ -230,19 +225,16 @@ static void test_endianness_split(gconstpointer data)
     g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
     g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
     qtest_quit(global_qtest);
-    g_free(args);
 }

 static void test_endianness_combine(gconstpointer data)
 {
     const TestCase *test = data;
-    char *args;

-    args = g_strdup_printf("-M %s%s%s -device pc-testdev",
-                           test->machine,
-                           test->superio ? " -device " : "",
-                           test->superio ?: "");
-    qtest_start(args);
+    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
+                              test->machine,
+                              test->superio ? " -device " : "",
+                              test->superio ?: "");
     isa_outl(test, 0xe0, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
@@ -277,7 +269,6 @@ static void test_endianness_combine(gconstpointer data)
     g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
     g_assert_cmphex(isa_inw(test, 0xe8), ==, 0x4321);
     qtest_quit(global_qtest);
-    g_free(args);
 }

 int main(int argc, char **argv)
diff --git a/tests/es1370-test.c b/tests/es1370-test.c
index 199fe193ce..edeea13ae7 100644
--- a/tests/es1370-test.c
+++ b/tests/es1370-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/es1370/nop", nop);

-    qtest_start("-device ES1370");
+    global_qtest = qtest_init("-device ES1370");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 325712e0f2..893097f5a3 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -564,7 +564,7 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    qtest_start("-device floppy,id=floppy0");
+    global_qtest = qtest_init("-device floppy,id=floppy0");
     qtest_irq_intercept_in(global_qtest, "ioapic");
     qtest_add_func("/fdc/cmos", test_cmos);
     qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
@@ -583,7 +583,7 @@ int main(int argc, char **argv)
     ret = g_test_run();

     /* Cleanup */
-    qtest_end();
+    qtest_quit(global_qtest);
     unlink(test_image);

     return ret;
diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
index 24870b38f4..e0b19cdf17 100644
--- a/tests/hd-geo-test.c
+++ b/tests/hd-geo-test.c
@@ -241,11 +241,11 @@ static void test_ide_none(void)

     setup_common(argv, ARGV_SIZE);
     args = g_strjoinv(" ", argv);
-    qtest_start(args);
+    global_qtest = qtest_init("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_ide_mbr(bool use_device, MBRcontents mbr)
@@ -263,11 +263,11 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
         argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr, "");
     }
     args = g_strjoinv(" ", argv);
-    qtest_start(args);
+    global_qtest = qtest_init("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 /*
@@ -339,11 +339,11 @@ static void test_ide_drive_user(const char *dev, bool trans)
                      dev ? "" : opts);
     g_free(opts);
     args = g_strjoinv(" ", argv);
-    qtest_start(args);
+    global_qtest = qtest_init("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 /*
@@ -396,11 +396,11 @@ static void test_ide_drive_cd_0(void)
                          ide_idx, NULL, i, mbr_blank, "");
     }
     args = g_strjoinv(" ", argv);
-    qtest_start(args);
+    global_qtest = qtest_init("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index 4390e5591e..bfedd5d953 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -33,11 +33,7 @@ typedef struct FirmwareTestFixture {

 static QPCIBus *test_start_get_bus(const TestData *s)
 {
-    char *cmdline;
-
-    cmdline = g_strdup_printf("-smp %d", s->num_cpus);
-    qtest_start(cmdline);
-    g_free(cmdline);
+    global_qtest = qtest_init("-smp %d", s->num_cpus);
     return qpci_init_pc(global_qtest, NULL);
 }

@@ -136,7 +132,7 @@ static void test_i440fx_defaults(gconstpointer opaque)

     g_free(dev);
     qpci_free_pc(bus);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 #define PAM_RE 1
@@ -275,7 +271,7 @@ static void test_i440fx_pam(gconstpointer opaque)

     g_free(dev);
     qpci_free_pc(bus);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 #define BLOB_SIZE ((size_t)65536)
@@ -344,10 +340,10 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture,
                                          : "-drive if=pflash,format=raw,file=",
                               fw_pathname);
     g_test_message("qemu cmdline: %s", cmdline);
-    qtest_start(cmdline);
+    global_qtest = qtest_init("%s", cmdline);
     g_free(cmdline);

-    /* QEMU has loaded the firmware (because qtest_start() only returns after
+    /* QEMU has loaded the firmware (because qtest_init() only returns after
      * the QMP handshake completes). We must unlink the firmware blob right
      * here, because any assertion firing below would leak it in the
      * filesystem. This is also the reason why we recreate the blob every time
@@ -373,7 +369,7 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture,
     }

     g_free(buf);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void add_firmware_test(const char *testpath,
diff --git a/tests/i82801b11-test.c b/tests/i82801b11-test.c
index a6e31594c9..58436172b7 100644
--- a/tests/i82801b11-test.c
+++ b/tests/i82801b11-test.c
@@ -22,10 +22,11 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/i82801b11/nop", nop);

-    qtest_start("-machine q35 -device i82801b11-bridge,bus=pcie.0,addr=1e.0");
+    global_qtest = qtest_init("-machine q35 "
+                              "-device i82801b11-bridge,bus=pcie.0,addr=1e.0");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/ide-test.c b/tests/ide-test.c
index 084f6a5f96..b22a4fc1c5 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -124,7 +124,7 @@ static void ide_test_start(const char *cmdline_fmt, ...)
     cmdline = g_strdup_vprintf(cmdline_fmt, ap);
     va_end(ap);

-    qtest_start(cmdline);
+    global_qtest = qtest_init("%s", cmdline);
     guest_malloc = pc_alloc_init(global_qtest);

     g_free(cmdline);
@@ -134,7 +134,7 @@ static void ide_test_quit(void)
 {
     pc_alloc_uninit(guest_malloc);
     guest_malloc = NULL;
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, QPCIBar *ide_bar)
diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c
index b782b2e944..c10a59d932 100644
--- a/tests/intel-hda-test.c
+++ b/tests/intel-hda-test.c
@@ -18,15 +18,16 @@
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void ich6_test(void)
 {
-    qtest_start("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
-    qtest_end();
+    global_qtest = qtest_init("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
+    qtest_quit(global_qtest);
 }

 static void ich9_test(void)
 {
-    qtest_start("-machine q35 -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id="
-                HDA_ID CODEC_DEVICES);
-    qtest_end();
+    global_qtest = qtest_init(
+        "-machine q35 -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id="
+        HDA_ID CODEC_DEVICES);
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/ioh3420-test.c b/tests/ioh3420-test.c
index b54c4b9f11..cd5d062370 100644
--- a/tests/ioh3420-test.c
+++ b/tests/ioh3420-test.c
@@ -22,11 +22,12 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ioh3420/nop", nop);

-    qtest_start("-machine q35 -device ioh3420,bus=pcie.0,addr=1c.0,port=1,"
-                "chassis=1,multifunction=on");
+    global_qtest = qtest_init(
+        "-machine q35 -device ioh3420,bus=pcie.0,addr=1c.0,port=1,"
+        "chassis=1,multifunction=on");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
index 7e21a9bbcb..476d527cfd 100644
--- a/tests/ipmi-bt-test.c
+++ b/tests/ipmi-bt-test.c
@@ -401,7 +401,6 @@ static void open_socket(void)
 int main(int argc, char **argv)
 {
     const char *arch = qtest_get_arch();
-    char *cmdline;
     int ret;

     /* Check architecture */
@@ -415,12 +414,10 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    cmdline = g_strdup_printf(
-          " -chardev socket,id=ipmi0,host=localhost,port=%d,reconnect=10"
-          " -device ipmi-bmc-extern,chardev=ipmi0,id=bmc0"
-          " -device isa-ipmi-bt,bmc=bmc0", emu_port);
-    qtest_start(cmdline);
-    g_free(cmdline);
+    global_qtest = qtest_init(
+        " -chardev socket,id=ipmi0,host=localhost,port=%d,reconnect=10"
+        " -device ipmi-bmc-extern,chardev=ipmi0,id=bmc0"
+        " -device isa-ipmi-bt,bmc=bmc0", emu_port);
     qtest_irq_intercept_in(global_qtest, "ioapic");
     qtest_add_func("/ipmi/extern/connect", test_connect);
     qtest_add_func("/ipmi/extern/bt_base", test_bt_base);
diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c
index 178ffc1797..2bd3771e9f 100644
--- a/tests/ipmi-kcs-test.c
+++ b/tests/ipmi-kcs-test.c
@@ -264,7 +264,6 @@ static void test_enable_irq(void)
 int main(int argc, char **argv)
 {
     const char *arch = qtest_get_arch();
-    char *cmdline;
     int ret;

     /* Check architecture */
@@ -276,10 +275,8 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    cmdline = g_strdup_printf("-device ipmi-bmc-sim,id=bmc0"
+    global_qtest = qtest_init("-device ipmi-bmc-sim,id=bmc0"
                               " -device isa-ipmi-kcs,bmc=bmc0");
-    qtest_start(cmdline);
-    g_free(cmdline);
     qtest_irq_intercept_in(global_qtest, "ioapic");
     qtest_add_func("/ipmi/local/kcs_base", test_kcs_base);
     qtest_add_func("/ipmi/local/kcs_abort", test_kcs_abort);
diff --git a/tests/ipoctal232-test.c b/tests/ipoctal232-test.c
index 684914164d..5e1cae3917 100644
--- a/tests/ipoctal232-test.c
+++ b/tests/ipoctal232-test.c
@@ -22,10 +22,11 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ipoctal232/tpci200/nop", nop);

-    qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0");
+    global_qtest = qtest_init("-device tpci200,id=ipack0 "
+                              "-device ipoctal232,bus=ipack0.0");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index b9e0f573f6..f254f09487 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -407,7 +407,7 @@ static void test_ivshmem_hotplug(void)
     const char *arch = qtest_get_arch();
     gchar *opts;

-    qtest_start("");
+    global_qtest = qtest_init(" ");

     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);

@@ -416,7 +416,7 @@ static void test_ivshmem_hotplug(void)
         qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
     }

-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(opts);
 }

diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 24e8156fe2..bd9106a132 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -20,7 +20,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
     struct QOSState *qs = g_malloc(sizeof(QOSState));

     cmdline = g_strdup_vprintf(cmdline_fmt, ap);
-    qs->qts = qtest_start(cmdline);
+    qs->qts = global_qtest = qtest_init("%s", cmdline);
     qs->ops = ops;
     if (ops) {
         if (ops->init_allocator) {
diff --git a/tests/m25p80-test.c b/tests/m25p80-test.c
index 244aa33dd9..18135cfb86 100644
--- a/tests/m25p80-test.c
+++ b/tests/m25p80-test.c
@@ -354,7 +354,6 @@ int main(int argc, char **argv)
 {
     int ret;
     int fd;
-    char *args;

     g_test_init(&argc, &argv, NULL);

@@ -364,10 +363,9 @@ int main(int argc, char **argv)
     g_assert(ret == 0);
     close(fd);

-    args = g_strdup_printf("-m 256 -machine palmetto-bmc "
-                           "-drive file=%s,format=raw,if=mtd",
-                           tmp_path);
-    qtest_start(args);
+    global_qtest = qtest_init("-m 256 -machine palmetto-bmc "
+                              "-drive file=%s,format=raw,if=mtd",
+                              tmp_path);

     qtest_add_func("/m25p80/read_jedec", test_read_jedec);
     qtest_add_func("/m25p80/erase_sector", test_erase_sector);
@@ -380,6 +378,5 @@ int main(int argc, char **argv)

     qtest_quit(global_qtest);
     unlink(tmp_path);
-    g_free(args);
     return ret;
 }
diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c
index 0f921ef38a..52c61fe33e 100644
--- a/tests/m48t59-test.c
+++ b/tests/m48t59-test.c
@@ -246,7 +246,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = qtest_start("-rtc clock=vm");
+    s = global_qtest = qtest_init("-rtc clock=vm");

     qtest_add_func("/rtc/bcd/check-time", bcd_check_time);
     qtest_add_func("/rtc/fuzz-registers", fuzz_registers);
diff --git a/tests/ne2000-test.c b/tests/ne2000-test.c
index b7cf3dd2f5..d205bc91a6 100644
--- a/tests/ne2000-test.c
+++ b/tests/ne2000-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ne2000/pci/nop", pci_nop);

-    qtest_start("-device ne2k_pci");
+    global_qtest = qtest_init("-device ne2k_pci");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/numa-test.c b/tests/numa-test.c
index e1b6152244..17bbc0f5f8 100644
--- a/tests/numa-test.c
+++ b/tests/numa-test.c
@@ -25,14 +25,14 @@ static void test_mon_explicit(const void *data)
     cli = make_cli(data, "-smp 8 "
                    "-numa node,nodeid=0,cpus=0-3 "
                    "-numa node,nodeid=1,cpus=4-7 ");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
     g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
     g_free(s);

-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -42,14 +42,14 @@ static void test_mon_default(const void *data)
     char *cli;

     cli = make_cli(data, "-smp 8 -numa node -numa node");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
     g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
     g_free(s);

-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -61,14 +61,14 @@ static void test_mon_partial(const void *data)
     cli = make_cli(data, "-smp 8 "
                    "-numa node,nodeid=0,cpus=0-1 "
                    "-numa node,nodeid=1,cpus=4-5 ");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
     g_assert(strstr(s, "node 1 cpus: 4 5"));
     g_free(s);

-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -88,7 +88,7 @@ static void test_query_cpus(const void *data)
     QObject *e;

     cli = make_cli(data, "-smp 8 -numa node,cpus=0-3 -numa node,cpus=4-7");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -113,7 +113,7 @@ static void test_query_cpus(const void *data)
     }

     QDECREF(resp);
-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -130,7 +130,7 @@ static void pc_numa_cpu(const void *data)
         "-numa cpu,node-id=0,socket-id=1,core-id=0 "
         "-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
         "-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -166,7 +166,7 @@ static void pc_numa_cpu(const void *data)
     }

     QDECREF(resp);
-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -183,7 +183,7 @@ static void spapr_numa_cpu(const void *data)
         "-numa cpu,node-id=0,core-id=1 "
         "-numa cpu,node-id=0,core-id=2 "
         "-numa cpu,node-id=1,core-id=3");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -211,7 +211,7 @@ static void spapr_numa_cpu(const void *data)
     }

     QDECREF(resp);
-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

@@ -226,7 +226,7 @@ static void aarch64_numa_cpu(const void *data)
         "-numa node,nodeid=0 -numa node,nodeid=1 "
         "-numa cpu,node-id=1,thread-id=0 "
         "-numa cpu,node-id=0,thread-id=1");
-    qtest_start(cli);
+    global_qtest = qtest_init("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -254,7 +254,7 @@ static void aarch64_numa_cpu(const void *data)
     }

     QDECREF(resp);
-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(cli);
 }

diff --git a/tests/nvme-test.c b/tests/nvme-test.c
index 7674a446e4..382d26671f 100644
--- a/tests/nvme-test.c
+++ b/tests/nvme-test.c
@@ -22,11 +22,12 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/nvme/nop", nop);

-    qtest_start("-drive id=drv0,if=none,file=null-co://,format=raw "
-                "-device nvme,drive=drv0,serial=foo");
+    global_qtest = qtest_init(
+        "-drive id=drv0,if=none,file=null-co://,format=raw "
+        "-device nvme,drive=drv0,serial=foo");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index c4211a4e85..9c36051c07 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -26,15 +26,13 @@ typedef struct PCTestData PCTestData;
 static void test_pc_with_cpu_add(gconstpointer data)
 {
     const PCTestData *s = data;
-    char *args;
     QDict *response;
     unsigned int i;

-    args = g_strdup_printf("-machine %s -cpu %s "
-                           "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
-                           s->machine, s->cpu_model,
-                           s->sockets, s->cores, s->threads, s->maxcpus);
-    qtest_start(args);
+    global_qtest = qtest_init("-machine %s -cpu %s "
+                              "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+                              s->machine, s->cpu_model,
+                              s->sockets, s->cores, s->threads, s->maxcpus);

     for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
         response = qmp("{ 'execute': 'cpu-add',"
@@ -44,21 +42,18 @@ static void test_pc_with_cpu_add(gconstpointer data)
         QDECREF(response);
     }

-    qtest_end();
-    g_free(args);
+    qtest_quit(global_qtest);
 }

 static void test_pc_without_cpu_add(gconstpointer data)
 {
     const PCTestData *s = data;
-    char *args;
     QDict *response;

-    args = g_strdup_printf("-machine %s -cpu %s "
-                           "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
-                           s->machine, s->cpu_model,
-                           s->sockets, s->cores, s->threads, s->maxcpus);
-    qtest_start(args);
+    global_qtest = qtest_init("-machine %s -cpu %s "
+                              "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+                              s->machine, s->cpu_model,
+                              s->sockets, s->cores, s->threads, s->maxcpus);

     response = qmp("{ 'execute': 'cpu-add',"
                    "  'arguments': { 'id': %d } }",
@@ -67,8 +62,7 @@ static void test_pc_without_cpu_add(gconstpointer data)
     g_assert(qdict_haskey(response, "error"));
     QDECREF(response);

-    qtest_end();
-    g_free(args);
+    qtest_quit(global_qtest);
 }

 static void test_data_free(gpointer data)
diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c
index efb1ef44e9..23e36da805 100644
--- a/tests/pcnet-test.c
+++ b/tests/pcnet-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/pcnet/pci/nop", pci_nop);

-    qtest_start("-device pcnet");
+    global_qtest = qtest_init("-device pcnet");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c
index 5adc3fd3a9..852322b3f2 100644
--- a/tests/pnv-xscom-test.c
+++ b/tests/pnv-xscom-test.c
@@ -81,16 +81,11 @@ static void test_xscom_cfam_id(const PnvChip *chip)

 static void test_cfam_id(const void *data)
 {
-    char *args;
     const PnvChip *chip = data;

-    args = g_strdup_printf("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
-
-    qtest_start(args);
+    global_qtest = qtest_init("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
     test_xscom_cfam_id(chip);
     qtest_quit(global_qtest);
-
-    g_free(args);
 }

 #define PNV_XSCOM_EX_CORE_BASE(chip, i)                 \
@@ -109,16 +104,11 @@ static void test_xscom_core(const PnvChip *chip)

 static void test_core(const void *data)
 {
-    char *args;
     const PnvChip *chip = data;

-    args = g_strdup_printf("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
-
-    qtest_start(args);
+    global_qtest = qtest_init("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
     test_xscom_core(chip);
     qtest_quit(global_qtest);
-
-    g_free(args);
 }

 static void add_test(const char *name, void (*test)(const void *data))
diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c
index eac207b30e..fffef0b252 100644
--- a/tests/prom-env-test.c
+++ b/tests/prom-env-test.c
@@ -44,21 +44,18 @@ static void check_guest_memory(void)

 static void test_machine(const void *machine)
 {
-    char *args;
     const char *extra_args;

     /* The pseries firmware boots much faster without the default devices */
     extra_args = strcmp(machine, "pseries") == 0 ? "-nodefaults" : "";

-    args = g_strdup_printf("-M %s,accel=tcg %s -prom-env 'use-nvramrc?=true' "
-                           "-prom-env 'nvramrc=%x %x l!' ",
-                           (const char *)machine, extra_args, MAGIC, ADDRESS);
-
-    qtest_start(args);
+    global_qtest = qtest_init("-M %s,accel=tcg %s "
+                              "-prom-env 'use-nvramrc?=true' "
+                              "-prom-env 'nvramrc=%x %x l!' ",
+                              (const char *)machine, extra_args,
+                              MAGIC, ADDRESS);
     check_guest_memory();
     qtest_quit(global_qtest);
-
-    g_free(args);
 }

 static void add_tests(const char *machines[])
diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c
index 71ebb5c02c..48b71be26f 100644
--- a/tests/pvpanic-test.c
+++ b/tests/pvpanic-test.c
@@ -37,10 +37,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/pvpanic/panic", test_panic);

-    qtest_start("-device pvpanic");
+    global_qtest = qtest_init("-device pvpanic");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index e2d3853534..eaad88601a 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -23,17 +23,13 @@ static char disk[] = "tests/pxe-test-disk-XXXXXX";

 static void test_pxe_one(const char *params, bool ipv6)
 {
-    char *args;
-
-    args = g_strdup_printf("-machine accel=kvm:tcg -nodefaults -boot order=n "
-                           "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,"
-                           "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on",
-                           ipv6 ? "on" : "off", params);
-
-    qtest_start(args);
+    global_qtest = qtest_init("-machine accel=kvm:tcg -nodefaults "
+                              "-boot order=n "
+                              "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,"
+                              "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on",
+                              ipv6 ? "on" : "off", params);
     boot_sector_test(global_qtest);
     qtest_quit(global_qtest);
-    g_free(args);
 }

 static void test_pxe_e1000(void)
diff --git a/tests/q35-test.c b/tests/q35-test.c
index e149c4c51d..91a189ce62 100644
--- a/tests/q35-test.c
+++ b/tests/q35-test.c
@@ -84,7 +84,7 @@ static void test_smram_lock(void)
     QPCIDevice *pcidev;
     QDict *response;

-    qtest_start("-M q35");
+    global_qtest = qtest_init("-M q35");

     pcibus = qpci_init_pc(global_qtest, NULL);
     g_assert(pcibus != NULL);
@@ -119,7 +119,7 @@ static void test_smram_lock(void)
     g_free(pcidev);
     qpci_free_pc(pcibus);

-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_tseg_size(const void *data)
@@ -141,7 +141,7 @@ static void test_tseg_size(const void *data)
         cmdline = g_strdup_printf("-M q35 -m %uM",
                                   TSEG_SIZE_TEST_GUEST_RAM_MBYTES);
     }
-    qtest_start(cmdline);
+    global_qtest = qtest_init("%s", cmdline);
     g_free(cmdline);

     /* locate the DRAM controller */
@@ -185,7 +185,7 @@ static void test_tseg_size(const void *data)

     g_free(pcidev);
     qpci_free_pc(pcibus);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/qom-test.c b/tests/qom-test.c
index ab0595dc75..5edd735387 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -90,11 +90,9 @@ static void test_properties(const char *path, bool recurse)
 static void test_machine(gconstpointer data)
 {
     const char *machine = data;
-    char *args;
     QDict *response;

-    args = g_strdup_printf("-machine %s", machine);
-    qtest_start(args);
+    global_qtest = qtest_init("-machine %s", machine);

     test_properties("/machine", true);

@@ -102,8 +100,7 @@ static void test_machine(gconstpointer data)
     g_assert(qdict_haskey(response, "return"));
     QDECREF(response);

-    qtest_end();
-    g_free(args);
+    qtest_quit(global_qtest);
     g_free((void *)machine);
 }

diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index d7a96cbd79..b6058d28f5 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -690,7 +690,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = qtest_start("-rtc clock=vm");
+    s = global_qtest = qtest_init("-rtc clock=vm");
     qtest_irq_intercept_in(s, "ioapic");

     qtest_add_func("/rtc/check-time/bcd", bcd_check_time);
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index 68bfc42178..dc9935439f 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -197,7 +197,7 @@ int main(int argc, char **argv)
 {
     int ret;

-    qtest_start("-device rtl8139");
+    global_qtest = qtest_init("-device rtl8139");

     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/rtl8139/nop", nop);
@@ -205,7 +205,7 @@ int main(int argc, char **argv)

     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/spapr-phb-test.c b/tests/spapr-phb-test.c
index d3522ea093..0d26cbda6c 100644
--- a/tests/spapr-phb-test.c
+++ b/tests/spapr-phb-test.c
@@ -25,11 +25,12 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/spapr-phb/device", test_phb_device);

-    qtest_start("-device " TYPE_SPAPR_PCI_HOST_BRIDGE ",index=30");
+    global_qtest = qtest_init("-device " TYPE_SPAPR_PCI_HOST_BRIDGE
+                              ",index=30");

     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/tco-test.c b/tests/tco-test.c
index 0387971953..b2a4baeeef 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -49,20 +49,18 @@ static void test_end(TestData *d)
 {
     g_free(d->dev);
     qpci_free_pc(d->bus);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_init(TestData *d)
 {
     QTestState *qs;
-    char *s;

-    s = g_strdup_printf("-machine q35 %s %s",
-                        d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
-                        !d->args ? "" : d->args);
-    qs = qtest_start(s);
+    qs = qtest_init("-machine q35 %s %s",
+                    d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
+                    !d->args ? "" : d->args);
+    global_qtest = qs;
     qtest_irq_intercept_in(qs, "ioapic");
-    g_free(s);

     d->bus = qpci_init_pc(qs, NULL);
     d->dev = qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00));
diff --git a/tests/test-arm-mptimer.c b/tests/test-arm-mptimer.c
index cb8f2df914..a4bef2322a 100644
--- a/tests/test-arm-mptimer.c
+++ b/tests/test-arm-mptimer.c
@@ -1097,9 +1097,9 @@ tests_with_prescaler_arg:
         goto tests_with_prescaler_arg;
     }

-    qtest_start("-machine vexpress-a9");
+    global_qtest = qtest_init("-machine vexpress-a9");
     ret = g_test_run();
-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c
index d569d27657..9d8608a609 100644
--- a/tests/test-filter-mirror.c
+++ b/tests/test-filter-mirror.c
@@ -18,7 +18,6 @@
 static void test_mirror(void)
 {
     int send_sock[2], recv_sock;
-    char *cmdline;
     uint32_t ret = 0, len = 0;
     char send_buf[] = "Hello! filter-mirror~";
     char sock_path[] = "filter-mirror.XXXXXX";
@@ -37,13 +36,12 @@ static void test_mirror(void)
     ret = mkstemp(sock_path);
     g_assert_cmpint(ret, !=, -1);

-    cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
-                 "-device %s,netdev=qtest-bn0,id=qtest-e0 "
-                 "-chardev socket,id=mirror0,path=%s,server,nowait "
-                 "-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
-                 , send_sock[1], devstr, sock_path);
-    qtest_start(cmdline);
-    g_free(cmdline);
+    global_qtest = qtest_init(
+        "-netdev socket,id=qtest-bn0,fd=%d "
+        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-chardev socket,id=mirror0,path=%s,server,nowait "
+        "-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
+        , send_sock[1], devstr, sock_path);

     recv_sock = unix_connect(sock_path, NULL);
     g_assert_cmpint(recv_sock, !=, -1);
@@ -86,7 +84,7 @@ int main(int argc, char **argv)

     qtest_add_func("/netfilter/mirror", test_mirror);
     ret = g_test_run();
-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c
index 3afd41110d..b34f8ec2ad 100644
--- a/tests/test-filter-redirector.c
+++ b/tests/test-filter-redirector.c
@@ -70,7 +70,6 @@ static const char *get_devstr(void)
 static void test_redirector_tx(void)
 {
     int backend_sock[2], recv_sock;
-    char *cmdline;
     uint32_t ret = 0, len = 0;
     char send_buf[] = "Hello!!";
     char sock_path0[] = "filter-redirector0.XXXXXX";
@@ -87,20 +86,19 @@ static void test_redirector_tx(void)
     ret = mkstemp(sock_path1);
     g_assert_cmpint(ret, !=, -1);

-    cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
-                "-device %s,netdev=qtest-bn0,id=qtest-e0 "
-                "-chardev socket,id=redirector0,path=%s,server,nowait "
-                "-chardev socket,id=redirector1,path=%s,server,nowait "
-                "-chardev socket,id=redirector2,path=%s,nowait "
-                "-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
-                "queue=tx,outdev=redirector0 "
-                "-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
-                "queue=tx,indev=redirector2 "
-                "-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
-                "queue=tx,outdev=redirector1 ", backend_sock[1], get_devstr(),
-                sock_path0, sock_path1, sock_path0);
-    qtest_start(cmdline);
-    g_free(cmdline);
+    global_qtest = qtest_init(
+        "-netdev socket,id=qtest-bn0,fd=%d "
+        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-chardev socket,id=redirector0,path=%s,server,nowait "
+        "-chardev socket,id=redirector1,path=%s,server,nowait "
+        "-chardev socket,id=redirector2,path=%s,nowait "
+        "-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
+        "queue=tx,outdev=redirector0 "
+        "-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
+        "queue=tx,indev=redirector2 "
+        "-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
+        "queue=tx,outdev=redirector1 ", backend_sock[1], get_devstr(),
+        sock_path0, sock_path1, sock_path0);

     recv_sock = unix_connect(sock_path1, NULL);
     g_assert_cmpint(recv_sock, !=, -1);
@@ -135,13 +133,12 @@ static void test_redirector_tx(void)
     close(recv_sock);
     unlink(sock_path0);
     unlink(sock_path1);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void test_redirector_rx(void)
 {
     int backend_sock[2], send_sock;
-    char *cmdline;
     uint32_t ret = 0, len = 0;
     char send_buf[] = "Hello!!";
     char sock_path0[] = "filter-redirector0.XXXXXX";
@@ -158,20 +155,19 @@ static void test_redirector_rx(void)
     ret = mkstemp(sock_path1);
     g_assert_cmpint(ret, !=, -1);

-    cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
-                "-device %s,netdev=qtest-bn0,id=qtest-e0 "
-                "-chardev socket,id=redirector0,path=%s,server,nowait "
-                "-chardev socket,id=redirector1,path=%s,server,nowait "
-                "-chardev socket,id=redirector2,path=%s,nowait "
-                "-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
-                "queue=rx,indev=redirector0 "
-                "-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
-                "queue=rx,outdev=redirector2 "
-                "-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
-                "queue=rx,indev=redirector1 ", backend_sock[1], get_devstr(),
-                sock_path0, sock_path1, sock_path0);
-    qtest_start(cmdline);
-    g_free(cmdline);
+    global_qtest = qtest_init(
+        "-netdev socket,id=qtest-bn0,fd=%d "
+        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-chardev socket,id=redirector0,path=%s,server,nowait "
+        "-chardev socket,id=redirector1,path=%s,server,nowait "
+        "-chardev socket,id=redirector2,path=%s,nowait "
+        "-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
+        "queue=rx,indev=redirector0 "
+        "-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
+        "queue=rx,outdev=redirector2 "
+        "-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
+        "queue=rx,indev=redirector1 ", backend_sock[1], get_devstr(),
+        sock_path0, sock_path1, sock_path0);

     struct iovec iov[] = {
         {
@@ -204,7 +200,7 @@ static void test_redirector_rx(void)
     g_free(recv_buf);
     unlink(sock_path0);
     unlink(sock_path1);
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/test-hmp.c b/tests/test-hmp.c
index 729c0339f7..dd03693707 100644
--- a/tests/test-hmp.c
+++ b/tests/test-hmp.c
@@ -119,16 +119,13 @@ static void test_info_commands(void)
 static void test_machine(gconstpointer data)
 {
     const char *machine = data;
-    char *args;

-    args = g_strdup_printf("-S -M %s", machine);
-    qtest_start(args);
+    global_qtest = qtest_init("-S -M %s", machine);

     test_info_commands();
     test_commands();

-    qtest_end();
-    g_free(args);
+    qtest_quit(global_qtest);
     g_free((void *)data);
 }

diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c
index 2506473365..76caaedfc1 100644
--- a/tests/test-netfilter.c
+++ b/tests/test-netfilter.c
@@ -182,7 +182,6 @@ static void remove_netdev_with_multi_netfilter(void)
 int main(int argc, char **argv)
 {
     int ret;
-    char *args;
     const char *devstr = "e1000";

     if (g_str_equal(qtest_get_arch(), "s390x")) {
@@ -197,13 +196,11 @@ int main(int argc, char **argv)
     qtest_add_func("/netfilter/remove_netdev_multi",
                    remove_netdev_with_multi_netfilter);

-    args = g_strdup_printf("-netdev user,id=qtest-bn0 "
-                           "-device %s,netdev=qtest-bn0", devstr);
-    qtest_start(args);
+    global_qtest = qtest_init("-netdev user,id=qtest-bn0 "
+                              "-device %s,netdev=qtest-bn0", devstr);
     ret = g_test_run();

-    qtest_end();
-    g_free(args);
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 58a2dd9fe8..5b026ac38a 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -59,12 +59,12 @@ static void test_cpuid_prop(const void *data)
     QNum *value;
     int64_t val;

-    qtest_start(args->cmdline);
+    global_qtest = qtest_init("%s", args->cmdline);
     path = get_cpu0_qom_path();
     value = qobject_to_qnum(qom_get(path, args->property));
     g_assert(qnum_get_try_int(value, &val));
     g_assert_cmpint(val, ==, args->expected_value);
-    qtest_end();
+    qtest_quit(global_qtest);

     QDECREF(value);
     g_free(path);
@@ -131,13 +131,13 @@ static void test_feature_flag(const void *data)
     QList *present, *filtered;
     uint32_t value;

-    qtest_start(args->cmdline);
+    global_qtest = qtest_init("%s", args->cmdline);
     path = get_cpu0_qom_path();
     present = qobject_to_qlist(qom_get(path, "feature-words"));
     filtered = qobject_to_qlist(qom_get(path, "filtered-features"));
     value = get_feature_word(present, args->in_eax, args->in_ecx, args->reg);
     value |= get_feature_word(filtered, args->in_eax, args->in_ecx, args->reg);
-    qtest_end();
+    qtest_quit(global_qtest);

     g_assert(!!(value & (1U << args->bitnr)) == args->expected_value);

@@ -181,7 +181,8 @@ static void test_plus_minus_subprocess(void)
      * Note: rules 1 and 2 are planned to be removed soon, and
      * should generate a warning.
      */
-    qtest_start("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,cx8=off,+sse4_1,sse4_2=on");
+    global_qtest = qtest_init("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,"
+                              "cx8=off,+sse4_1,sse4_2=on");
     path = get_cpu0_qom_path();

     g_assert_false(qom_get_bool(path, "fpu"));
@@ -195,7 +196,7 @@ static void test_plus_minus_subprocess(void)
     g_assert_true(qom_get_bool(path, "sse4-2"));
     g_assert_true(qom_get_bool(path, "sse4.2"));

-    qtest_end();
+    qtest_quit(global_qtest);
     g_free(path);
 }

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index a7940a4639..3ef2efff6e 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -151,7 +151,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = qtest_start("-machine n800 "
+    s = global_qtest = qtest_init("-machine n800 "
                     "-device tmp105,bus=i2c-bus.0,id=" TMP105_TEST_ID
                     ",address=0x49");
     i2c = omap_i2c_create(OMAP2_I2C_1_BASE);
diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c
index 0321ec27ec..2ed378196d 100644
--- a/tests/tpci200-test.c
+++ b/tests/tpci200-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/tpci200/nop", nop);

-    qtest_start("-device tpci200");
+    global_qtest = qtest_init("-device tpci200");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index 55d4743a2a..55349a39a2 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -156,23 +156,24 @@ int main(int argc, char **argv)
     qtest_add_func("/ehci/pci/ehci-port-2", pci_ehci_port_2);
     qtest_add_func("/ehci/pci/ehci-port-3-hotplug", pci_ehci_port_hotplug);

-    qtest_start("-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
-                "multifunction=on,id=ich9-ehci-1 "
-                "-device ich9-usb-uhci1,bus=pcie.0,addr=1d.0,"
-                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=0 "
-                "-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
-                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
-                "-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
-                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
-                "-drive if=none,id=usbcdrom,media=cdrom "
-                "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
-                "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom ");
+    global_qtest = qtest_init(
+        "-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
+        "multifunction=on,id=ich9-ehci-1 "
+        "-device ich9-usb-uhci1,bus=pcie.0,addr=1d.0,"
+        "multifunction=on,masterbus=ich9-ehci-1.0,firstport=0 "
+        "-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
+        "multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
+        "-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
+        "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
+        "-drive if=none,id=usbcdrom,media=cdrom "
+        "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
+        "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom ");

     test_init();
     ret = g_test_run();
     test_deinit();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c
index 4758813d78..2763c9ec24 100644
--- a/tests/usb-hcd-ohci-test.c
+++ b/tests/usb-hcd-ohci-test.c
@@ -31,9 +31,9 @@ int main(int argc, char **argv)
     qtest_add_func("/ohci/pci/init", test_ohci_init);
     qtest_add_func("/ohci/pci/hotplug", test_ohci_hotplug);

-    qtest_start("-device pci-ohci,id=ohci");
+    global_qtest = qtest_init("-device pci-ohci,id=ohci");
     ret = g_test_run();
-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
index c05a339894..cc3fcd82fa 100644
--- a/tests/usb-hcd-xhci-test.c
+++ b/tests/usb-hcd-xhci-test.c
@@ -80,10 +80,10 @@ int main(int argc, char **argv)
     qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
     qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);

-    qtest_start("-device nec-usb-xhci,id=xhci"
+    global_qtest = qtest_init("-device nec-usb-xhci,id=xhci"
                 " -drive id=drive0,if=none,file=null-co://,format=raw");
     ret = g_test_run();
-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c
index 0d0046bf25..7304392c17 100644
--- a/tests/virtio-balloon-test.c
+++ b/tests/virtio-balloon-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/virtio/balloon/pci/nop", pci_nop);

-    qtest_start("-device virtio-balloon-pci");
+    global_qtest = qtest_init("-device virtio-balloon-pci");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 26d0a7e9af..063b0f4013 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -84,24 +84,21 @@ static QOSState *pci_test_start(void)

 static void arm_test_start(void)
 {
-    char *cmdline;
     char *tmp_path;

     tmp_path = drive_create();

-    cmdline = g_strdup_printf("-machine virt "
-                                "-drive if=none,id=drive0,file=%s,format=raw "
-                                "-device virtio-blk-device,drive=drive0",
-                                tmp_path);
-    qtest_start(cmdline);
+    global_qtest = qtest_init("-machine virt "
+                              "-drive if=none,id=drive0,file=%s,format=raw "
+                              "-device virtio-blk-device,drive=drive0",
+                              tmp_path);
     unlink(tmp_path);
     g_free(tmp_path);
-    g_free(cmdline);
 }

 static void test_end(void)
 {
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot)
diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c
index 1c3de072f4..73fb30b051 100644
--- a/tests/virtio-console-test.c
+++ b/tests/virtio-console-test.c
@@ -13,16 +13,16 @@
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void console_pci_nop(void)
 {
-    qtest_start("-device virtio-serial-pci,id=vser0 "
+    global_qtest = qtest_init("-device virtio-serial-pci,id=vser0 "
                 "-device virtconsole,bus=vser0.0");
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 static void serialport_pci_nop(void)
 {
-    qtest_start("-device virtio-serial-pci,id=vser0 "
+    global_qtest = qtest_init("-device virtio-serial-pci,id=vser0 "
                 "-device virtserialport,bus=vser0.0");
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 int main(int argc, char **argv)
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 635b942c36..9b32866fb1 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -30,7 +30,7 @@

 static void test_end(void)
 {
-    qtest_end();
+    qtest_quit(global_qtest);
 }

 #ifndef _WIN32
@@ -243,7 +243,7 @@ static void hotplug(void)
 {
     const char *arch = qtest_get_arch();

-    qtest_start("-device virtio-net-pci");
+    global_qtest = qtest_init("-device virtio-net-pci");

     qpci_plug_device_test("virtio-net-pci", "net1", PCI_SLOT_HP, NULL);

diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index dcecf77463..e1b1e89b59 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -37,10 +37,10 @@ int main(int argc, char **argv)
     qtest_add_func("/virtio/rng/pci/nop", pci_nop);
     qtest_add_func("/virtio/rng/pci/hotplug", hotplug);

-    qtest_start("-device virtio-rng-pci");
+    global_qtest = qtest_init("-device virtio-rng-pci");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c
index b14d943ada..ce708cc11e 100644
--- a/tests/virtio-serial-test.c
+++ b/tests/virtio-serial-test.c
@@ -49,10 +49,10 @@ int main(int argc, char **argv)
     qtest_add_func("/virtio/serial/pci/nop", pci_nop);
     qtest_add_func("/virtio/serial/pci/hotplug", hotplug);

-    qtest_start("-device virtio-serial-pci");
+    global_qtest = qtest_init("-device virtio-serial-pci");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index 73473162d0..b149690a1a 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -130,41 +130,32 @@ static void read_guid_from_monitor(QemuUUID *guid)

 static char disk[] = "tests/vmgenid-test-disk-XXXXXX";

-static char *guid_cmd_strdup(const char *guid)
-{
-    return g_strdup_printf("-machine accel=kvm:tcg "
-                           "-device vmgenid,id=testvgid,guid=%s "
-                           "-drive id=hd0,if=none,file=%s,format=raw "
-                           "-device ide-hd,drive=hd0 ",
-                           guid, disk);
-}
-
+#define GUID_CMD(guid)                          \
+    "-machine accel=kvm:tcg "                   \
+    "-device vmgenid,id=testvgid,guid=%s "      \
+    "-drive id=hd0,if=none,file=%s,format=raw " \
+    "-device ide-hd,drive=hd0 ", guid, disk

 static void vmgenid_set_guid_test(void)
 {
     QemuUUID expected, measured;
-    gchar *cmd;

     g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);

-    cmd = guid_cmd_strdup(VGID_GUID);
-    qtest_start(cmd);
+    global_qtest = qtest_init(GUID_CMD(VGID_GUID));

     /* Read the GUID from accessing guest memory */
     read_guid_from_memory(&measured);
     g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);

     qtest_quit(global_qtest);
-    g_free(cmd);
 }

 static void vmgenid_set_guid_auto_test(void)
 {
-    char *cmd;
     QemuUUID measured;

-    cmd = guid_cmd_strdup("auto");
-    qtest_start(cmd);
+    global_qtest = qtest_init(GUID_CMD("auto"));

     read_guid_from_memory(&measured);

@@ -172,25 +163,21 @@ static void vmgenid_set_guid_auto_test(void)
     g_assert(!qemu_uuid_is_null(&measured));

     qtest_quit(global_qtest);
-    g_free(cmd);
 }

 static void vmgenid_query_monitor_test(void)
 {
     QemuUUID expected, measured;
-    gchar *cmd;

     g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);

-    cmd = guid_cmd_strdup(VGID_GUID);
-    qtest_start(cmd);
+    global_qtest = qtest_init(GUID_CMD(VGID_GUID));

     /* Read the GUID via the monitor */
     read_guid_from_monitor(&measured);
     g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);

     qtest_quit(global_qtest);
-    g_free(cmd);
 }

 int main(int argc, char **argv)
diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c
index 159c0ad728..c9a876bcd9 100644
--- a/tests/vmxnet3-test.c
+++ b/tests/vmxnet3-test.c
@@ -22,10 +22,10 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/vmxnet3/nop", nop);

-    qtest_start("-device vmxnet3");
+    global_qtest = qtest_init("-device vmxnet3");
     ret = g_test_run();

-    qtest_end();
+    qtest_quit(global_qtest);

     return ret;
 }
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start()
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (27 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts Eric Blake
@ 2017-09-01 18:03 ` Eric Blake
  2017-09-01 23:17   ` John Snow
  2017-09-05 13:10   ` Thomas Huth
  2017-09-01 18:31 ` [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups no-reply
  29 siblings, 2 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: armbru, pbonzini, Gerd Hoffmann, Michael S. Tsirkin,
	Igor Mammedov, John Snow, Keith Busch, Thomas Huth,
	Andreas Färber, David Gibson, Alexander Graf,
	Dr. David Alan Gilbert, Stefan Hajnoczi, Amit Shah, Jason Wang,
	Ben Warren, open list:Floppy, open list:sPAPR

We already have another qtest_init() in the tree, for the
top-level qtest.c device; having two functions with different
signatures is confusing.  Rename the libqtest version to
qtest_start() to eliminate the duplication.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/libqtest.h               |  8 ++++----
 tests/libqtest.c               |  8 ++++----
 tests/ac97-test.c              |  2 +-
 tests/bios-tables-test.c       | 12 ++++++------
 tests/boot-order-test.c        |  8 ++++----
 tests/boot-serial-test.c       |  8 ++++----
 tests/device-introspect-test.c | 12 ++++++------
 tests/display-vga-test.c       | 12 ++++++------
 tests/drive_del-test.c         |  6 +++---
 tests/ds1338-test.c            |  2 +-
 tests/e1000-test.c             |  2 +-
 tests/e1000e-test.c            |  6 +++---
 tests/eepro100-test.c          |  2 +-
 tests/endianness-test.c        | 24 ++++++++++++------------
 tests/es1370-test.c            |  2 +-
 tests/fdc-test.c               |  2 +-
 tests/fw_cfg-test.c            |  2 +-
 tests/hd-geo-test.c            |  8 ++++----
 tests/i440fx-test.c            |  6 +++---
 tests/i82801b11-test.c         |  4 ++--
 tests/ide-test.c               |  2 +-
 tests/intel-hda-test.c         |  4 ++--
 tests/ioh3420-test.c           |  2 +-
 tests/ipmi-bt-test.c           |  2 +-
 tests/ipmi-kcs-test.c          |  4 ++--
 tests/ipoctal232-test.c        |  4 ++--
 tests/ivshmem-test.c           |  2 +-
 tests/libqos/libqos.c          |  2 +-
 tests/m25p80-test.c            |  6 +++---
 tests/m48t59-test.c            |  2 +-
 tests/ne2000-test.c            |  2 +-
 tests/numa-test.c              | 14 +++++++-------
 tests/nvme-test.c              |  2 +-
 tests/pc-cpu-test.c            | 16 ++++++++--------
 tests/pcnet-test.c             |  2 +-
 tests/pnv-xscom-test.c         |  4 ++--
 tests/postcopy-test.c          |  4 ++--
 tests/prom-env-test.c          | 10 +++++-----
 tests/pvpanic-test.c           |  2 +-
 tests/pxe-test.c               | 10 +++++-----
 tests/q35-test.c               |  4 ++--
 tests/qmp-test.c               |  2 +-
 tests/qom-test.c               |  2 +-
 tests/rtc-test.c               |  2 +-
 tests/rtl8139-test.c           |  2 +-
 tests/spapr-phb-test.c         |  4 ++--
 tests/tco-test.c               |  6 +++---
 tests/test-arm-mptimer.c       |  2 +-
 tests/test-filter-mirror.c     |  2 +-
 tests/test-filter-redirector.c |  4 ++--
 tests/test-hmp.c               |  2 +-
 tests/test-netfilter.c         |  4 ++--
 tests/test-x86-cpuid-compat.c  |  8 ++++----
 tests/tmp105-test.c            |  7 ++++---
 tests/tpci200-test.c           |  2 +-
 tests/usb-hcd-ehci-test.c      |  2 +-
 tests/usb-hcd-ohci-test.c      |  2 +-
 tests/usb-hcd-xhci-test.c      |  5 +++--
 tests/vhost-user-test.c        | 22 +++++++++++-----------
 tests/virtio-balloon-test.c    |  2 +-
 tests/virtio-blk-test.c        |  8 ++++----
 tests/virtio-console-test.c    |  8 ++++----
 tests/virtio-net-test.c        |  2 +-
 tests/virtio-rng-test.c        |  2 +-
 tests/virtio-serial-test.c     |  2 +-
 tests/vmgenid-test.c           |  6 +++---
 tests/vmxnet3-test.c           |  2 +-
 tests/wdt_ib700-test.c         |  8 ++++----
 68 files changed, 179 insertions(+), 177 deletions(-)

diff --git a/tests/libqtest.h b/tests/libqtest.h
index 0459526187..3f6c71f0e3 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -24,21 +24,21 @@ typedef struct QTestState QTestState;
 extern QTestState *global_qtest;

 /**
- * qtest_init:
+ * qtest_start:
  * @extra_args...: other arguments to pass to QEMU, formatted as if by
  * sprintf().
  *
  * Returns: #QTestState instance.
  */
-QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);
+QTestState *qtest_start(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);

 /**
- * qtest_init_without_qmp_handshake:
+ * qtest_start_without_qmp_handshake:
  * @extra_args: other arguments to pass to QEMU.
  *
  * Returns: #QTestState instance.
  */
-QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
+QTestState *qtest_start_without_qmp_handshake(const char *extra_args);

 /**
  * qtest_quit:
diff --git a/tests/libqtest.c b/tests/libqtest.c
index fa4e47c137..76c8029f7e 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -266,7 +266,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data)
     g_hook_prepend(&abrt_hooks, hook);
 }

-QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
+QTestState *qtest_start_without_qmp_handshake(const char *extra_args)
 {
     QTestState *s;
     int sock, qmpsock, i;
@@ -347,7 +347,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     return s;
 }

-QTestState *qtest_init(const char *extra_args, ...)
+QTestState *qtest_start(const char *extra_args, ...)
 {
     va_list ap;
     QTestState *s;
@@ -357,7 +357,7 @@ QTestState *qtest_init(const char *extra_args, ...)
     cmd = g_strdup_vprintf(extra_args, ap);
     va_end(ap);

-    s = qtest_init_without_qmp_handshake(cmd);
+    s = qtest_start_without_qmp_handshake(cmd);
     g_free(cmd);

     /* Read the QMP greeting and then do the handshake */
@@ -970,7 +970,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
     QString *qstr;
     const char *mname;

-    global_qtest = qtest_init("-machine none");
+    global_qtest = qtest_start("-machine none");
     response = qmp("{ 'execute': 'query-machines' }");
     g_assert(response);
     list = qdict_get_qlist(response, "return");
diff --git a/tests/ac97-test.c b/tests/ac97-test.c
index 6a1edaa85a..2f5fb10632 100644
--- a/tests/ac97-test.c
+++ b/tests/ac97-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ac97/nop", nop);

-    global_qtest = qtest_init("-device AC97");
+    global_qtest = qtest_start("-device AC97");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index f8a107499f..9735073c22 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -624,12 +624,12 @@ static void test_smbios_structs(test_data *data)
 static void test_acpi_one(const char *params, test_data *data)
 {
     /* Disable kernel irqchip to be able to override apic irq0. */
-    data->qts = qtest_init("-machine %s,accel=%s,kernel-irqchip=off "
-                           "-net none -display none %s "
-                           "-drive id=hd0,if=none,file=%s,format=raw "
-                           "-device ide-hd,drive=hd0 ",
-                           data->machine, "kvm:tcg",
-                           params ? params : "", disk);
+    data->qts = qtest_start("-machine %s,accel=%s,kernel-irqchip=off "
+                            "-net none -display none %s "
+                            "-drive id=hd0,if=none,file=%s,format=raw "
+                            "-device ide-hd,drive=hd0 ",
+                            data->machine, "kvm:tcg",
+                            params ? params : "", disk);

     boot_sector_test(data->qts);

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index e6efea6852..81b0d32a01 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -30,10 +30,10 @@ static void test_a_boot_order(const char *machine,
 {
     uint64_t actual;

-    global_qtest = qtest_init("-nodefaults%s%s %s",
-                              machine ? " -M " : "",
-                              machine ?: "",
-                              test_args);
+    global_qtest = qtest_start("-nodefaults%s%s %s",
+                               machine ? " -M " : "",
+                               machine ?: "",
+                               test_args);
     actual = read_boot_order();
     g_assert_cmphex(actual, ==, expected_boot);
     qmp_discard_response("{ 'execute': 'system_reset' }");
diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index d7c0c320d7..d337fc9c4b 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -81,10 +81,10 @@ static void test_machine(const void *data)
      * Make sure that this test uses tcg if available: It is used as a
      * fast-enough smoketest for that.
      */
-    global_qtest = qtest_init("-M %s,accel=tcg:kvm "
-                              "-chardev file,id=serial0,path=%s "
-                              "-no-shutdown -serial chardev:serial0 %s",
-                              test->machine, tmpname, test->extra);
+    global_qtest = qtest_start("-M %s,accel=tcg:kvm "
+                               "-chardev file,id=serial0,path=%s "
+                               "-no-shutdown -serial chardev:serial0 %s",
+                               test->machine, tmpname, test->extra);
     unlink(tmpname);

     check_guest_output(test, fd);
diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
index 1c23b71038..f7af40acc2 100644
--- a/tests/device-introspect-test.c
+++ b/tests/device-introspect-test.c
@@ -126,7 +126,7 @@ static void test_device_intro_list(void)
     QList *types;
     char *help;

-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);

     types = device_type_list(true);
     QDECREF(types);
@@ -167,7 +167,7 @@ static void test_qom_list_fields(void)
     QList *non_abstract;
     QListEntry *e;

-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);

     all_types = qom_list_types(NULL, true);
     non_abstract = qom_list_types(NULL, false);
@@ -194,14 +194,14 @@ static void test_qom_list_fields(void)

 static void test_device_intro_none(void)
 {
-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);
     test_one_device("nonexistent");
     qtest_quit(global_qtest);
 }

 static void test_device_intro_abstract(void)
 {
-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);
     test_one_device("device");
     qtest_quit(global_qtest);
 }
@@ -212,7 +212,7 @@ static void test_device_intro_concrete(void)
     QListEntry *entry;
     const char *type;

-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);
     types = device_type_list(false);

     QLIST_FOREACH_ENTRY(types, entry) {
@@ -232,7 +232,7 @@ static void test_abstract_interfaces(void)
     QListEntry *e;
     QDict *index;

-    global_qtest = qtest_init("%s", common_args);
+    global_qtest = qtest_start("%s", common_args);

     all_types = qom_list_types("interface", true);
     index = qom_type_index(all_types);
diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c
index 51c6feaaf1..d638f15ec3 100644
--- a/tests/display-vga-test.c
+++ b/tests/display-vga-test.c
@@ -12,33 +12,33 @@

 static void pci_cirrus(void)
 {
-    qtest_quit(qtest_init("-vga none -device cirrus-vga"));
+    qtest_quit(qtest_start("-vga none -device cirrus-vga"));
 }

 static void pci_stdvga(void)
 {
-    qtest_quit(qtest_init("-vga none -device VGA"));
+    qtest_quit(qtest_start("-vga none -device VGA"));
 }

 static void pci_secondary(void)
 {
-    qtest_quit(qtest_init("-vga none -device secondary-vga"));
+    qtest_quit(qtest_start("-vga none -device secondary-vga"));
 }

 static void pci_multihead(void)
 {
-    qtest_quit(qtest_init("-vga none -device VGA -device secondary-vga"));
+    qtest_quit(qtest_start("-vga none -device VGA -device secondary-vga"));
 }

 static void pci_virtio_gpu(void)
 {
-    qtest_quit(qtest_init("-vga none -device virtio-gpu-pci"));
+    qtest_quit(qtest_start("-vga none -device virtio-gpu-pci"));
 }

 #ifdef CONFIG_VIRTIO_VGA
 static void pci_virtio_vga(void)
 {
-    qtest_quit(qtest_init("-vga none -device virtio-vga"));
+    qtest_quit(qtest_start("-vga none -device virtio-vga"));
 }
 #endif

diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c
index 602ab062b4..f68c4bc176 100644
--- a/tests/drive_del-test.c
+++ b/tests/drive_del-test.c
@@ -45,7 +45,7 @@ static void device_del(void)
 static void test_drive_without_dev(void)
 {
     /* Start with an empty drive */
-    global_qtest = qtest_init("-drive if=none,id=drive0");
+    global_qtest = qtest_start("-drive if=none,id=drive0");

     /* Delete the drive */
     drive_del();
@@ -63,7 +63,7 @@ static void test_after_failed_device_add(void)
     QDict *response;
     QDict *error;

-    global_qtest = qtest_init("-drive if=none,id=drive0");
+    global_qtest = qtest_start("-drive if=none,id=drive0");

     /* Make device_add fail.  If this leaks the virtio-blk-pci device then a
      * reference to drive0 will also be held (via qdev properties).
@@ -92,7 +92,7 @@ static void test_after_failed_device_add(void)
 static void test_drive_del_device_del(void)
 {
     /* Start with a drive used by a device that unplugs instantaneously */
-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-drive if=none,id=drive0,file=null-co://,format=raw"
         " -device virtio-scsi-pci"
         " -device scsi-hd,drive=drive0,id=dev0");
diff --git a/tests/ds1338-test.c b/tests/ds1338-test.c
index da5b852351..ad5f5b138a 100644
--- a/tests/ds1338-test.c
+++ b/tests/ds1338-test.c
@@ -60,7 +60,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = global_qtest = qtest_init("-display none -machine imx25-pdk");
+    s = global_qtest = qtest_start("-display none -machine imx25-pdk");
     i2c = imx_i2c_create(IMX25_I2C_0_BASE);
     addr = DS1338_ADDR;

diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index 59bd8b781f..1ee33fdd52 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -16,7 +16,7 @@ static void test_device(gconstpointer data)
     const char *model = data;
     QTestState *s;

-    s = qtest_init("-device %s", model);
+    s = qtest_start("-device %s", model);
     qtest_quit(s);
 }

diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 6ef240dc8f..0f6214b70a 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -383,8 +383,8 @@ static void data_test_init(e1000e_device *d)
     int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, test_sockets);
     g_assert_cmpint(ret, != , -1);

-    global_qtest = qtest_init("-netdev socket,fd=%d,id=hs0 "
-                              "-device e1000e,netdev=hs0", test_sockets[1]);
+    global_qtest = qtest_start("-netdev socket,fd=%d,id=hs0 "
+                               "-device e1000e,netdev=hs0", test_sockets[1]);

     test_alloc = pc_alloc_init(global_qtest);
     g_assert_nonnull(test_alloc);
@@ -452,7 +452,7 @@ static void test_e1000e_hotplug(gconstpointer data)
 {
     static const uint8_t slot = 0x06;

-    global_qtest = qtest_init("-device e1000e");
+    global_qtest = qtest_start("-device e1000e");

     qpci_plug_device_test("e1000e", "e1000e_net", slot, NULL);
     qpci_unplug_acpi_device_test("e1000e_net", slot);
diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c
index 6f49ac2656..be31f5d40d 100644
--- a/tests/eepro100-test.c
+++ b/tests/eepro100-test.c
@@ -16,7 +16,7 @@ static void test_device(gconstpointer data)
     QTestState *s;

     /* Tests only initialization so far. TODO: Implement functional tests */
-    s = qtest_init("-device %s", model);
+    s = qtest_start("-device %s", model);
     qtest_quit(s);
 }

diff --git a/tests/endianness-test.c b/tests/endianness-test.c
index 68d5dbcd14..2c0f2df366 100644
--- a/tests/endianness-test.c
+++ b/tests/endianness-test.c
@@ -115,10 +115,10 @@ static void test_endianness(gconstpointer data)
 {
     const TestCase *test = data;

-    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
-                              test->machine,
-                              test->superio ? " -device " : "",
-                              test->superio ?: "");
+    global_qtest = qtest_start("-M %s%s%s -device pc-testdev",
+                               test->machine,
+                               test->superio ? " -device " : "",
+                               test->superio ?: "");
     isa_outl(test, 0xe0, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
@@ -187,10 +187,10 @@ static void test_endianness_split(gconstpointer data)
 {
     const TestCase *test = data;

-    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
-                              test->machine,
-                              test->superio ? " -device " : "",
-                              test->superio ?: "");
+    global_qtest = qtest_start("-M %s%s%s -device pc-testdev",
+                               test->machine,
+                               test->superio ? " -device " : "",
+                               test->superio ?: "");
     isa_outl(test, 0xe8, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
@@ -231,10 +231,10 @@ static void test_endianness_combine(gconstpointer data)
 {
     const TestCase *test = data;

-    global_qtest = qtest_init("-M %s%s%s -device pc-testdev",
-                              test->machine,
-                              test->superio ? " -device " : "",
-                              test->superio ?: "");
+    global_qtest = qtest_start("-M %s%s%s -device pc-testdev",
+                               test->machine,
+                               test->superio ? " -device " : "",
+                               test->superio ?: "");
     isa_outl(test, 0xe0, 0x87654321);
     g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321);
     g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765);
diff --git a/tests/es1370-test.c b/tests/es1370-test.c
index edeea13ae7..ff6fdbfe57 100644
--- a/tests/es1370-test.c
+++ b/tests/es1370-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/es1370/nop", nop);

-    global_qtest = qtest_init("-device ES1370");
+    global_qtest = qtest_start("-device ES1370");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 893097f5a3..ec83625db2 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -564,7 +564,7 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    global_qtest = qtest_init("-device floppy,id=floppy0");
+    global_qtest = qtest_start("-device floppy,id=floppy0");
     qtest_irq_intercept_in(global_qtest, "ioapic");
     qtest_add_func("/fdc/cmos", test_cmos);
     qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 3a8dc7a2cd..37214fdf10 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -106,7 +106,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
+    s = qtest_start("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");

     fw_cfg = pc_fw_cfg_init(s);

diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
index e0b19cdf17..73d23b14b8 100644
--- a/tests/hd-geo-test.c
+++ b/tests/hd-geo-test.c
@@ -241,7 +241,7 @@ static void test_ide_none(void)

     setup_common(argv, ARGV_SIZE);
     args = g_strjoinv(" ", argv);
-    global_qtest = qtest_init("%s", args);
+    global_qtest = qtest_start("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
@@ -263,7 +263,7 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
         argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr, "");
     }
     args = g_strjoinv(" ", argv);
-    global_qtest = qtest_init("%s", args);
+    global_qtest = qtest_start("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
@@ -339,7 +339,7 @@ static void test_ide_drive_user(const char *dev, bool trans)
                      dev ? "" : opts);
     g_free(opts);
     args = g_strjoinv(" ", argv);
-    global_qtest = qtest_init("%s", args);
+    global_qtest = qtest_start("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
@@ -396,7 +396,7 @@ static void test_ide_drive_cd_0(void)
                          ide_idx, NULL, i, mbr_blank, "");
     }
     args = g_strjoinv(" ", argv);
-    global_qtest = qtest_init("%s", args);
+    global_qtest = qtest_start("%s", args);
     g_strfreev(argv);
     g_free(args);
     test_cmos();
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index bfedd5d953..ac98101e6f 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -33,7 +33,7 @@ typedef struct FirmwareTestFixture {

 static QPCIBus *test_start_get_bus(const TestData *s)
 {
-    global_qtest = qtest_init("-smp %d", s->num_cpus);
+    global_qtest = qtest_start("-smp %d", s->num_cpus);
     return qpci_init_pc(global_qtest, NULL);
 }

@@ -340,10 +340,10 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture,
                                          : "-drive if=pflash,format=raw,file=",
                               fw_pathname);
     g_test_message("qemu cmdline: %s", cmdline);
-    global_qtest = qtest_init("%s", cmdline);
+    global_qtest = qtest_start("%s", cmdline);
     g_free(cmdline);

-    /* QEMU has loaded the firmware (because qtest_init() only returns after
+    /* QEMU has loaded the firmware (because qtest_start() only returns after
      * the QMP handshake completes). We must unlink the firmware blob right
      * here, because any assertion firing below would leak it in the
      * filesystem. This is also the reason why we recreate the blob every time
diff --git a/tests/i82801b11-test.c b/tests/i82801b11-test.c
index 58436172b7..b76714ae16 100644
--- a/tests/i82801b11-test.c
+++ b/tests/i82801b11-test.c
@@ -22,8 +22,8 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/i82801b11/nop", nop);

-    global_qtest = qtest_init("-machine q35 "
-                              "-device i82801b11-bridge,bus=pcie.0,addr=1e.0");
+    global_qtest = qtest_start("-machine q35 "
+                               "-device i82801b11-bridge,bus=pcie.0,addr=1e.0");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/ide-test.c b/tests/ide-test.c
index b22a4fc1c5..7b7cc10176 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -124,7 +124,7 @@ static void ide_test_start(const char *cmdline_fmt, ...)
     cmdline = g_strdup_vprintf(cmdline_fmt, ap);
     va_end(ap);

-    global_qtest = qtest_init("%s", cmdline);
+    global_qtest = qtest_start("%s", cmdline);
     guest_malloc = pc_alloc_init(global_qtest);

     g_free(cmdline);
diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c
index c10a59d932..86f7719d39 100644
--- a/tests/intel-hda-test.c
+++ b/tests/intel-hda-test.c
@@ -18,13 +18,13 @@
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void ich6_test(void)
 {
-    global_qtest = qtest_init("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
+    global_qtest = qtest_start("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
     qtest_quit(global_qtest);
 }

 static void ich9_test(void)
 {
-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-machine q35 -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id="
         HDA_ID CODEC_DEVICES);
     qtest_quit(global_qtest);
diff --git a/tests/ioh3420-test.c b/tests/ioh3420-test.c
index cd5d062370..aff569b99e 100644
--- a/tests/ioh3420-test.c
+++ b/tests/ioh3420-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ioh3420/nop", nop);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-machine q35 -device ioh3420,bus=pcie.0,addr=1c.0,port=1,"
         "chassis=1,multifunction=on");
     ret = g_test_run();
diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
index 476d527cfd..fdcbadb755 100644
--- a/tests/ipmi-bt-test.c
+++ b/tests/ipmi-bt-test.c
@@ -414,7 +414,7 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         " -chardev socket,id=ipmi0,host=localhost,port=%d,reconnect=10"
         " -device ipmi-bmc-extern,chardev=ipmi0,id=bmc0"
         " -device isa-ipmi-bt,bmc=bmc0", emu_port);
diff --git a/tests/ipmi-kcs-test.c b/tests/ipmi-kcs-test.c
index 2bd3771e9f..5acc0d9e35 100644
--- a/tests/ipmi-kcs-test.c
+++ b/tests/ipmi-kcs-test.c
@@ -275,8 +275,8 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);

-    global_qtest = qtest_init("-device ipmi-bmc-sim,id=bmc0"
-                              " -device isa-ipmi-kcs,bmc=bmc0");
+    global_qtest = qtest_start("-device ipmi-bmc-sim,id=bmc0"
+                               " -device isa-ipmi-kcs,bmc=bmc0");
     qtest_irq_intercept_in(global_qtest, "ioapic");
     qtest_add_func("/ipmi/local/kcs_base", test_kcs_base);
     qtest_add_func("/ipmi/local/kcs_abort", test_kcs_abort);
diff --git a/tests/ipoctal232-test.c b/tests/ipoctal232-test.c
index 5e1cae3917..90b683284a 100644
--- a/tests/ipoctal232-test.c
+++ b/tests/ipoctal232-test.c
@@ -22,8 +22,8 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ipoctal232/tpci200/nop", nop);

-    global_qtest = qtest_init("-device tpci200,id=ipack0 "
-                              "-device ipoctal232,bus=ipack0.0");
+    global_qtest = qtest_start("-device tpci200,id=ipack0 "
+                               "-device ipoctal232,bus=ipack0.0");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index f254f09487..6ad3e5f834 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -407,7 +407,7 @@ static void test_ivshmem_hotplug(void)
     const char *arch = qtest_get_arch();
     gchar *opts;

-    global_qtest = qtest_init(" ");
+    global_qtest = qtest_start(" ");

     opts = g_strdup_printf("'shm': '%s', 'size': '1M'", tmpshm);

diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index bd9106a132..1dea434e37 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -20,7 +20,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
     struct QOSState *qs = g_malloc(sizeof(QOSState));

     cmdline = g_strdup_vprintf(cmdline_fmt, ap);
-    qs->qts = global_qtest = qtest_init("%s", cmdline);
+    qs->qts = global_qtest = qtest_start("%s", cmdline);
     qs->ops = ops;
     if (ops) {
         if (ops->init_allocator) {
diff --git a/tests/m25p80-test.c b/tests/m25p80-test.c
index 18135cfb86..82d9bb9ff0 100644
--- a/tests/m25p80-test.c
+++ b/tests/m25p80-test.c
@@ -363,9 +363,9 @@ int main(int argc, char **argv)
     g_assert(ret == 0);
     close(fd);

-    global_qtest = qtest_init("-m 256 -machine palmetto-bmc "
-                              "-drive file=%s,format=raw,if=mtd",
-                              tmp_path);
+    global_qtest = qtest_start("-m 256 -machine palmetto-bmc "
+                               "-drive file=%s,format=raw,if=mtd",
+                               tmp_path);

     qtest_add_func("/m25p80/read_jedec", test_read_jedec);
     qtest_add_func("/m25p80/erase_sector", test_erase_sector);
diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c
index 52c61fe33e..aadd770f4f 100644
--- a/tests/m48t59-test.c
+++ b/tests/m48t59-test.c
@@ -246,7 +246,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = global_qtest = qtest_init("-rtc clock=vm");
+    s = global_qtest = qtest_start("-rtc clock=vm");

     qtest_add_func("/rtc/bcd/check-time", bcd_check_time);
     qtest_add_func("/rtc/fuzz-registers", fuzz_registers);
diff --git a/tests/ne2000-test.c b/tests/ne2000-test.c
index d205bc91a6..8e6f7b07c6 100644
--- a/tests/ne2000-test.c
+++ b/tests/ne2000-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/ne2000/pci/nop", pci_nop);

-    global_qtest = qtest_init("-device ne2k_pci");
+    global_qtest = qtest_start("-device ne2k_pci");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/numa-test.c b/tests/numa-test.c
index 17bbc0f5f8..5653eaac47 100644
--- a/tests/numa-test.c
+++ b/tests/numa-test.c
@@ -25,7 +25,7 @@ static void test_mon_explicit(const void *data)
     cli = make_cli(data, "-smp 8 "
                    "-numa node,nodeid=0,cpus=0-3 "
                    "-numa node,nodeid=1,cpus=4-7 ");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
@@ -42,7 +42,7 @@ static void test_mon_default(const void *data)
     char *cli;

     cli = make_cli(data, "-smp 8 -numa node -numa node");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
@@ -61,7 +61,7 @@ static void test_mon_partial(const void *data)
     cli = make_cli(data, "-smp 8 "
                    "-numa node,nodeid=0,cpus=0-1 "
                    "-numa node,nodeid=1,cpus=4-5 ");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);

     s = hmp("info numa");
     g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
@@ -88,7 +88,7 @@ static void test_query_cpus(const void *data)
     QObject *e;

     cli = make_cli(data, "-smp 8 -numa node,cpus=0-3 -numa node,cpus=4-7");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -130,7 +130,7 @@ static void pc_numa_cpu(const void *data)
         "-numa cpu,node-id=0,socket-id=1,core-id=0 "
         "-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
         "-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -183,7 +183,7 @@ static void spapr_numa_cpu(const void *data)
         "-numa cpu,node-id=0,core-id=1 "
         "-numa cpu,node-id=0,core-id=2 "
         "-numa cpu,node-id=1,core-id=3");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

@@ -226,7 +226,7 @@ static void aarch64_numa_cpu(const void *data)
         "-numa node,nodeid=0 -numa node,nodeid=1 "
         "-numa cpu,node-id=1,thread-id=0 "
         "-numa cpu,node-id=0,thread-id=1");
-    global_qtest = qtest_init("%s", cli);
+    global_qtest = qtest_start("%s", cli);
     cpus = get_cpus(&resp);
     g_assert(cpus);

diff --git a/tests/nvme-test.c b/tests/nvme-test.c
index 382d26671f..b054ad6fcd 100644
--- a/tests/nvme-test.c
+++ b/tests/nvme-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/nvme/nop", nop);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-drive id=drv0,if=none,file=null-co://,format=raw "
         "-device nvme,drive=drv0,serial=foo");
     ret = g_test_run();
diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index 9c36051c07..1243bc64b8 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -29,10 +29,10 @@ static void test_pc_with_cpu_add(gconstpointer data)
     QDict *response;
     unsigned int i;

-    global_qtest = qtest_init("-machine %s -cpu %s "
-                              "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
-                              s->machine, s->cpu_model,
-                              s->sockets, s->cores, s->threads, s->maxcpus);
+    global_qtest = qtest_start("-machine %s -cpu %s "
+                               "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+                               s->machine, s->cpu_model,
+                               s->sockets, s->cores, s->threads, s->maxcpus);

     for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
         response = qmp("{ 'execute': 'cpu-add',"
@@ -50,10 +50,10 @@ static void test_pc_without_cpu_add(gconstpointer data)
     const PCTestData *s = data;
     QDict *response;

-    global_qtest = qtest_init("-machine %s -cpu %s "
-                              "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
-                              s->machine, s->cpu_model,
-                              s->sockets, s->cores, s->threads, s->maxcpus);
+    global_qtest = qtest_start("-machine %s -cpu %s "
+                               "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+                               s->machine, s->cpu_model,
+                               s->sockets, s->cores, s->threads, s->maxcpus);

     response = qmp("{ 'execute': 'cpu-add',"
                    "  'arguments': { 'id': %d } }",
diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c
index 23e36da805..a58a5fd7bf 100644
--- a/tests/pcnet-test.c
+++ b/tests/pcnet-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/pcnet/pci/nop", pci_nop);

-    global_qtest = qtest_init("-device pcnet");
+    global_qtest = qtest_start("-device pcnet");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c
index 852322b3f2..ee25bf7dae 100644
--- a/tests/pnv-xscom-test.c
+++ b/tests/pnv-xscom-test.c
@@ -83,7 +83,7 @@ static void test_cfam_id(const void *data)
 {
     const PnvChip *chip = data;

-    global_qtest = qtest_init("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
+    global_qtest = qtest_start("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
     test_xscom_cfam_id(chip);
     qtest_quit(global_qtest);
 }
@@ -106,7 +106,7 @@ static void test_core(const void *data)
 {
     const PnvChip *chip = data;

-    global_qtest = qtest_init("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
+    global_qtest = qtest_start("-M powernv,accel=tcg -cpu %s", chip->cpu_model);
     test_xscom_core(chip);
     qtest_quit(global_qtest);
 }
diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 20cfb280f6..4cd75400af 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -403,10 +403,10 @@ static void test_migrate(void)

     g_free(bootpath);

-    from = qtest_init("%s", cmd_src);
+    from = qtest_start("%s", cmd_src);
     g_free(cmd_src);

-    to = qtest_init("%s", cmd_dst);
+    to = qtest_start("%s", cmd_dst);
     g_free(cmd_dst);

     assert(!global_qtest);
diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c
index fffef0b252..501075724a 100644
--- a/tests/prom-env-test.c
+++ b/tests/prom-env-test.c
@@ -49,11 +49,11 @@ static void test_machine(const void *machine)
     /* The pseries firmware boots much faster without the default devices */
     extra_args = strcmp(machine, "pseries") == 0 ? "-nodefaults" : "";

-    global_qtest = qtest_init("-M %s,accel=tcg %s "
-                              "-prom-env 'use-nvramrc?=true' "
-                              "-prom-env 'nvramrc=%x %x l!' ",
-                              (const char *)machine, extra_args,
-                              MAGIC, ADDRESS);
+    global_qtest = qtest_start("-M %s,accel=tcg %s "
+                               "-prom-env 'use-nvramrc?=true' "
+                               "-prom-env 'nvramrc=%x %x l!' ",
+                               (const char *)machine, extra_args,
+                               MAGIC, ADDRESS);
     check_guest_memory();
     qtest_quit(global_qtest);
 }
diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c
index 48b71be26f..c09b3ddac6 100644
--- a/tests/pvpanic-test.c
+++ b/tests/pvpanic-test.c
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/pvpanic/panic", test_panic);

-    global_qtest = qtest_init("-device pvpanic");
+    global_qtest = qtest_start("-device pvpanic");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index eaad88601a..4bcf8ce124 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -23,11 +23,11 @@ static char disk[] = "tests/pxe-test-disk-XXXXXX";

 static void test_pxe_one(const char *params, bool ipv6)
 {
-    global_qtest = qtest_init("-machine accel=kvm:tcg -nodefaults "
-                              "-boot order=n "
-                              "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,"
-                              "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on",
-                              ipv6 ? "on" : "off", params);
+    global_qtest = qtest_start(
+        "-machine accel=kvm:tcg -nodefaults -boot order=n "
+        "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,"
+        "ipv4=%s,ipv6=%s %s", disk, ipv6 ? "off" : "on",
+        ipv6 ? "on" : "off", params);
     boot_sector_test(global_qtest);
     qtest_quit(global_qtest);
 }
diff --git a/tests/q35-test.c b/tests/q35-test.c
index 91a189ce62..21c0fd9bab 100644
--- a/tests/q35-test.c
+++ b/tests/q35-test.c
@@ -84,7 +84,7 @@ static void test_smram_lock(void)
     QPCIDevice *pcidev;
     QDict *response;

-    global_qtest = qtest_init("-M q35");
+    global_qtest = qtest_start("-M q35");

     pcibus = qpci_init_pc(global_qtest, NULL);
     g_assert(pcibus != NULL);
@@ -141,7 +141,7 @@ static void test_tseg_size(const void *data)
         cmdline = g_strdup_printf("-M q35 -m %uM",
                                   TSEG_SIZE_TEST_GUEST_RAM_MBYTES);
     }
-    global_qtest = qtest_init("%s", cmdline);
+    global_qtest = qtest_start("%s", cmdline);
     g_free(cmdline);

     /* locate the DRAM controller */
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index cf523b325e..14f4f57600 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -76,7 +76,7 @@ static void test_qmp_protocol(void)
     QList *capabilities;
     QTestState *qts;

-    qts = qtest_init_without_qmp_handshake(common_args);
+    qts = qtest_start_without_qmp_handshake(common_args);

     /* Test greeting */
     resp = qtest_qmp_receive(qts);
diff --git a/tests/qom-test.c b/tests/qom-test.c
index 5edd735387..9aecf40f96 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -92,7 +92,7 @@ static void test_machine(gconstpointer data)
     const char *machine = data;
     QDict *response;

-    global_qtest = qtest_init("-machine %s", machine);
+    global_qtest = qtest_start("-machine %s", machine);

     test_properties("/machine", true);

diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index b6058d28f5..dd5430dd2d 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -690,7 +690,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = global_qtest = qtest_init("-rtc clock=vm");
+    s = global_qtest = qtest_start("-rtc clock=vm");
     qtest_irq_intercept_in(s, "ioapic");

     qtest_add_func("/rtc/check-time/bcd", bcd_check_time);
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index dc9935439f..1741f0ec47 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -197,7 +197,7 @@ int main(int argc, char **argv)
 {
     int ret;

-    global_qtest = qtest_init("-device rtl8139");
+    global_qtest = qtest_start("-device rtl8139");

     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/rtl8139/nop", nop);
diff --git a/tests/spapr-phb-test.c b/tests/spapr-phb-test.c
index 0d26cbda6c..058ab447d7 100644
--- a/tests/spapr-phb-test.c
+++ b/tests/spapr-phb-test.c
@@ -25,8 +25,8 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/spapr-phb/device", test_phb_device);

-    global_qtest = qtest_init("-device " TYPE_SPAPR_PCI_HOST_BRIDGE
-                              ",index=30");
+    global_qtest = qtest_start("-device " TYPE_SPAPR_PCI_HOST_BRIDGE
+                               ",index=30");

     ret = g_test_run();

diff --git a/tests/tco-test.c b/tests/tco-test.c
index b2a4baeeef..9d406dcdc7 100644
--- a/tests/tco-test.c
+++ b/tests/tco-test.c
@@ -56,9 +56,9 @@ static void test_init(TestData *d)
 {
     QTestState *qs;

-    qs = qtest_init("-machine q35 %s %s",
-                    d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
-                    !d->args ? "" : d->args);
+    qs = qtest_start("-machine q35 %s %s",
+                     d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
+                     !d->args ? "" : d->args);
     global_qtest = qs;
     qtest_irq_intercept_in(qs, "ioapic");

diff --git a/tests/test-arm-mptimer.c b/tests/test-arm-mptimer.c
index a4bef2322a..9631c55fe3 100644
--- a/tests/test-arm-mptimer.c
+++ b/tests/test-arm-mptimer.c
@@ -1097,7 +1097,7 @@ tests_with_prescaler_arg:
         goto tests_with_prescaler_arg;
     }

-    global_qtest = qtest_init("-machine vexpress-a9");
+    global_qtest = qtest_start("-machine vexpress-a9");
     ret = g_test_run();
     qtest_quit(global_qtest);

diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c
index 9d8608a609..18f7af5f25 100644
--- a/tests/test-filter-mirror.c
+++ b/tests/test-filter-mirror.c
@@ -36,7 +36,7 @@ static void test_mirror(void)
     ret = mkstemp(sock_path);
     g_assert_cmpint(ret, !=, -1);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-netdev socket,id=qtest-bn0,fd=%d "
         "-device %s,netdev=qtest-bn0,id=qtest-e0 "
         "-chardev socket,id=mirror0,path=%s,server,nowait "
diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c
index b34f8ec2ad..becf74ef14 100644
--- a/tests/test-filter-redirector.c
+++ b/tests/test-filter-redirector.c
@@ -86,7 +86,7 @@ static void test_redirector_tx(void)
     ret = mkstemp(sock_path1);
     g_assert_cmpint(ret, !=, -1);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-netdev socket,id=qtest-bn0,fd=%d "
         "-device %s,netdev=qtest-bn0,id=qtest-e0 "
         "-chardev socket,id=redirector0,path=%s,server,nowait "
@@ -155,7 +155,7 @@ static void test_redirector_rx(void)
     ret = mkstemp(sock_path1);
     g_assert_cmpint(ret, !=, -1);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-netdev socket,id=qtest-bn0,fd=%d "
         "-device %s,netdev=qtest-bn0,id=qtest-e0 "
         "-chardev socket,id=redirector0,path=%s,server,nowait "
diff --git a/tests/test-hmp.c b/tests/test-hmp.c
index dd03693707..d7d5f13a14 100644
--- a/tests/test-hmp.c
+++ b/tests/test-hmp.c
@@ -120,7 +120,7 @@ static void test_machine(gconstpointer data)
 {
     const char *machine = data;

-    global_qtest = qtest_init("-S -M %s", machine);
+    global_qtest = qtest_start("-S -M %s", machine);

     test_info_commands();
     test_commands();
diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c
index 76caaedfc1..1215d13a62 100644
--- a/tests/test-netfilter.c
+++ b/tests/test-netfilter.c
@@ -196,8 +196,8 @@ int main(int argc, char **argv)
     qtest_add_func("/netfilter/remove_netdev_multi",
                    remove_netdev_with_multi_netfilter);

-    global_qtest = qtest_init("-netdev user,id=qtest-bn0 "
-                              "-device %s,netdev=qtest-bn0", devstr);
+    global_qtest = qtest_start("-netdev user,id=qtest-bn0 "
+                               "-device %s,netdev=qtest-bn0", devstr);
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 5b026ac38a..a5c2f10ebb 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -59,7 +59,7 @@ static void test_cpuid_prop(const void *data)
     QNum *value;
     int64_t val;

-    global_qtest = qtest_init("%s", args->cmdline);
+    global_qtest = qtest_start("%s", args->cmdline);
     path = get_cpu0_qom_path();
     value = qobject_to_qnum(qom_get(path, args->property));
     g_assert(qnum_get_try_int(value, &val));
@@ -131,7 +131,7 @@ static void test_feature_flag(const void *data)
     QList *present, *filtered;
     uint32_t value;

-    global_qtest = qtest_init("%s", args->cmdline);
+    global_qtest = qtest_start("%s", args->cmdline);
     path = get_cpu0_qom_path();
     present = qobject_to_qlist(qom_get(path, "feature-words"));
     filtered = qobject_to_qlist(qom_get(path, "filtered-features"));
@@ -181,8 +181,8 @@ static void test_plus_minus_subprocess(void)
      * Note: rules 1 and 2 are planned to be removed soon, and
      * should generate a warning.
      */
-    global_qtest = qtest_init("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,"
-                              "cx8=off,+sse4_1,sse4_2=on");
+    global_qtest = qtest_start("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,"
+                               "cx8=off,+sse4_1,sse4_2=on");
     path = get_cpu0_qom_path();

     g_assert_false(qom_get_bool(path, "fpu"));
diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 3ef2efff6e..9233585e4b 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -151,9 +151,10 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);

-    s = global_qtest = qtest_init("-machine n800 "
-                    "-device tmp105,bus=i2c-bus.0,id=" TMP105_TEST_ID
-                    ",address=0x49");
+    s = global_qtest = qtest_start(
+        "-machine n800 "
+        "-device tmp105,bus=i2c-bus.0,id=" TMP105_TEST_ID
+        ",address=0x49");
     i2c = omap_i2c_create(OMAP2_I2C_1_BASE);

     qtest_add_func("/tmp105/tx-rx", send_and_receive);
diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c
index 2ed378196d..223d44da35 100644
--- a/tests/tpci200-test.c
+++ b/tests/tpci200-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/tpci200/nop", nop);

-    global_qtest = qtest_init("-device tpci200");
+    global_qtest = qtest_start("-device tpci200");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index 55349a39a2..c3568a1782 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
     qtest_add_func("/ehci/pci/ehci-port-2", pci_ehci_port_2);
     qtest_add_func("/ehci/pci/ehci-port-3-hotplug", pci_ehci_port_hotplug);

-    global_qtest = qtest_init(
+    global_qtest = qtest_start(
         "-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
         "multifunction=on,id=ich9-ehci-1 "
         "-device ich9-usb-uhci1,bus=pcie.0,addr=1d.0,"
diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c
index 2763c9ec24..62fd35f69a 100644
--- a/tests/usb-hcd-ohci-test.c
+++ b/tests/usb-hcd-ohci-test.c
@@ -31,7 +31,7 @@ int main(int argc, char **argv)
     qtest_add_func("/ohci/pci/init", test_ohci_init);
     qtest_add_func("/ohci/pci/hotplug", test_ohci_hotplug);

-    global_qtest = qtest_init("-device pci-ohci,id=ohci");
+    global_qtest = qtest_start("-device pci-ohci,id=ohci");
     ret = g_test_run();
     qtest_quit(global_qtest);

diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c
index cc3fcd82fa..bd3c65ae85 100644
--- a/tests/usb-hcd-xhci-test.c
+++ b/tests/usb-hcd-xhci-test.c
@@ -80,8 +80,9 @@ int main(int argc, char **argv)
     qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
     qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);

-    global_qtest = qtest_init("-device nec-usb-xhci,id=xhci"
-                " -drive id=drive0,if=none,file=null-co://,format=raw");
+    global_qtest = qtest_start(
+        "-device nec-usb-xhci,id=xhci"
+        " -drive id=drive0,if=none,file=null-co://,format=raw");
     ret = g_test_run();
     qtest_quit(global_qtest);

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 0dbed5a36a..0fe52428e6 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -644,14 +644,14 @@ static void test_migrate(void)
     test_server_listen(s);
     test_server_listen(dest);

-    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, "", ""));
+    s->qts = qtest_start(GET_QEMU_CMDE(s, 2, "", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));

-    dest->qts = qtest_init(GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri));
+    dest->qts = qtest_start(GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri));

     source = g_source_new(&test_migrate_source_funcs,
                           sizeof(TestMigrateSource));
@@ -746,7 +746,7 @@ static void test_reconnect_subprocess(void)
     TestServer *s = test_server_new("reconnect");

     g_thread_new("connect", connect_thread, s);
-    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));
+    s->qts = qtest_start(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -778,7 +778,7 @@ static void test_connect_fail_subprocess(void)

     s->test_fail = true;
     g_thread_new("connect", connect_thread, s);
-    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));
+    s->qts = qtest_start(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -802,7 +802,7 @@ static void test_flags_mismatch_subprocess(void)

     s->test_flags = TEST_FLAGS_DISCONNECT;
     g_thread_new("connect", connect_thread, s);
-    s->qts = qtest_init(GET_QEMU_CMDE(s, 2, ",server", ""));
+    s->qts = qtest_start(GET_QEMU_CMDE(s, 2, ",server", ""));

     init_virtio_dev(s);
     wait_for_fds(s);
@@ -866,11 +866,11 @@ static void test_multiqueue(void)
     s->queues = queues;
     test_server_listen(s);

-    s->qts = qtest_init(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
-                        "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
-                        512, 512, root, s->chr_name,
-                        s->socket_path, "", s->chr_name,
-                        queues, queues * 2 + 2);
+    s->qts = qtest_start(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d "
+                         "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d",
+                         512, 512, root, s->chr_name,
+                         s->socket_path, "", s->chr_name,
+                         queues, queues * 2 + 2);

     bus = qpci_init_pc(s->qts, NULL);
     dev = virtio_net_pci_init(bus, PCI_SLOT);
@@ -931,7 +931,7 @@ int main(int argc, char **argv)
     /* run the main loop thread so the chardev may operate */
     thread = g_thread_new(NULL, thread_function, loop);

-    server->qts = qtest_init(GET_QEMU_CMD(server));
+    server->qts = qtest_start(GET_QEMU_CMD(server));
     init_virtio_dev(server);

     qtest_add_data_func("/vhost-user/read-guest-mem", server, read_guest_mem);
diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c
index 7304392c17..cca7b0e8fb 100644
--- a/tests/virtio-balloon-test.c
+++ b/tests/virtio-balloon-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/virtio/balloon/pci/nop", pci_nop);

-    global_qtest = qtest_init("-device virtio-balloon-pci");
+    global_qtest = qtest_start("-device virtio-balloon-pci");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 063b0f4013..146e182ae9 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -88,10 +88,10 @@ static void arm_test_start(void)

     tmp_path = drive_create();

-    global_qtest = qtest_init("-machine virt "
-                              "-drive if=none,id=drive0,file=%s,format=raw "
-                              "-device virtio-blk-device,drive=drive0",
-                              tmp_path);
+    global_qtest = qtest_start("-machine virt "
+                               "-drive if=none,id=drive0,file=%s,format=raw "
+                               "-device virtio-blk-device,drive=drive0",
+                               tmp_path);
     unlink(tmp_path);
     g_free(tmp_path);
 }
diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c
index 73fb30b051..ce0da47b2d 100644
--- a/tests/virtio-console-test.c
+++ b/tests/virtio-console-test.c
@@ -13,15 +13,15 @@
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void console_pci_nop(void)
 {
-    global_qtest = qtest_init("-device virtio-serial-pci,id=vser0 "
-                "-device virtconsole,bus=vser0.0");
+    global_qtest = qtest_start("-device virtio-serial-pci,id=vser0 "
+                               "-device virtconsole,bus=vser0.0");
     qtest_quit(global_qtest);
 }

 static void serialport_pci_nop(void)
 {
-    global_qtest = qtest_init("-device virtio-serial-pci,id=vser0 "
-                "-device virtserialport,bus=vser0.0");
+    global_qtest = qtest_start("-device virtio-serial-pci,id=vser0 "
+                               "-device virtserialport,bus=vser0.0");
     qtest_quit(global_qtest);
 }

diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 9b32866fb1..13a4116d26 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -243,7 +243,7 @@ static void hotplug(void)
 {
     const char *arch = qtest_get_arch();

-    global_qtest = qtest_init("-device virtio-net-pci");
+    global_qtest = qtest_start("-device virtio-net-pci");

     qpci_plug_device_test("virtio-net-pci", "net1", PCI_SLOT_HP, NULL);

diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c
index e1b1e89b59..64b2bd4b19 100644
--- a/tests/virtio-rng-test.c
+++ b/tests/virtio-rng-test.c
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
     qtest_add_func("/virtio/rng/pci/nop", pci_nop);
     qtest_add_func("/virtio/rng/pci/hotplug", hotplug);

-    global_qtest = qtest_init("-device virtio-rng-pci");
+    global_qtest = qtest_start("-device virtio-rng-pci");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c
index ce708cc11e..1cc43465e6 100644
--- a/tests/virtio-serial-test.c
+++ b/tests/virtio-serial-test.c
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
     qtest_add_func("/virtio/serial/pci/nop", pci_nop);
     qtest_add_func("/virtio/serial/pci/hotplug", hotplug);

-    global_qtest = qtest_init("-device virtio-serial-pci");
+    global_qtest = qtest_start("-device virtio-serial-pci");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index b149690a1a..832c82c32f 100644
--- a/tests/vmgenid-test.c
+++ b/tests/vmgenid-test.c
@@ -142,7 +142,7 @@ static void vmgenid_set_guid_test(void)

     g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);

-    global_qtest = qtest_init(GUID_CMD(VGID_GUID));
+    global_qtest = qtest_start(GUID_CMD(VGID_GUID));

     /* Read the GUID from accessing guest memory */
     read_guid_from_memory(&measured);
@@ -155,7 +155,7 @@ static void vmgenid_set_guid_auto_test(void)
 {
     QemuUUID measured;

-    global_qtest = qtest_init(GUID_CMD("auto"));
+    global_qtest = qtest_start(GUID_CMD("auto"));

     read_guid_from_memory(&measured);

@@ -171,7 +171,7 @@ static void vmgenid_query_monitor_test(void)

     g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);

-    global_qtest = qtest_init(GUID_CMD(VGID_GUID));
+    global_qtest = qtest_start(GUID_CMD(VGID_GUID));

     /* Read the GUID via the monitor */
     read_guid_from_monitor(&measured);
diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c
index c9a876bcd9..0b4b807616 100644
--- a/tests/vmxnet3-test.c
+++ b/tests/vmxnet3-test.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/vmxnet3/nop", nop);

-    global_qtest = qtest_init("-device vmxnet3");
+    global_qtest = qtest_start("-device vmxnet3");
     ret = g_test_run();

     qtest_quit(global_qtest);
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
index 4bb8374011..a169265e16 100644
--- a/tests/wdt_ib700-test.c
+++ b/tests/wdt_ib700-test.c
@@ -56,7 +56,7 @@ static QDict *ib700_program_and_wait(QTestState *s)
 static void ib700_pause(void)
 {
     QDict *d;
-    QTestState *s = qtest_init("-watchdog-action pause -device ib700");
+    QTestState *s = qtest_start("-watchdog-action pause -device ib700");

     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
@@ -69,7 +69,7 @@ static void ib700_pause(void)
 static void ib700_reset(void)
 {
     QDict *d;
-    QTestState *s = qtest_init("-watchdog-action reset -device ib700");
+    QTestState *s = qtest_start("-watchdog-action reset -device ib700");

     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
@@ -84,7 +84,7 @@ static void ib700_shutdown(void)
     QDict *d;
     QTestState *s;

-    s = qtest_init("-watchdog-action reset -no-reboot -device ib700");
+    s = qtest_start("-watchdog-action reset -no-reboot -device ib700");
     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
     g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
@@ -96,7 +96,7 @@ static void ib700_shutdown(void)
 static void ib700_none(void)
 {
     QDict *d;
-    QTestState *s = qtest_init("-watchdog-action none -device ib700");
+    QTestState *s = qtest_start("-watchdog-action none -device ib700");

     qtest_irq_intercept_in(s, "ioapic");
     d = ib700_program_and_wait(s);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups
  2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
                   ` (28 preceding siblings ...)
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start() Eric Blake
@ 2017-09-01 18:31 ` no-reply
  2017-09-01 18:44   ` Eric Blake
  29 siblings, 1 reply; 99+ messages in thread
From: no-reply @ 2017-09-01 18:31 UTC (permalink / raw)
  To: eblake; +Cc: famz, qemu-devel, pbonzini, armbru

Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Message-id: 20170901180340.30009-1-eblake@redhat.com
Subject: [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
4b4cadba2b libqtest: Rename qtest_init() to qtest_start()
70d71c0ade libqtest: Remove qtest_start() and qtest_end() shortcuts
f8300a9efa libqtest: Make qtest_init() accept format string
05cc948a3a fw_cfg-test: Drop dependence on global_qtest
7416a005e6 wdt_ib700-test: Drop dependence on global_qtest
8a924203d4 bios-tables-test: Drop dependence on global_qtest
3389146c14 tests/acpi-utils: Drop dependence on global_qtest
e0f0b853d0 tests/boot-sector: Drop dependence on global_qtest
137719bb86 qmp-test: Drop dependence on global_qtest
37b6a30c1a vhost-user-test: Drop dependence on global_qtest
f286f58d36 postcopy-test: Drop dependence on global_qtest
32a12b51e9 ivshmem-test: Drop dependence on global_qtest
ffd602d50b ahci-test: Drop dependence on global_qtest
68f907dd01 libqos: Use explicit QTestState for virtio operations
6ad86de782 libqos: Use explicit QTestState for rtas operations
30fed12892 libqos: Use explicit QTestState for fw_cfg operations
e02f6045ad libqos: Use explicit QTestState for pci operations
90286a8350 libqos: Track QTestState with QPCIBus
485ea3c661 libqtest: Inline qtest_query_target_endianness()
24e0c69a42 libqtest: Topologically sort functions
9e897f1808 libqtest: Use qemu_strtoul()
30652df988 libqtest: Let socket_send() compute length
0c76269466 libqtest: Remove dead qtest_instances variable
a788ac0653 tests: Clean up wait for event
d3b51dbc07 numa-test: Use hmp()
bfe4814910 qtest: Don't perform side effects inside assertion
10817e054e test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code
2f5263cef9 tests: Sort .gitignore
14007faa85 tests: Improve .gitignore for tests/multiboot

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-13jkjuzx/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-13jkjuzx/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPY    RUNNER
    RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
bison-2.4.1-5.el6.x86_64
bzip2-devel-1.0.5-7.el6_0.x86_64
ccache-3.1.6-2.el6.x86_64
csnappy-devel-0-6.20150729gitd7bc683.el6.x86_64
flex-2.5.35-9.el6.x86_64
gcc-4.4.7-18.el6.x86_64
git-1.7.1-8.el6.x86_64
glib2-devel-2.28.8-9.el6.x86_64
libepoxy-devel-1.2-3.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
librdmacm-devel-1.0.21-0.el6.x86_64
lzo-devel-2.03-3.1.el6_5.1.x86_64
make-3.81-23.el6.x86_64
mesa-libEGL-devel-11.0.7-4.el6.x86_64
mesa-libgbm-devel-11.0.7-4.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
spice-glib-devel-0.26-8.el6.x86_64
spice-server-devel-0.12.4-16.el6.x86_64
tar-1.23-15.el6_8.x86_64
vte-devel-0.25.1-9.el6.x86_64
xen-devel-4.6.3-15.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=bison     bzip2-devel     ccache     csnappy-devel     flex     g++     gcc     git     glib2-devel     libepoxy-devel     libfdt-devel     librdmacm-devel     lzo-devel     make     mesa-libEGL-devel     mesa-libgbm-devel     pixman-devel     SDL-devel     spice-glib-devel     spice-server-devel     tar     vte-devel     xen-devel     zlib-devel
HOSTNAME=8329856ff088
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix    /var/tmp/qemu-build/install
BIOS directory    /var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /tmp/qemu-test/src
C compiler        cc
Host C compiler   cc
C++ compiler      
Objective-C compiler cc
ARFLAGS           rv
CFLAGS            -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS       -I/usr/include/pixman-1   -I$(SRC_PATH)/dtc/libfdt -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -DNCURSES_WIDECHAR   -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all  -I/usr/include/libpng12   -I/usr/include/libdrm     -I/usr/include/spice-server -I/usr/include/cacard -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/spice-1   -I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4  
LDFLAGS           -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make              make
install           install
python            python -B
smbd              /usr/sbin/smbd
module support    no
host CPU          x86_64
host big endian   no
target list       x86_64-softmmu aarch64-softmmu
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
pixman            system
SDL support       yes (1.2.14)
GTK support       yes (2.24.23)
GTK GL support    no
VTE support       yes (0.25.1)
TLS priority      NORMAL
GNUTLS support    no
GNUTLS rnd        no
libgcrypt         no
libgcrypt kdf     no
nettle            no 
nettle kdf        no
libtasn1          no
curses support    yes
virgl support     no
curl support      no
mingw32 support   no
Audio drivers     oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS support    no
VNC support       yes
VNC SASL support  no
VNC JPEG support  yes
VNC PNG support   yes
xen support       yes
xen ctrl version  40600
pv dom build      no
brlapi support    no
bluez  support    no
Documentation     no
PIE               yes
vde support       no
netmap support    no
Linux AIO support no
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
HAX support       no
TCG support       yes
TCG debug enabled no
TCG interpreter   no
RDMA support      yes
fdt support       yes
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
vhost-user support yes
Trace backends    log
spice support     yes (0.12.6/0.12.4)
rbd support       no
xfsctl support    no
smartcard support yes
libusb            no
usb net redir     no
OpenGL support    yes
OpenGL dmabufs    no
libiscsi support  no
libnfs support    no
build guest agent yes
QGA VSS support   no
QGA w32 disk info no
QGA MSI support   no
seccomp support   no
coroutine backend ucontext
coroutine pool    yes
debug stack usage no
crypto afalg      no
GlusterFS support no
gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
QOM debugging     yes
Live block migration yes
lzo support       yes
snappy support    no
bzip2 support     yes
NUMA host support no
tcmalloc support  no
jemalloc support  no
avx2 optimization no
replication support yes
VxHS block device no
mkdir -p dtc/libfdt
mkdir -p dtc/tests
  GEN     x86_64-softmmu/config-devices.mak.tmp
  GEN     aarch64-softmmu/config-devices.mak.tmp
  GEN     qemu-options.def
  GEN     config-host.h
  GEN     qapi-types.h
  GEN     qmp-commands.h
  GEN     qapi-visit.h
  GEN     qapi-event.h
  GEN     x86_64-softmmu/config-devices.mak
  GEN     aarch64-softmmu/config-devices.mak
  GEN     qmp-marshal.c
  GEN     qapi-types.c
  GEN     qapi-visit.c
  GEN     qapi-event.c
  GEN     qmp-introspect.h
  GEN     qmp-introspect.c
  GEN     trace/generated-tcg-tracers.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-helpers.h
  GEN     trace/generated-helpers.c
  GEN     module_block.h
  GEN     tests/test-qapi-types.h
  GEN     tests/test-qapi-visit.h
  GEN     tests/test-qmp-commands.h
  GEN     tests/test-qapi-event.h
  GEN     tests/test-qmp-introspect.h
  GEN     trace-root.h
  GEN     util/trace.h
  GEN     crypto/trace.h
  GEN     io/trace.h
  GEN     migration/trace.h
  GEN     block/trace.h
  GEN     chardev/trace.h
  GEN     hw/block/trace.h
  GEN     hw/block/dataplane/trace.h
  GEN     hw/char/trace.h
  GEN     hw/intc/trace.h
  GEN     hw/net/trace.h
  GEN     hw/virtio/trace.h
  GEN     hw/audio/trace.h
  GEN     hw/misc/trace.h
  GEN     hw/usb/trace.h
  GEN     hw/scsi/trace.h
  GEN     hw/nvram/trace.h
  GEN     hw/display/trace.h
  GEN     hw/input/trace.h
  GEN     hw/timer/trace.h
  GEN     hw/dma/trace.h
  GEN     hw/sparc/trace.h
  GEN     hw/sd/trace.h
  GEN     hw/isa/trace.h
  GEN     hw/mem/trace.h
  GEN     hw/i386/trace.h
  GEN     hw/i386/xen/trace.h
  GEN     hw/9pfs/trace.h
  GEN     hw/ppc/trace.h
  GEN     hw/pci/trace.h
  GEN     hw/s390x/trace.h
  GEN     hw/vfio/trace.h
  GEN     hw/acpi/trace.h
  GEN     hw/arm/trace.h
  GEN     hw/alpha/trace.h
  GEN     hw/xen/trace.h
  GEN     ui/trace.h
  GEN     audio/trace.h
  GEN     net/trace.h
  GEN     target/arm/trace.h
  GEN     target/i386/trace.h
  GEN     target/mips/trace.h
  GEN     target/sparc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/ppc/trace.h
  GEN     qom/trace.h
  GEN     linux-user/trace.h
  GEN     qapi/trace.h
  GEN     accel/tcg/trace.h
  GEN     accel/kvm/trace.h
  GEN     nbd/trace.h
  GEN     trace-root.c
  GEN     util/trace.c
  GEN     crypto/trace.c
  GEN     io/trace.c
  GEN     migration/trace.c
  GEN     block/trace.c
  GEN     chardev/trace.c
  GEN     hw/block/trace.c
  GEN     hw/block/dataplane/trace.c
  GEN     hw/char/trace.c
  GEN     hw/intc/trace.c
  GEN     hw/net/trace.c
  GEN     hw/virtio/trace.c
  GEN     hw/audio/trace.c
  GEN     hw/misc/trace.c
  GEN     hw/usb/trace.c
  GEN     hw/scsi/trace.c
  GEN     hw/nvram/trace.c
  GEN     hw/display/trace.c
  GEN     hw/input/trace.c
  GEN     hw/timer/trace.c
  GEN     hw/dma/trace.c
  GEN     hw/sparc/trace.c
  GEN     hw/sd/trace.c
  GEN     hw/isa/trace.c
  GEN     hw/mem/trace.c
  GEN     hw/i386/trace.c
  GEN     hw/i386/xen/trace.c
  GEN     hw/9pfs/trace.c
  GEN     hw/ppc/trace.c
  GEN     hw/pci/trace.c
  GEN     hw/s390x/trace.c
  GEN     hw/vfio/trace.c
  GEN     hw/acpi/trace.c
  GEN     hw/arm/trace.c
  GEN     hw/alpha/trace.c
  GEN     hw/xen/trace.c
  GEN     ui/trace.c
  GEN     audio/trace.c
  GEN     net/trace.c
  GEN     target/arm/trace.c
  GEN     target/i386/trace.c
  GEN     target/mips/trace.c
  GEN     target/sparc/trace.c
  GEN     target/s390x/trace.c
  GEN     target/ppc/trace.c
  GEN     qom/trace.c
  GEN     linux-user/trace.c
  GEN     qapi/trace.c
  GEN     accel/tcg/trace.c
  GEN     accel/kvm/trace.c
  GEN     nbd/trace.c
  GEN     config-all-devices.mak
	 DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
	 DEP /tmp/qemu-test/src/dtc/tests/trees.S
	 DEP /tmp/qemu-test/src/dtc/tests/testutils.c
	 DEP /tmp/qemu-test/src/dtc/tests/value-labels.c
	 DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.c
	 DEP /tmp/qemu-test/src/dtc/tests/truncated_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/check_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay_bad_fixup.c
	 DEP /tmp/qemu-test/src/dtc/tests/property_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/integer-expressions.c
	 DEP /tmp/qemu-test/src/dtc/tests/utilfdt_test.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset_aliases.c
	 DEP /tmp/qemu-test/src/dtc/tests/add_subnode_with_nops.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_unordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtb_reverse.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_ordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/extra-terminating-null.c
	 DEP /tmp/qemu-test/src/dtc/tests/incbin.c
	 DEP /tmp/qemu-test/src/dtc/tests/boot-cpuid.c
	 DEP /tmp/qemu-test/src/dtc/tests/phandle_format.c
	 DEP /tmp/qemu-test/src/dtc/tests/path-references.c
	 DEP /tmp/qemu-test/src/dtc/tests/references.c
	 DEP /tmp/qemu-test/src/dtc/tests/string_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/propname_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop2.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop1.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/set_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/rw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/open_pack.c
	 DEP /tmp/qemu-test/src/dtc/tests/mangle-layout.c
	 DEP /tmp/qemu-test/src/dtc/tests/nopulate.c
	 DEP /tmp/qemu-test/src/dtc/tests/move_and_save.c
	 DEP /tmp/qemu-test/src/dtc/tests/sw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.c
	 DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
	 DEP /tmp/qemu-test/src/dtc/tests/addr_size_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/notfound.c
	 DEP /tmp/qemu-test/src/dtc/tests/sized_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/char_literal.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_alias.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_check_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_prop_value.c
	 DEP /tmp/qemu-test/src/dtc/tests/parent_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/supernode_atdepth_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/getprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/find_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/root_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_mem_rsv.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_addresses.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_empty_tree.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_strerror.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_rw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_sw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_wip.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_ro.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt.c
	 DEP /tmp/qemu-test/src/dtc/fdtput.c
	 DEP /tmp/qemu-test/src/dtc/util.c
	 DEP /tmp/qemu-test/src/dtc/fdtget.c
	 DEP /tmp/qemu-test/src/dtc/fdtdump.c
	 LEX convert-dtsv0-lexer.lex.c
	 DEP /tmp/qemu-test/src/dtc/srcpos.c
	 BISON dtc-parser.tab.c
	 LEX dtc-lexer.lex.c
	 DEP /tmp/qemu-test/src/dtc/treesource.c
	 DEP /tmp/qemu-test/src/dtc/livetree.c
	 DEP /tmp/qemu-test/src/dtc/fstree.c
	 DEP /tmp/qemu-test/src/dtc/flattree.c
	 DEP /tmp/qemu-test/src/dtc/dtc.c
	 DEP /tmp/qemu-test/src/dtc/data.c
	 DEP /tmp/qemu-test/src/dtc/checks.c
	 DEP convert-dtsv0-lexer.lex.c
	 DEP dtc-lexer.lex.c
	 DEP dtc-parser.tab.c
	CHK version_gen.h
	UPD version_gen.h
	 DEP /tmp/qemu-test/src/dtc/util.c
	 CC libfdt/fdt.o
	 CC libfdt/fdt_ro.o
	 CC libfdt/fdt_rw.o
	 CC libfdt/fdt_wip.o
	 CC libfdt/fdt_strerror.o
	 CC libfdt/fdt_empty_tree.o
	 CC libfdt/fdt_addresses.o
	 CC libfdt/fdt_sw.o
	 CC libfdt/fdt_overlay.o
	 AR libfdt/libfdt.a
ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
  CC      tests/qemu-iotests/socket_scm_helper.o
  GEN     qga/qapi-generated/qga-qapi-types.h
  GEN     qga/qapi-generated/qga-qapi-visit.h
  GEN     qga/qapi-generated/qga-qmp-commands.h
  CC      qmp-introspect.o
  GEN     qga/qapi-generated/qga-qapi-visit.c
  GEN     qga/qapi-generated/qga-qmp-marshal.c
  GEN     qga/qapi-generated/qga-qapi-types.c
  CC      qapi-types.o
  CC      qapi-visit.o
  CC      qapi-event.o
  CC      qapi/qapi-visit-core.o
  CC      qapi/qapi-dealloc-visitor.o
  CC      qapi/qobject-input-visitor.o
  CC      qapi/qobject-output-visitor.o
  CC      qapi/qmp-registry.o
  CC      qapi/qmp-dispatch.o
  CC      qapi/string-input-visitor.o
  CC      qapi/string-output-visitor.o
  CC      qapi/opts-visitor.o
  CC      qapi/qapi-clone-visitor.o
  CC      qapi/qmp-event.o
  CC      qapi/qapi-util.o
  CC      qobject/qnull.o
  CC      qobject/qnum.o
  CC      qobject/qstring.o
  CC      qobject/qdict.o
  CC      qobject/qlist.o
  CC      qobject/qbool.o
  CC      qobject/qobject.o
  CC      qobject/json-lexer.o
  CC      qobject/qjson.o
  CC      qobject/json-streamer.o
  CC      qobject/json-parser.o
  CC      trace/control.o
  CC      trace/qmp.o
  CC      util/osdep.o
  CC      util/cutils.o
  CC      util/unicode.o
  CC      util/qemu-timer-common.o
  CC      util/bufferiszero.o
  CC      util/lockcnt.o
  CC      util/aiocb.o
  CC      util/async.o
  CC      util/thread-pool.o
  CC      util/qemu-timer.o
  CC      util/main-loop.o
  CC      util/iohandler.o
  CC      util/compatfd.o
  CC      util/event_notifier-posix.o
  CC      util/aio-posix.o
  CC      util/mmap-alloc.o
  CC      util/oslib-posix.o
  CC      util/qemu-openpty.o
  CC      util/qemu-thread-posix.o
  CC      util/memfd.o
  CC      util/envlist.o
  CC      util/path.o
  CC      util/module.o
  CC      util/host-utils.o
  CC      util/bitmap.o
  CC      util/bitops.o
  CC      util/hbitmap.o
  CC      util/fifo8.o
  CC      util/acl.o
  CC      util/cacheinfo.o
  CC      util/error.o
  CC      util/qemu-error.o
  CC      util/iov.o
  CC      util/id.o
  CC      util/qemu-sockets.o
  CC      util/uri.o
  CC      util/qemu-config.o
  CC      util/notify.o
  CC      util/qemu-option.o
  CC      util/qemu-progress.o
  CC      util/keyval.o
  CC      util/hexdump.o
  CC      util/crc32c.o
  CC      util/uuid.o
  CC      util/throttle.o
  CC      util/getauxval.o
  CC      util/readline.o
  CC      util/rcu.o
  CC      util/qemu-coroutine.o
  CC      util/qemu-coroutine-lock.o
  CC      util/qemu-coroutine-io.o
  CC      util/qemu-coroutine-sleep.o
  CC      util/coroutine-ucontext.o
  CC      util/buffer.o
  CC      util/timed-average.o
  CC      util/base64.o
  CC      util/log.o
  CC      util/qdist.o
  CC      util/qht.o
  CC      util/range.o
  CC      util/stats64.o
  CC      trace-root.o
  CC      util/systemd.o
  CC      util/trace.o
  CC      crypto/trace.o
  CC      io/trace.o
  CC      migration/trace.o
  CC      block/trace.o
  CC      chardev/trace.o
  CC      hw/block/trace.o
  CC      hw/block/dataplane/trace.o
  CC      hw/char/trace.o
  CC      hw/intc/trace.o
  CC      hw/net/trace.o
  CC      hw/virtio/trace.o
  CC      hw/audio/trace.o
  CC      hw/misc/trace.o
  CC      hw/usb/trace.o
  CC      hw/scsi/trace.o
  CC      hw/display/trace.o
  CC      hw/nvram/trace.o
  CC      hw/input/trace.o
  CC      hw/dma/trace.o
  CC      hw/timer/trace.o
  CC      hw/sparc/trace.o
  CC      hw/isa/trace.o
  CC      hw/sd/trace.o
  CC      hw/mem/trace.o
  CC      hw/i386/trace.o
  CC      hw/i386/xen/trace.o
  CC      hw/9pfs/trace.o
  CC      hw/ppc/trace.o
  CC      hw/pci/trace.o
  CC      hw/s390x/trace.o
  CC      hw/vfio/trace.o
  CC      hw/acpi/trace.o
  CC      hw/arm/trace.o
  CC      ui/trace.o
  CC      hw/alpha/trace.o
  CC      hw/xen/trace.o
  CC      net/trace.o
  CC      target/arm/trace.o
  CC      audio/trace.o
  CC      target/i386/trace.o
  CC      target/sparc/trace.o
  CC      target/mips/trace.o
  CC      target/s390x/trace.o
  CC      target/ppc/trace.o
  CC      qom/trace.o
  CC      linux-user/trace.o
  CC      qapi/trace.o
  CC      accel/tcg/trace.o
  CC      accel/kvm/trace.o
  CC      nbd/trace.o
  CC      crypto/pbkdf-stub.o
  CC      stubs/arch-query-cpu-def.o
  CC      stubs/arch-query-cpu-model-expansion.o
  CC      stubs/arch-query-cpu-model-comparison.o
  CC      stubs/arch-query-cpu-model-baseline.o
  CC      stubs/bdrv-next-monitor-owned.o
  CC      stubs/blk-commit-all.o
  CC      stubs/blockdev-close-all-bdrv-states.o
  CC      stubs/cpu-get-clock.o
  CC      stubs/clock-warp.o
  CC      stubs/cpu-get-icount.o
  CC      stubs/error-printf.o
  CC      stubs/fdset.o
  CC      stubs/dump.o
  CC      stubs/get-vm-name.o
  CC      stubs/gdbstub.o
  CC      stubs/iothread-lock.o
  CC      stubs/iothread.o
  CC      stubs/is-daemonized.o
  CC      stubs/machine-init-done.o
  CC      stubs/migr-blocker.o
  CC      stubs/change-state-handler.o
  CC      stubs/monitor.o
  CC      stubs/notify-event.o
  CC      stubs/qtest.o
  CC      stubs/replay.o
  CC      stubs/runstate-check.o
  CC      stubs/set-fd-handler.o
  CC      stubs/slirp.o
  CC      stubs/sysbus.o
  CC      stubs/trace-control.o
  CC      stubs/uuid.o
  CC      stubs/vm-stop.o
  CC      stubs/qmp_pc_dimm_device_list.o
  CC      stubs/vmstate.o
  CC      stubs/target-get-monitor-def.o
  CC      stubs/target-monitor-defs.o
  CC      stubs/pc_madt_cpu_entry.o
  CC      stubs/vmgenid.o
  CC      stubs/xen-common.o
  CC      stubs/xen-hvm.o
  CC      contrib/ivshmem-client/ivshmem-client.o
  CC      contrib/ivshmem-client/main.o
  CC      contrib/ivshmem-server/ivshmem-server.o
  CC      contrib/ivshmem-server/main.o
  CC      qemu-nbd.o
  CC      block.o
  CC      blockjob.o
  CC      qemu-io-cmds.o
  CC      block/raw-format.o
  CC      block/qcow.o
  CC      replication.o
  CC      block/vdi.o
  CC      block/vmdk.o
  CC      block/cloop.o
  CC      block/bochs.o
  CC      block/vpc.o
  CC      block/vvfat.o
  CC      block/dmg.o
  CC      block/qcow2.o
  CC      block/qcow2-refcount.o
  CC      block/qcow2-cluster.o
  CC      block/qcow2-snapshot.o
  CC      block/qcow2-cache.o
  CC      block/qed.o
  CC      block/qed-l2-cache.o
  CC      block/qed-table.o
  CC      block/qcow2-bitmap.o
  CC      block/qed-cluster.o
  CC      block/qed-check.o
  CC      block/vhdx.o
  CC      block/vhdx-endian.o
  CC      block/vhdx-log.o
  CC      block/quorum.o
  CC      block/parallels.o
  CC      block/blkdebug.o
  CC      block/blkverify.o
  CC      block/blkreplay.o
  CC      block/snapshot.o
  CC      block/block-backend.o
  CC      block/qapi.o
  CC      block/file-posix.o
  CC      block/null.o
  CC      block/mirror.o
  CC      block/commit.o
  CC      block/io.o
  CC      block/throttle-groups.o
  CC      block/nbd.o
  CC      block/nbd-client.o
  CC      block/sheepdog.o
  CC      block/accounting.o
  CC      block/write-threshold.o
  CC      block/dirty-bitmap.o
  CC      block/backup.o
  CC      block/replication.o
  CC      block/crypto.o
  CC      nbd/server.o
  CC      nbd/client.o
  CC      nbd/common.o
  CC      block/dmg-bz2.o
  CC      crypto/init.o
  CC      crypto/hash.o
  CC      crypto/hash-glib.o
  CC      crypto/hmac.o
  CC      crypto/hmac-glib.o
  CC      crypto/aes.o
  CC      crypto/desrfb.o
  CC      crypto/cipher.o
  CC      crypto/tlscreds.o
  CC      crypto/tlscredsanon.o
  CC      crypto/tlscredsx509.o
  CC      crypto/tlssession.o
  CC      crypto/secret.o
  CC      crypto/random-platform.o
  CC      crypto/pbkdf.o
  CC      crypto/ivgen.o
  CC      crypto/ivgen-essiv.o
  CC      crypto/ivgen-plain.o
  CC      crypto/ivgen-plain64.o
  CC      crypto/afsplit.o
  CC      crypto/xts.o
  CC      crypto/block.o
  CC      crypto/block-qcow.o
  CC      crypto/block-luks.o
  CC      io/channel-buffer.o
  CC      io/channel.o
  CC      io/channel-command.o
  CC      io/channel-file.o
  CC      io/channel-socket.o
  CC      io/channel-tls.o
  CC      io/channel-watch.o
  CC      io/channel-websock.o
  CC      io/channel-util.o
  CC      io/dns-resolver.o
  CC      io/task.o
  CC      qom/object.o
  CC      qom/container.o
  CC      qom/qom-qobject.o
  CC      qom/object_interfaces.o
  GEN     qemu-img-cmds.h
  CC      qemu-bridge-helper.o
  CC      qemu-io.o
  CC      blockdev.o
  CC      blockdev-nbd.o
  CC      bootdevice.o
  CC      iothread.o
  CC      qdev-monitor.o
  CC      os-posix.o
  CC      device-hotplug.o
  CC      bt-host.o
  CC      bt-vhci.o
  CC      dma-helpers.o
  CC      vl.o
  CC      tpm.o
  CC      qmp-marshal.o
  CC      device_tree.o
  CC      qmp.o
  CC      cpus-common.o
  CC      hmp.o
  CC      audio/audio.o
  CC      audio/noaudio.o
  CC      audio/wavaudio.o
  CC      audio/mixeng.o
  CC      audio/sdlaudio.o
  CC      audio/ossaudio.o
  CC      audio/spiceaudio.o
  CC      audio/wavcapture.o
  CC      backends/rng.o
  CC      backends/rng-egd.o
  CC      backends/rng-random.o
  CC      backends/tpm.o
  CC      backends/hostmem.o
  CC      backends/hostmem-ram.o
  CC      backends/hostmem-file.o
  CC      backends/cryptodev.o
  CC      block/stream.o
  CC      backends/cryptodev-builtin.o
  CC      chardev/msmouse.o
  CC      chardev/wctablet.o
  CC      chardev/testdev.o
  CC      chardev/spice.o
  CC      disas/arm.o
  CC      disas/i386.o
  CC      fsdev/qemu-fsdev-dummy.o
  CC      fsdev/qemu-fsdev-opts.o
  CC      fsdev/qemu-fsdev-throttle.o
  CC      hw/acpi/core.o
  CC      hw/acpi/piix4.o
  CC      hw/acpi/pcihp.o
  CC      hw/acpi/ich9.o
  CC      hw/acpi/tco.o
  CC      hw/acpi/cpu_hotplug.o
  CC      hw/acpi/memory_hotplug.o
  CC      hw/acpi/cpu.o
  CC      hw/acpi/nvdimm.o
  CC      hw/acpi/vmgenid.o
  CC      hw/acpi/acpi_interface.o
  CC      hw/acpi/bios-linker-loader.o
  CC      hw/acpi/aml-build.o
  CC      hw/acpi/ipmi.o
  CC      hw/acpi/ipmi-stub.o
  CC      hw/audio/sb16.o
  CC      hw/acpi/acpi-stub.o
  CC      hw/audio/es1370.o
  CC      hw/audio/ac97.o
  CC      hw/audio/fmopl.o
  CC      hw/audio/adlib.o
  CC      hw/audio/gus.o
  CC      hw/audio/gusemu_hal.o
  CC      hw/audio/gusemu_mixer.o
  CC      hw/audio/cs4231a.o
  CC      hw/audio/intel-hda.o
  CC      hw/audio/hda-codec.o
  CC      hw/audio/pcspk.o
  CC      hw/audio/wm8750.o
  CC      hw/audio/pl041.o
  CC      hw/audio/lm4549.o
  CC      hw/audio/marvell_88w8618.o
  CC      hw/audio/soundhw.o
  CC      hw/block/block.o
  CC      hw/block/cdrom.o
  CC      hw/block/hd-geometry.o
  CC      hw/block/fdc.o
  CC      hw/block/m25p80.o
  CC      hw/block/nand.o
  CC      hw/block/pflash_cfi01.o
  CC      hw/block/pflash_cfi02.o
  CC      hw/block/xen_disk.o
  CC      hw/block/ecc.o
  CC      hw/block/onenand.o
  CC      hw/block/nvme.o
  CC      hw/bt/core.o
  CC      hw/bt/l2cap.o
  CC      hw/bt/hci.o
  CC      hw/bt/sdp.o
  CC      hw/bt/hid.o
  CC      hw/bt/hci-csr.o
  CC      hw/char/ipoctal232.o
  CC      hw/char/parallel.o
  CC      hw/char/pl011.o
  CC      hw/char/serial.o
  CC      hw/char/serial-isa.o
  CC      hw/char/serial-pci.o
  CC      hw/char/virtio-console.o
  CC      hw/char/xen_console.o
  CC      hw/char/cadence_uart.o
  CC      hw/char/cmsdk-apb-uart.o
  CC      hw/char/debugcon.o
  CC      hw/char/imx_serial.o
  CC      hw/core/qdev-properties.o
  CC      hw/core/reset.o
  CC      hw/core/qdev.o
  CC      hw/core/bus.o
  CC      hw/core/fw-path-provider.o
  CC      hw/core/irq.o
  CC      hw/core/nmi.o
  CC      hw/core/hotplug.o
  CC      hw/core/ptimer.o
  CC      hw/core/sysbus.o
  CC      hw/core/machine.o
  CC      hw/core/loader.o
  CC      hw/core/or-irq.o
  CC      hw/core/qdev-properties-system.o
  CC      hw/core/register.o
  CC      hw/core/platform-bus.o
  CC      hw/display/ads7846.o
  CC      hw/cpu/core.o
  CC      hw/display/cirrus_vga.o
  CC      hw/display/pl110.o
  CC      hw/display/ssd0303.o
  CC      hw/display/ssd0323.o
  CC      hw/display/xenfb.o
  CC      hw/display/vga-pci.o
  CC      hw/display/vga-isa.o
  CC      hw/display/vmware_vga.o
  CC      hw/display/blizzard.o
  CC      hw/display/exynos4210_fimd.o
  CC      hw/display/qxl.o
  CC      hw/display/qxl-logger.o
  CC      hw/display/tc6393xb.o
  CC      hw/display/framebuffer.o
  CC      hw/display/qxl-render.o
  CC      hw/dma/pl080.o
  CC      hw/dma/pl330.o
  CC      hw/dma/i8257.o
  CC      hw/dma/xlnx-zynq-devcfg.o
  CC      hw/gpio/max7310.o
  CC      hw/gpio/pl061.o
  CC      hw/gpio/gpio_key.o
  CC      hw/gpio/zaurus.o
  CC      hw/i2c/core.o
  CC      hw/i2c/smbus.o
  CC      hw/i2c/i2c-ddc.o
  CC      hw/i2c/smbus_eeprom.o
  CC      hw/i2c/versatile_i2c.o
  CC      hw/i2c/smbus_ich9.o
  CC      hw/i2c/pm_smbus.o
  CC      hw/i2c/bitbang_i2c.o
  CC      hw/i2c/exynos4210_i2c.o
  CC      hw/i2c/imx_i2c.o
  CC      hw/i2c/aspeed_i2c.o
  CC      hw/ide/core.o
  CC      hw/ide/qdev.o
  CC      hw/ide/atapi.o
  CC      hw/ide/pci.o
  CC      hw/ide/microdrive.o
  CC      hw/ide/piix.o
  CC      hw/ide/isa.o
  CC      hw/ide/ahci.o
  CC      hw/ide/ich.o
  CC      hw/input/hid.o
  CC      hw/input/lm832x.o
  CC      hw/input/pckbd.o
  CC      hw/input/pl050.o
  CC      hw/input/ps2.o
  CC      hw/input/stellaris_input.o
  CC      hw/input/tsc2005.o
  CC      hw/input/virtio-input.o
  CC      hw/input/vmmouse.o
  CC      hw/input/virtio-input-hid.o
  CC      hw/input/virtio-input-host.o
  CC      hw/intc/i8259_common.o
  CC      hw/intc/pl190.o
  CC      hw/intc/i8259.o
  CC      hw/intc/imx_avic.o
  CC      hw/intc/realview_gic.o
  CC      hw/intc/ioapic_common.o
  CC      hw/intc/arm_gic_common.o
  CC      hw/intc/arm_gicv2m.o
  CC      hw/intc/arm_gic.o
  CC      hw/intc/arm_gicv3_common.o
  CC      hw/intc/arm_gicv3_dist.o
  CC      hw/intc/arm_gicv3.o
  CC      hw/intc/intc.o
  CC      hw/intc/arm_gicv3_redist.o
  CC      hw/ipack/ipack.o
  CC      hw/intc/arm_gicv3_its_common.o
  CC      hw/ipack/tpci200.o
  CC      hw/ipmi/ipmi.o
  CC      hw/ipmi/ipmi_bmc_sim.o
  CC      hw/ipmi/ipmi_bmc_extern.o
  CC      hw/ipmi/isa_ipmi_bt.o
  CC      hw/isa/isa-bus.o
  CC      hw/ipmi/isa_ipmi_kcs.o
  CC      hw/isa/apm.o
  CC      hw/mem/pc-dimm.o
  CC      hw/mem/nvdimm.o
  CC      hw/misc/applesmc.o
  CC      hw/misc/max111x.o
  CC      hw/misc/tmp105.o
  CC      hw/misc/tmp421.o
  CC      hw/misc/sga.o
  CC      hw/misc/debugexit.o
  CC      hw/misc/pc-testdev.o
  CC      hw/misc/pci-testdev.o
  CC      hw/misc/edu.o
  CC      hw/misc/unimp.o
  CC      hw/misc/arm_l2x0.o
  CC      hw/misc/arm_integrator_debug.o
  CC      hw/misc/a9scu.o
  CC      hw/net/ne2000.o
  CC      hw/misc/arm11scu.o
  CC      hw/net/xen_nic.o
  CC      hw/net/pcnet-pci.o
  CC      hw/net/eepro100.o
  CC      hw/net/pcnet.o
  CC      hw/net/e1000.o
  CC      hw/net/e1000x_common.o
  CC      hw/net/net_tx_pkt.o
  CC      hw/net/net_rx_pkt.o
  CC      hw/net/e1000e.o
  CC      hw/net/rtl8139.o
  CC      hw/net/e1000e_core.o
  CC      hw/net/smc91c111.o
  CC      hw/net/vmxnet3.o
  CC      hw/net/lan9118.o
  CC      hw/net/ne2000-isa.o
  CC      hw/net/xgmac.o
  CC      hw/net/allwinner_emac.o
  CC      hw/net/imx_fec.o
  CC      hw/net/cadence_gem.o
  CC      hw/net/stellaris_enet.o
  CC      hw/net/rocker/rocker.o
  CC      hw/net/ftgmac100.o
  CC      hw/net/rocker/rocker_fp.o
  CC      hw/net/rocker/rocker_desc.o
  CC      hw/net/rocker/rocker_world.o
  CC      hw/net/rocker/rocker_of_dpa.o
  CC      hw/nvram/eeprom93xx.o
  CC      hw/nvram/fw_cfg.o
  CC      hw/nvram/chrp_nvram.o
  CC      hw/pci-bridge/pci_bridge_dev.o
  CC      hw/pci-bridge/gen_pcie_root_port.o
  CC      hw/pci-bridge/pcie_root_port.o
  CC      hw/pci-bridge/pci_expander_bridge.o
  CC      hw/pci-bridge/xio3130_upstream.o
  CC      hw/pci-bridge/ioh3420.o
  CC      hw/pci-bridge/xio3130_downstream.o
  CC      hw/pci-bridge/i82801b11.o
  CC      hw/pci-host/pam.o
  CC      hw/pci-host/versatile.o
  CC      hw/pci-host/piix.o
  CC      hw/pci-host/q35.o
  CC      hw/pci/pci.o
  CC      hw/pci/pci_bridge.o
  CC      hw/pci/msix.o
  CC      hw/pci-host/gpex.o
  CC      hw/pci/msi.o
  CC      hw/pci/shpc.o
  CC      hw/pci/slotid_cap.o
  CC      hw/pci/pci_host.o
  CC      hw/pci/pcie_host.o
  CC      hw/pci/pcie.o
  CC      hw/pci/pcie_aer.o
  CC      hw/pci/pcie_port.o
  CC      hw/pci/pci-stub.o
  CC      hw/pcmcia/pcmcia.o
  CC      hw/scsi/scsi-disk.o
  CC      hw/scsi/scsi-generic.o
  CC      hw/scsi/scsi-bus.o
  CC      hw/scsi/lsi53c895a.o
  CC      hw/scsi/mptsas.o
  CC      hw/scsi/mptconfig.o
  CC      hw/scsi/mptendian.o
  CC      hw/scsi/megasas.o
  CC      hw/scsi/vmw_pvscsi.o
  CC      hw/scsi/esp.o
  CC      hw/scsi/esp-pci.o
  CC      hw/sd/pl181.o
  CC      hw/sd/ssi-sd.o
  CC      hw/sd/sd.o
  CC      hw/sd/core.o
  CC      hw/sd/sdhci.o
  CC      hw/smbios/smbios.o
  CC      hw/smbios/smbios_type_38.o
  CC      hw/smbios/smbios-stub.o
  CC      hw/smbios/smbios_type_38-stub.o
  CC      hw/ssi/pl022.o
  CC      hw/ssi/ssi.o
  CC      hw/ssi/xilinx_spips.o
  CC      hw/ssi/aspeed_smc.o
  CC      hw/ssi/stm32f2xx_spi.o
  CC      hw/timer/arm_timer.o
  CC      hw/timer/arm_mptimer.o
  CC      hw/timer/armv7m_systick.o
  CC      hw/timer/a9gtimer.o
  CC      hw/timer/cadence_ttc.o
  CC      hw/timer/ds1338.o
  CC      hw/timer/hpet.o
  CC      hw/timer/i8254.o
  CC      hw/timer/i8254_common.o
  CC      hw/timer/pl031.o
  CC      hw/timer/twl92230.o
  CC      hw/timer/imx_epit.o
  CC      hw/timer/imx_gpt.o
  CC      hw/timer/stm32f2xx_timer.o
  CC      hw/timer/aspeed_timer.o
  CC      hw/tpm/tpm_tis.o
  CC      hw/timer/cmsdk-apb-timer.o
  CC      hw/tpm/tpm_passthrough.o
  CC      hw/tpm/tpm_util.o
  CC      hw/usb/core.o
  CC      hw/usb/combined-packet.o
  CC      hw/usb/libhw.o
  CC      hw/usb/bus.o
  CC      hw/usb/desc.o
  CC      hw/usb/desc-msos.o
  CC      hw/usb/hcd-uhci.o
  CC      hw/usb/hcd-ohci.o
  CC      hw/usb/hcd-ehci-pci.o
  CC      hw/usb/hcd-ehci.o
  CC      hw/usb/hcd-ehci-sysbus.o
  CC      hw/usb/hcd-xhci.o
  CC      hw/usb/hcd-xhci-nec.o
  CC      hw/usb/hcd-musb.o
  CC      hw/usb/dev-hub.o
  CC      hw/usb/dev-hid.o
  CC      hw/usb/dev-wacom.o
  CC      hw/usb/dev-storage.o
  CC      hw/usb/dev-uas.o
  CC      hw/usb/dev-audio.o
  CC      hw/usb/dev-serial.o
  CC      hw/usb/dev-network.o
  CC      hw/usb/dev-bluetooth.o
  CC      hw/usb/dev-smartcard-reader.o
  CC      hw/usb/ccid-card-passthru.o
  CC      hw/usb/dev-mtp.o
  CC      hw/usb/ccid-card-emulated.o
  CC      hw/usb/host-stub.o
  CC      hw/virtio/virtio-rng.o
  CC      hw/virtio/virtio-pci.o
  CC      hw/virtio/virtio-bus.o
  CC      hw/virtio/vhost-stub.o
  CC      hw/virtio/virtio-mmio.o
  CC      hw/watchdog/wdt_i6300esb.o
  CC      hw/watchdog/watchdog.o
  CC      hw/watchdog/wdt_ib700.o
  CC      hw/xen/xen_backend.o
  CC      hw/xen/xen_devconfig.o
  CC      hw/xen/xen-common.o
  CC      hw/xen/xen_pvdev.o
  CC      hw/watchdog/wdt_aspeed.o
  CC      migration/migration.o
  CC      migration/socket.o
  CC      migration/exec.o
  CC      migration/fd.o
  CC      migration/tls.o
  CC      migration/channel.o
  CC      migration/savevm.o
  CC      migration/colo-comm.o
  CC      migration/colo.o
  CC      migration/colo-failover.o
  CC      migration/vmstate.o
  CC      migration/vmstate-types.o
  CC      migration/page_cache.o
  CC      migration/qemu-file.o
  CC      migration/global_state.o
  CC      migration/qemu-file-channel.o
  CC      migration/xbzrle.o
  CC      migration/postcopy-ram.o
  CC      migration/qjson.o
  CC      migration/block.o
  CC      migration/rdma.o
  CC      net/net.o
  CC      net/queue.o
  CC      net/checksum.o
  CC      net/util.o
  CC      net/hub.o
  CC      net/socket.o
  CC      net/eth.o
  CC      net/dump.o
  CC      net/l2tpv3.o
  CC      net/slirp.o
  CC      net/vhost-user.o
  CC      net/filter.o
  CC      net/filter-buffer.o
  CC      net/filter-mirror.o
  CC      net/colo-compare.o
  CC      net/colo.o
  CC      net/filter-rewriter.o
  CC      net/filter-replay.o
  CC      net/tap.o
  CC      net/tap-linux.o
  CC      qom/cpu.o
  CC      replay/replay.o
  CC      replay/replay-internal.o
  CC      replay/replay-events.o
  CC      replay/replay-time.o
  CC      replay/replay-input.o
  CC      replay/replay-char.o
  CC      replay/replay-snapshot.o
  CC      replay/replay-net.o
  CC      replay/replay-audio.o
/tmp/qemu-test/src/replay/replay-internal.c: In function ‘replay_put_array’:
/tmp/qemu-test/src/replay/replay-internal.c:65: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
  CC      slirp/cksum.o
  CC      slirp/if.o
  CC      slirp/ip_icmp.o
  CC      slirp/ip6_icmp.o
  CC      slirp/ip6_input.o
  CC      slirp/ip6_output.o
  CC      slirp/ip_input.o
  CC      slirp/ip_output.o
  CC      slirp/dnssearch.o
  CC      slirp/dhcpv6.o
  CC      slirp/slirp.o
  CC      slirp/mbuf.o
  CC      slirp/misc.o
  CC      slirp/sbuf.o
  CC      slirp/socket.o
  CC      slirp/tcp_input.o
  CC      slirp/tcp_output.o
  CC      slirp/tcp_subr.o
  CC      slirp/tcp_timer.o
  CC      slirp/udp.o
  CC      slirp/udp6.o
  CC      slirp/bootp.o
  CC      slirp/tftp.o
  CC      slirp/arp_table.o
/tmp/qemu-test/src/slirp/tcp_input.c: In function ‘tcp_input’:
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_p’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_len’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_tos’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_id’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_off’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_ttl’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_sum’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_src.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_dst.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:220: warning: ‘save_ip6.ip_nh’ may be used uninitialized in this function
  CC      slirp/ndp_table.o
  CC      slirp/ncsi.o
  CC      ui/keymaps.o
  CC      ui/console.o
  CC      ui/cursor.o
  CC      ui/qemu-pixman.o
  CC      ui/input.o
  CC      ui/input-keymap.o
  CC      ui/input-legacy.o
  CC      ui/input-linux.o
  CC      ui/spice-core.o
  CC      ui/spice-input.o
  CC      ui/spice-display.o
  CC      ui/sdl.o
  CC      ui/sdl_zoom.o
  CC      ui/x_keymap.o
  CC      ui/curses.o
  CC      ui/vnc.o
  CC      ui/vnc-enc-hextile.o
  CC      ui/vnc-enc-zlib.o
  CC      ui/vnc-palette.o
  CC      ui/vnc-enc-tight.o
  CC      ui/vnc-enc-zrle.o
  CC      ui/vnc-auth-vencrypt.o
  CC      ui/vnc-ws.o
  CC      ui/vnc-jobs.o
  CC      ui/gtk.o
  CC      ui/shader.o
  VERT    ui/shader/texture-blit-vert.h
  FRAG    ui/shader/texture-blit-frag.h
  CC      ui/egl-helpers.o
  CC      ui/egl-context.o
  CC      chardev/char.o
  CC      ui/gtk-egl.o
  CC      chardev/char-fd.o
  CC      chardev/char-fe.o
  CC      chardev/char-file.o
  CC      chardev/char-io.o
  CC      chardev/char-mux.o
  CC      chardev/char-null.o
  CC      chardev/char-parallel.o
  CC      chardev/char-pipe.o
  CC      chardev/char-pty.o
  CC      chardev/char-ringbuf.o
  CC      chardev/char-serial.o
  CC      chardev/char-socket.o
  CC      chardev/char-stdio.o
In file included from /usr/include/gtk-2.0/gtk/gtk.h:235,
                 from /tmp/qemu-test/src/include/ui/gtk.h:10,
                 from /tmp/qemu-test/src/ui/gtk.c:43:
/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47: warning: function declaration isn’t a prototype
  CC      chardev/char-udp.o
In file included from /usr/include/gtk-2.0/gtk/gtk.h:235,
                 from /tmp/qemu-test/src/include/ui/gtk.h:10,
                 from /tmp/qemu-test/src/ui/gtk-egl.c:21:
/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47: warning: function declaration isn’t a prototype
  LINK    tests/qemu-iotests/socket_scm_helper
  CC      qga/commands.o
  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
  CC      qga/commands-posix.o
  CC      qga/channel-posix.o
  CC      qga/qapi-generated/qga-qapi-types.o
  CC      qga/qapi-generated/qga-qapi-visit.o
  CC      qga/qapi-generated/qga-qmp-marshal.o
  AR      libqemuutil.a
  AR      libqemustub.a
  CC      qemu-img.o
  CC      ui/console-gl.o
  AS      optionrom/multiboot.o
  CC      optionrom/linuxboot_dma.o
  AS      optionrom/linuxboot.o
cc: unrecognized option '-no-integrated-as'
cc: unrecognized option '-no-integrated-as'
  AS      optionrom/kvmvapic.o
  LINK    qemu-ga
  BUILD   optionrom/linuxboot_dma.img
  BUILD   optionrom/linuxboot_dma.raw
  SIGN    optionrom/linuxboot_dma.bin
  BUILD   optionrom/multiboot.img
  BUILD   optionrom/linuxboot.img
  BUILD   optionrom/kvmvapic.img
  BUILD   optionrom/multiboot.raw
  BUILD   optionrom/linuxboot.raw
  BUILD   optionrom/kvmvapic.raw
  SIGN    optionrom/multiboot.bin
  SIGN    optionrom/linuxboot.bin
  SIGN    optionrom/kvmvapic.bin
  LINK    ivshmem-client
  LINK    ivshmem-server
  LINK    qemu-nbd
  LINK    qemu-img
  LINK    qemu-io
  LINK    qemu-bridge-helper
  GEN     x86_64-softmmu/hmp-commands.h
  GEN     x86_64-softmmu/hmp-commands-info.h
  GEN     x86_64-softmmu/config-target.h
  GEN     aarch64-softmmu/hmp-commands-info.h
  GEN     aarch64-softmmu/config-target.h
  GEN     aarch64-softmmu/hmp-commands.h
  CC      x86_64-softmmu/exec.o
  CC      x86_64-softmmu/tcg/tcg.o
  CC      x86_64-softmmu/tcg/tcg-op.o
  CC      x86_64-softmmu/tcg/tcg-common.o
  CC      x86_64-softmmu/tcg/tcg-runtime.o
  CC      x86_64-softmmu/tcg/optimize.o
  CC      x86_64-softmmu/fpu/softfloat.o
  CC      aarch64-softmmu/exec.o
  CC      aarch64-softmmu/tcg/tcg.o
  CC      x86_64-softmmu/disas.o
  CC      aarch64-softmmu/tcg/tcg-op.o
  GEN     x86_64-softmmu/gdbstub-xml.c
  CC      x86_64-softmmu/hax-stub.o
  CC      x86_64-softmmu/arch_init.o
  CC      aarch64-softmmu/tcg/optimize.o
  CC      x86_64-softmmu/cpus.o
  CC      x86_64-softmmu/monitor.o
  CC      aarch64-softmmu/tcg/tcg-common.o
  CC      aarch64-softmmu/tcg/tcg-runtime.o
  CC      aarch64-softmmu/fpu/softfloat.o
  CC      x86_64-softmmu/gdbstub.o
  CC      x86_64-softmmu/balloon.o
  CC      x86_64-softmmu/ioport.o
  CC      x86_64-softmmu/numa.o
  CC      aarch64-softmmu/disas.o
  GEN     aarch64-softmmu/gdbstub-xml.c
  CC      aarch64-softmmu/hax-stub.o
  CC      x86_64-softmmu/qtest.o
  CC      x86_64-softmmu/memory.o
  CC      aarch64-softmmu/arch_init.o
  CC      aarch64-softmmu/cpus.o
  CC      x86_64-softmmu/memory_mapping.o
  CC      aarch64-softmmu/monitor.o
  CC      aarch64-softmmu/gdbstub.o
  CC      aarch64-softmmu/balloon.o
  CC      x86_64-softmmu/dump.o
  CC      aarch64-softmmu/ioport.o
  CC      x86_64-softmmu/migration/ram.o
  CC      aarch64-softmmu/numa.o
  CC      aarch64-softmmu/qtest.o
  CC      aarch64-softmmu/memory.o
  CC      x86_64-softmmu/accel/accel.o
  CC      aarch64-softmmu/memory_mapping.o
  CC      aarch64-softmmu/dump.o
  CC      aarch64-softmmu/migration/ram.o
  CC      aarch64-softmmu/accel/accel.o
  CC      aarch64-softmmu/accel/stubs/kvm-stub.o
  CC      x86_64-softmmu/accel/kvm/kvm-all.o
  CC      aarch64-softmmu/accel/tcg/tcg-all.o
  CC      aarch64-softmmu/accel/tcg/cputlb.o
  CC      x86_64-softmmu/accel/tcg/tcg-all.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec-common.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec.o
  CC      aarch64-softmmu/accel/tcg/translate-all.o
  CC      aarch64-softmmu/hw/adc/stm32f2xx_adc.o
  CC      aarch64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/accel/tcg/cputlb.o
  CC      aarch64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/hw/char/exynos4210_uart.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec.o
  CC      aarch64-softmmu/hw/char/omap_uart.o
  CC      aarch64-softmmu/hw/char/digic-uart.o
  CC      aarch64-softmmu/hw/char/stm32f2xx_usart.o
  CC      aarch64-softmmu/hw/char/bcm2835_aux.o
  CC      aarch64-softmmu/hw/char/virtio-serial-bus.o
  CC      aarch64-softmmu/hw/core/generic-loader.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec-common.o
  CC      x86_64-softmmu/accel/tcg/translate-all.o
  CC      aarch64-softmmu/hw/core/null-machine.o
  CC      aarch64-softmmu/hw/cpu/arm11mpcore.o
  CC      aarch64-softmmu/hw/cpu/realview_mpcore.o
  CC      x86_64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/hw/cpu/a9mpcore.o
  CC      x86_64-softmmu/hw/char/virtio-serial-bus.o
  CC      aarch64-softmmu/hw/cpu/a15mpcore.o
  CC      x86_64-softmmu/hw/core/generic-loader.o
  CC      aarch64-softmmu/hw/display/omap_dss.o
  CC      x86_64-softmmu/hw/core/null-machine.o
  CC      x86_64-softmmu/hw/display/vga.o
  CC      aarch64-softmmu/hw/display/omap_lcdc.o
  CC      aarch64-softmmu/hw/display/pxa2xx_lcd.o
  CC      x86_64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-3d.o
  CC      aarch64-softmmu/hw/display/vga.o
  CC      aarch64-softmmu/hw/display/bcm2835_fb.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-pci.o
  CC      aarch64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/display/virtio-vga.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-3d.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-pci.o
  CC      aarch64-softmmu/hw/display/dpcd.o
  CC      aarch64-softmmu/hw/display/xlnx_dp.o
  CC      aarch64-softmmu/hw/dma/xlnx_dpdma.o
  CC      x86_64-softmmu/hw/intc/apic.o
  CC      x86_64-softmmu/hw/intc/apic_common.o
  CC      x86_64-softmmu/hw/intc/ioapic.o
  CC      aarch64-softmmu/hw/dma/omap_dma.o
  CC      aarch64-softmmu/hw/dma/soc_dma.o
  CC      x86_64-softmmu/hw/misc/vmport.o
  CC      x86_64-softmmu/hw/isa/lpc_ich9.o
  CC      aarch64-softmmu/hw/dma/pxa2xx_dma.o
  CC      x86_64-softmmu/hw/misc/ivshmem.o
  CC      aarch64-softmmu/hw/dma/bcm2835_dma.o
  CC      aarch64-softmmu/hw/gpio/omap_gpio.o
  CC      x86_64-softmmu/hw/misc/pvpanic.o
  CC      aarch64-softmmu/hw/gpio/imx_gpio.o
  CC      aarch64-softmmu/hw/gpio/bcm2835_gpio.o
  CC      aarch64-softmmu/hw/i2c/omap_i2c.o
  CC      aarch64-softmmu/hw/input/pxa2xx_keypad.o
  CC      x86_64-softmmu/hw/misc/hyperv_testdev.o
  CC      aarch64-softmmu/hw/input/tsc210x.o
  CC      aarch64-softmmu/hw/intc/armv7m_nvic.o
  CC      aarch64-softmmu/hw/intc/exynos4210_gic.o
  CC      x86_64-softmmu/hw/misc/mmio_interface.o
  CC      aarch64-softmmu/hw/intc/exynos4210_combiner.o
  CC      aarch64-softmmu/hw/intc/omap_intc.o
  CC      aarch64-softmmu/hw/intc/bcm2835_ic.o
  CC      aarch64-softmmu/hw/intc/bcm2836_control.o
  CC      x86_64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/intc/allwinner-a10-pic.o
  CC      aarch64-softmmu/hw/intc/aspeed_vic.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      aarch64-softmmu/hw/misc/ivshmem.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi.o
  CC      aarch64-softmmu/hw/misc/arm_sysctl.o
  CC      aarch64-softmmu/hw/misc/cbus.o
  CC      aarch64-softmmu/hw/misc/exynos4210_pmu.o
  CC      x86_64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      x86_64-softmmu/hw/timer/mc146818rtc.o
  CC      aarch64-softmmu/hw/misc/exynos4210_clk.o
  CC      aarch64-softmmu/hw/misc/exynos4210_rng.o
  CC      x86_64-softmmu/hw/vfio/common.o
  CC      x86_64-softmmu/hw/vfio/pci.o
  CC      x86_64-softmmu/hw/vfio/pci-quirks.o
  CC      aarch64-softmmu/hw/misc/imx_ccm.o
  CC      x86_64-softmmu/hw/vfio/platform.o
  CC      aarch64-softmmu/hw/misc/imx31_ccm.o
  CC      x86_64-softmmu/hw/vfio/spapr.o
  CC      x86_64-softmmu/hw/virtio/virtio.o
  CC      x86_64-softmmu/hw/virtio/virtio-balloon.o
  CC      x86_64-softmmu/hw/virtio/vhost.o
  CC      aarch64-softmmu/hw/misc/imx6_ccm.o
  CC      aarch64-softmmu/hw/misc/imx25_ccm.o
  CC      x86_64-softmmu/hw/virtio/vhost-user.o
  CC      x86_64-softmmu/hw/virtio/vhost-backend.o
  CC      aarch64-softmmu/hw/misc/imx6_src.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/misc/mst_fpga.o
  CC      x86_64-softmmu/hw/xen/xen-host-pci-device.o
  CC      aarch64-softmmu/hw/misc/omap_clk.o
  CC      aarch64-softmmu/hw/misc/omap_gpmc.o
  CC      aarch64-softmmu/hw/misc/omap_l4.o
  CC      aarch64-softmmu/hw/misc/omap_sdrc.o
  CC      x86_64-softmmu/hw/xen/xen_pt.o
  CC      x86_64-softmmu/hw/xen/xen_pt_config_init.o
  CC      x86_64-softmmu/hw/virtio/vhost-vsock.o
  CC      x86_64-softmmu/hw/xen/xen_pt_graphics.o
  CC      x86_64-softmmu/hw/xen/xen_pt_msi.o
  CC      aarch64-softmmu/hw/misc/omap_tap.o
  CC      x86_64-softmmu/hw/i386/multiboot.o
  CC      x86_64-softmmu/hw/i386/pc.o
  CC      x86_64-softmmu/hw/i386/pc_piix.o
  CC      aarch64-softmmu/hw/misc/bcm2835_mbox.o
  CC      x86_64-softmmu/hw/i386/pc_q35.o
  CC      x86_64-softmmu/hw/i386/pc_sysfw.o
  CC      aarch64-softmmu/hw/misc/bcm2835_property.o
/tmp/qemu-test/src/hw/i386/pc_piix.c: In function ‘igd_passthrough_isa_bridge_create’:
/tmp/qemu-test/src/hw/i386/pc_piix.c:1065: warning: ‘pch_rev_id’ may be used uninitialized in this function
  CC      x86_64-softmmu/hw/i386/x86-iommu.o
  CC      x86_64-softmmu/hw/i386/intel_iommu.o
  CC      aarch64-softmmu/hw/misc/bcm2835_rng.o
  CC      aarch64-softmmu/hw/misc/zynq_slcr.o
  CC      x86_64-softmmu/hw/i386/amd_iommu.o
  CC      aarch64-softmmu/hw/misc/zynq-xadc.o
  CC      aarch64-softmmu/hw/misc/stm32f2xx_syscfg.o
  CC      x86_64-softmmu/hw/i386/kvmvapic.o
  CC      aarch64-softmmu/hw/misc/mps2-scc.o
  CC      x86_64-softmmu/hw/i386/acpi-build.o
  CC      aarch64-softmmu/hw/misc/auxbus.o
  CC      x86_64-softmmu/hw/i386/pci-assign-load-rom.o
  CC      aarch64-softmmu/hw/misc/aspeed_scu.o
  CC      aarch64-softmmu/hw/misc/aspeed_sdmc.o
  CC      aarch64-softmmu/hw/misc/mmio_interface.o
  CC      x86_64-softmmu/hw/i386/../xenpv/xen_machine_pv.o
  CC      aarch64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/hw/i386/kvm/clock.o
  CC      x86_64-softmmu/hw/i386/kvm/apic.o
  CC      x86_64-softmmu/hw/i386/kvm/i8259.o
  CC      x86_64-softmmu/hw/i386/kvm/ioapic.o
  CC      aarch64-softmmu/hw/net/vhost_net.o
  CC      x86_64-softmmu/hw/i386/kvm/i8254.o
  CC      aarch64-softmmu/hw/pcmcia/pxa2xx.o
  CC      x86_64-softmmu/hw/i386/kvm/pci-assign.o
  CC      x86_64-softmmu/hw/i386/xen/xen_platform.o
  CC      x86_64-softmmu/hw/i386/xen/xen_apic.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
/tmp/qemu-test/src/hw/i386/acpi-build.c: In function ‘build_append_pci_bus_devices’:
/tmp/qemu-test/src/hw/i386/acpi-build.c:539: warning: ‘notify_method’ may be used uninitialized in this function
  CC      x86_64-softmmu/hw/i386/xen/xen_pvdevice.o
  CC      x86_64-softmmu/hw/i386/xen/xen-hvm.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi.o
  CC      x86_64-softmmu/hw/i386/xen/xen-mapcache.o
  CC      x86_64-softmmu/target/i386/helper.o
  CC      x86_64-softmmu/target/i386/cpu.o
  CC      x86_64-softmmu/target/i386/gdbstub.o
  CC      aarch64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      aarch64-softmmu/hw/sd/omap_mmc.o
  CC      x86_64-softmmu/target/i386/xsave_helper.o
  CC      aarch64-softmmu/hw/sd/pxa2xx_mmci.o
  CC      x86_64-softmmu/target/i386/translate.o
  CC      x86_64-softmmu/target/i386/bpt_helper.o
  CC      x86_64-softmmu/target/i386/cc_helper.o
  CC      aarch64-softmmu/hw/sd/bcm2835_sdhost.o
  CC      aarch64-softmmu/hw/ssi/omap_spi.o
  CC      x86_64-softmmu/target/i386/excp_helper.o
  CC      aarch64-softmmu/hw/ssi/imx_spi.o
  CC      aarch64-softmmu/hw/timer/exynos4210_mct.o
  CC      aarch64-softmmu/hw/timer/exynos4210_pwm.o
  CC      x86_64-softmmu/target/i386/fpu_helper.o
  CC      x86_64-softmmu/target/i386/int_helper.o
  CC      x86_64-softmmu/target/i386/mem_helper.o
  CC      x86_64-softmmu/target/i386/misc_helper.o
  CC      aarch64-softmmu/hw/timer/exynos4210_rtc.o
  CC      aarch64-softmmu/hw/timer/omap_gptimer.o
  CC      aarch64-softmmu/hw/timer/omap_synctimer.o
  CC      x86_64-softmmu/target/i386/mpx_helper.o
  CC      x86_64-softmmu/target/i386/seg_helper.o
  CC      x86_64-softmmu/target/i386/smm_helper.o
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      x86_64-softmmu/target/i386/arch_memory_mapping.o
  CC      x86_64-softmmu/target/i386/machine.o
  CC      x86_64-softmmu/target/i386/arch_dump.o
  CC      aarch64-softmmu/hw/timer/pxa2xx_timer.o
  CC      x86_64-softmmu/target/i386/monitor.o
  CC      x86_64-softmmu/target/i386/kvm.o
  CC      x86_64-softmmu/target/i386/hyperv.o
  CC      aarch64-softmmu/hw/timer/digic-timer.o
  GEN     trace/generated-helpers.c
  CC      x86_64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/hw/timer/allwinner-a10-pit.o
  CC      x86_64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/usb/tusb6010.o
  CC      aarch64-softmmu/hw/vfio/pci.o
  CC      aarch64-softmmu/hw/vfio/pci-quirks.o
  CC      aarch64-softmmu/hw/vfio/platform.o
  CC      aarch64-softmmu/hw/vfio/amd-xgbe.o
  CC      aarch64-softmmu/hw/vfio/calxeda-xgmac.o
  CC      aarch64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/virtio/virtio-balloon.o
  CC      aarch64-softmmu/hw/virtio/vhost-backend.o
  CC      aarch64-softmmu/hw/virtio/vhost.o
  CC      x86_64-softmmu/trace/generated-helpers.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto.o
  CC      aarch64-softmmu/hw/virtio/vhost-user.o
  CC      aarch64-softmmu/hw/virtio/vhost-vsock.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/arm/collie.o
  CC      aarch64-softmmu/hw/arm/boot.o
  CC      aarch64-softmmu/hw/arm/exynos4_boards.o
  CC      aarch64-softmmu/hw/arm/highbank.o
  CC      aarch64-softmmu/hw/arm/gumstix.o
  CC      aarch64-softmmu/hw/arm/digic_boards.o
  CC      aarch64-softmmu/hw/arm/mainstone.o
  CC      aarch64-softmmu/hw/arm/integratorcp.o
  LINK    x86_64-softmmu/qemu-system-x86_64
  CC      aarch64-softmmu/hw/arm/musicpal.o
  CC      aarch64-softmmu/hw/arm/omap_sx1.o
  CC      aarch64-softmmu/hw/arm/palm.o
  CC      aarch64-softmmu/hw/arm/nseries.o
  CC      aarch64-softmmu/hw/arm/realview.o
  CC      aarch64-softmmu/hw/arm/stellaris.o
  CC      aarch64-softmmu/hw/arm/tosa.o
  CC      aarch64-softmmu/hw/arm/spitz.o
  CC      aarch64-softmmu/hw/arm/versatilepb.o
  CC      aarch64-softmmu/hw/arm/vexpress.o
  CC      aarch64-softmmu/hw/arm/virt.o
  CC      aarch64-softmmu/hw/arm/xilinx_zynq.o
  CC      aarch64-softmmu/hw/arm/z2.o
  CC      aarch64-softmmu/hw/arm/virt-acpi-build.o
  CC      aarch64-softmmu/hw/arm/netduino2.o
  CC      aarch64-softmmu/hw/arm/sysbus-fdt.o
  CC      aarch64-softmmu/hw/arm/armv7m.o
  CC      aarch64-softmmu/hw/arm/exynos4210.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_gpio.o
  CC      aarch64-softmmu/hw/arm/pxa2xx.o
  CC      aarch64-softmmu/hw/arm/digic.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_pic.o
  CC      aarch64-softmmu/hw/arm/omap1.o
  CC      aarch64-softmmu/hw/arm/omap2.o
  CC      aarch64-softmmu/hw/arm/allwinner-a10.o
  CC      aarch64-softmmu/hw/arm/cubieboard.o
  CC      aarch64-softmmu/hw/arm/strongarm.o
  CC      aarch64-softmmu/hw/arm/bcm2835_peripherals.o
  CC      aarch64-softmmu/hw/arm/bcm2836.o
  CC      aarch64-softmmu/hw/arm/raspi.o
  CC      aarch64-softmmu/hw/arm/xlnx-zynqmp.o
  CC      aarch64-softmmu/hw/arm/stm32f205_soc.o
  CC      aarch64-softmmu/hw/arm/xlnx-ep108.o
  CC      aarch64-softmmu/hw/arm/fsl-imx25.o
  CC      aarch64-softmmu/hw/arm/imx25_pdk.o
  CC      aarch64-softmmu/hw/arm/fsl-imx31.o
  CC      aarch64-softmmu/hw/arm/kzm.o
  CC      aarch64-softmmu/hw/arm/fsl-imx6.o
  CC      aarch64-softmmu/hw/arm/sabrelite.o
  CC      aarch64-softmmu/hw/arm/aspeed_soc.o
  CC      aarch64-softmmu/hw/arm/aspeed.o
  CC      aarch64-softmmu/hw/arm/mps2.o
  CC      aarch64-softmmu/target/arm/arm-semi.o
  CC      aarch64-softmmu/target/arm/machine.o
  CC      aarch64-softmmu/target/arm/psci.o
  CC      aarch64-softmmu/target/arm/arch_dump.o
  CC      aarch64-softmmu/target/arm/monitor.o
  CC      aarch64-softmmu/target/arm/kvm-stub.o
  CC      aarch64-softmmu/target/arm/translate.o
  CC      aarch64-softmmu/target/arm/op_helper.o
  CC      aarch64-softmmu/target/arm/helper.o
  CC      aarch64-softmmu/target/arm/cpu.o
  CC      aarch64-softmmu/target/arm/neon_helper.o
  CC      aarch64-softmmu/target/arm/iwmmxt_helper.o
  CC      aarch64-softmmu/target/arm/gdbstub.o
  CC      aarch64-softmmu/target/arm/cpu64.o
  CC      aarch64-softmmu/target/arm/translate-a64.o
  CC      aarch64-softmmu/target/arm/helper-a64.o
  CC      aarch64-softmmu/target/arm/crypto_helper.o
  CC      aarch64-softmmu/target/arm/gdbstub64.o
  CC      aarch64-softmmu/target/arm/arm-powerctl.o
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘handle_shri_with_rndacc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:6372: warning: ‘tcg_src_hi’ may be used uninitialized in this function
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘disas_simd_scalar_two_reg_misc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:8099: warning: ‘rmode’ may be used uninitialized in this function
  GEN     trace/generated-helpers.c
  CC      aarch64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/trace/generated-helpers.o
  LINK    aarch64-softmmu/qemu-system-aarch64
  TEST    tests/qapi-schema/alternate-any.out
  TEST    tests/qapi-schema/alternate-array.out
  TEST    tests/qapi-schema/alternate-clash.out
  TEST    tests/qapi-schema/alternate-base.out
  TEST    tests/qapi-schema/alternate-conflict-enum-bool.out
  TEST    tests/qapi-schema/alternate-conflict-dict.out
  TEST    tests/qapi-schema/alternate-conflict-string.out
  TEST    tests/qapi-schema/alternate-conflict-enum-int.out
  TEST    tests/qapi-schema/alternate-empty.out
  TEST    tests/qapi-schema/alternate-nested.out
  TEST    tests/qapi-schema/alternate-unknown.out
  TEST    tests/qapi-schema/args-alternate.out
  TEST    tests/qapi-schema/args-array-empty.out
  TEST    tests/qapi-schema/args-any.out
  TEST    tests/qapi-schema/args-array-unknown.out
  TEST    tests/qapi-schema/args-bad-boxed.out
  TEST    tests/qapi-schema/args-boxed-anon.out
  TEST    tests/qapi-schema/args-boxed-empty.out
  TEST    tests/qapi-schema/args-boxed-string.out
  TEST    tests/qapi-schema/args-int.out
  TEST    tests/qapi-schema/args-invalid.out
  TEST    tests/qapi-schema/args-member-array-bad.out
  TEST    tests/qapi-schema/args-member-unknown.out
  TEST    tests/qapi-schema/args-member-case.out
  TEST    tests/qapi-schema/args-name-clash.out
  TEST    tests/qapi-schema/args-union.out
  TEST    tests/qapi-schema/args-unknown.out
  TEST    tests/qapi-schema/bad-base.out
  TEST    tests/qapi-schema/bad-data.out
  TEST    tests/qapi-schema/bad-ident.out
  TEST    tests/qapi-schema/bad-type-bool.out
  TEST    tests/qapi-schema/bad-type-dict.out
  TEST    tests/qapi-schema/bad-type-int.out
  TEST    tests/qapi-schema/base-cycle-direct.out
  TEST    tests/qapi-schema/base-cycle-indirect.out
  TEST    tests/qapi-schema/command-int.out
  TEST    tests/qapi-schema/comments.out
  TEST    tests/qapi-schema/doc-bad-alternate-member.out
  TEST    tests/qapi-schema/doc-bad-command-arg.out
  TEST    tests/qapi-schema/doc-bad-symbol.out
  TEST    tests/qapi-schema/doc-bad-union-member.out
  TEST    tests/qapi-schema/doc-before-include.out
  TEST    tests/qapi-schema/doc-before-pragma.out
  TEST    tests/qapi-schema/doc-duplicated-arg.out
  TEST    tests/qapi-schema/doc-duplicated-return.out
  TEST    tests/qapi-schema/doc-duplicated-since.out
  TEST    tests/qapi-schema/doc-empty-arg.out
  TEST    tests/qapi-schema/doc-empty-section.out
  TEST    tests/qapi-schema/doc-empty-symbol.out
  TEST    tests/qapi-schema/doc-good.out
  TEST    tests/qapi-schema/doc-interleaved-section.out
  TEST    tests/qapi-schema/doc-invalid-end.out
  TEST    tests/qapi-schema/doc-invalid-end2.out
  TEST    tests/qapi-schema/doc-invalid-return.out
  TEST    tests/qapi-schema/doc-invalid-section.out
  TEST    tests/qapi-schema/doc-invalid-start.out
  TEST    tests/qapi-schema/doc-missing.out
  TEST    tests/qapi-schema/doc-missing-colon.out
  TEST    tests/qapi-schema/doc-missing-expr.out
  TEST    tests/qapi-schema/doc-missing-space.out
  TEST    tests/qapi-schema/doc-no-symbol.out
  TEST    tests/qapi-schema/double-data.out
  TEST    tests/qapi-schema/double-type.out
  TEST    tests/qapi-schema/duplicate-key.out
  TEST    tests/qapi-schema/empty.out
  TEST    tests/qapi-schema/enum-bad-name.out
  TEST    tests/qapi-schema/enum-bad-prefix.out
  TEST    tests/qapi-schema/enum-clash-member.out
  TEST    tests/qapi-schema/enum-dict-member.out
  TEST    tests/qapi-schema/enum-int-member.out
  TEST    tests/qapi-schema/enum-member-case.out
  TEST    tests/qapi-schema/enum-missing-data.out
  TEST    tests/qapi-schema/enum-wrong-data.out
  TEST    tests/qapi-schema/escape-outside-string.out
  TEST    tests/qapi-schema/escape-too-big.out
  TEST    tests/qapi-schema/escape-too-short.out
  TEST    tests/qapi-schema/event-boxed-empty.out
  TEST    tests/qapi-schema/event-case.out
  TEST    tests/qapi-schema/event-nest-struct.out
  TEST    tests/qapi-schema/flat-union-array-branch.out
  TEST    tests/qapi-schema/flat-union-bad-base.out
  TEST    tests/qapi-schema/flat-union-bad-discriminator.out
  TEST    tests/qapi-schema/flat-union-base-any.out
  TEST    tests/qapi-schema/flat-union-base-union.out
  TEST    tests/qapi-schema/flat-union-clash-member.out
  TEST    tests/qapi-schema/flat-union-empty.out
  TEST    tests/qapi-schema/flat-union-incomplete-branch.out
  TEST    tests/qapi-schema/flat-union-inline.out
  TEST    tests/qapi-schema/flat-union-int-branch.out
  TEST    tests/qapi-schema/flat-union-invalid-branch-key.out
  TEST    tests/qapi-schema/flat-union-invalid-discriminator.out
  TEST    tests/qapi-schema/flat-union-no-base.out
  TEST    tests/qapi-schema/flat-union-optional-discriminator.out
  TEST    tests/qapi-schema/flat-union-string-discriminator.out
  TEST    tests/qapi-schema/funny-char.out
  TEST    tests/qapi-schema/ident-with-escape.out
  TEST    tests/qapi-schema/include-before-err.out
  TEST    tests/qapi-schema/include-cycle.out
  TEST    tests/qapi-schema/include-extra-junk.out
  TEST    tests/qapi-schema/include-format-err.out
  TEST    tests/qapi-schema/include-nested-err.out
  TEST    tests/qapi-schema/include-no-file.out
  TEST    tests/qapi-schema/include-non-file.out
  TEST    tests/qapi-schema/include-relpath.out
  TEST    tests/qapi-schema/include-repetition.out
  TEST    tests/qapi-schema/include-self-cycle.out
  TEST    tests/qapi-schema/include-simple.out
  TEST    tests/qapi-schema/indented-expr.out
  TEST    tests/qapi-schema/leading-comma-list.out
  TEST    tests/qapi-schema/leading-comma-object.out
  TEST    tests/qapi-schema/missing-colon.out
  TEST    tests/qapi-schema/missing-comma-list.out
  TEST    tests/qapi-schema/missing-comma-object.out
  TEST    tests/qapi-schema/missing-type.out
  TEST    tests/qapi-schema/nested-struct-data.out
  TEST    tests/qapi-schema/non-objects.out
  TEST    tests/qapi-schema/pragma-doc-required-crap.out
  TEST    tests/qapi-schema/pragma-extra-junk.out
  TEST    tests/qapi-schema/pragma-name-case-whitelist-crap.out
  TEST    tests/qapi-schema/pragma-non-dict.out
  TEST    tests/qapi-schema/pragma-returns-whitelist-crap.out
  TEST    tests/qapi-schema/qapi-schema-test.out
  TEST    tests/qapi-schema/quoted-structural-chars.out
  TEST    tests/qapi-schema/redefined-builtin.out
  TEST    tests/qapi-schema/redefined-command.out
  TEST    tests/qapi-schema/redefined-event.out
  TEST    tests/qapi-schema/redefined-type.out
  TEST    tests/qapi-schema/reserved-command-q.out
  TEST    tests/qapi-schema/reserved-enum-q.out
  TEST    tests/qapi-schema/reserved-member-has.out
  TEST    tests/qapi-schema/reserved-member-q.out
  TEST    tests/qapi-schema/reserved-member-u.out
  TEST    tests/qapi-schema/reserved-member-underscore.out
  TEST    tests/qapi-schema/reserved-type-kind.out
  TEST    tests/qapi-schema/reserved-type-list.out
  TEST    tests/qapi-schema/returns-alternate.out
  TEST    tests/qapi-schema/returns-array-bad.out
  TEST    tests/qapi-schema/returns-dict.out
  TEST    tests/qapi-schema/returns-unknown.out
  TEST    tests/qapi-schema/returns-whitelist.out
  TEST    tests/qapi-schema/struct-base-clash-deep.out
  TEST    tests/qapi-schema/struct-base-clash.out
  TEST    tests/qapi-schema/struct-data-invalid.out
  TEST    tests/qapi-schema/struct-member-invalid.out
  TEST    tests/qapi-schema/trailing-comma-list.out
  TEST    tests/qapi-schema/type-bypass-bad-gen.out
  TEST    tests/qapi-schema/unclosed-list.out
  TEST    tests/qapi-schema/trailing-comma-object.out
  TEST    tests/qapi-schema/unclosed-object.out
  TEST    tests/qapi-schema/unclosed-string.out
  TEST    tests/qapi-schema/unicode-str.out
  TEST    tests/qapi-schema/union-base-empty.out
  TEST    tests/qapi-schema/union-base-no-discriminator.out
  TEST    tests/qapi-schema/union-branch-case.out
  TEST    tests/qapi-schema/union-clash-branches.out
  TEST    tests/qapi-schema/union-empty.out
  TEST    tests/qapi-schema/union-optional-branch.out
  TEST    tests/qapi-schema/union-invalid-base.out
  TEST    tests/qapi-schema/union-unknown.out
  TEST    tests/qapi-schema/unknown-escape.out
  TEST    tests/qapi-schema/unknown-expr-key.out
  GEN     tests/qapi-schema/doc-good.test.texi
  CC      tests/check-qdict.o
  CC      tests/test-char.o
  CC      tests/check-qnum.o
  CC      tests/check-qstring.o
  CC      tests/check-qnull.o
  CC      tests/check-qjson.o
  CC      tests/check-qlist.o
  CC      tests/test-qobject-output-visitor.o
  GEN     tests/test-qapi-visit.c
  GEN     tests/test-qapi-event.c
  GEN     tests/test-qapi-types.c
  GEN     tests/test-qmp-introspect.c
  CC      tests/test-clone-visitor.o
  CC      tests/test-qobject-input-visitor.o
  CC      tests/test-qmp-commands.o
  GEN     tests/test-qmp-marshal.c
  CC      tests/test-string-input-visitor.o
  CC      tests/test-string-output-visitor.o
  CC      tests/test-qmp-event.o
  CC      tests/test-opts-visitor.o
  CC      tests/test-coroutine.o
  CC      tests/iothread.o
  CC      tests/test-visitor-serialization.o
  CC      tests/test-iov.o
  CC      tests/test-aio.o
  CC      tests/test-aio-multithread.o
  CC      tests/test-throttle.o
  CC      tests/test-thread-pool.o
  CC      tests/test-hbitmap.o
  CC      tests/test-blockjob-txn.o
  CC      tests/test-x86-cpuid.o
  CC      tests/test-blockjob.o
  CC      tests/test-xbzrle.o
  CC      tests/test-vmstate.o
  CC      tests/test-cutils.o
  CC      tests/test-shift128.o
  CC      tests/test-mul64.o
  CC      tests/rcutorture.o
  CC      tests/test-int128.o
  CC      tests/test-rcu-list.o
  CC      tests/test-qdist.o
  CC      tests/test-qht.o
  CC      tests/test-qht-par.o
  CC      tests/qht-bench.o
  CC      tests/test-bitops.o
/tmp/qemu-test/src/tests/test-int128.c:180: warning: ‘__noclone__’ attribute directive ignored
  CC      tests/test-bitcnt.o
  CC      tests/check-qom-interface.o
  CC      tests/check-qom-proplist.o
  CC      tests/test-qemu-opts.o
  CC      tests/test-keyval.o
  CC      tests/test-write-threshold.o
  CC      tests/test-crypto-hash.o
  CC      tests/test-crypto-hmac.o
  CC      tests/test-crypto-secret.o
  CC      tests/test-crypto-cipher.o
  CC      tests/test-qga.o
  CC      tests/libqtest.o
  CC      tests/test-io-channel-socket.o
  CC      tests/test-timed-average.o
  CC      tests/test-io-task.o
  CC      tests/io-channel-helpers.o
  CC      tests/test-io-channel-file.o
  CC      tests/test-io-channel-command.o
  CC      tests/test-io-channel-buffer.o
  CC      tests/test-crypto-ivgen.o
  CC      tests/test-base64.o
  CC      tests/test-crypto-afsplit.o
  CC      tests/test-crypto-xts.o
  CC      tests/test-crypto-block.o
  CC      tests/test-logging.o
  CC      tests/test-replication.o
  CC      tests/test-bufferiszero.o
  CC      tests/test-uuid.o
  CC      tests/ptimer-test.o
  CC      tests/ptimer-test-stubs.o
  CC      tests/test-qapi-util.o
  CC      tests/vhost-user-test.o
  CC      tests/libqos/pci.o
  CC      tests/libqos/fw_cfg.o
  CC      tests/libqos/malloc.o
In file included from /tmp/qemu-test/src/tests/libqos/fw_cfg.c:18:
/tmp/qemu-test/src/tests/libqtest.h:22: error: redefinition of typedef ‘QTestState’
/tmp/qemu-test/src/tests/libqos/fw_cfg.h:18: note: previous declaration of ‘QTestState’ was here
make: *** [tests/libqos/fw_cfg.o] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 384, in <module>
    sys.exit(main())
  File "./tests/docker/docker.py", line 381, in main
    return args.cmdobj.run(args, argv)
  File "./tests/docker/docker.py", line 239, in run
    return Docker().run(argv, args.keep, quiet=args.quiet)
  File "./tests/docker/docker.py", line 207, in run
    quiet=quiet)
  File "./tests/docker/docker.py", line 125, in _do_check
    return subprocess.check_call(self._command + cmd, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['docker', 'run', '--label', 'com.qemu.instance.uuid=91fcb00a8f4311e7939e52540069c830', '-u', '0', '-t', '--rm', '--net=none', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=8', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/var/tmp/patchew-tester-tmp-13jkjuzx/src/docker-src.2017-09-01-14.29.58.15129:/var/tmp/qemu:z,ro', '-v', '/root/.cache/qemu-docker-ccache:/var/tmp/ccache:z', 'qemu:centos6', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2
make[1]: *** [tests/docker/Makefile.include:139: docker-run] Error 1
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-13jkjuzx/src'
make: *** [tests/docker/Makefile.include:168: docker-run-test-quick@centos6] Error 2

real	1m48.927s
user	0m5.794s
sys	0m2.281s
=== OUTPUT END ===

Test command exited with code: 2


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups
  2017-09-01 18:31 ` [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups no-reply
@ 2017-09-01 18:44   ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 18:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: famz, pbonzini, armbru

[-- Attachment #1: Type: text/plain, Size: 938 bytes --]

On 09/01/2017 01:31 PM, no-reply@patchew.org wrote:
> Hi,
> 
> This series failed automatic build test. Please find the testing commands and
> their output below. If you have docker installed, you can probably reproduce it
> locally.
> 
>   CC      tests/libqos/pci.o
>   CC      tests/libqos/fw_cfg.o
>   CC      tests/libqos/malloc.o
> In file included from /tmp/qemu-test/src/tests/libqos/fw_cfg.c:18:
> /tmp/qemu-test/src/tests/libqtest.h:22: error: redefinition of typedef ‘QTestState’
> /tmp/qemu-test/src/tests/libqos/fw_cfg.h:18: note: previous declaration of ‘QTestState’ was here
> make: *** [tests/libqos/fw_cfg.o] Error 1
> make: *** Waiting for unfinished jobs....

Legitimate complaint due to different gcc version; I'll send a fixup
patch for the offending commit.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
@ 2017-09-01 19:20   ` Philippe Mathieu-Daudé
  2017-09-06 20:48     ` Eric Blake
  2017-09-01 23:06   ` John Snow
  2017-09-05  9:36   ` Thomas Huth
  2 siblings, 1 reply; 99+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-01 19:20 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

Hi Eric,

On 09/01/2017 03:03 PM, Eric Blake wrote:
> When initializing a QPCIBus, track which QTestState the bus is
> associated with (so that a later patch can then explicitly use
> that test state for all communication on the bus, rather than
> blindly relying on global_qtest).  Update the initialization
> functions to take another parameter, and update all callers to
> pass in state (for now, most callers get away with passing the
> current global_qtest as the current state, although this required
> fixing the order of initialization to ensure qtest_start() is
> called before qpci_init*() in rtl8139-test, and provided an
> opportunity to pass in the allocator in e1000e-test).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>   tests/libqos/ahci.h       | 2 +-
>   tests/libqos/libqos.h     | 2 +-
>   tests/libqos/pci-pc.h     | 2 +-
>   tests/libqos/pci-spapr.h  | 2 +-
>   tests/libqos/pci.h        | 1 +
>   tests/ahci-test.c         | 2 +-
>   tests/e1000e-test.c       | 6 +++---
>   tests/i440fx-test.c       | 2 +-
>   tests/ide-test.c          | 2 +-
>   tests/libqos/ahci.c       | 4 ++--
>   tests/libqos/libqos.c     | 4 ++--
>   tests/libqos/pci-pc.c     | 5 ++++-
>   tests/libqos/pci-spapr.c  | 6 +++++-
>   tests/q35-test.c          | 4 ++--
>   tests/rtl8139-test.c      | 5 +++--
>   tests/tco-test.c          | 2 +-
>   tests/usb-hcd-ehci-test.c | 2 +-
>   tests/vhost-user-test.c   | 4 ++--
>   18 files changed, 33 insertions(+), 24 deletions(-)
> 
> diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
> index 5f9627bb0f..715ca1e226 100644
> --- a/tests/libqos/ahci.h
> +++ b/tests/libqos/ahci.h
> @@ -571,7 +571,7 @@ void ahci_free(AHCIQState *ahci, uint64_t addr);
>   void ahci_clean_mem(AHCIQState *ahci);
> 
>   /* Device management */
> -QPCIDevice *get_ahci_device(uint32_t *fingerprint);
> +QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint);
>   void free_ahci_device(QPCIDevice *dev);
>   void ahci_pci_enable(AHCIQState *ahci);
>   void start_ahci_device(AHCIQState *ahci);
> diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
> index 231969766f..78e5c044a0 100644
> --- a/tests/libqos/libqos.h
> +++ b/tests/libqos/libqos.h
> @@ -10,7 +10,7 @@ typedef struct QOSState QOSState;
>   typedef struct QOSOps {
>       QGuestAllocator *(*init_allocator)(QAllocOpts);
>       void (*uninit_allocator)(QGuestAllocator *);
> -    QPCIBus *(*qpci_init)(QGuestAllocator *alloc);
> +    QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc);
>       void (*qpci_free)(QPCIBus *bus);
>       void (*shutdown)(QOSState *);
>   } QOSOps;
> diff --git a/tests/libqos/pci-pc.h b/tests/libqos/pci-pc.h
> index 9479b51642..491eeac756 100644
> --- a/tests/libqos/pci-pc.h
> +++ b/tests/libqos/pci-pc.h
> @@ -16,7 +16,7 @@
>   #include "libqos/pci.h"
>   #include "libqos/malloc.h"
> 
> -QPCIBus *qpci_init_pc(QGuestAllocator *alloc);
> +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc);
>   void     qpci_free_pc(QPCIBus *bus);
> 
>   #endif
> diff --git a/tests/libqos/pci-spapr.h b/tests/libqos/pci-spapr.h
> index 4192126d86..387686dfc8 100644
> --- a/tests/libqos/pci-spapr.h
> +++ b/tests/libqos/pci-spapr.h
> @@ -11,7 +11,7 @@
>   #include "libqos/malloc.h"
>   #include "libqos/pci.h"
> 
> -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc);
> +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc);
>   void     qpci_free_spapr(QPCIBus *bus);
> 
>   #endif
> diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
> index ed480614ff..429c382282 100644
> --- a/tests/libqos/pci.h
> +++ b/tests/libqos/pci.h
> @@ -48,6 +48,7 @@ struct QPCIBus {
>       void (*config_writel)(QPCIBus *bus, int devfn,
>                             uint8_t offset, uint32_t value);
> 
> +    QTestState *qts;
>       uint16_t pio_alloc_ptr;
>       uint64_t mmio_alloc_ptr, mmio_limit;
>   };
> diff --git a/tests/ahci-test.c b/tests/ahci-test.c
> index 999121bb7c..c94d1bd712 100644
> --- a/tests/ahci-test.c
> +++ b/tests/ahci-test.c
> @@ -160,7 +160,7 @@ static AHCIQState *ahci_vboot(const char *cli, va_list ap)
>       alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);
> 
>       /* Verify that we have an AHCI device present. */
> -    s->dev = get_ahci_device(&s->fingerprint);
> +    s->dev = get_ahci_device(s->parent->qts, &s->fingerprint);
> 
>       return s;
>   }
> diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
> index c612dc64ec..d8085d944e 100644
> --- a/tests/e1000e-test.c
> +++ b/tests/e1000e-test.c
> @@ -392,12 +392,12 @@ static void data_test_init(e1000e_device *d)
>       qtest_start(cmdline);
>       g_free(cmdline);
> 
> -    test_bus = qpci_init_pc(NULL);
> -    g_assert_nonnull(test_bus);
> -
>       test_alloc = pc_alloc_init();
>       g_assert_nonnull(test_alloc);
> 
> +    test_bus = qpci_init_pc(global_qtest, test_alloc);
> +    g_assert_nonnull(test_bus);
> +
>       e1000e_device_init(test_bus, d);
>   }
> 
> diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
> index e9d05c87d1..4390e5591e 100644
> --- a/tests/i440fx-test.c
> +++ b/tests/i440fx-test.c
> @@ -38,7 +38,7 @@ static QPCIBus *test_start_get_bus(const TestData *s)
>       cmdline = g_strdup_printf("-smp %d", s->num_cpus);
>       qtest_start(cmdline);
>       g_free(cmdline);
> -    return qpci_init_pc(NULL);
> +    return qpci_init_pc(global_qtest, NULL);
>   }
> 
>   static void test_i440fx_defaults(gconstpointer opaque)
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index aa9de065fc..b2237b6158 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -143,7 +143,7 @@ static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, QPCIBar *ide_bar)
>       uint16_t vendor_id, device_id;
> 
>       if (!pcibus) {
> -        pcibus = qpci_init_pc(NULL);
> +        pcibus = qpci_init_pc(global_qtest, NULL);
>       }
> 
>       /* Find PCI device and verify it's the right one */
> diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
> index 1ca7f456b5..790ef991b3 100644
> --- a/tests/libqos/ahci.c
> +++ b/tests/libqos/ahci.c
> @@ -123,13 +123,13 @@ bool is_atapi(AHCIQState *ahci, uint8_t port)
>   /**
>    * Locate, verify, and return a handle to the AHCI device.
>    */
> -QPCIDevice *get_ahci_device(uint32_t *fingerprint)
> +QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint)
>   {
>       QPCIDevice *ahci;
>       uint32_t ahci_fingerprint;
>       QPCIBus *pcibus;
> 
> -    pcibus = qpci_init_pc(NULL);
> +    pcibus = qpci_init_pc(qts, NULL);
> 
>       /* Find the AHCI PCI device and verify it's the right one. */
>       ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));
> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
> index 6226546c28..c95428e1cb 100644
> --- a/tests/libqos/libqos.c
> +++ b/tests/libqos/libqos.c
> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>           if (ops->init_allocator) {
>               qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
>           }
> -        if (ops->qpci_init && qs->alloc) {
> -            qs->pcibus = ops->qpci_init(qs->alloc);
> +        if (ops->qpci_init) {
> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
>           }
>       }
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 02ce49927a..85b34c6d13 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -115,11 +115,14 @@ static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint3
>       outl(0xcfc, value);
>   }
> 
> -QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
> +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
>   {
>       QPCIBusPC *ret;
> 
> +    assert(qts);
> +
>       ret = g_malloc(sizeof(*ret));

I'd rather use g_malloc0() here (safer!)

> +    ret->bus.qts = qts;
> 
>       ret->bus.pio_readb = qpci_pc_pio_readb;
>       ret->bus.pio_readw = qpci_pc_pio_readw;

or init qts field in same order than struct:

...
         ret->bus.config_writel = qpci_pc_config_writel;

+       ret->bus.qts = qts;

         ret->bus.pio_alloc_ptr = 0xc000;
...

> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index 2043f1e123..cd9b8f52d2 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -154,11 +154,14 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
>   #define SPAPR_PCI_MMIO32_WIN_SIZE    0x80000000 /* 2 GiB */
>   #define SPAPR_PCI_IO_WIN_SIZE        0x10000
> 
> -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
> +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc)
>   {
>       QPCIBusSPAPR *ret;
> 
> +    assert(qts);
> +
>       ret = g_malloc(sizeof(*ret));
> +    ret->bus.qts = qts;

same

Either ways:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
>       ret->alloc = alloc;
> 
> @@ -201,6 +204,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
>       ret->bus.mmio_alloc_ptr = ret->mmio32.pci_base;
>       ret->bus.mmio_limit = ret->mmio32.pci_base + ret->mmio32.size;
> 
> +
>       return &ret->bus;
>   }
> 
> diff --git a/tests/q35-test.c b/tests/q35-test.c
> index f98bed7a2d..e149c4c51d 100644
> --- a/tests/q35-test.c
> +++ b/tests/q35-test.c
> @@ -86,7 +86,7 @@ static void test_smram_lock(void)
> 
>       qtest_start("-M q35");
> 
> -    pcibus = qpci_init_pc(NULL);
> +    pcibus = qpci_init_pc(global_qtest, NULL);
>       g_assert(pcibus != NULL);
> 
>       pcidev = qpci_device_find(pcibus, 0);
> @@ -145,7 +145,7 @@ static void test_tseg_size(const void *data)
>       g_free(cmdline);
> 
>       /* locate the DRAM controller */
> -    pcibus = qpci_init_pc(NULL);
> +    pcibus = qpci_init_pc(global_qtest, NULL);
>       g_assert(pcibus != NULL);
>       pcidev = qpci_device_find(pcibus, 0);
>       g_assert(pcidev != NULL);
> diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
> index 7de7dc45ae..68bfc42178 100644
> --- a/tests/rtl8139-test.c
> +++ b/tests/rtl8139-test.c
> @@ -35,7 +35,7 @@ static QPCIDevice *get_device(void)
>   {
>       QPCIDevice *dev;
> 
> -    pcibus = qpci_init_pc(NULL);
> +    pcibus = qpci_init_pc(global_qtest, NULL);
>       qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev);
>       g_assert(dev != NULL);
> 
> @@ -197,11 +197,12 @@ int main(int argc, char **argv)
>   {
>       int ret;
> 
> +    qtest_start("-device rtl8139");
> +
>       g_test_init(&argc, &argv, NULL);
>       qtest_add_func("/rtl8139/nop", nop);
>       qtest_add_func("/rtl8139/timer", test_init);
> 
> -    qtest_start("-device rtl8139");
>       ret = g_test_run();
> 
>       qtest_end();
> diff --git a/tests/tco-test.c b/tests/tco-test.c
> index f2ed6ed91c..0387971953 100644
> --- a/tests/tco-test.c
> +++ b/tests/tco-test.c
> @@ -64,7 +64,7 @@ static void test_init(TestData *d)
>       qtest_irq_intercept_in(qs, "ioapic");
>       g_free(s);
> 
> -    d->bus = qpci_init_pc(NULL);
> +    d->bus = qpci_init_pc(qs, NULL);
>       d->dev = qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00));
>       g_assert(d->dev != NULL);
> 
> diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
> index 944eb1c088..55d4743a2a 100644
> --- a/tests/usb-hcd-ehci-test.c
> +++ b/tests/usb-hcd-ehci-test.c
> @@ -52,7 +52,7 @@ static void ehci_port_test(struct qhc *hc, int port, uint32_t expect)
> 
>   static void test_init(void)
>   {
> -    pcibus = qpci_init_pc(NULL);
> +    pcibus = qpci_init_pc(global_qtest, NULL);
>       g_assert(pcibus != NULL);
> 
>       qusb_pci_init_one(pcibus, &uhci1, QPCI_DEVFN(0x1d, 0), 4);
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index d4da09f147..ea7d38ea44 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -164,7 +164,7 @@ static void init_virtio_dev(TestServer *s)
>       QVirtioPCIDevice *dev;
>       uint32_t features;
> 
> -    s->bus = qpci_init_pc(NULL);
> +    s->bus = qpci_init_pc(global_qtest, NULL);
>       g_assert_nonnull(s->bus);
> 
>       dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
> @@ -891,7 +891,7 @@ static void test_multiqueue(void)
>       qtest_start(cmd);
>       g_free(cmd);
> 
> -    bus = qpci_init_pc(NULL);
> +    bus = qpci_init_pc(global_qtest, NULL);
>       dev = virtio_net_pci_init(bus, PCI_SLOT);
> 
>       alloc = pc_alloc_init();
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* [Qemu-devel] [PATCH v6 14.5/29] fixup! libqos: Use explicit QTestState for fw_cfg operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
@ 2017-09-01 19:21   ` Eric Blake
  2017-09-01 19:24   ` [Qemu-devel] [PATCH v6 14/29] " Philippe Mathieu-Daudé
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-01 19:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pbonzini

Signed-off-by: Eric Blake <eblake@redhat.com>

---
Fix older gcc duplicate typedef warning [patchew]
---
 tests/libqos/fw_cfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 396dd4ee1e..0353416af0 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -13,9 +13,9 @@
 #ifndef LIBQOS_FW_CFG_H
 #define LIBQOS_FW_CFG_H

+#include "libqtest.h"

 typedef struct QFWCFG QFWCFG;
-typedef struct QTestState QTestState;

 struct QFWCFG
 {
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations Eric Blake
@ 2017-09-01 19:22   ` Philippe Mathieu-Daudé
  2017-09-05 10:03   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-01 19:22 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Alexander Graf, open list:sPAPR, armbru, David Gibson

On 09/01/2017 03:03 PM, Eric Blake wrote:
> Now that the QPCIBus tracks QTestState, use that state instead
> of an implicit reliance on global_qtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/libqos/pci-pc.c    | 47 ++++++++++++++++++++++++-----------------------
>   tests/libqos/pci-spapr.c | 20 ++++++++++----------
>   2 files changed, 34 insertions(+), 33 deletions(-)
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 85b34c6d13..9545f881ee 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -29,90 +29,91 @@ typedef struct QPCIBusPC
> 
>   static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr)
>   {
> -    return inb(addr);
> +    return qtest_inb(bus->qts, addr);
>   }
> 
>   static void qpci_pc_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
>   {
> -    outb(addr, val);
> +    qtest_outb(bus->qts, addr, val);
>   }
> 
>   static uint16_t qpci_pc_pio_readw(QPCIBus *bus, uint32_t addr)
>   {
> -    return inw(addr);
> +    return qtest_inw(bus->qts, addr);
>   }
> 
>   static void qpci_pc_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
>   {
> -    outw(addr, val);
> +    qtest_outw(bus->qts, addr, val);
>   }
> 
>   static uint32_t qpci_pc_pio_readl(QPCIBus *bus, uint32_t addr)
>   {
> -    return inl(addr);
> +    return qtest_inl(bus->qts, addr);
>   }
> 
>   static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>   {
> -    outl(addr, val);
> +    qtest_outl(bus->qts, addr, val);
>   }
> 
>   static uint64_t qpci_pc_pio_readq(QPCIBus *bus, uint32_t addr)
>   {
> -    return (uint64_t)inl(addr) + ((uint64_t)inl(addr + 4) << 32);
> +    return (uint64_t)qtest_inl(bus->qts, addr) +
> +        ((uint64_t)qtest_inl(bus->qts, addr + 4) << 32);
>   }
> 
>   static void qpci_pc_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
>   {
> -    outl(addr, val & 0xffffffff);
> -    outl(addr + 4, val >> 32);
> +    qtest_outl(bus->qts, addr, val & 0xffffffff);
> +    qtest_outl(bus->qts, addr + 4, val >> 32);
>   }
> 
>   static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len)
>   {
> -    memread(addr, buf, len);
> +    qtest_memread(bus->qts, addr, buf, len);
>   }
> 
>   static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr,
>                                const void *buf, size_t len)
>   {
> -    memwrite(addr, buf, len);
> +    qtest_memwrite(bus->qts, addr, buf, len);
>   }
> 
>   static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inb(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inb(bus->qts, 0xcfc);
>   }
> 
>   static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inw(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inw(bus->qts, 0xcfc);
>   }
> 
>   static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inl(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inl(bus->qts, 0xcfc);
>   }
> 
>   static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outb(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outb(bus->qts, 0xcfc, value);
>   }
> 
>   static void qpci_pc_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16_t value)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outw(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outw(bus->qts, 0xcfc, value);
>   }
> 
>   static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value)
>   {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outl(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outl(bus->qts, 0xcfc, value);
>   }
> 
>   QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index cd9b8f52d2..d7b2aa75e6 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR {
>   static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return readb(s->pio_cpu_base + addr);
> +    return qtest_readb(bus->qts, s->pio_cpu_base + addr);
>   }
> 
>   static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writeb(s->pio_cpu_base + addr, val);
> +    qtest_writeb(bus->qts, s->pio_cpu_base + addr, val);
>   }
> 
>   static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap16(readw(s->pio_cpu_base + addr));
> +    return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr));
>   }
> 
>   static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writew(s->pio_cpu_base + addr, bswap16(val));
> +    qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val));
>   }
> 
>   static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap32(readl(s->pio_cpu_base + addr));
> +    return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr));
>   }
> 
>   static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writel(s->pio_cpu_base + addr, bswap32(val));
> +    qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val));
>   }
> 
>   static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap64(readq(s->pio_cpu_base + addr));
> +    return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr));
>   }
> 
>   static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writeq(s->pio_cpu_base + addr, bswap64(val));
> +    qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(val));
>   }
> 
>   static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr,
>                                  void *buf, size_t len)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    memread(s->mmio32_cpu_base + addr, buf, len);
> +    qtest_memread(bus->qts, s->mmio32_cpu_base + addr, buf, len);
>   }
> 
>   static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr,
>                                   const void *buf, size_t len)
>   {
>       QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    memwrite(s->mmio32_cpu_base + addr, buf, len);
> +    qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len);
>   }
> 
>   static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
  2017-09-01 19:21   ` [Qemu-devel] [PATCH v6 14.5/29] fixup! " Eric Blake
@ 2017-09-01 19:24   ` Philippe Mathieu-Daudé
  2017-09-01 23:06   ` John Snow
  2017-09-05 10:12   ` Thomas Huth
  3 siblings, 0 replies; 99+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-01 19:24 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	John Snow, David Gibson

On 09/01/2017 03:03 PM, Eric Blake wrote:
> Drop one more client of global_qtest by teaching all fw_cfg test
> functionality (invoked through alloc-pc) to pass in an explicit
> QTestState, adjusting all callers.  In particular, fw_cfg-test
> had to reorder things to create the test state prior to creating
> the fw_cfg.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/libqos/fw_cfg.h       | 10 ++++++----
>   tests/libqos/libqos.h       |  2 +-
>   tests/libqos/malloc-pc.h    |  4 ++--
>   tests/libqos/malloc-spapr.h |  2 +-
>   tests/libqos/malloc.h       |  1 +
>   tests/boot-order-test.c     |  6 +++---
>   tests/e1000e-test.c         |  2 +-
>   tests/fw_cfg-test.c         | 14 ++++++--------
>   tests/ide-test.c            |  2 +-
>   tests/libqos/fw_cfg.c       | 14 ++++++++------
>   tests/libqos/libqos.c       |  2 +-
>   tests/libqos/malloc-pc.c    |  8 ++++----
>   tests/libqos/malloc-spapr.c |  4 ++--
>   tests/vhost-user-test.c     |  2 +-
>   14 files changed, 38 insertions(+), 35 deletions(-)
> 
> diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
> index e8371b2317..396dd4ee1e 100644
> --- a/tests/libqos/fw_cfg.h
> +++ b/tests/libqos/fw_cfg.h
> @@ -15,10 +15,12 @@
> 
> 
>   typedef struct QFWCFG QFWCFG;
> +typedef struct QTestState QTestState;
> 
>   struct QFWCFG
>   {
>       uint64_t base;
> +    QTestState *qts;
>       void (*select)(QFWCFG *fw_cfg, uint16_t key);
>       void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
>   };
> @@ -30,12 +32,12 @@ uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
>   uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
>   uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
> 
> -QFWCFG *mm_fw_cfg_init(uint64_t base);
> -QFWCFG *io_fw_cfg_init(uint16_t base);
> +QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
> +QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
> 
> -static inline QFWCFG *pc_fw_cfg_init(void)
> +static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
>   {
> -    return io_fw_cfg_init(0x510);
> +    return io_fw_cfg_init(qts, 0x510);
>   }
> 
>   #endif
> diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
> index 78e5c044a0..07d4b93d1d 100644
> --- a/tests/libqos/libqos.h
> +++ b/tests/libqos/libqos.h
> @@ -8,7 +8,7 @@
>   typedef struct QOSState QOSState;
> 
>   typedef struct QOSOps {
> -    QGuestAllocator *(*init_allocator)(QAllocOpts);
> +    QGuestAllocator *(*init_allocator)(QTestState *qts, QAllocOpts);
>       void (*uninit_allocator)(QGuestAllocator *);
>       QPCIBus *(*qpci_init)(QTestState *qts, QGuestAllocator *alloc);
>       void (*qpci_free)(QPCIBus *bus);
> diff --git a/tests/libqos/malloc-pc.h b/tests/libqos/malloc-pc.h
> index 86ab9f0429..10f3da6cf2 100644
> --- a/tests/libqos/malloc-pc.h
> +++ b/tests/libqos/malloc-pc.h
> @@ -15,8 +15,8 @@
> 
>   #include "libqos/malloc.h"
> 
> -QGuestAllocator *pc_alloc_init(void);
> -QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags);
> +QGuestAllocator *pc_alloc_init(QTestState *qts);
> +QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags);
>   void pc_alloc_uninit(QGuestAllocator *allocator);
> 
>   #endif
> diff --git a/tests/libqos/malloc-spapr.h b/tests/libqos/malloc-spapr.h
> index 64d0e770d1..52a9346a26 100644
> --- a/tests/libqos/malloc-spapr.h
> +++ b/tests/libqos/malloc-spapr.h
> @@ -11,7 +11,7 @@
>   #include "libqos/malloc.h"
> 
>   QGuestAllocator *spapr_alloc_init(void);
> -QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags);
> +QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags);
>   void spapr_alloc_uninit(QGuestAllocator *allocator);
> 
>   #endif
> diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h
> index ae9dac8f61..828fddabdb 100644
> --- a/tests/libqos/malloc.h
> +++ b/tests/libqos/malloc.h
> @@ -14,6 +14,7 @@
>   #define LIBQOS_MALLOC_H
> 
>   #include "qemu/queue.h"
> +#include "libqtest.h"
> 
>   typedef enum {
>       ALLOC_NO_FLAGS    = 0x00,
> diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
> index 9d516830dd..5fc2ca8e9e 100644
> --- a/tests/boot-order-test.c
> +++ b/tests/boot-order-test.c
> @@ -135,7 +135,7 @@ static void test_prep_boot_order(void)
> 
>   static uint64_t read_boot_order_pmac(void)
>   {
> -    QFWCFG *fw_cfg = mm_fw_cfg_init(0xf0000510);
> +    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf0000510);
> 
>       return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
>   }
> @@ -160,7 +160,7 @@ static void test_pmac_newworld_boot_order(void)
> 
>   static uint64_t read_boot_order_sun4m(void)
>   {
> -    QFWCFG *fw_cfg = mm_fw_cfg_init(0xd00000510ULL);
> +    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd00000510ULL);
> 
>       return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
>   }
> @@ -172,7 +172,7 @@ static void test_sun4m_boot_order(void)
> 
>   static uint64_t read_boot_order_sun4u(void)
>   {
> -    QFWCFG *fw_cfg = io_fw_cfg_init(0x510);
> +    QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510);
> 
>       return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
>   }
> diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
> index d8085d944e..32aa738b72 100644
> --- a/tests/e1000e-test.c
> +++ b/tests/e1000e-test.c
> @@ -392,7 +392,7 @@ static void data_test_init(e1000e_device *d)
>       qtest_start(cmdline);
>       g_free(cmdline);
> 
> -    test_alloc = pc_alloc_init();
> +    test_alloc = pc_alloc_init(global_qtest);
>       g_assert_nonnull(test_alloc);
> 
>       test_bus = qpci_init_pc(global_qtest, test_alloc);
> diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
> index 688342bed5..47596c57a1 100644
> --- a/tests/fw_cfg-test.c
> +++ b/tests/fw_cfg-test.c
> @@ -107,7 +107,11 @@ int main(int argc, char **argv)
> 
>       g_test_init(&argc, &argv, NULL);
> 
> -    fw_cfg = pc_fw_cfg_init();
> +    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> +    s = qtest_start(cmdline);
> +    g_free(cmdline);
> +
> +    fw_cfg = pc_fw_cfg_init(s);
> 
>       qtest_add_func("fw_cfg/signature", test_fw_cfg_signature);
>       qtest_add_func("fw_cfg/id", test_fw_cfg_id);
> @@ -125,15 +129,9 @@ int main(int argc, char **argv)
>       qtest_add_func("fw_cfg/numa", test_fw_cfg_numa);
>       qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);
> 
> -    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> -    s = qtest_start(cmdline);
> -    g_free(cmdline);
> -
>       ret = g_test_run();
> 
> -    if (s) {
> -        qtest_quit(s);
> -    }
> +    qtest_quit(s);
> 
>       return ret;
>   }
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index b2237b6158..084f6a5f96 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -125,7 +125,7 @@ static void ide_test_start(const char *cmdline_fmt, ...)
>       va_end(ap);
> 
>       qtest_start(cmdline);
> -    guest_malloc = pc_alloc_init();
> +    guest_malloc = pc_alloc_init(global_qtest);
> 
>       g_free(cmdline);
>   }
> diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
> index 4d9dc3fd0b..d0889d1e22 100644
> --- a/tests/libqos/fw_cfg.c
> +++ b/tests/libqos/fw_cfg.c
> @@ -56,7 +56,7 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)
> 
>   static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
>   {
> -    writew(fw_cfg->base, key);
> +    qtest_writew(fw_cfg->qts, fw_cfg->base, key);
>   }
> 
>   static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
> @@ -65,15 +65,16 @@ static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
>       int i;
> 
>       for (i = 0; i < len; i++) {
> -        ptr[i] = readb(fw_cfg->base + 2);
> +        ptr[i] = qtest_readb(fw_cfg->qts, fw_cfg->base + 2);
>       }
>   }
> 
> -QFWCFG *mm_fw_cfg_init(uint64_t base)
> +QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base)
>   {
>       QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
> 
>       fw_cfg->base = base;
> +    fw_cfg->qts = qts;
>       fw_cfg->select = mm_fw_cfg_select;
>       fw_cfg->read = mm_fw_cfg_read;
> 
> @@ -82,7 +83,7 @@ QFWCFG *mm_fw_cfg_init(uint64_t base)
> 
>   static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
>   {
> -    outw(fw_cfg->base, key);
> +    qtest_outw(fw_cfg->qts, fw_cfg->base, key);
>   }
> 
>   static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
> @@ -91,15 +92,16 @@ static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
>       int i;
> 
>       for (i = 0; i < len; i++) {
> -        ptr[i] = inb(fw_cfg->base + 1);
> +        ptr[i] = qtest_inb(fw_cfg->qts, fw_cfg->base + 1);
>       }
>   }
> 
> -QFWCFG *io_fw_cfg_init(uint16_t base)
> +QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base)
>   {
>       QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
> 
>       fw_cfg->base = base;
> +    fw_cfg->qts = qts;
>       fw_cfg->select = io_fw_cfg_select;
>       fw_cfg->read = io_fw_cfg_read;
> 
> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
> index c95428e1cb..62d2f39b93 100644
> --- a/tests/libqos/libqos.c
> +++ b/tests/libqos/libqos.c
> @@ -24,7 +24,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>       qs->ops = ops;
>       if (ops) {
>           if (ops->init_allocator) {
> -            qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
> +            qs->alloc = ops->init_allocator(qs->qts, ALLOC_NO_FLAGS);
>           }
>           if (ops->qpci_init) {
>               qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
> diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
> index dd2b900c5f..634b9c288a 100644
> --- a/tests/libqos/malloc-pc.c
> +++ b/tests/libqos/malloc-pc.c
> @@ -29,11 +29,11 @@ void pc_alloc_uninit(QGuestAllocator *allocator)
>       alloc_uninit(allocator);
>   }
> 
> -QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
> +QGuestAllocator *pc_alloc_init_flags(QTestState *qts, QAllocOpts flags)
>   {
>       QGuestAllocator *s;
>       uint64_t ram_size;
> -    QFWCFG *fw_cfg = pc_fw_cfg_init();
> +    QFWCFG *fw_cfg = pc_fw_cfg_init(qts);
> 
>       ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
>       s = alloc_init_flags(flags, 1 << 20, MIN(ram_size, 0xE0000000));
> @@ -45,7 +45,7 @@ QGuestAllocator *pc_alloc_init_flags(QAllocOpts flags)
>       return s;
>   }
> 
> -inline QGuestAllocator *pc_alloc_init(void)
> +inline QGuestAllocator *pc_alloc_init(QTestState *qts)
>   {
> -    return pc_alloc_init_flags(ALLOC_NO_FLAGS);
> +    return pc_alloc_init_flags(qts, ALLOC_NO_FLAGS);
>   }
> diff --git a/tests/libqos/malloc-spapr.c b/tests/libqos/malloc-spapr.c
> index 006404af33..1c359cea6c 100644
> --- a/tests/libqos/malloc-spapr.c
> +++ b/tests/libqos/malloc-spapr.c
> @@ -22,7 +22,7 @@ void spapr_alloc_uninit(QGuestAllocator *allocator)
>       alloc_uninit(allocator);
>   }
> 
> -QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags)
> +QGuestAllocator *spapr_alloc_init_flags(QTestState *qts, QAllocOpts flags)
>   {
>       QGuestAllocator *s;
> 
> @@ -34,5 +34,5 @@ QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags)
> 
>   QGuestAllocator *spapr_alloc_init(void)
>   {
> -    return spapr_alloc_init_flags(ALLOC_NO_FLAGS);
> +    return spapr_alloc_init_flags(NULL, ALLOC_NO_FLAGS);
>   }
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index ea7d38ea44..562bfaefd2 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -894,7 +894,7 @@ static void test_multiqueue(void)
>       bus = qpci_init_pc(global_qtest, NULL);
>       dev = virtio_net_pci_init(bus, PCI_SLOT);
> 
> -    alloc = pc_alloc_init();
> +    alloc = pc_alloc_init(global_qtest);
>       for (i = 0; i < queues * 2; i++) {
>           vq[i] = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, i);
>       }
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
  2017-09-01 19:20   ` Philippe Mathieu-Daudé
@ 2017-09-01 23:06   ` John Snow
  2017-09-05  9:36   ` Thomas Huth
  2 siblings, 0 replies; 99+ messages in thread
From: John Snow @ 2017-09-01 23:06 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, David Gibson



On 09/01/2017 02:03 PM, Eric Blake wrote:
> When initializing a QPCIBus, track which QTestState the bus is
> associated with (so that a later patch can then explicitly use
> that test state for all communication on the bus, rather than
> blindly relying on global_qtest).  Update the initialization
> functions to take another parameter, and update all callers to
> pass in state (for now, most callers get away with passing the
> current global_qtest as the current state, although this required
> fixing the order of initialization to ensure qtest_start() is
> called before qpci_init*() in rtl8139-test, and provided an
> opportunity to pass in the allocator in e1000e-test).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
  2017-09-01 19:21   ` [Qemu-devel] [PATCH v6 14.5/29] fixup! " Eric Blake
  2017-09-01 19:24   ` [Qemu-devel] [PATCH v6 14/29] " Philippe Mathieu-Daudé
@ 2017-09-01 23:06   ` John Snow
  2017-09-05 10:12   ` Thomas Huth
  3 siblings, 0 replies; 99+ messages in thread
From: John Snow @ 2017-09-01 23:06 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	David Gibson



On 09/01/2017 02:03 PM, Eric Blake wrote:
> Drop one more client of global_qtest by teaching all fw_cfg test
> functionality (invoked through alloc-pc) to pass in an explicit
> QTestState, adjusting all callers.  In particular, fw_cfg-test
> had to reorder things to create the test state prior to creating
> the fw_cfg.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest Eric Blake
@ 2017-09-01 23:11   ` John Snow
  2017-09-05 10:32   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: John Snow @ 2017-09-01 23:11 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru, open list:IDE



On 09/01/2017 02:03 PM, Eric Blake wrote:
> Managing parallel connections to two different monitors via
> the implicit global_qtest makes it hard to copy-and-paste code
> to tests that are not aware of the implicit state; the
> management of global_qtest is even harder to follow because
> it was masked behind set_context().
> 
> Instead, explicitly pass QTestState* around (generally, by
> reusing the member already present in ahci->parent QOSState),
> and call explicit qtest_* functions on all places that
> interact with a monitor.
> 
> We can assert that the conversion is correct by checking that
> global_qtest remains NULL throughout the test (a later patch
> that changes global_qtest to not be a public global variable
> will drop the assertions).
> 
> Bonus: there were several spots that were constructing a JSON
> string, then passing that through qmp() as the format, rather
> than directly using qmp() to construct the JSON.  Fixing that
> gets us one step closer to enabling -Wformat checking on
> constructed JSON.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>

I think you've stumbled across why I was not a big fan of the implicit
context versions of these functions.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts Eric Blake
@ 2017-09-01 23:16   ` John Snow
  2017-09-05 13:06   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: John Snow @ 2017-09-01 23:16 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Thomas Huth, open list:Floppy, Ben Warren, Michael S. Tsirkin,
	Jason Wang, Amit Shah, armbru, Alexander Graf, Keith Busch,
	open list:sPAPR, Gerd Hoffmann, Stefan Hajnoczi, pbonzini,
	Andreas Färber, Dr. David Alan Gilbert, David Gibson



On 09/01/2017 02:03 PM, Eric Blake wrote:
> Remove the trivial wrappers qtest_start() and qtest_end(), to make
> it obvious in the rest of the testsuite where we are still relying on
> global_qtest.  Doing this makes it easier to see what remaining
> cleanups will be needed if we don't want an implicit dependency
> on global state.  Many tests can also take advantage of qtest_init()
> doing formatting of args, avoiding a temporary local variable.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: John Snow <jsnow@redhat.com>

diffstat looks like a win overall, unless it's just a local minima ;)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start() Eric Blake
@ 2017-09-01 23:17   ` John Snow
  2017-09-05 13:10   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: John Snow @ 2017-09-01 23:17 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: Thomas Huth, open list:Floppy, Ben Warren, Michael S. Tsirkin,
	Jason Wang, Amit Shah, armbru, Alexander Graf, Keith Busch,
	open list:sPAPR, Gerd Hoffmann, Stefan Hajnoczi, Igor Mammedov,
	pbonzini, Andreas Färber, Dr. David Alan Gilbert,
	David Gibson



On 09/01/2017 02:03 PM, Eric Blake wrote:
> We already have another qtest_init() in the tree, for the
> top-level qtest.c device; having two functions with different
> signatures is confusing.  Rename the libqtest version to
> qtest_start() to eliminate the duplication.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Why not.

Reviewed-by: John Snow <jsnow@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: " Eric Blake
@ 2017-09-02  0:07   ` Philippe Mathieu-Daudé
  2017-09-05 11:05   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-02  0:07 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 09/01/2017 03:03 PM, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  It turns out that with the
> recent changes to libqos, fw_cfg-test was not even using
> global_qtest any more.  Avoid a pointless strdup while at it.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/fw_cfg-test.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
> index 47596c57a1..3a8dc7a2cd 100644
> --- a/tests/fw_cfg-test.c
> +++ b/tests/fw_cfg-test.c
> @@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
>   int main(int argc, char **argv)
>   {
>       QTestState *s;
> -    char *cmdline;
>       int ret;
> 
>       g_test_init(&argc, &argv, NULL);
> 
> -    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> -    s = qtest_start(cmdline);
> -    g_free(cmdline);
> +    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
> 
>       fw_cfg = pc_fw_cfg_init(s);
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness() Eric Blake
@ 2017-09-02  0:10   ` Philippe Mathieu-Daudé
  2017-09-05  9:25   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-02  0:10 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 09/01/2017 03:03 PM, Eric Blake wrote:
> There was only one caller; it's easier to inline things.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/libqtest.c | 22 ++++++----------------
>   1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 5d16351e24..b6dd26e54a 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -244,20 +244,6 @@ redo:
>       return words;
>   }
> 
> -static int qtest_query_target_endianness(QTestState *s)
> -{
> -    gchar **args;
> -    int big_endian;
> -
> -    qtest_sendf(s, "endianness\n");
> -    args = qtest_rsp(s, 1);
> -    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> -    big_endian = strcmp(args[1], "big") == 0;
> -    g_strfreev(args);
> -
> -    return big_endian;
> -}
> -
>   static void cleanup_sigabrt_handler(void)
>   {
>       sigaction(SIGABRT, &sigact_old, NULL);
> @@ -288,6 +274,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>       gchar *qmp_socket_path;
>       gchar *command;
>       const char *qemu_binary;
> +    gchar **args;
> 
>       qemu_binary = getenv("QTEST_QEMU_BINARY");
>       if (!qemu_binary) {
> @@ -351,8 +338,11 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>       }
> 
>       /* ask endianness of the target */
> -
> -    s->big_endian = qtest_query_target_endianness(s);
> +    qtest_sendf(s, "endianness\n");
> +    args = qtest_rsp(s, 1);
> +    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> +    s->big_endian = strcmp(args[1], "big") == 0;
> +    g_strfreev(args);
> 
>       return s;
>   }
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot Eric Blake
@ 2017-09-04 14:03   ` Thomas Huth
  2017-09-06 19:33     ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-04 14:03 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru, Kevin Wolf

On 01.09.2017 20:03, Eric Blake wrote:
> Right now, tests/multiboot is not run by default during 'make check';
> but when it is run in-tree, it was leaving some junk behind that could
> accidentally get checked in with a careless 'git add tests'.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/.gitignore | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index fed0189a5a..64ecd6683b 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -10,6 +10,8 @@ check-qnull
>  check-qstring
>  check-qom-interface
>  check-qom-proplist
> +multiboot/test.out

Your patch is of course a good idea ... but that test.out smells quite
bad ... I guess it should (a) use mktemp for a better file name instead
so that we can run this in parallel and (b) clean up the temporary file
once the test has been done?

> +multiboot/*.elf
>  qht-bench
>  rcutorture
>  test-aio
> 

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion Eric Blake
@ 2017-09-04 14:06   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-04 14:06 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Assertions should be separate from the side effects, since in
> theory, g_assert() can be disabled (in practice, we can't really
> ever do that).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  qtest.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 57 insertions(+), 23 deletions(-)

Right, we should get rid of this bad coding style in the QEMU sources.

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable Eric Blake
@ 2017-09-04 17:02   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-04 17:02 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Prior to commit 063c23d9, we were tracking a list of parallel
> qtest objects, in order to safely clean up a SIGABRT handler
> only after the last connection quits.  But when we switched to
> more of glib's infrastructure, the list became dead code that
> is never assigned to.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/libqtest.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: " Eric Blake
@ 2017-09-05  7:04   ` Thomas Huth
  2017-09-08 12:48   ` Michael S. Tsirkin
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  7:04 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Ben Warren, Michael S. Tsirkin

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Adjust the helper code to
> use explicit state instead, and update all callers.
> 
> Fix some trailing whitespace while touching the file.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/boot-sector.h      | 6 ++++--
>  tests/bios-tables-test.c | 2 +-
>  tests/boot-sector.c      | 8 ++++----
>  tests/pxe-test.c         | 2 +-
>  tests/vmgenid-test.c     | 2 +-
>  5 files changed, 11 insertions(+), 9 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 21/29] qmp-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 21/29] qmp-test: " Eric Blake
@ 2017-09-05  7:11   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  7:11 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Although qmp-test does not
> maintain parallel qtest connections, it was the last test
> assigning to global_qtest.  It's just as easy to be explicit
> about the state; once all tests have been cleaned up, a later
> patch can then get rid of global_qtest and a layer of wrappers
> in libqtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/qmp-test.c | 35 ++++++++++++++++++-----------------
>  1 file changed, 18 insertions(+), 17 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore Eric Blake
@ 2017-09-05  7:20   ` Thomas Huth
  2017-09-05  9:53     ` Markus Armbruster
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  7:20 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru, Marc-André Lureau

On 01.09.2017 20:03, Eric Blake wrote:
> It doesn't matter if things are unsorted, but finding stuff in a list
> is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
> en_US.UTF-8).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/.gitignore | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

BTW, did you note the patch "build-sys: generate tests/.gitignore" from
Marc-André ? Maybe the list can be generated automatically, too...

> diff --git a/tests/.gitignore b/tests/.gitignore
> index 64ecd6683b..8d35a58751 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -1,25 +1,27 @@
> +*-test

... but looking at this wildcard, I wonder if we just named most of our
tests in a bad way. If we name the files something-test instead of
test-something, we maybe do not need the automatic generation from
Marc-André (which is kind of ugly because it writes to the source
directory - and this should not happen when doing out of tree builds).

So what do you think about renaming our tests, so that the above
wildcard applies instead?

 Thomas

>  atomic_add-bench
>  benchmark-crypto-cipher
>  benchmark-crypto-hash
>  benchmark-crypto-hmac
>  check-qdict
> -check-qnum
>  check-qjson
>  check-qlist
>  check-qnull
> -check-qstring
> +check-qnum
>  check-qom-interface
>  check-qom-proplist
> -multiboot/test.out
> +check-qstring
>  multiboot/*.elf
> +multiboot/test.out
> +qapi-schema/*.test.*
>  qht-bench
>  rcutorture
>  test-aio
>  test-aio-multithread
>  test-arm-mptimer
>  test-base64
> -test-bitops
>  test-bitcnt
> +test-bitops
>  test-blockjob
>  test-blockjob-txn
>  test-bufferiszero
> @@ -35,18 +37,19 @@ test-crypto-ivgen
>  test-crypto-pbkdf
>  test-crypto-secret
>  test-crypto-tlscredsx509
> -test-crypto-tlscredsx509-work/
>  test-crypto-tlscredsx509-certs/
> +test-crypto-tlscredsx509-work/
>  test-crypto-tlssession
> -test-crypto-tlssession-work/
>  test-crypto-tlssession-client/
>  test-crypto-tlssession-server/
> +test-crypto-tlssession-work/
>  test-crypto-xts
>  test-cutils
> +test-filter-mirror
> +test-filter-redirector
>  test-hbitmap
>  test-hmp
>  test-int128
> -test-iov
>  test-io-channel-buffer
>  test-io-channel-command
>  test-io-channel-command.fifo
> @@ -55,27 +58,29 @@ test-io-channel-file.txt
>  test-io-channel-socket
>  test-io-channel-tls
>  test-io-task
> +test-iov
>  test-keyval
>  test-logging
>  test-mul64
> +test-netfilter
>  test-opts-visitor
>  test-qapi-event.[ch]
>  test-qapi-types.[ch]
>  test-qapi-util
>  test-qapi-visit.[ch]
>  test-qdev-global-props
> -test-qemu-opts
>  test-qdist
> +test-qemu-opts
>  test-qga
>  test-qht
>  test-qht-par
>  test-qmp-commands
>  test-qmp-commands.h
>  test-qmp-event
> -test-qobject-input-strict
> -test-qobject-input-visitor
>  test-qmp-introspect.[ch]
>  test-qmp-marshal.c
> +test-qobject-input-strict
> +test-qobject-input-visitor
>  test-qobject-output-visitor
>  test-rcu-list
>  test-replication
> @@ -92,8 +97,3 @@ test-write-threshold
>  test-x86-cpuid
>  test-x86-cpuid-compat
>  test-xbzrle
> -test-netfilter
> -test-filter-mirror
> -test-filter-redirector
> -*-test
> -qapi-schema/*.test.*
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
@ 2017-09-05  7:43   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  7:43 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Back when the test was introduced, in commit 62c39b307, the
> test was set up to run qemu-ga directly on the host performing
> the test, and defaults to limiting itself to safe commands.  At
> the time, it was envisioned that setting QGA_TEST_SIDE_EFFECTING
> in the environment could cover a few more commands, while noting
> the potential danger of those side effects running in the host.
> 
> But this has NEVER been tested: if you enable the environment
> variable, the test WILL fail.  One obvious reason: if you are not
> running as root, you'll probably get a permission failure when
> trying to freeze the file systems, or when changing system time.
> Less obvious: if you run the test as root (wow, you're brave), you
> could end up hanging if the test tries to log things to a
> temporarily frozen filesystem.  But the cutest reason of all: if
> you get past the above hurdles, the test uses invalid JSON in
> test_qga_fstrim() (missing '' around the dictionary key 'minimum'),
> and will thus fail an assertion in qmp_fd().
> 
> Rather than leave this untested time-bomb in place, rip it out.
> Hopefully, as originally envisioned, we can find an opportunity
> to test an actual sandboxed guest where the guest-agent has
> full permissions and will not unduly affect the host running
> the test - if so, 'git revert' can be used if desired, for
> salvaging any useful parts of this attempt.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/test-qga.c | 90 --------------------------------------------------------
>  1 file changed, 90 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp() Eric Blake
@ 2017-09-05  7:44   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  7:44 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Don't open-code something that has a convenient helper available.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> 
> ---
>  tests/numa-test.c | 21 +++------------------
>  1 file changed, 3 insertions(+), 18 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length Eric Blake
@ 2017-09-05  8:12   ` Thomas Huth
  2017-09-05  9:54     ` Markus Armbruster
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  8:12 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Rather than make multiple callers call strlen(), it's easier if
> socket_send() itself can compute a length via strlen() if none
> was provided (caller passes -1).  Callers that can get at the
> length more efficiently are left that way.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqtest.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

I have to say that I don't like this idea very much. socket_send()
should IMHO not know about the type of the data that should be sent,
i.e. it should not assume that the content is a zero-terminated string.
This also could lead to some hard to detect bugs later in case somebody
is calling the function like this:

  size = someotherfunction();
  socket_send(fd, buf, size);

... and the someotherfunction() returned a negative error code instead
of a correct size.

So I'd like to suggest to simply drop this patch.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul() Eric Blake
@ 2017-09-05  9:11   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  9:11 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> This will keep checkpatch happy when the next patch does code motion.
> Fix the include order to match HACKING when adding the needed header.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> 
> ---
>  tests/libqtest.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions Eric Blake
@ 2017-09-05  9:22   ` Thomas Huth
  2017-09-05 10:01     ` Markus Armbruster
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  9:22 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Put static functions prior to public ones, in part so that
> improvements to qtest_start() can benefit from the static
> helpers without needing forward references.  Code motion, with
> no semantic change.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqtest.c | 263 +++++++++++++++++++++++++++----------------------------
>  1 file changed, 131 insertions(+), 132 deletions(-)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 438a22678d..5d16351e24 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -49,7 +49,6 @@ static struct sigaction sigact_old;
>      g_assert_cmpint(ret, !=, -1); \
>  } while (0)
> 
> -static int qtest_query_target_endianness(QTestState *s);
> 
>  static int init_socket(const char *socket_path)
>  {
> @@ -128,6 +127,137 @@ static void setup_sigabrt_handler(void)
>      sigaction(SIGABRT, &sigact, &sigact_old);
>  }
> 
> +static void socket_send(int fd, const char *buf, ssize_t size)
> +{
> +    size_t offset;
> +
> +    if (size < 0) {
> +        size = strlen(buf);
> +    }
> +    offset = 0;
> +    while (offset < size) {
> +        ssize_t len;
> +
> +        len = write(fd, buf + offset, size - offset);
> +        if (len == -1 && errno == EINTR) {
> +            continue;
> +        }
> +
> +        g_assert_no_errno(len);
> +        g_assert_cmpint(len, >, 0);
> +
> +        offset += len;
> +    }
> +}
> +
> +static void socket_sendf(int fd, const char *fmt, va_list ap)
> +{
> +    gchar *str = g_strdup_vprintf(fmt, ap);
> +
> +    socket_send(fd, str, -1);
> +    g_free(str);
> +}
> +
> +static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
> +{
> +    va_list ap;
> +
> +    va_start(ap, fmt);
> +    socket_sendf(s->fd, fmt, ap);
> +    va_end(ap);
> +}
> +
> +static GString *qtest_recv_line(QTestState *s)
> +{
> +    GString *line;
> +    size_t offset;
> +    char *eol;
> +
> +    while ((eol = strchr(s->rx->str, '\n')) == NULL) {
> +        ssize_t len;
> +        char buffer[1024];
> +
> +        len = read(s->fd, buffer, sizeof(buffer));
> +        if (len == -1 && errno == EINTR) {
> +            continue;
> +        }
> +
> +        if (len == -1 || len == 0) {
> +            fprintf(stderr, "Broken pipe\n");
> +            exit(1);
> +        }
> +
> +        g_string_append_len(s->rx, buffer, len);
> +    }
> +
> +    offset = eol - s->rx->str;
> +    line = g_string_new_len(s->rx->str, offset);
> +    g_string_erase(s->rx, 0, offset + 1);
> +
> +    return line;
> +}
> +
> +static gchar **qtest_rsp(QTestState *s, int expected_args)
> +{
> +    GString *line;
> +    gchar **words;
> +    int i;
> +
> +redo:
> +    line = qtest_recv_line(s);
> +    words = g_strsplit(line->str, " ", 0);
> +    g_string_free(line, TRUE);
> +
> +    if (strcmp(words[0], "IRQ") == 0) {
> +        long irq;
> +        int ret;
> +
> +        g_assert(words[1] != NULL);
> +        g_assert(words[2] != NULL);
> +
> +        ret = qemu_strtol(words[2], NULL, 0, &irq);
> +        g_assert(!ret);
> +        g_assert_cmpint(irq, >=, 0);
> +        g_assert_cmpint(irq, <, MAX_IRQ);
> +
> +        if (strcmp(words[1], "raise") == 0) {
> +            s->irq_level[irq] = true;
> +        } else {
> +            s->irq_level[irq] = false;
> +        }
> +
> +        g_strfreev(words);
> +        goto redo;
> +    }
> +
> +    g_assert(words[0] != NULL);
> +    g_assert_cmpstr(words[0], ==, "OK");
> +
> +    if (expected_args) {
> +        for (i = 0; i < expected_args; i++) {
> +            g_assert(words[i] != NULL);
> +        }
> +    } else {
> +        g_strfreev(words);
> +    }
> +
> +    return words;
> +}
> +
> +static int qtest_query_target_endianness(QTestState *s)
> +{
> +    gchar **args;
> +    int big_endian;
> +
> +    qtest_sendf(s, "endianness\n");
> +    args = qtest_rsp(s, 1);
> +    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> +    big_endian = strcmp(args[1], "big") == 0;
> +    g_strfreev(args);
> +
> +    return big_endian;
> +}
> +
>  static void cleanup_sigabrt_handler(void)
>  {
>      sigaction(SIGABRT, &sigact_old, NULL);
> @@ -252,137 +382,6 @@ void qtest_quit(QTestState *s)
>      g_free(s);
>  }
> 
> -static void socket_send(int fd, const char *buf, ssize_t size)
> -{
> -    size_t offset;
> -
> -    if (size < 0) {
> -        size = strlen(buf);
> -    }
> -    offset = 0;
> -    while (offset < size) {
> -        ssize_t len;
> -
> -        len = write(fd, buf + offset, size - offset);
> -        if (len == -1 && errno == EINTR) {
> -            continue;
> -        }
> -
> -        g_assert_no_errno(len);
> -        g_assert_cmpint(len, >, 0);
> -
> -        offset += len;
> -    }
> -}
> -
> -static void socket_sendf(int fd, const char *fmt, va_list ap)
> -{
> -    gchar *str = g_strdup_vprintf(fmt, ap);
> -
> -    socket_send(fd, str, -1);
> -    g_free(str);
> -}
> -
> -static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
> -{
> -    va_list ap;
> -
> -    va_start(ap, fmt);
> -    socket_sendf(s->fd, fmt, ap);
> -    va_end(ap);
> -}
> -
> -static GString *qtest_recv_line(QTestState *s)
> -{
> -    GString *line;
> -    size_t offset;
> -    char *eol;
> -
> -    while ((eol = strchr(s->rx->str, '\n')) == NULL) {
> -        ssize_t len;
> -        char buffer[1024];
> -
> -        len = read(s->fd, buffer, sizeof(buffer));
> -        if (len == -1 && errno == EINTR) {
> -            continue;
> -        }
> -
> -        if (len == -1 || len == 0) {
> -            fprintf(stderr, "Broken pipe\n");
> -            exit(1);
> -        }
> -
> -        g_string_append_len(s->rx, buffer, len);
> -    }
> -
> -    offset = eol - s->rx->str;
> -    line = g_string_new_len(s->rx->str, offset);
> -    g_string_erase(s->rx, 0, offset + 1);
> -
> -    return line;
> -}
> -
> -static gchar **qtest_rsp(QTestState *s, int expected_args)
> -{
> -    GString *line;
> -    gchar **words;
> -    int i;
> -
> -redo:
> -    line = qtest_recv_line(s);
> -    words = g_strsplit(line->str, " ", 0);
> -    g_string_free(line, TRUE);
> -
> -    if (strcmp(words[0], "IRQ") == 0) {
> -        long irq;
> -        int ret;
> -
> -        g_assert(words[1] != NULL);
> -        g_assert(words[2] != NULL);
> -
> -        ret = qemu_strtol(words[2], NULL, 0, &irq);
> -        g_assert(!ret);
> -        g_assert_cmpint(irq, >=, 0);
> -        g_assert_cmpint(irq, <, MAX_IRQ);
> -
> -        if (strcmp(words[1], "raise") == 0) {
> -            s->irq_level[irq] = true;
> -        } else {
> -            s->irq_level[irq] = false;
> -        }
> -
> -        g_strfreev(words);
> -        goto redo;
> -    }
> -
> -    g_assert(words[0] != NULL);
> -    g_assert_cmpstr(words[0], ==, "OK");
> -
> -    if (expected_args) {
> -        for (i = 0; i < expected_args; i++) {
> -            g_assert(words[i] != NULL);
> -        }
> -    } else {
> -        g_strfreev(words);
> -    }
> -
> -    return words;
> -}
> -
> -static int qtest_query_target_endianness(QTestState *s)
> -{
> -    gchar **args;
> -    int big_endian;
> -
> -    qtest_sendf(s, "endianness\n");
> -    args = qtest_rsp(s, 1);
> -    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> -    big_endian = strcmp(args[1], "big") == 0;
> -    g_strfreev(args);
> -
> -    return big_endian;
> -}
> -
>  typedef struct {
>      JSONMessageParser parser;
>      QDict *response;
> 

That's a *lot* of code motion - just to get rid of one forward
declaration. IMHO getting rid of just one forward declaration does not
justify this code churn. But if we really, really want to get rid of the
forward declaration here, it's maybe better to move the
qtest_init_without_qmp_handshake() and qtest_init() function to the end
of the file instead?

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness() Eric Blake
  2017-09-02  0:10   ` Philippe Mathieu-Daudé
@ 2017-09-05  9:25   ` Thomas Huth
  2017-09-06 20:12     ` Eric Blake
  1 sibling, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  9:25 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> There was only one caller; it's easier to inline things.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqtest.c | 22 ++++++----------------
>  1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 5d16351e24..b6dd26e54a 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -244,20 +244,6 @@ redo:
>      return words;
>  }
> 
> -static int qtest_query_target_endianness(QTestState *s)
> -{
> -    gchar **args;
> -    int big_endian;
> -
> -    qtest_sendf(s, "endianness\n");
> -    args = qtest_rsp(s, 1);
> -    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> -    big_endian = strcmp(args[1], "big") == 0;
> -    g_strfreev(args);
> -
> -    return big_endian;
> -}
> -
>  static void cleanup_sigabrt_handler(void)
>  {
>      sigaction(SIGABRT, &sigact_old, NULL);
> @@ -288,6 +274,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>      gchar *qmp_socket_path;
>      gchar *command;
>      const char *qemu_binary;
> +    gchar **args;
> 
>      qemu_binary = getenv("QTEST_QEMU_BINARY");
>      if (!qemu_binary) {
> @@ -351,8 +338,11 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>      }
> 
>      /* ask endianness of the target */
> -
> -    s->big_endian = qtest_query_target_endianness(s);
> +    qtest_sendf(s, "endianness\n");
> +    args = qtest_rsp(s, 1);
> +    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
> +    s->big_endian = strcmp(args[1], "big") == 0;
> +    g_strfreev(args);
> 
>      return s;
>  }

Ah, well, now that's another way of getting rid of the forward
declaration in the previous patch - so may I suggest to drop the
previous patch, and simply do the code inlining here instead?

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
  2017-09-01 19:20   ` Philippe Mathieu-Daudé
  2017-09-01 23:06   ` John Snow
@ 2017-09-05  9:36   ` Thomas Huth
  2017-09-06 21:00     ` Eric Blake
  2 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  9:36 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> When initializing a QPCIBus, track which QTestState the bus is
> associated with (so that a later patch can then explicitly use
> that test state for all communication on the bus, rather than
> blindly relying on global_qtest).  Update the initialization
> functions to take another parameter, and update all callers to
> pass in state (for now, most callers get away with passing the
> current global_qtest as the current state, although this required
> fixing the order of initialization to ensure qtest_start() is
> called before qpci_init*() in rtl8139-test, and provided an
> opportunity to pass in the allocator in e1000e-test).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
[...]
> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
> index 6226546c28..c95428e1cb 100644
> --- a/tests/libqos/libqos.c
> +++ b/tests/libqos/libqos.c
> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>          if (ops->init_allocator) {
>              qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
>          }
> -        if (ops->qpci_init && qs->alloc) {
> -            qs->pcibus = ops->qpci_init(qs->alloc);
> +        if (ops->qpci_init) {

Why did you remove the check for qs->alloc?

> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
>          }
>      }
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 02ce49927a..85b34c6d13 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -115,11 +115,14 @@ static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint3
>      outl(0xcfc, value);
>  }
> 
> -QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
> +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
>  {
>      QPCIBusPC *ret;
> 
> +    assert(qts);
> +
>      ret = g_malloc(sizeof(*ret));
> +    ret->bus.qts = qts;
> 
>      ret->bus.pio_readb = qpci_pc_pio_readb;
>      ret->bus.pio_readw = qpci_pc_pio_readw;
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index 2043f1e123..cd9b8f52d2 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -154,11 +154,14 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
>  #define SPAPR_PCI_MMIO32_WIN_SIZE    0x80000000 /* 2 GiB */
>  #define SPAPR_PCI_IO_WIN_SIZE        0x10000
> 
> -QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
> +QPCIBus *qpci_init_spapr(QTestState *qts, QGuestAllocator *alloc)
>  {
>      QPCIBusSPAPR *ret;
> 
> +    assert(qts);
> +
>      ret = g_malloc(sizeof(*ret));

+1 for using g_malloc0 here instead.

> +    ret->bus.qts = qts;
> 
>      ret->alloc = alloc;
> 
> @@ -201,6 +204,7 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
>      ret->bus.mmio_alloc_ptr = ret->mmio32.pci_base;
>      ret->bus.mmio_limit = ret->mmio32.pci_base + ret->mmio32.size;
> 
> +

Superfluous white space change.

>      return &ret->bus;
>  }

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-05  7:20   ` Thomas Huth
@ 2017-09-05  9:53     ` Markus Armbruster
  2017-09-05  9:58       ` Thomas Huth
  2017-09-05 10:10       ` Daniel P. Berrange
  0 siblings, 2 replies; 99+ messages in thread
From: Markus Armbruster @ 2017-09-05  9:53 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Eric Blake, qemu-devel, pbonzini, Marc-André Lureau

Thomas Huth <thuth@redhat.com> writes:

> On 01.09.2017 20:03, Eric Blake wrote:
>> It doesn't matter if things are unsorted, but finding stuff in a list
>> is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
>> en_US.UTF-8).
>> 
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/.gitignore | 30 +++++++++++++++---------------
>>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
> BTW, did you note the patch "build-sys: generate tests/.gitignore" from
> Marc-André ? Maybe the list can be generated automatically, too...
>
>> diff --git a/tests/.gitignore b/tests/.gitignore
>> index 64ecd6683b..8d35a58751 100644
>> --- a/tests/.gitignore
>> +++ b/tests/.gitignore
>> @@ -1,25 +1,27 @@
>> +*-test
>
> ... but looking at this wildcard, I wonder if we just named most of our
> tests in a bad way. If we name the files something-test instead of
> test-something, we maybe do not need the automatic generation from
> Marc-André (which is kind of ugly because it writes to the source
> directory - and this should not happen when doing out of tree builds).
>
> So what do you think about renaming our tests, so that the above
> wildcard applies instead?

Apropos naming tests: there's an (unspoken) convention to name unit
tests check-FOO or test-FOO and tests using libqtest FOO-test, but it's
not really honored anymore, probably because people creating tests
didn't know about it.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length
  2017-09-05  8:12   ` Thomas Huth
@ 2017-09-05  9:54     ` Markus Armbruster
  2017-09-05 22:20       ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Markus Armbruster @ 2017-09-05  9:54 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Eric Blake, qemu-devel, pbonzini

Thomas Huth <thuth@redhat.com> writes:

> On 01.09.2017 20:03, Eric Blake wrote:
>> Rather than make multiple callers call strlen(), it's easier if
>> socket_send() itself can compute a length via strlen() if none
>> was provided (caller passes -1).  Callers that can get at the
>> length more efficiently are left that way.
>> 
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/libqtest.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> I have to say that I don't like this idea very much. socket_send()
> should IMHO not know about the type of the data that should be sent,
> i.e. it should not assume that the content is a zero-terminated string.

I agree.

> This also could lead to some hard to detect bugs later in case somebody
> is calling the function like this:
>
>   size = someotherfunction();
>   socket_send(fd, buf, size);
>
> ... and the someotherfunction() returned a negative error code instead
> of a correct size.
>
> So I'd like to suggest to simply drop this patch.

A separate wrapper function for sending zero-terminated strings would be
fine with me.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-05  9:53     ` Markus Armbruster
@ 2017-09-05  9:58       ` Thomas Huth
  2017-09-05 10:10       ` Daniel P. Berrange
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05  9:58 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Eric Blake, qemu-devel, pbonzini, Marc-André Lureau

On 05.09.2017 11:53, Markus Armbruster wrote:
> Thomas Huth <thuth@redhat.com> writes:
> 
>> On 01.09.2017 20:03, Eric Blake wrote:
>>> It doesn't matter if things are unsorted, but finding stuff in a list
>>> is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
>>> en_US.UTF-8).
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> ---
>>>  tests/.gitignore | 30 +++++++++++++++---------------
>>>  1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>
>> BTW, did you note the patch "build-sys: generate tests/.gitignore" from
>> Marc-André ? Maybe the list can be generated automatically, too...
>>
>>> diff --git a/tests/.gitignore b/tests/.gitignore
>>> index 64ecd6683b..8d35a58751 100644
>>> --- a/tests/.gitignore
>>> +++ b/tests/.gitignore
>>> @@ -1,25 +1,27 @@
>>> +*-test
>>
>> ... but looking at this wildcard, I wonder if we just named most of our
>> tests in a bad way. If we name the files something-test instead of
>> test-something, we maybe do not need the automatic generation from
>> Marc-André (which is kind of ugly because it writes to the source
>> directory - and this should not happen when doing out of tree builds).
>>
>> So what do you think about renaming our tests, so that the above
>> wildcard applies instead?
> 
> Apropos naming tests: there's an (unspoken) convention to name unit
> tests check-FOO or test-FOO and tests using libqtest FOO-test, but it's
> not really honored anymore, probably because people creating tests
> didn't know about it.

Maybe it would help to have an entry for libqtest in MAINTAINERS with a
wildcard for tests/*-test.c ? Then we would have at least some kind of
documentation for this... (BTW: Any volunteers here for such a
maintainer job? ;-))

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions
  2017-09-05  9:22   ` Thomas Huth
@ 2017-09-05 10:01     ` Markus Armbruster
  0 siblings, 0 replies; 99+ messages in thread
From: Markus Armbruster @ 2017-09-05 10:01 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Eric Blake, qemu-devel, pbonzini

Thomas Huth <thuth@redhat.com> writes:

> On 01.09.2017 20:03, Eric Blake wrote:
>> Put static functions prior to public ones, in part so that
>> improvements to qtest_start() can benefit from the static
>> helpers without needing forward references.  Code motion, with
>> no semantic change.
>> 
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/libqtest.c | 263 +++++++++++++++++++++++++++----------------------------
>>  1 file changed, 131 insertions(+), 132 deletions(-)
[...]
> That's a *lot* of code motion - just to get rid of one forward
> declaration. IMHO getting rid of just one forward declaration does not
> justify this code churn. But if we really, really want to get rid of the
> forward declaration here, it's maybe better to move the
> qtest_init_without_qmp_handshake() and qtest_init() function to the end
> of the file instead?

I've never understood why people hate forward declarations so much.
Just because the compiler needs to see a declaration before any use
doesn't mean a human reader profits from seeing the definition before
any use.  Sometimes the code is easier to understand in top-down order.

For code I maintain, I evaluate code motion proposals strictly on
readability merits, with complete disregard for the number of forward
declarations added or deleted.

I'm very much not maintaining this code, though :)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations Eric Blake
  2017-09-01 19:22   ` Philippe Mathieu-Daudé
@ 2017-09-05 10:03   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:03 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Alexander Graf, open list:sPAPR, armbru, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> Now that the QPCIBus tracks QTestState, use that state instead
> of an implicit reliance on global_qtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqos/pci-pc.c    | 47 ++++++++++++++++++++++++-----------------------
>  tests/libqos/pci-spapr.c | 20 ++++++++++----------
>  2 files changed, 34 insertions(+), 33 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-05  9:53     ` Markus Armbruster
  2017-09-05  9:58       ` Thomas Huth
@ 2017-09-05 10:10       ` Daniel P. Berrange
  2017-09-05 10:44         ` Thomas Huth
  2017-09-05 14:22         ` Eric Blake
  1 sibling, 2 replies; 99+ messages in thread
From: Daniel P. Berrange @ 2017-09-05 10:10 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Thomas Huth, pbonzini, qemu-devel, Marc-André Lureau

On Tue, Sep 05, 2017 at 11:53:22AM +0200, Markus Armbruster wrote:
> Thomas Huth <thuth@redhat.com> writes:
> 
> > On 01.09.2017 20:03, Eric Blake wrote:
> >> It doesn't matter if things are unsorted, but finding stuff in a list
> >> is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
> >> en_US.UTF-8).
> >> 
> >> Signed-off-by: Eric Blake <eblake@redhat.com>
> >> ---
> >>  tests/.gitignore | 30 +++++++++++++++---------------
> >>  1 file changed, 15 insertions(+), 15 deletions(-)
> >
> > Reviewed-by: Thomas Huth <thuth@redhat.com>
> >
> > BTW, did you note the patch "build-sys: generate tests/.gitignore" from
> > Marc-André ? Maybe the list can be generated automatically, too...
> >
> >> diff --git a/tests/.gitignore b/tests/.gitignore
> >> index 64ecd6683b..8d35a58751 100644
> >> --- a/tests/.gitignore
> >> +++ b/tests/.gitignore
> >> @@ -1,25 +1,27 @@
> >> +*-test
> >
> > ... but looking at this wildcard, I wonder if we just named most of our
> > tests in a bad way. If we name the files something-test instead of
> > test-something, we maybe do not need the automatic generation from
> > Marc-André (which is kind of ugly because it writes to the source
> > directory - and this should not happen when doing out of tree builds).
> >
> > So what do you think about renaming our tests, so that the above
> > wildcard applies instead?
> 
> Apropos naming tests: there's an (unspoken) convention to name unit
> tests check-FOO or test-FOO and tests using libqtest FOO-test, but it's
> not really honored anymore, probably because people creating tests
> didn't know about it.

$ ls *test.c | wc -l
67
$ ls test*.c | wc -l
73
$ ls check*.c | wc -l
8

Fairly even split between 'test' as a prefix vs suffix. 'check' as a
prefix should clearly be killed as a minority pattern. Any appetite
for standardizing naming of everything else ?

A further idea might be to actually have separate sub-directories for
unit tests vs qtests. eg go for

  tests
    +- unit
    +- qtest
    +- iotests

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
                     ` (2 preceding siblings ...)
  2017-09-01 23:06   ` John Snow
@ 2017-09-05 10:12   ` Thomas Huth
  2017-09-05 11:03     ` Thomas Huth
  3 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:12 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	John Snow, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> Drop one more client of global_qtest by teaching all fw_cfg test
> functionality (invoked through alloc-pc) to pass in an explicit
> QTestState, adjusting all callers.  In particular, fw_cfg-test
> had to reorder things to create the test state prior to creating
> the fw_cfg.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqos/fw_cfg.h       | 10 ++++++----
>  tests/libqos/libqos.h       |  2 +-
>  tests/libqos/malloc-pc.h    |  4 ++--
>  tests/libqos/malloc-spapr.h |  2 +-
>  tests/libqos/malloc.h       |  1 +
>  tests/boot-order-test.c     |  6 +++---
>  tests/e1000e-test.c         |  2 +-
>  tests/fw_cfg-test.c         | 14 ++++++--------
>  tests/ide-test.c            |  2 +-
>  tests/libqos/fw_cfg.c       | 14 ++++++++------
>  tests/libqos/libqos.c       |  2 +-
>  tests/libqos/malloc-pc.c    |  8 ++++----
>  tests/libqos/malloc-spapr.c |  4 ++--
>  tests/vhost-user-test.c     |  2 +-
>  14 files changed, 38 insertions(+), 35 deletions(-)
> 
> diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
> index e8371b2317..396dd4ee1e 100644
> --- a/tests/libqos/fw_cfg.h
> +++ b/tests/libqos/fw_cfg.h
> @@ -15,10 +15,12 @@
> 
> 
>  typedef struct QFWCFG QFWCFG;
> +typedef struct QTestState QTestState;

Not sure, but I slightly remember that typedeffing a struct like this in
multiple places can cause compiler warnings or errors with certain
versions of GCC or clang? So a file that includes both, fw_cfg.h and
libqtest.h will then fail to compile?

I think it would be better to change the include order in the .c files
instead, so that libqtest.h is always included before fw_cfg.h.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations Eric Blake
@ 2017-09-05 10:16   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:16 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Laurent Vivier, qemu-ppc, armbru, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> Drop one more client of global_qtest by teaching all rtas test
> functionality to pass in an explicit QTestState, adjusting all
> callers.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqos/rtas.h      |  9 ++++++---
>  tests/libqos/pci-spapr.c | 18 ++++++++++++------
>  tests/libqos/rtas.c      | 21 ++++++++++++---------
>  tests/rtas-test.c        |  2 +-
>  4 files changed, 31 insertions(+), 19 deletions(-)
> 
> diff --git a/tests/libqos/rtas.h b/tests/libqos/rtas.h
> index 498eb19230..e3d0f850a7 100644
> --- a/tests/libqos/rtas.h
> +++ b/tests/libqos/rtas.h
> @@ -7,9 +7,12 @@
>  #define LIBQOS_RTAS_H
>  #include "libqos/malloc.h"
> 
> -int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns);
> -uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
> +int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc,
> +                          struct tm *tm, uint32_t *ns);
> +uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc,
> +                                   uint64_t buid,
>                                     uint32_t addr, uint32_t size);
> -int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
> +int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc,
> +                               uint64_t buid,
>                                 uint32_t addr, uint32_t size, uint32_t val);
>  #endif /* LIBQOS_RTAS_H */
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index d7b2aa75e6..b7199501b4 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -108,21 +108,24 @@ static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 1);
> +    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
> +                                     config_addr, 1);
>  }
> 
>  static uint16_t qpci_spapr_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 2);
> +    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
> +                                     config_addr, 2);
>  }
> 
>  static uint32_t qpci_spapr_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    return qrtas_ibm_read_pci_config(s->alloc, s->buid, config_addr, 4);
> +    return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid,
> +                                     config_addr, 4);
>  }
> 
>  static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,
> @@ -130,7 +133,8 @@ static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offset,
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 1, value);
> +    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
> +                               config_addr, 1, value);
>  }
> 
>  static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offset,
> @@ -138,7 +142,8 @@ static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offset,
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 2, value);
> +    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
> +                               config_addr, 2, value);
>  }
> 
>  static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
> @@ -146,7 +151,8 @@ static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset,
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
>      uint32_t config_addr = (devfn << 8) | offset;
> -    qrtas_ibm_write_pci_config(s->alloc, s->buid, config_addr, 4, value);
> +    qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid,
> +                               config_addr, 4, value);
>  }
> 
>  #define SPAPR_PCI_BASE               (1ULL << 45)
> diff --git a/tests/libqos/rtas.c b/tests/libqos/rtas.c
> index 0269803ce0..fb25f91723 100644
> --- a/tests/libqos/rtas.c
> +++ b/tests/libqos/rtas.c
> @@ -26,7 +26,8 @@ static void qrtas_copy_ret(uint64_t target_ret, uint32_t nret, uint32_t *ret)
>      }
>  }
> 
> -static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
> +static uint64_t qrtas_call(QTestState *qts, QGuestAllocator *alloc,
> +                           const char *name,
>                             uint32_t nargs, uint32_t *args,
>                             uint32_t nret, uint32_t *ret)
>  {
> @@ -37,8 +38,7 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
>      target_ret = guest_alloc(alloc, nret * sizeof(uint32_t));
> 
>      qrtas_copy_args(target_args, nargs, args);
> -    res = qtest_rtas_call(global_qtest, name,
> -                          nargs, target_args, nret, target_ret);
> +    res = qtest_rtas_call(qts, name, nargs, target_args, nret, target_ret);
>      qrtas_copy_ret(target_ret, nret, ret);
> 
>      guest_free(alloc, target_ret);
> @@ -47,12 +47,13 @@ static uint64_t qrtas_call(QGuestAllocator *alloc, const char *name,
>      return res;
>  }
> 
> -int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns)
> +int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc,
> +                          struct tm *tm, uint32_t *ns)
>  {
>      int res;
>      uint32_t ret[8];
> 
> -    res = qrtas_call(alloc, "get-time-of-day", 0, NULL, 8, ret);
> +    res = qrtas_call(qts, alloc, "get-time-of-day", 0, NULL, 8, ret);
>      if (res != 0) {
>          return res;
>      }
> @@ -70,7 +71,8 @@ int qrtas_get_time_of_day(QGuestAllocator *alloc, struct tm *tm, uint32_t *ns)
>      return res;
>  }
> 
> -uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
> +uint32_t qrtas_ibm_read_pci_config(QTestState *qts, QGuestAllocator *alloc,
> +                                   uint64_t buid,
>                                     uint32_t addr, uint32_t size)
>  {
>      int res;
> @@ -80,7 +82,7 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
>      args[1] = buid >> 32;
>      args[2] = buid & 0xffffffff;
>      args[3] = size;
> -    res = qrtas_call(alloc, "ibm,read-pci-config", 4, args, 2, ret);
> +    res = qrtas_call(qts, alloc, "ibm,read-pci-config", 4, args, 2, ret);
>      if (res != 0) {
>          return -1;
>      }
> @@ -92,7 +94,8 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
>      return ret[1];
>  }
> 
> -int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
> +int qrtas_ibm_write_pci_config(QTestState *qts, QGuestAllocator *alloc,
> +                               uint64_t buid,
>                                 uint32_t addr, uint32_t size, uint32_t val)
>  {
>      int res;
> @@ -103,7 +106,7 @@ int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
>      args[2] = buid & 0xffffffff;
>      args[3] = size;
>      args[4] = val;
> -    res = qrtas_call(alloc, "ibm,write-pci-config", 5, args, 1, ret);
> +    res = qrtas_call(qts, alloc, "ibm,write-pci-config", 5, args, 1, ret);
>      if (res != 0) {
>          return -1;
>      }
> diff --git a/tests/rtas-test.c b/tests/rtas-test.c
> index 276c87ef84..34a692163f 100644
> --- a/tests/rtas-test.c
> +++ b/tests/rtas-test.c
> @@ -16,7 +16,7 @@ static void test_rtas_get_time_of_day(void)
>      qs = qtest_spapr_boot("-machine pseries");
> 
>      t1 = time(NULL);
> -    ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);
> +    ret = qrtas_get_time_of_day(qs->qts, qs->alloc, &tm, &ns);
>      g_assert_cmpint(ret, ==, 0);
>      t2 = mktimegm(&tm);
>      g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations Eric Blake
@ 2017-09-05 10:26   ` Thomas Huth
  2017-09-05 12:43     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:26 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, open list:virtio-blk, armbru, Stefan Hajnoczi

On 01.09.2017 20:03, Eric Blake wrote:
> Drop one more client of global_qtest by teaching all virtio test
> functionality to pass in an explicit QTestState in constructors,
> where it is then reused for later access.  Adjust all callers.
> This gets us one step closer to eliminating implicit use of
> global_qtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqos/virtio-mmio.h |  3 +-
>  tests/libqos/virtio.h      |  5 ++-
>  tests/libqos/virtio-mmio.c | 54 +++++++++++++++++---------------
>  tests/libqos/virtio-pci.c  |  3 ++
>  tests/libqos/virtio.c      | 77 ++++++++++++++++++++++++++--------------------
>  tests/virtio-blk-test.c    |  3 +-
>  6 files changed, 84 insertions(+), 61 deletions(-)
> 
> diff --git a/tests/libqos/virtio-mmio.h b/tests/libqos/virtio-mmio.h
> index e3e52b9ce1..bd01386054 100644
> --- a/tests/libqos/virtio-mmio.h
> +++ b/tests/libqos/virtio-mmio.h
> @@ -41,6 +41,7 @@ typedef struct QVirtioMMIODevice {
> 
>  extern const QVirtioBus qvirtio_mmio;
> 
> -QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size);
> +QVirtioMMIODevice *qvirtio_mmio_init_device(QTestState *qts, uint64_t addr,
> +                                            uint32_t page_size);
> 
>  #endif
> diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
> index 8fbcd1869c..d180d54fc4 100644
> --- a/tests/libqos/virtio.h
> +++ b/tests/libqos/virtio.h
> @@ -19,6 +19,7 @@ typedef struct QVirtioBus QVirtioBus;
> 
>  typedef struct QVirtioDevice {
>      const QVirtioBus *bus;
> +    QTestState *qts;
>      /* Device type */
>      uint16_t device_type;
>  } QVirtioDevice;
> @@ -35,12 +36,14 @@ typedef struct QVirtQueue {
>      uint16_t last_used_idx;
>      bool indirect;
>      bool event;
> +    QTestState *qts;
>  } QVirtQueue;
> 
>  typedef struct QVRingIndirectDesc {
>      uint64_t desc; /* This points to an array fo struct vring_desc */
>      uint16_t index;
>      uint16_t elem;
> +    QTestState *qts;
>  } QVRingIndirectDesc;

Adding QTestState to QVRingIndirectDesc and QVirtQueue sounds somewhat
ugly to me. I think they should either rather have a pointer to the
associated QVirtioDevice, or the functions where this is needed
(qvring_init() for example) should get a "QTestState *" parameter instead.

Just my 0.02 €.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest Eric Blake
  2017-09-01 23:11   ` John Snow
@ 2017-09-05 10:32   ` Thomas Huth
  2017-09-07 20:19     ` Eric Blake
  1 sibling, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:32 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, John Snow, armbru, open list:IDE

On 01.09.2017 20:03, Eric Blake wrote:
> Managing parallel connections to two different monitors via
> the implicit global_qtest makes it hard to copy-and-paste code
> to tests that are not aware of the implicit state; the
> management of global_qtest is even harder to follow because
> it was masked behind set_context().
> 
> Instead, explicitly pass QTestState* around (generally, by
> reusing the member already present in ahci->parent QOSState),
> and call explicit qtest_* functions on all places that
> interact with a monitor.
> 
> We can assert that the conversion is correct by checking that
> global_qtest remains NULL throughout the test (a later patch
> that changes global_qtest to not be a public global variable
> will drop the assertions).
> 
> Bonus: there were several spots that were constructing a JSON
> string, then passing that through qmp() as the format, rather
> than directly using qmp() to construct the JSON.  Fixing that
> gets us one step closer to enabling -Wformat checking on
> constructed JSON.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqos/libqos.h    |  1 -
>  tests/ahci-test.c        | 83 +++++++++++++++++++++++-------------------------
>  tests/libqos/ahci.c      | 45 +++++++++++++-------------
>  tests/libqos/libqos-pc.c |  2 +-
>  tests/libqos/libqos.c    | 37 ++++++---------------
>  5 files changed, 73 insertions(+), 95 deletions(-)

Might be easier to review if you'd split the changes to libqos.c into a
separate patch. But anyway:

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 18/29] ivshmem-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 18/29] ivshmem-test: " Eric Blake
@ 2017-09-05 10:36   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:36 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Managing parallel connections to two different monitors via
> the implicit global_qtest makes it hard to copy-and-paste code
> to tests that are not aware of the implicit state.  Since we
> have already fixed qpci to avoid global_qtest, we can now
> simplify by not using global_qtest anywhere in ivshmem-test.
> 
> We can assert that the conversion is correct by checking that
> global_qtest remains NULL throughout the test (a later patch
> that changes global_qtest to not be a public global variable
> will drop the assertions).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/ivshmem-test.c | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
> 
> diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
> index 37763425ee..b9e0f573f6 100644
> --- a/tests/ivshmem-test.c
> +++ b/tests/ivshmem-test.c
> @@ -71,13 +71,10 @@ static const char* reg2str(enum Reg reg) {
>  static inline unsigned in_reg(IVState *s, enum Reg reg)
>  {
>      const char *name = reg2str(reg);
> -    QTestState *qtest = global_qtest;
>      unsigned res;
> 
> -    global_qtest = s->qs->qts;
>      res = qpci_io_readl(s->dev, s->reg_bar, reg);
>      g_test_message("*%s -> %x\n", name, res);
> -    global_qtest = qtest;
> 
>      return res;
>  }
> @@ -85,35 +82,25 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)
>  static inline void out_reg(IVState *s, enum Reg reg, unsigned v)
>  {
>      const char *name = reg2str(reg);
> -    QTestState *qtest = global_qtest;
> 
> -    global_qtest = s->qs->qts;
>      g_test_message("%x -> *%s\n", v, name);
>      qpci_io_writel(s->dev, s->reg_bar, reg, v);
> -    global_qtest = qtest;
>  }
> 
>  static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
>  {
> -    QTestState *qtest = global_qtest;
> -
> -    global_qtest = s->qs->qts;
>      qpci_memread(s->dev, s->mem_bar, off, buf, len);
> -    global_qtest = qtest;
>  }
> 
>  static inline void write_mem(IVState *s, uint64_t off,
>                               const void *buf, size_t len)
>  {
> -    QTestState *qtest = global_qtest;
> -
> -    global_qtest = s->qs->qts;
>      qpci_memwrite(s->dev, s->mem_bar, off, buf, len);
> -    global_qtest = qtest;
>  }
> 
>  static void cleanup_vm(IVState *s)
>  {
> +    assert(!global_qtest);
>      g_free(s->dev);
>      qtest_shutdown(s->qs);
>  }
> @@ -131,6 +118,7 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
>          g_printerr("ivshmem-test tests are only available on x86 or ppc64\n");
>          exit(EXIT_FAILURE);
>      }
> +    global_qtest = NULL;
>      s->dev = get_device(s->qs->pcibus);
> 
>      s->reg_bar = qpci_iomap(s->dev, 0, &barsize);
> @@ -353,7 +341,6 @@ static void test_ivshmem_server(bool msi)
>      g_assert_cmpint(vm1, !=, vm2);
> 
>      /* check number of MSI-X vectors */
> -    global_qtest = s1->qs->qts;
>      if (msi) {
>          ret = qpci_msix_table_size(s1->dev);
>          g_assert_cmpuint(ret, ==, nvectors);
> @@ -376,7 +363,6 @@ static void test_ivshmem_server(bool msi)
>      g_assert_cmpuint(ret, !=, 0);
> 
>      /* ping vm1 -> vm2 on vector 1 */
> -    global_qtest = s2->qs->qts;
>      if (msi) {
>          ret = qpci_msix_pending(s2->dev, 1);
>          g_assert_cmpuint(ret, ==, 0);
> 

OMG, now I see why you want to get rid of this global_test stuff ...
that was really ugly!

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 19/29] postcopy-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 19/29] postcopy-test: " Eric Blake
@ 2017-09-05 10:41   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:41 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Managing parallel connections to two different monitors via
> the implicit global_qtest makes it hard to copy-and-paste code
> to tests that are not aware of the implicit state.  We are
> already half-using the explicit APIs, so fix the remaining
> spots to also be explicit about which connection is in use,
> and avoid global_qtest.
> 
> We can assert that the conversion is correct by checking that
> global_qtest remains NULL throughout the test (a later patch
> that changes global_qtest to not be a public global variable
> will drop the assertions).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/postcopy-test.c | 84 ++++++++++++++++++++++++---------------------------
>  1 file changed, 40 insertions(+), 44 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-05 10:10       ` Daniel P. Berrange
@ 2017-09-05 10:44         ` Thomas Huth
  2017-09-05 14:22         ` Eric Blake
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:44 UTC (permalink / raw)
  To: Daniel P. Berrange, Markus Armbruster
  Cc: pbonzini, qemu-devel, Marc-André Lureau

On 05.09.2017 12:10, Daniel P. Berrange wrote:
> On Tue, Sep 05, 2017 at 11:53:22AM +0200, Markus Armbruster wrote:
>> Thomas Huth <thuth@redhat.com> writes:
>>
>>> On 01.09.2017 20:03, Eric Blake wrote:
>>>> It doesn't matter if things are unsorted, but finding stuff in a list
>>>> is easier when it is sorted.  (Sorted under LC_ALL=C rules, rather than
>>>> en_US.UTF-8).
>>>>
>>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>>> ---
>>>>  tests/.gitignore | 30 +++++++++++++++---------------
>>>>  1 file changed, 15 insertions(+), 15 deletions(-)
>>>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>>
>>> BTW, did you note the patch "build-sys: generate tests/.gitignore" from
>>> Marc-André ? Maybe the list can be generated automatically, too...
>>>
>>>> diff --git a/tests/.gitignore b/tests/.gitignore
>>>> index 64ecd6683b..8d35a58751 100644
>>>> --- a/tests/.gitignore
>>>> +++ b/tests/.gitignore
>>>> @@ -1,25 +1,27 @@
>>>> +*-test
>>>
>>> ... but looking at this wildcard, I wonder if we just named most of our
>>> tests in a bad way. If we name the files something-test instead of
>>> test-something, we maybe do not need the automatic generation from
>>> Marc-André (which is kind of ugly because it writes to the source
>>> directory - and this should not happen when doing out of tree builds).
>>>
>>> So what do you think about renaming our tests, so that the above
>>> wildcard applies instead?
>>
>> Apropos naming tests: there's an (unspoken) convention to name unit
>> tests check-FOO or test-FOO and tests using libqtest FOO-test, but it's
>> not really honored anymore, probably because people creating tests
>> didn't know about it.
> 
> $ ls *test.c | wc -l
> 67
> $ ls test*.c | wc -l
> 73
> $ ls check*.c | wc -l
> 8
> 
> Fairly even split between 'test' as a prefix vs suffix. 'check' as a
> prefix should clearly be killed as a minority pattern. Any appetite
> for standardizing naming of everything else ?
> 
> A further idea might be to actually have separate sub-directories for
> unit tests vs qtests. eg go for
> 
>   tests
>     +- unit
>     +- qtest
>     +- iotests

That sounds like a good idea to me, too.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 20/29] vhost-user-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 20/29] vhost-user-test: " Eric Blake
@ 2017-09-05 10:49   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:49 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> Managing parallel connections to two different monitors via
> the implicit global_qtest makes it hard to copy-and-paste code
> to tests that are not aware of the implicit state.  Now that
> libqos is fully-explicit, it is easy to expand the rest of
> vhost-user-test to also use explicit state everywhere.
> 
> We can assert that the conversion is correct by checking that
> global_qtest remains NULL throughout the test (a later patch
> that changes global_qtest to not be a public global variable
> will drop the assertions).
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/vhost-user-test.c | 68 ++++++++++++++++++++++---------------------------
>  1 file changed, 30 insertions(+), 38 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: " Eric Blake
@ 2017-09-05 10:57   ` Thomas Huth
  2017-09-08 12:48   ` Michael S. Tsirkin
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:57 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Ben Warren, Michael S. Tsirkin

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Adjust the helper code to
> use explicit state instead, and update all callers.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/acpi-utils.h       |  65 +++++++++----------
>  tests/acpi-utils.c       |  19 +++---
>  tests/bios-tables-test.c | 161 ++++++++++++++++++++++++-----------------------
>  tests/vmgenid-test.c     |  18 +++---
>  4 files changed, 133 insertions(+), 130 deletions(-)
[...]
> @@ -87,7 +87,7 @@ static void test_acpi_rsdp_table(test_data *data)
>      AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
>      uint32_t addr = data->rsdp_addr;
> 
> -    acpi_parse_rsdp_table(addr, rsdp_table);
> +    acpi_parse_rsdp_table(global_qtest, addr, rsdp_table);
> 
>      /* rsdp checksum is not for the whole table, but for the first 20 bytes */
>      g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
> @@ -102,7 +102,7 @@ static void test_acpi_rsdt_table(test_data *data)
>      uint8_t checksum;
> 
>      /* read the header */
> -    ACPI_READ_TABLE_HEADER(rsdt_table, addr);
> +    ACPI_READ_TABLE_HEADER(global_qtest, rsdt_table, addr);
>      ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");
> 
>      /* compute the table entries in rsdt */
> @@ -112,7 +112,7 @@ static void test_acpi_rsdt_table(test_data *data)
> 
>      /* get the addresses of the tables pointed by rsdt */
>      tables = g_new0(uint32_t, tables_nr);
> -    ACPI_READ_ARRAY_PTR(tables, tables_nr, addr);
> +    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, addr);
> 
>      checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
>                 acpi_calc_checksum((uint8_t *)tables,

Wouldn't it be better to use a "QTestState *qts = global_qtest" variable
in this function, like you do it below in test_acpi_fadt_table()? Or
even pass it via test_data already? Otherwise you've got to change all
lines again when finally getting rid of global_qtest ...

> @@ -128,63 +128,64 @@ static void test_acpi_fadt_table(test_data *data)
>  {
>      AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
>      uint32_t addr;
> +    QTestState *qts = global_qtest;
> 
>      /* FADT table comes first */
>      addr = data->rsdt_tables_addr[0];
> -    ACPI_READ_TABLE_HEADER(fadt_table, addr);
> +    ACPI_READ_TABLE_HEADER(qts, fadt_table, addr);
> 
> -    ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
> -    ACPI_READ_FIELD(fadt_table->dsdt, addr);
> -    ACPI_READ_FIELD(fadt_table->model, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved1, addr);
> -    ACPI_READ_FIELD(fadt_table->sci_int, addr);
> -    ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
> -    ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
> -    ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
> -    ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved2, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved3, addr);
> -    ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
> -    ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
> -    ACPI_READ_FIELD(fadt_table->flush_size, addr);
> -    ACPI_READ_FIELD(fadt_table->flush_stride, addr);
> -    ACPI_READ_FIELD(fadt_table->duty_offset, addr);
> -    ACPI_READ_FIELD(fadt_table->duty_width, addr);
> -    ACPI_READ_FIELD(fadt_table->day_alrm, addr);
> -    ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
> -    ACPI_READ_FIELD(fadt_table->century, addr);
> -    ACPI_READ_FIELD(fadt_table->boot_flags, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved, addr);
> -    ACPI_READ_FIELD(fadt_table->flags, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr);
> -    ACPI_READ_FIELD(fadt_table->reset_value, addr);
> -    ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr);
> -    ACPI_READ_FIELD(fadt_table->minor_revision, addr);
> -    ACPI_READ_FIELD(fadt_table->x_facs, addr);
> -    ACPI_READ_FIELD(fadt_table->x_dsdt, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->firmware_ctrl, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->dsdt, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->model, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved1, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->sci_int, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->smi_cmd, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->acpi_enable, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->acpi_disable, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->S4bios_req, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved2, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1a_evt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1b_evt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1a_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1b_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1_evt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1_cnt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_base, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved3, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->plvl2_lat, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->plvl3_lat, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flush_size, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flush_stride, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->duty_offset, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->duty_width, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->day_alrm, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->mon_alrm, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->century, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->boot_flags, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flags, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->reset_register, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reset_value, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->arm_boot_flags, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->minor_revision, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->x_facs, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->x_dsdt, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_event_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_event_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm2_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm_timer_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe0_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe1_block, addr);
> 
>      ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
>      g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
> @@ -195,13 +196,13 @@ static void test_acpi_facs_table(test_data *data)
>      AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
>      uint32_t addr = data->fadt_table.firmware_ctrl;
> 
> -    ACPI_READ_FIELD(facs_table->signature, addr);
> -    ACPI_READ_FIELD(facs_table->length, addr);
> -    ACPI_READ_FIELD(facs_table->hardware_signature, addr);
> -    ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr);
> -    ACPI_READ_FIELD(facs_table->global_lock, addr);
> -    ACPI_READ_FIELD(facs_table->flags, addr);
> -    ACPI_READ_ARRAY(facs_table->resverved3, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->signature, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->length, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->hardware_signature, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->firmware_waking_vector, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->global_lock, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->flags, addr);
> +    ACPI_READ_ARRAY(global_qtest, facs_table->resverved3, addr);

Dito, i.e. use a local "QTestState *qts = global_qtest" variable instead?

Same comment applies to the other functions where you were using
global_test like this.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 24/29] bios-tables-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 24/29] bios-tables-test: " Eric Blake
@ 2017-09-05 10:59   ` Thomas Huth
  2017-09-07 21:30     ` Eric Blake
  2017-09-08 12:49   ` Michael S. Tsirkin
  1 sibling, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 10:59 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Michael S. Tsirkin

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Although bios-tables-test does
> not maintain parallel qtest connections, it's just as easy to be
> explicit about the state; once all tests have been cleaned up, a
> later patch can then get rid of global_qtest and a layer of
> wrappers in libqtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/bios-tables-test.c | 78 +++++++++++++++++++++++++-----------------------
>  1 file changed, 40 insertions(+), 38 deletions(-)
> 
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 75b29df493..976792f2c5 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -38,6 +38,7 @@ typedef struct {
>      struct smbios_21_entry_point smbios_ep_table;
>      uint8_t *required_struct_types;
>      int required_struct_types_len;
> +    QTestState *qts;
>  } test_data;

Ah, well, ok, here it is. Please merge this with the previous patch!

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: " Eric Blake
@ 2017-09-05 11:01   ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 11:01 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Improve this test to be
> explicit about the state.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/wdt_ib700-test.c | 63 +++++++++++++++++++++++++++-----------------------
>  1 file changed, 34 insertions(+), 29 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-05 10:12   ` Thomas Huth
@ 2017-09-05 11:03     ` Thomas Huth
  2017-09-06 21:10       ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 11:03 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	John Snow, David Gibson

On 05.09.2017 12:12, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> Drop one more client of global_qtest by teaching all fw_cfg test
>> functionality (invoked through alloc-pc) to pass in an explicit
>> QTestState, adjusting all callers.  In particular, fw_cfg-test
>> had to reorder things to create the test state prior to creating
>> the fw_cfg.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/libqos/fw_cfg.h       | 10 ++++++----
>>  tests/libqos/libqos.h       |  2 +-
>>  tests/libqos/malloc-pc.h    |  4 ++--
>>  tests/libqos/malloc-spapr.h |  2 +-
>>  tests/libqos/malloc.h       |  1 +
>>  tests/boot-order-test.c     |  6 +++---
>>  tests/e1000e-test.c         |  2 +-
>>  tests/fw_cfg-test.c         | 14 ++++++--------
>>  tests/ide-test.c            |  2 +-
>>  tests/libqos/fw_cfg.c       | 14 ++++++++------
>>  tests/libqos/libqos.c       |  2 +-
>>  tests/libqos/malloc-pc.c    |  8 ++++----
>>  tests/libqos/malloc-spapr.c |  4 ++--
>>  tests/vhost-user-test.c     |  2 +-
>>  14 files changed, 38 insertions(+), 35 deletions(-)
>>
>> diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
>> index e8371b2317..396dd4ee1e 100644
>> --- a/tests/libqos/fw_cfg.h
>> +++ b/tests/libqos/fw_cfg.h
>> @@ -15,10 +15,12 @@
>>
>>
>>  typedef struct QFWCFG QFWCFG;
>> +typedef struct QTestState QTestState;
> 
> Not sure, but I slightly remember that typedeffing a struct like this in
> multiple places can cause compiler warnings or errors with certain
> versions of GCC or clang? So a file that includes both, fw_cfg.h and
> libqtest.h will then fail to compile?
> 
> I think it would be better to change the include order in the .c files
> instead, so that libqtest.h is always included before fw_cfg.h.

Ah, well, I just saw that you also sent a fixup patch for this. Anyway,
I'm not a fan of including header files from other header files, so
changing the include order in the .c files sounds like the better
solution to me.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: " Eric Blake
  2017-09-02  0:07   ` Philippe Mathieu-Daudé
@ 2017-09-05 11:05   ` Thomas Huth
  2017-09-06 21:45     ` Eric Blake
  1 sibling, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 11:05 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: pbonzini, armbru

On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  It turns out that with the
> recent changes to libqos, fw_cfg-test was not even using
> global_qtest any more.  Avoid a pointless strdup while at it.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/fw_cfg-test.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
> index 47596c57a1..3a8dc7a2cd 100644
> --- a/tests/fw_cfg-test.c
> +++ b/tests/fw_cfg-test.c
> @@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
>  int main(int argc, char **argv)
>  {
>      QTestState *s;
> -    char *cmdline;
>      int ret;
> 
>      g_test_init(&argc, &argv, NULL);
> 
> -    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> -    s = qtest_start(cmdline);
> -    g_free(cmdline);
> +    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
> 
>      fw_cfg = pc_fw_cfg_init(s);
> 

Why don't you merge this with patch 14/29?

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations
  2017-09-05 10:26   ` Thomas Huth
@ 2017-09-05 12:43     ` Paolo Bonzini
  2017-09-06 21:42       ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Paolo Bonzini @ 2017-09-05 12:43 UTC (permalink / raw)
  To: Thomas Huth
  Cc: open list:Block layer core, qemu-devel, Stefan Hajnoczi, armbru,
	Eric Blake

>  typedef struct QVirtioDevice {
>      const QVirtioBus *bus;
> +    QTestState *qts;
>      /* Device type */
>      uint16_t device_type;
>  } QVirtioDevice;
> @@ -35,12 +36,14 @@ typedef struct QVirtQueue {
>      uint16_t last_used_idx;
>      bool indirect;
>      bool event;
> +    QTestState *qts;
>  } QVirtQueue;
>
>  typedef struct QVRingIndirectDesc {
>      uint64_t desc; /* This points to an array fo struct vring_desc */
>      uint16_t index;
>      uint16_t elem;
> +    QTestState *qts;
>  } QVRingIndirectDesc;

Adding QTestState to QVRingIndirectDesc and QVirtQueue sounds somewhat
ugly to me. I think they should either rather have a pointer to the
associated QVirtioDevice, or the functions where this is needed
(qvring_init() for example) should get a "QTestState *" parameter instead.


I agree with Thomas and even extend it to QVirtioDevice. If there is a
has-a hierarchy between libqos objects, only the topmost one (such as the
virtio mmio bus device, and the PCI host bridge---or possibly even the
machine object exclusively) should have a QTestState. Everyone else can
access it implicitly through operations on its bus.

Test code on the other hand can use global_qtest implicitly when they
prepare/read buffers that the devices do DMA from/to.

Paolo



Just my 0.02 €.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string Eric Blake
@ 2017-09-05 12:46   ` Thomas Huth
  2017-09-07 18:00     ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 12:46 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Michael S. Tsirkin

On 01.09.2017 20:03, Eric Blake wrote:
> Several callers were formatting a string into a temporary
> variable before calling qtest_init(); factor that into the
> common code.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqtest.h         |  7 ++++---
>  tests/libqtest.c         | 13 ++++++++++--
>  tests/bios-tables-test.c |  7 +------
>  tests/postcopy-test.c    |  4 ++--
>  tests/vhost-user-test.c  | 51 ++++++++++++++----------------------------------
>  5 files changed, 33 insertions(+), 49 deletions(-)
> 
> diff --git a/tests/libqtest.h b/tests/libqtest.h
> index 3ae570927a..d338de3e22 100644
> --- a/tests/libqtest.h
> +++ b/tests/libqtest.h
> @@ -25,11 +25,12 @@ extern QTestState *global_qtest;
> 
>  /**
>   * qtest_init:
> - * @extra_args: other arguments to pass to QEMU.
> + * @extra_args...: other arguments to pass to QEMU, formatted as if by
> + * sprintf().
>   *
>   * Returns: #QTestState instance.
>   */
> -QTestState *qtest_init(const char *extra_args);
> +QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);

Maybe the parameter should be called "fmt" or "format" now instead?
(similar to printf() and friends)

>  /**
>   * qtest_init_without_qmp_handshake:
> @@ -518,7 +519,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);
>   */
>  static inline QTestState *qtest_start(const char *args)
>  {
> -    global_qtest = qtest_init(args);
> +    global_qtest = qtest_init("%s", args);

That's a little bit sad that there are some spots which need an explicit
"%s" now ... maybe it would be nicer to add a new function called
qtest_initf() instead and keep the old one (without the "f") as it is?

>      return global_qtest;
>  }
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index b6dd26e54a..18facbf130 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -347,9 +347,18 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>      return s;
>  }
> 
> -QTestState *qtest_init(const char *extra_args)
> +QTestState *qtest_init(const char *extra_args, ...)
>  {
> -    QTestState *s = qtest_init_without_qmp_handshake(extra_args);
> +    va_list ap;
> +    QTestState *s;
> +    char *cmd;
> +
> +    va_start(ap, extra_args);
> +    cmd = g_strdup_vprintf(extra_args, ap);
> +    va_end(ap);
> +
> +    s = qtest_init_without_qmp_handshake(cmd);
> +    g_free(cmd);
> 
>      /* Read the QMP greeting and then do the handshake */
>      qtest_qmp_discard_response(s, "");
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 976792f2c5..f8a107499f 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -623,18 +623,14 @@ static void test_smbios_structs(test_data *data)
> 
>  static void test_acpi_one(const char *params, test_data *data)
>  {
> -    char *args;
> -
>      /* Disable kernel irqchip to be able to override apic irq0. */
> -    args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
> +    data->qts = qtest_init("-machine %s,accel=%s,kernel-irqchip=off "
>                             "-net none -display none %s "
>                             "-drive id=hd0,if=none,file=%s,format=raw "
>                             "-device ide-hd,drive=hd0 ",
>                             data->machine, "kvm:tcg",
>                             params ? params : "", disk);
> 
> -    data->qts = qtest_init(args);
> -
>      boot_sector_test(data->qts);
> 
>      test_acpi_rsdp_address(data);
> @@ -657,7 +653,6 @@ static void test_acpi_one(const char *params, test_data *data)
>      test_smbios_structs(data);
> 
>      qtest_quit(data->qts);
> -    g_free(args);
>  }
> 
>  static uint8_t base_required_struct_types[] = {
> diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
> index 0e5fe20a83..20cfb280f6 100644
> --- a/tests/postcopy-test.c
> +++ b/tests/postcopy-test.c
> @@ -403,10 +403,10 @@ static void test_migrate(void)
> 
>      g_free(bootpath);
> 
> -    from = qtest_init(cmd_src);
> +    from = qtest_init("%s", cmd_src);
>      g_free(cmd_src);
> 
> -    to = qtest_init(cmd_dst);
> +    to = qtest_init("%s", cmd_dst);
>      g_free(cmd_dst);
> 
>      assert(!global_qtest);

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts Eric Blake
  2017-09-01 23:16   ` John Snow
@ 2017-09-05 13:06   ` Thomas Huth
  1 sibling, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 13:06 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:Floppy, Ben Warren, Michael S. Tsirkin, Jason Wang,
	Amit Shah, armbru, Alexander Graf, Keith Busch, open list:sPAPR,
	Gerd Hoffmann, Stefan Hajnoczi, pbonzini, John Snow,
	Andreas Färber, Dr. David Alan Gilbert, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> Remove the trivial wrappers qtest_start() and qtest_end(), to make
> it obvious in the rest of the testsuite where we are still relying on
> global_qtest.  Doing this makes it easier to see what remaining
> cleanups will be needed if we don't want an implicit dependency
> on global state.  Many tests can also take advantage of qtest_init()
> doing formatting of args, avoiding a temporary local variable.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/libqtest.h               | 26 ------------------
>  tests/libqtest.c               |  4 +--
>  tests/ac97-test.c              |  4 +--
>  tests/boot-order-test.c        | 11 +++-----
>  tests/boot-serial-test.c       | 12 +++------
>  tests/device-introspect-test.c | 24 ++++++++---------
>  tests/display-vga-test.c       | 18 +++++--------
>  tests/drive_del-test.c         | 17 ++++++------
>  tests/ds1338-test.c            |  2 +-
>  tests/e1000-test.c             | 10 ++-----
>  tests/e1000e-test.c            | 14 +++-------
>  tests/eepro100-test.c          | 11 ++------
>  tests/endianness-test.c        | 33 +++++++++--------------
>  tests/es1370-test.c            |  4 +--
>  tests/fdc-test.c               |  4 +--
>  tests/hd-geo-test.c            | 16 +++++------
>  tests/i440fx-test.c            | 16 +++++------
>  tests/i82801b11-test.c         |  5 ++--
>  tests/ide-test.c               |  4 +--
>  tests/intel-hda-test.c         | 11 ++++----
>  tests/ioh3420-test.c           |  7 ++---
>  tests/ipmi-bt-test.c           | 11 +++-----
>  tests/ipmi-kcs-test.c          |  5 +---
>  tests/ipoctal232-test.c        |  5 ++--
>  tests/ivshmem-test.c           |  4 +--
>  tests/libqos/libqos.c          |  2 +-
>  tests/m25p80-test.c            |  9 +++----
>  tests/m48t59-test.c            |  2 +-
>  tests/ne2000-test.c            |  4 +--
>  tests/numa-test.c              | 28 ++++++++++----------
>  tests/nvme-test.c              |  7 ++---
>  tests/pc-cpu-test.c            | 26 +++++++-----------
>  tests/pcnet-test.c             |  4 +--
>  tests/pnv-xscom-test.c         | 14 ++--------
>  tests/prom-env-test.c          | 13 ++++-----
>  tests/pvpanic-test.c           |  4 +--
>  tests/pxe-test.c               | 14 ++++------
>  tests/q35-test.c               |  8 +++---
>  tests/qom-test.c               |  7 ++---
>  tests/rtc-test.c               |  2 +-
>  tests/rtl8139-test.c           |  4 +--
>  tests/spapr-phb-test.c         |  5 ++--
>  tests/tco-test.c               | 12 ++++-----
>  tests/test-arm-mptimer.c       |  4 +--
>  tests/test-filter-mirror.c     | 16 +++++------
>  tests/test-filter-redirector.c | 60 ++++++++++++++++++++----------------------
>  tests/test-hmp.c               |  7 ++---
>  tests/test-netfilter.c         |  9 +++----
>  tests/test-x86-cpuid-compat.c  | 13 ++++-----
>  tests/tmp105-test.c            |  2 +-
>  tests/tpci200-test.c           |  4 +--
>  tests/usb-hcd-ehci-test.c      | 25 +++++++++---------
>  tests/usb-hcd-ohci-test.c      |  4 +--
>  tests/usb-hcd-xhci-test.c      |  4 +--
>  tests/virtio-balloon-test.c    |  4 +--
>  tests/virtio-blk-test.c        | 13 ++++-----
>  tests/virtio-console-test.c    |  8 +++---
>  tests/virtio-net-test.c        |  4 +--
>  tests/virtio-rng-test.c        |  4 +--
>  tests/virtio-serial-test.c     |  4 +--
>  tests/vmgenid-test.c           | 29 ++++++--------------
>  tests/vmxnet3-test.c           |  4 +--
>  62 files changed, 267 insertions(+), 394 deletions(-)
> 
> diff --git a/tests/libqtest.h b/tests/libqtest.h
> index d338de3e22..0459526187 100644
> --- a/tests/libqtest.h
> +++ b/tests/libqtest.h
> @@ -509,32 +509,6 @@ void qtest_add_data_func_full(const char *str, void *data,
>  void qtest_add_abrt_handler(GHookFunc fn, const void *data);
> 
>  /**
> - * qtest_start:
> - * @args: other arguments to pass to QEMU
> - *
> - * Start QEMU and assign the resulting #QTestState to a global variable.
> - * The global variable is used by "shortcut" functions documented below.
> - *
> - * Returns: #QTestState instance.
> - */
> -static inline QTestState *qtest_start(const char *args)
> -{
> -    global_qtest = qtest_init("%s", args);
> -    return global_qtest;
> -}
> -
> -/**
> - * qtest_end:
> - *
> - * Shut down the QEMU process started by qtest_start().
> - */
> -static inline void qtest_end(void)
> -{
> -    qtest_quit(global_qtest);
> -    global_qtest = NULL;
> -}
> -
> -/**
>   * qmp:
>   * @fmt...: QMP message to send to qemu
>   *
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 18facbf130..fa4e47c137 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -970,7 +970,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
>      QString *qstr;
>      const char *mname;
> 
> -    qtest_start("-machine none");
> +    global_qtest = qtest_init("-machine none");
>      response = qmp("{ 'execute': 'query-machines' }");
>      g_assert(response);
>      list = qdict_get_qlist(response, "return");
> @@ -987,6 +987,6 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
>          cb(mname);
>      }
> 
> -    qtest_end();
> +    qtest_quit(global_qtest);
>      QDECREF(response);
>  }
[...]

Maybe this patch could be postponed 'till we can completely remove
global_qtest? Otherwise you've got to change these lines over and over
again...

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start()
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start() Eric Blake
  2017-09-01 23:17   ` John Snow
@ 2017-09-05 13:10   ` Thomas Huth
  2017-09-07  2:57     ` Eric Blake
  1 sibling, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-05 13:10 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:Floppy, Ben Warren, Michael S. Tsirkin, Jason Wang,
	Amit Shah, armbru, Alexander Graf, Keith Busch, open list:sPAPR,
	Gerd Hoffmann, Stefan Hajnoczi, Igor Mammedov, pbonzini,
	John Snow, Dr. David Alan Gilbert, David Gibson

On 01.09.2017 20:03, Eric Blake wrote:
> We already have another qtest_init() in the tree, for the
> top-level qtest.c device; having two functions with different
> signatures is confusing.  Rename the libqtest version to
> qtest_start() to eliminate the duplication.

This is too much code churn for my taste, and I also do not like the
idea of naming the function qtest_start() - since this was a function
with different semantics before your patch 28/29, so this will cause
confusion for all the people who are used to the old qtest_start()
function or who want to backport patches that have done after this
change to a code level before this change.

If you are really bugged by the qtest_init() name clash, I think it's
way easier if you rename the qtest_init() in the qtest.c file instead.

 Thomas

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore
  2017-09-05 10:10       ` Daniel P. Berrange
  2017-09-05 10:44         ` Thomas Huth
@ 2017-09-05 14:22         ` Eric Blake
  1 sibling, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-05 14:22 UTC (permalink / raw)
  To: Daniel P. Berrange, Markus Armbruster
  Cc: pbonzini, Thomas Huth, qemu-devel, Marc-André Lureau

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]

On 09/05/2017 05:10 AM, Daniel P. Berrange wrote:

> Fairly even split between 'test' as a prefix vs suffix. 'check' as a
> prefix should clearly be killed as a minority pattern. Any appetite
> for standardizing naming of everything else ?
> 
> A further idea might be to actually have separate sub-directories for
> unit tests vs qtests. eg go for
> 
>   tests
>     +- unit
>     +- qtest
>     +- iotests

I like the idea, but don't know if I want to be the one tackling it...

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length
  2017-09-05  9:54     ` Markus Armbruster
@ 2017-09-05 22:20       ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-05 22:20 UTC (permalink / raw)
  To: Markus Armbruster, Thomas Huth; +Cc: qemu-devel, pbonzini

[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]

On 09/05/2017 04:54 AM, Markus Armbruster wrote:
> Thomas Huth <thuth@redhat.com> writes:
> 
>> On 01.09.2017 20:03, Eric Blake wrote:
>>> Rather than make multiple callers call strlen(), it's easier if
>>> socket_send() itself can compute a length via strlen() if none
>>> was provided (caller passes -1).  Callers that can get at the
>>> length more efficiently are left that way.
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> ---
>>>  tests/libqtest.c | 10 ++++++----
>>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> I have to say that I don't like this idea very much. socket_send()
>> should IMHO not know about the type of the data that should be sent,
>> i.e. it should not assume that the content is a zero-terminated string.
> 
> I agree.

It doesn't assume that the content is zero-terminated unless you pass a
negative length.

> 
>> This also could lead to some hard to detect bugs later in case somebody
>> is calling the function like this:
>>
>>   size = someotherfunction();
>>   socket_send(fd, buf, size);
>>
>> ... and the someotherfunction() returned a negative error code instead
>> of a correct size.
>>
>> So I'd like to suggest to simply drop this patch.
> 
> A separate wrapper function for sending zero-terminated strings would be
> fine with me.

I'm fine dropping the patch; computing the length in the callers is not
that much more onerous (there aren't that many), so I don't think
another wrapper is needed.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot
  2017-09-04 14:03   ` Thomas Huth
@ 2017-09-06 19:33     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 19:33 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: pbonzini, armbru, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]

On 09/04/2017 09:03 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> Right now, tests/multiboot is not run by default during 'make check';
>> but when it is run in-tree, it was leaving some junk behind that could
>> accidentally get checked in with a careless 'git add tests'.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/.gitignore | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/tests/.gitignore b/tests/.gitignore
>> index fed0189a5a..64ecd6683b 100644
>> --- a/tests/.gitignore
>> +++ b/tests/.gitignore
>> @@ -10,6 +10,8 @@ check-qnull
>>  check-qstring
>>  check-qom-interface
>>  check-qom-proplist
>> +multiboot/test.out
> 
> Your patch is of course a good idea ... but that test.out smells quite
> bad ... I guess it should (a) use mktemp for a better file name instead
> so that we can run this in parallel and (b) clean up the temporary file
> once the test has been done?

Indeed, making multiboot better, and run by default under 'make check',
is a better task than just tweaking .gitignore, but one orthogonal
enough to my libqtest changes that I will save this patch (and 2/29) for
another series (or if someone else wants to tackle it first).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness()
  2017-09-05  9:25   ` Thomas Huth
@ 2017-09-06 20:12     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 20:12 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: pbonzini, armbru

[-- Attachment #1: Type: text/plain, Size: 666 bytes --]

On 09/05/2017 04:25 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> There was only one caller; it's easier to inline things.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/libqtest.c | 22 ++++++----------------
>>  1 file changed, 6 insertions(+), 16 deletions(-)
>>

> 
> Ah, well, now that's another way of getting rid of the forward
> declaration in the previous patch - so may I suggest to drop the
> previous patch, and simply do the code inlining here instead?

Will do.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-01 19:20   ` Philippe Mathieu-Daudé
@ 2017-09-06 20:48     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 20:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

On 09/01/2017 02:20 PM, Philippe Mathieu-Daudé wrote:
> Hi Eric,
> 
> On 09/01/2017 03:03 PM, Eric Blake wrote:
>> When initializing a QPCIBus, track which QTestState the bus is
>> associated with (so that a later patch can then explicitly use
>> that test state for all communication on the bus, rather than
>> blindly relying on global_qtest).  Update the initialization
>> functions to take another parameter, and update all callers to
>> pass in state (for now, most callers get away with passing the
>> current global_qtest as the current state, although this required
>> fixing the order of initialization to ensure qtest_start() is
>> called before qpci_init*() in rtl8139-test, and provided an
>> opportunity to pass in the allocator in e1000e-test).
>>

>> +++ b/tests/libqos/pci-pc.c
>> @@ -115,11 +115,14 @@ static void qpci_pc_config_writel(QPCIBus *bus,
>> int devfn, uint8_t offset, uint3
>>       outl(0xcfc, value);
>>   }
>>
>> -QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
>> +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
>>   {
>>       QPCIBusPC *ret;
>>
>> +    assert(qts);
>> +
>>       ret = g_malloc(sizeof(*ret));
> 
> I'd rather use g_malloc0() here (safer!)

Pre-existing, but yes, I can touch it while in the area.

> 
>> +    ret->bus.qts = qts;
>>
>>       ret->bus.pio_readb = qpci_pc_pio_readb;
>>       ret->bus.pio_readw = qpci_pc_pio_readw;
> 
> or init qts field in same order than struct:

Okay.

> 
> Either ways:
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-05  9:36   ` Thomas Huth
@ 2017-09-06 21:00     ` Eric Blake
  2017-09-07  5:35       ` Thomas Huth
  0 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-06 21:00 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 2049 bytes --]

On 09/05/2017 04:36 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> When initializing a QPCIBus, track which QTestState the bus is
>> associated with (so that a later patch can then explicitly use
>> that test state for all communication on the bus, rather than
>> blindly relying on global_qtest).  Update the initialization
>> functions to take another parameter, and update all callers to
>> pass in state (for now, most callers get away with passing the
>> current global_qtest as the current state, although this required
>> fixing the order of initialization to ensure qtest_start() is
>> called before qpci_init*() in rtl8139-test, and provided an
>> opportunity to pass in the allocator in e1000e-test).
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
> [...]
>> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
>> index 6226546c28..c95428e1cb 100644
>> --- a/tests/libqos/libqos.c
>> +++ b/tests/libqos/libqos.c
>> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>>          if (ops->init_allocator) {
>>              qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
>>          }
>> -        if (ops->qpci_init && qs->alloc) {
>> -            qs->pcibus = ops->qpci_init(qs->alloc);
>> +        if (ops->qpci_init) {
> 
> Why did you remove the check for qs->alloc?
> 
>> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);

Because we want to ensure qpci_init() is called to set qs->qts
(presumably, whether or not qs->alloc is set).  Furthermore, only two
files declare a 'static QOSOps' structure in the first place
(libqos-pc.c and libqos-spapr.c); where both files set both the
.init_allocator and .qpci_init callbacks; a little bit of auditing shows
that the .init_allocator() never returns NULL (although that requires
browsing yet more files for malloc-{pc,spapr}.c).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-05 11:03     ` Thomas Huth
@ 2017-09-06 21:10       ` Eric Blake
  2017-09-06 21:25         ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-06 21:10 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1974 bytes --]

On 09/05/2017 06:03 AM, Thomas Huth wrote:
> On 05.09.2017 12:12, Thomas Huth wrote:
>> On 01.09.2017 20:03, Eric Blake wrote:
>>> Drop one more client of global_qtest by teaching all fw_cfg test
>>> functionality (invoked through alloc-pc) to pass in an explicit
>>> QTestState, adjusting all callers.  In particular, fw_cfg-test
>>> had to reorder things to create the test state prior to creating
>>> the fw_cfg.
>>>

>>> +++ b/tests/libqos/fw_cfg.h
>>> @@ -15,10 +15,12 @@
>>>
>>>
>>>  typedef struct QFWCFG QFWCFG;
>>> +typedef struct QTestState QTestState;
>>
>> Not sure, but I slightly remember that typedeffing a struct like this in
>> multiple places can cause compiler warnings or errors with certain
>> versions of GCC or clang? So a file that includes both, fw_cfg.h and
>> libqtest.h will then fail to compile?

Yes, older gcc fails to compile (my off-hand recollection is that it was
a bug in the older gcc, and not a standards-compliance issue to
encounter the same typedef twice, but I could be wrong), ergo the fixup
that you later noticed.

>>
>> I think it would be better to change the include order in the .c files
>> instead, so that libqtest.h is always included before fw_cfg.h.
> 
> Ah, well, I just saw that you also sent a fixup patch for this. Anyway,
> I'm not a fan of including header files from other header files, so
> changing the include order in the .c files sounds like the better
> solution to me.

Eww. I like headers to be self-contained.  Other than stuff we get from
osdep.h (which we know is included by EVERY .c file), I prefer that if a
header uses another type, then it guarantees that an idempotent
inclusion of a header that declares that type is also present in the
header file, rather than forcing .c files to know which order to include
things in.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations
  2017-09-06 21:10       ` Eric Blake
@ 2017-09-06 21:25         ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 21:25 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR, pbonzini,
	John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

On 09/06/2017 04:10 PM, Eric Blake wrote:
>> I'm not a fan of including header files from other header files, so
>> changing the include order in the .c files sounds like the better
>> solution to me.
> 
> Eww. I like headers to be self-contained.  Other than stuff we get from
> osdep.h (which we know is included by EVERY .c file), I prefer that if a
> header uses another type, then it guarantees that an idempotent
> inclusion of a header that declares that type is also present in the
> header file, rather than forcing .c files to know which order to include
> things in.

The qemu tree-wide policy appears to be that a header should be
self-contained (order of inclusion in .c files shouldn't matter).  Also,
if header A only uses 'SomeType *', it can either get the definition of
SomeType from header B, or we can add the typedef to typedef.h at which
point both header A and B get the typedef from there (that is, typedef.h
is great for breaking what would otherwise be cyclic inclusion of
mutually-recursive types across different headers, as well as a way to
speed up compilation when a typedef is sufficient rather than a full
definition).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations
  2017-09-05 12:43     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
@ 2017-09-06 21:42       ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 21:42 UTC (permalink / raw)
  To: Paolo Bonzini, Thomas Huth
  Cc: open list:Block layer core, qemu-devel, Stefan Hajnoczi, armbru

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

On 09/05/2017 07:43 AM, Paolo Bonzini wrote:
>>  typedef struct QVirtioDevice {
>>      const QVirtioBus *bus;
>> +    QTestState *qts;
>>      /* Device type */
>>      uint16_t device_type;
>>  } QVirtioDevice;
>> @@ -35,12 +36,14 @@ typedef struct QVirtQueue {
>>      uint16_t last_used_idx;
>>      bool indirect;
>>      bool event;
>> +    QTestState *qts;
>>  } QVirtQueue;
>>
>>  typedef struct QVRingIndirectDesc {
>>      uint64_t desc; /* This points to an array fo struct vring_desc */
>>      uint16_t index;
>>      uint16_t elem;
>> +    QTestState *qts;
>>  } QVRingIndirectDesc;
> 
> Adding QTestState to QVRingIndirectDesc and QVirtQueue sounds somewhat
> ugly to me. I think they should either rather have a pointer to the
> associated QVirtioDevice, or the functions where this is needed
> (qvring_init() for example) should get a "QTestState *" parameter instead.
> 
> 
> I agree with Thomas and even extend it to QVirtioDevice. If there is a
> has-a hierarchy between libqos objects, only the topmost one (such as the
> virtio mmio bus device, and the PCI host bridge---or possibly even the
> machine object exclusively) should have a QTestState. Everyone else can
> access it implicitly through operations on its bus.

[Paolo, gmail is really messing up with your quoting style ;( ]

Okay, so if I understand correctly, at most a QVRingIndirectDesc can
have a pointer back to the QVirtioDevice that owns it, and in turn the
QVirtioDevice has a pointer back to the QPCIBus that the device is on,
and anywhere that needs a QTestState follows the chain back to the
QPCIBus to get it.  I'll play with the idea, as it may still allow for
more compact code than passing an explicit QTestState parameter through
every call.

> 
> Test code on the other hand can use global_qtest implicitly when they
> prepare/read buffers that the devices do DMA from/to.

Not when I'm done - my next series gets rid of implicit global_qtest
everywhere.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
  2017-09-05 11:05   ` Thomas Huth
@ 2017-09-06 21:45     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-06 21:45 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: pbonzini, armbru

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On 09/05/2017 06:05 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> As a general rule, we prefer avoiding implicit global state
>> because it makes code harder to safely copy and paste without
>> thinking about the global state.  It turns out that with the
>> recent changes to libqos, fw_cfg-test was not even using
>> global_qtest any more.  Avoid a pointless strdup while at it.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/fw_cfg-test.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>

>>
> 
> Why don't you merge this with patch 14/29?

Sure.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start()
  2017-09-05 13:10   ` Thomas Huth
@ 2017-09-07  2:57     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-07  2:57 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: open list:Floppy, Ben Warren, Michael S. Tsirkin, Jason Wang,
	Amit Shah, armbru, Alexander Graf, Keith Busch, open list:sPAPR,
	Gerd Hoffmann, Stefan Hajnoczi, Igor Mammedov, pbonzini,
	John Snow, Dr. David Alan Gilbert, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

On 09/05/2017 08:10 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> We already have another qtest_init() in the tree, for the
>> top-level qtest.c device; having two functions with different
>> signatures is confusing.  Rename the libqtest version to
>> qtest_start() to eliminate the duplication.
> 
> This is too much code churn for my taste, and I also do not like the
> idea of naming the function qtest_start() - since this was a function
> with different semantics before your patch 28/29, so this will cause
> confusion for all the people who are used to the old qtest_start()
> function or who want to backport patches that have done after this
> change to a code level before this change.
> 
> If you are really bugged by the qtest_init() name clash, I think it's
> way easier if you rename the qtest_init() in the qtest.c file instead.

Except the qtest_init() in qtest.c really is our normal pattern of
*_init for devices, so that one's named correctly.  Our testsuite is the
one that is using a name different from its normal usage in the rest of
the tree.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-06 21:00     ` Eric Blake
@ 2017-09-07  5:35       ` Thomas Huth
  2017-09-07 13:32         ` Eric Blake
  0 siblings, 1 reply; 99+ messages in thread
From: Thomas Huth @ 2017-09-07  5:35 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 2170 bytes --]

On 06.09.2017 23:00, Eric Blake wrote:
> On 09/05/2017 04:36 AM, Thomas Huth wrote:
>> On 01.09.2017 20:03, Eric Blake wrote:
>>> When initializing a QPCIBus, track which QTestState the bus is
>>> associated with (so that a later patch can then explicitly use
>>> that test state for all communication on the bus, rather than
>>> blindly relying on global_qtest).  Update the initialization
>>> functions to take another parameter, and update all callers to
>>> pass in state (for now, most callers get away with passing the
>>> current global_qtest as the current state, although this required
>>> fixing the order of initialization to ensure qtest_start() is
>>> called before qpci_init*() in rtl8139-test, and provided an
>>> opportunity to pass in the allocator in e1000e-test).
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> ---
>> [...]
>>> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
>>> index 6226546c28..c95428e1cb 100644
>>> --- a/tests/libqos/libqos.c
>>> +++ b/tests/libqos/libqos.c
>>> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
>>>          if (ops->init_allocator) {
>>>              qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
>>>          }
>>> -        if (ops->qpci_init && qs->alloc) {
>>> -            qs->pcibus = ops->qpci_init(qs->alloc);
>>> +        if (ops->qpci_init) {
>>
>> Why did you remove the check for qs->alloc?
>>
>>> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
> 
> Because we want to ensure qpci_init() is called to set qs->qts
> (presumably, whether or not qs->alloc is set).  Furthermore, only two
> files declare a 'static QOSOps' structure in the first place
> (libqos-pc.c and libqos-spapr.c); where both files set both the
> .init_allocator and .qpci_init callbacks; a little bit of auditing shows
> that the .init_allocator() never returns NULL (although that requires
> browsing yet more files for malloc-{pc,spapr}.c).

OK, thanks for the explanation! ... but maybe we should
g_assert(gs->alloc) somewhere instead? ... just an idea, I'm also fine
if you leave it away.

 Thomas


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus
  2017-09-07  5:35       ` Thomas Huth
@ 2017-09-07 13:32         ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-07 13:32 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: open list:IDE, Alexander Graf, armbru, open list:sPAPR,
	Gerd Hoffmann, pbonzini, John Snow, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]

On 09/07/2017 12:35 AM, Thomas Huth wrote:
> On 06.09.2017 23:00, Eric Blake wrote:
>> On 09/05/2017 04:36 AM, Thomas Huth wrote:
>>> On 01.09.2017 20:03, Eric Blake wrote:
>>>> When initializing a QPCIBus, track which QTestState the bus is
>>>> associated with (so that a later patch can then explicitly use
>>>> that test state for all communication on the bus, rather than
>>>> blindly relying on global_qtest).  Update the initialization
>>>> functions to take another parameter, and update all callers to
>>>> pass in state (for now, most callers get away with passing the
>>>> current global_qtest as the current state, although this required
>>>> fixing the order of initialization to ensure qtest_start() is
>>>> called before qpci_init*() in rtl8139-test, and provided an
>>>> opportunity to pass in the allocator in e1000e-test).
>>>>

>>>
>>> Why did you remove the check for qs->alloc?
>>>
>>>> +            qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
>>
>> Because we want to ensure qpci_init() is called to set qs->qts
>> (presumably, whether or not qs->alloc is set).  Furthermore, only two
>> files declare a 'static QOSOps' structure in the first place
>> (libqos-pc.c and libqos-spapr.c); where both files set both the
>> .init_allocator and .qpci_init callbacks; a little bit of auditing shows
>> that the .init_allocator() never returns NULL (although that requires
>> browsing yet more files for malloc-{pc,spapr}.c).
> 
> OK, thanks for the explanation! ... but maybe we should
> g_assert(gs->alloc) somewhere instead? ... just an idea, I'm also fine
> if you leave it away.

Users of QOSOps always supply qs->alloc, but there are tests that
successfully use NULL for qs->alloc (because they did not go through
QOSOps).  At any rate, I can certainly update the commit message.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string
  2017-09-05 12:46   ` Thomas Huth
@ 2017-09-07 18:00     ` Eric Blake
  2017-09-07 19:07       ` Thomas Huth
  0 siblings, 1 reply; 99+ messages in thread
From: Eric Blake @ 2017-09-07 18:00 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

On 09/05/2017 07:46 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> Several callers were formatting a string into a temporary
>> variable before calling qtest_init(); factor that into the
>> common code.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---

>> -QTestState *qtest_init(const char *extra_args);
>> +QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);
> 
> Maybe the parameter should be called "fmt" or "format" now instead?
> (similar to printf() and friends)

Sure.

> 
>>  /**
>>   * qtest_init_without_qmp_handshake:
>> @@ -518,7 +519,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);
>>   */
>>  static inline QTestState *qtest_start(const char *args)
>>  {
>> -    global_qtest = qtest_init(args);
>> +    global_qtest = qtest_init("%s", args);
> 
> That's a little bit sad that there are some spots which need an explicit
> "%s" now ... maybe it would be nicer to add a new function called
> qtest_initf() instead and keep the old one (without the "f") as it is?

Indeed, and looking back over my series, I see we could also benefit
from a va_list form.

Also, since you already questioned me on the churn from qtest_start() =>
qtest_init() => qtest_start(), I can make less churn in the next spin by
converging on qtest_start() from the get-go.

So I will go with qtest_start() (plain string), qtest_startf()
(formatted like sprintf), and qtest_vstartf() (formatted like vsprintf).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string
  2017-09-07 18:00     ` Eric Blake
@ 2017-09-07 19:07       ` Thomas Huth
  0 siblings, 0 replies; 99+ messages in thread
From: Thomas Huth @ 2017-09-07 19:07 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

On 07.09.2017 20:00, Eric Blake wrote:
> On 09/05/2017 07:46 AM, Thomas Huth wrote:
>> On 01.09.2017 20:03, Eric Blake wrote:
>>> Several callers were formatting a string into a temporary
>>> variable before calling qtest_init(); factor that into the
>>> common code.
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> ---
> 
>>> -QTestState *qtest_init(const char *extra_args);
>>> +QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);
>>
>> Maybe the parameter should be called "fmt" or "format" now instead?
>> (similar to printf() and friends)
> 
> Sure.
> 
>>
>>>  /**
>>>   * qtest_init_without_qmp_handshake:
>>> @@ -518,7 +519,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);
>>>   */
>>>  static inline QTestState *qtest_start(const char *args)
>>>  {
>>> -    global_qtest = qtest_init(args);
>>> +    global_qtest = qtest_init("%s", args);
>>
>> That's a little bit sad that there are some spots which need an explicit
>> "%s" now ... maybe it would be nicer to add a new function called
>> qtest_initf() instead and keep the old one (without the "f") as it is?
> 
> Indeed, and looking back over my series, I see we could also benefit
> from a va_list form.
> 
> Also, since you already questioned me on the churn from qtest_start() =>
> qtest_init() => qtest_start(), I can make less churn in the next spin by
> converging on qtest_start() from the get-go.
> 
> So I will go with qtest_start() (plain string), qtest_startf()
> (formatted like sprintf), and qtest_vstartf() (formatted like vsprintf).

Thanks, that sounds like a better way to me, too!

 Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest
  2017-09-05 10:32   ` Thomas Huth
@ 2017-09-07 20:19     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-07 20:19 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: pbonzini, John Snow, armbru, open list:IDE

[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]

On 09/05/2017 05:32 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> Managing parallel connections to two different monitors via
>> the implicit global_qtest makes it hard to copy-and-paste code
>> to tests that are not aware of the implicit state; the
>> management of global_qtest is even harder to follow because
>> it was masked behind set_context().
>>

>> ---
>>  tests/libqos/libqos.h    |  1 -
>>  tests/ahci-test.c        | 83 +++++++++++++++++++++++-------------------------
>>  tests/libqos/ahci.c      | 45 +++++++++++++-------------
>>  tests/libqos/libqos-pc.c |  2 +-
>>  tests/libqos/libqos.c    | 37 ++++++---------------
>>  5 files changed, 73 insertions(+), 95 deletions(-)
> 
> Might be easier to review if you'd split the changes to libqos.c into a
> separate patch. But anyway:
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>

I'll split it, even though it means dropping R-b on both halves of the
split (so you can make sure the pieces still look sane).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 24/29] bios-tables-test: Drop dependence on global_qtest
  2017-09-05 10:59   ` Thomas Huth
@ 2017-09-07 21:30     ` Eric Blake
  0 siblings, 0 replies; 99+ messages in thread
From: Eric Blake @ 2017-09-07 21:30 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: pbonzini, Igor Mammedov, armbru, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

On 09/05/2017 05:59 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> As a general rule, we prefer avoiding implicit global state
>> because it makes code harder to safely copy and paste without
>> thinking about the global state.  Although bios-tables-test does
>> not maintain parallel qtest connections, it's just as easy to be
>> explicit about the state; once all tests have been cleaned up, a
>> later patch can then get rid of global_qtest and a layer of
>> wrappers in libqtest.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/bios-tables-test.c | 78 +++++++++++++++++++++++++-----------------------
>>  1 file changed, 40 insertions(+), 38 deletions(-)
>>
>> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>> index 75b29df493..976792f2c5 100644
>> --- a/tests/bios-tables-test.c
>> +++ b/tests/bios-tables-test.c
>> @@ -38,6 +38,7 @@ typedef struct {
>>      struct smbios_21_entry_point smbios_ep_table;
>>      uint8_t *required_struct_types;
>>      int required_struct_types_len;
>> +    QTestState *qts;
>>  } test_data;
> 
> Ah, well, ok, here it is. Please merge this with the previous patch!

Sure, I'll merge the two.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: " Eric Blake
  2017-09-05  7:04   ` Thomas Huth
@ 2017-09-08 12:48   ` Michael S. Tsirkin
  1 sibling, 0 replies; 99+ messages in thread
From: Michael S. Tsirkin @ 2017-09-08 12:48 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, pbonzini, Igor Mammedov, armbru, Ben Warren

On Fri, Sep 01, 2017 at 01:03:33PM -0500, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Adjust the helper code to
> use explicit state instead, and update all callers.
> 
> Fix some trailing whitespace while touching the file.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  tests/boot-sector.h      | 6 ++++--
>  tests/bios-tables-test.c | 2 +-
>  tests/boot-sector.c      | 8 ++++----
>  tests/pxe-test.c         | 2 +-
>  tests/vmgenid-test.c     | 2 +-
>  5 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/tests/boot-sector.h b/tests/boot-sector.h
> index 35d61c7e2b..6ee6bb4d97 100644
> --- a/tests/boot-sector.h
> +++ b/tests/boot-sector.h
> @@ -5,7 +5,7 @@
>   *
>   * Authors:
>   *  Michael S. Tsirkin <mst@redhat.com>
> - *  Victor Kaplansky <victork@redhat.com>    
> + *  Victor Kaplansky <victork@redhat.com>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -14,11 +14,13 @@
>  #ifndef TEST_BOOT_SECTOR_H
>  #define TEST_BOOT_SECTOR_H
> 
> +#include "libqtest.h"
> +
>  /* Create boot disk file. fname must be a suitable string for mkstemp() */
>  int boot_sector_init(char *fname);
> 
>  /* Loop until signature in memory is OK.  */
> -void boot_sector_test(void);
> +void boot_sector_test(QTestState *qts);
> 
>  /* unlink boot disk file.  */
>  void boot_sector_cleanup(const char *fname);
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 564da45f65..bde62bf1cf 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -632,7 +632,7 @@ static void test_acpi_one(const char *params, test_data *data)
> 
>      qtest_start(args);
> 
> -    boot_sector_test();
> +    boot_sector_test(global_qtest);
> 
>      test_acpi_rsdp_address(data);
>      test_acpi_rsdp_table(data);
> diff --git a/tests/boot-sector.c b/tests/boot-sector.c
> index 9ee85370b0..8c8ac7f124 100644
> --- a/tests/boot-sector.c
> +++ b/tests/boot-sector.c
> @@ -5,7 +5,7 @@
>   *
>   * Authors:
>   *  Michael S. Tsirkin <mst@redhat.com>
> - *  Victor Kaplansky <victork@redhat.com>    
> + *  Victor Kaplansky <victork@redhat.com>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -130,7 +130,7 @@ int boot_sector_init(char *fname)
>  }
> 
>  /* Loop until signature in memory is OK.  */
> -void boot_sector_test(void)
> +void boot_sector_test(QTestState *qts)
>  {
>      uint8_t signature_low;
>      uint8_t signature_high;
> @@ -146,8 +146,8 @@ void boot_sector_test(void)
>       * instruction.
>       */
>      for (i = 0; i < TEST_CYCLES; ++i) {
> -        signature_low = readb(SIGNATURE_ADDR);
> -        signature_high = readb(SIGNATURE_ADDR + 1);
> +        signature_low = qtest_readb(qts, SIGNATURE_ADDR);
> +        signature_high = qtest_readb(qts, SIGNATURE_ADDR + 1);
>          signature = (signature_high << 8) | signature_low;
>          if (signature == SIGNATURE) {
>              break;
> diff --git a/tests/pxe-test.c b/tests/pxe-test.c
> index 0d70afccd6..e2d3853534 100644
> --- a/tests/pxe-test.c
> +++ b/tests/pxe-test.c
> @@ -31,7 +31,7 @@ static void test_pxe_one(const char *params, bool ipv6)
>                             ipv6 ? "on" : "off", params);
> 
>      qtest_start(args);
> -    boot_sector_test();
> +    boot_sector_test(global_qtest);
>      qtest_quit(global_qtest);
>      g_free(args);
>  }
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index 3d5c1c3615..4bdc8a15e7 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -47,7 +47,7 @@ static uint32_t acpi_find_vgia(void)
>      int i;
> 
>      /* Wait for guest firmware to finish and start the payload. */
> -    boot_sector_test();
> +    boot_sector_test(global_qtest);
> 
>      /* Tables should be initialized now. */
>      rsdp_offset = acpi_find_rsdp_address();
> -- 
> 2.13.5
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: " Eric Blake
  2017-09-05 10:57   ` Thomas Huth
@ 2017-09-08 12:48   ` Michael S. Tsirkin
  1 sibling, 0 replies; 99+ messages in thread
From: Michael S. Tsirkin @ 2017-09-08 12:48 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, pbonzini, Igor Mammedov, armbru, Ben Warren

On Fri, Sep 01, 2017 at 01:03:34PM -0500, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Adjust the helper code to
> use explicit state instead, and update all callers.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>


> ---
>  tests/acpi-utils.h       |  65 +++++++++----------
>  tests/acpi-utils.c       |  19 +++---
>  tests/bios-tables-test.c | 161 ++++++++++++++++++++++++-----------------------
>  tests/vmgenid-test.c     |  18 +++---
>  4 files changed, 133 insertions(+), 130 deletions(-)
> 
> diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
> index f8d87236c6..8ec83f71b1 100644
> --- a/tests/acpi-utils.h
> +++ b/tests/acpi-utils.h
> @@ -28,20 +28,20 @@ typedef struct {
>      bool tmp_files_retain;   /* do not delete the temp asl/aml */
>  } AcpiSdtTable;
> 
> -#define ACPI_READ_FIELD(field, addr)           \
> +#define ACPI_READ_FIELD(qts, field, addr)      \
>      do {                                       \
>          switch (sizeof(field)) {               \
>          case 1:                                \
> -            field = readb(addr);               \
> +            field = qtest_readb(qts, addr);    \
>              break;                             \
>          case 2:                                \
> -            field = readw(addr);               \
> +            field = qtest_readw(qts, addr);    \
>              break;                             \
>          case 4:                                \
> -            field = readl(addr);               \
> +            field = qtest_readl(qts, addr);    \
>              break;                             \
>          case 8:                                \
> -            field = readq(addr);               \
> +            field = qtest_readq(qts, addr);    \
>              break;                             \
>          default:                               \
>              g_assert(false);                   \
> @@ -49,28 +49,28 @@ typedef struct {
>          addr += sizeof(field);                  \
>      } while (0);
> 
> -#define ACPI_READ_ARRAY_PTR(arr, length, addr)  \
> -    do {                                        \
> -        int idx;                                \
> -        for (idx = 0; idx < length; ++idx) {    \
> -            ACPI_READ_FIELD(arr[idx], addr);    \
> -        }                                       \
> +#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr)      \
> +    do {                                                 \
> +        int idx;                                         \
> +        for (idx = 0; idx < length; ++idx) {             \
> +            ACPI_READ_FIELD(qts, arr[idx], addr);        \
> +        }                                                \
>      } while (0);
> 
> -#define ACPI_READ_ARRAY(arr, addr)                               \
> -    ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr)
> +#define ACPI_READ_ARRAY(qts, arr, addr)                                 \
> +    ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr)
> 
> -#define ACPI_READ_TABLE_HEADER(table, addr)                      \
> +#define ACPI_READ_TABLE_HEADER(qts, table, addr)                 \
>      do {                                                         \
> -        ACPI_READ_FIELD((table)->signature, addr);               \
> -        ACPI_READ_FIELD((table)->length, addr);                  \
> -        ACPI_READ_FIELD((table)->revision, addr);                \
> -        ACPI_READ_FIELD((table)->checksum, addr);                \
> -        ACPI_READ_ARRAY((table)->oem_id, addr);                  \
> -        ACPI_READ_ARRAY((table)->oem_table_id, addr);            \
> -        ACPI_READ_FIELD((table)->oem_revision, addr);            \
> -        ACPI_READ_ARRAY((table)->asl_compiler_id, addr);         \
> -        ACPI_READ_FIELD((table)->asl_compiler_revision, addr);   \
> +        ACPI_READ_FIELD(qts, (table)->signature, addr);          \
> +        ACPI_READ_FIELD(qts, (table)->length, addr);             \
> +        ACPI_READ_FIELD(qts, (table)->revision, addr);           \
> +        ACPI_READ_FIELD(qts, (table)->checksum, addr);           \
> +        ACPI_READ_ARRAY(qts, (table)->oem_id, addr);             \
> +        ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr);       \
> +        ACPI_READ_FIELD(qts, (table)->oem_revision, addr);       \
> +        ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr);    \
> +        ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr);     \
>      } while (0);
> 
>  #define ACPI_ASSERT_CMP(actual, expected) do { \
> @@ -87,18 +87,19 @@ typedef struct {
>      g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
>  } while (0)
> 
> -#define ACPI_READ_GENERIC_ADDRESS(field, addr)       \
> -    do {                                             \
> -        ACPI_READ_FIELD((field).space_id, addr);     \
> -        ACPI_READ_FIELD((field).bit_width, addr);    \
> -        ACPI_READ_FIELD((field).bit_offset, addr);   \
> -        ACPI_READ_FIELD((field).access_width, addr); \
> -        ACPI_READ_FIELD((field).address, addr);      \
> +#define ACPI_READ_GENERIC_ADDRESS(qts, field, addr)       \
> +    do {                                                  \
> +        ACPI_READ_FIELD(qts, (field).space_id, addr);     \
> +        ACPI_READ_FIELD(qts, (field).bit_width, addr);    \
> +        ACPI_READ_FIELD(qts, (field).bit_offset, addr);   \
> +        ACPI_READ_FIELD(qts, (field).access_width, addr); \
> +        ACPI_READ_FIELD(qts, (field).address, addr);      \
>      } while (0);
> 
> 
>  uint8_t acpi_calc_checksum(const uint8_t *data, int len);
> -uint32_t acpi_find_rsdp_address(void);
> -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table);
> +uint32_t acpi_find_rsdp_address(QTestState *qts);
> +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
> +                           AcpiRsdpDescriptor *rsdp_table);
> 
>  #endif  /* TEST_ACPI_UTILS_H */
> diff --git a/tests/acpi-utils.c b/tests/acpi-utils.c
> index 41dc1ea9b4..6dc8ca1a8c 100644
> --- a/tests/acpi-utils.c
> +++ b/tests/acpi-utils.c
> @@ -32,7 +32,7 @@ uint8_t acpi_calc_checksum(const uint8_t *data, int len)
>      return sum;
>  }
> 
> -uint32_t acpi_find_rsdp_address(void)
> +uint32_t acpi_find_rsdp_address(QTestState *qts)
>  {
>      uint32_t off;
> 
> @@ -42,7 +42,7 @@ uint32_t acpi_find_rsdp_address(void)
>          int i;
> 
>          for (i = 0; i < sizeof sig - 1; ++i) {
> -            sig[i] = readb(off + i);
> +            sig[i] = qtest_readb(qts, off + i);
>          }
> 
>          if (!memcmp(sig, "RSD PTR ", sizeof sig)) {
> @@ -52,14 +52,15 @@ uint32_t acpi_find_rsdp_address(void)
>      return off;
>  }
> 
> -void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table)
> +void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr,
> +                           AcpiRsdpDescriptor *rsdp_table)
>  {
> -    ACPI_READ_FIELD(rsdp_table->signature, addr);
> +    ACPI_READ_FIELD(qts, rsdp_table->signature, addr);
>      ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR ");
> 
> -    ACPI_READ_FIELD(rsdp_table->checksum, addr);
> -    ACPI_READ_ARRAY(rsdp_table->oem_id, addr);
> -    ACPI_READ_FIELD(rsdp_table->revision, addr);
> -    ACPI_READ_FIELD(rsdp_table->rsdt_physical_address, addr);
> -    ACPI_READ_FIELD(rsdp_table->length, addr);
> +    ACPI_READ_FIELD(qts, rsdp_table->checksum, addr);
> +    ACPI_READ_ARRAY(qts, rsdp_table->oem_id, addr);
> +    ACPI_READ_FIELD(qts, rsdp_table->revision, addr);
> +    ACPI_READ_FIELD(qts, rsdp_table->rsdt_physical_address, addr);
> +    ACPI_READ_FIELD(qts, rsdp_table->length, addr);
>  }
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index bde62bf1cf..75b29df493 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -77,7 +77,7 @@ static void free_test_data(test_data *data)
> 
>  static void test_acpi_rsdp_address(test_data *data)
>  {
> -    uint32_t off = acpi_find_rsdp_address();
> +    uint32_t off = acpi_find_rsdp_address(global_qtest);
>      g_assert_cmphex(off, <, 0x100000);
>      data->rsdp_addr = off;
>  }
> @@ -87,7 +87,7 @@ static void test_acpi_rsdp_table(test_data *data)
>      AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
>      uint32_t addr = data->rsdp_addr;
> 
> -    acpi_parse_rsdp_table(addr, rsdp_table);
> +    acpi_parse_rsdp_table(global_qtest, addr, rsdp_table);
> 
>      /* rsdp checksum is not for the whole table, but for the first 20 bytes */
>      g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
> @@ -102,7 +102,7 @@ static void test_acpi_rsdt_table(test_data *data)
>      uint8_t checksum;
> 
>      /* read the header */
> -    ACPI_READ_TABLE_HEADER(rsdt_table, addr);
> +    ACPI_READ_TABLE_HEADER(global_qtest, rsdt_table, addr);
>      ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");
> 
>      /* compute the table entries in rsdt */
> @@ -112,7 +112,7 @@ static void test_acpi_rsdt_table(test_data *data)
> 
>      /* get the addresses of the tables pointed by rsdt */
>      tables = g_new0(uint32_t, tables_nr);
> -    ACPI_READ_ARRAY_PTR(tables, tables_nr, addr);
> +    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, addr);
> 
>      checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
>                 acpi_calc_checksum((uint8_t *)tables,
> @@ -128,63 +128,64 @@ static void test_acpi_fadt_table(test_data *data)
>  {
>      AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
>      uint32_t addr;
> +    QTestState *qts = global_qtest;
> 
>      /* FADT table comes first */
>      addr = data->rsdt_tables_addr[0];
> -    ACPI_READ_TABLE_HEADER(fadt_table, addr);
> +    ACPI_READ_TABLE_HEADER(qts, fadt_table, addr);
> 
> -    ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
> -    ACPI_READ_FIELD(fadt_table->dsdt, addr);
> -    ACPI_READ_FIELD(fadt_table->model, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved1, addr);
> -    ACPI_READ_FIELD(fadt_table->sci_int, addr);
> -    ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
> -    ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
> -    ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
> -    ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved2, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
> -    ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
> -    ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved3, addr);
> -    ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
> -    ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
> -    ACPI_READ_FIELD(fadt_table->flush_size, addr);
> -    ACPI_READ_FIELD(fadt_table->flush_stride, addr);
> -    ACPI_READ_FIELD(fadt_table->duty_offset, addr);
> -    ACPI_READ_FIELD(fadt_table->duty_width, addr);
> -    ACPI_READ_FIELD(fadt_table->day_alrm, addr);
> -    ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
> -    ACPI_READ_FIELD(fadt_table->century, addr);
> -    ACPI_READ_FIELD(fadt_table->boot_flags, addr);
> -    ACPI_READ_FIELD(fadt_table->reserved, addr);
> -    ACPI_READ_FIELD(fadt_table->flags, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr);
> -    ACPI_READ_FIELD(fadt_table->reset_value, addr);
> -    ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr);
> -    ACPI_READ_FIELD(fadt_table->minor_revision, addr);
> -    ACPI_READ_FIELD(fadt_table->x_facs, addr);
> -    ACPI_READ_FIELD(fadt_table->x_dsdt, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr);
> -    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->firmware_ctrl, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->dsdt, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->model, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved1, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->sci_int, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->smi_cmd, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->acpi_enable, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->acpi_disable, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->S4bios_req, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved2, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1a_evt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1b_evt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1a_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1b_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1_evt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm1_cnt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm2_cnt_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->pm_tmr_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe0_blk_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_blk_len, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->gpe1_base, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved3, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->plvl2_lat, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->plvl3_lat, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flush_size, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flush_stride, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->duty_offset, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->duty_width, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->day_alrm, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->mon_alrm, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->century, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->boot_flags, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reserved, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->flags, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->reset_register, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->reset_value, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->arm_boot_flags, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->minor_revision, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->x_facs, addr);
> +    ACPI_READ_FIELD(qts, fadt_table->x_dsdt, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_event_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_event_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1a_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm1b_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm2_control_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xpm_timer_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe0_block, addr);
> +    ACPI_READ_GENERIC_ADDRESS(qts, fadt_table->xgpe1_block, addr);
> 
>      ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
>      g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
> @@ -195,13 +196,13 @@ static void test_acpi_facs_table(test_data *data)
>      AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
>      uint32_t addr = data->fadt_table.firmware_ctrl;
> 
> -    ACPI_READ_FIELD(facs_table->signature, addr);
> -    ACPI_READ_FIELD(facs_table->length, addr);
> -    ACPI_READ_FIELD(facs_table->hardware_signature, addr);
> -    ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr);
> -    ACPI_READ_FIELD(facs_table->global_lock, addr);
> -    ACPI_READ_FIELD(facs_table->flags, addr);
> -    ACPI_READ_ARRAY(facs_table->resverved3, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->signature, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->length, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->hardware_signature, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->firmware_waking_vector, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->global_lock, addr);
> +    ACPI_READ_FIELD(global_qtest, facs_table->flags, addr);
> +    ACPI_READ_ARRAY(global_qtest, facs_table->resverved3, addr);
> 
>      ACPI_ASSERT_CMP(facs_table->signature, "FACS");
>  }
> @@ -210,11 +211,11 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
>  {
>      uint8_t checksum;
> 
> -    ACPI_READ_TABLE_HEADER(&sdt_table->header, addr);
> +    ACPI_READ_TABLE_HEADER(global_qtest, &sdt_table->header, addr);
> 
>      sdt_table->aml_len = sdt_table->header.length - sizeof(AcpiTableHeader);
>      sdt_table->aml = g_malloc0(sdt_table->aml_len);
> -    ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
> +    ACPI_READ_ARRAY_PTR(global_qtest, sdt_table->aml, sdt_table->aml_len, addr);
> 
>      checksum = acpi_calc_checksum((uint8_t *)sdt_table,
>                                    sizeof(AcpiTableHeader)) +
> @@ -492,32 +493,32 @@ static bool smbios_ep_table_ok(test_data *data)
>      struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
>      uint32_t addr = data->smbios_ep_addr;
> 
> -    ACPI_READ_ARRAY(ep_table->anchor_string, addr);
> +    ACPI_READ_ARRAY(global_qtest, ep_table->anchor_string, addr);
>      if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
>          return false;
>      }
> -    ACPI_READ_FIELD(ep_table->checksum, addr);
> -    ACPI_READ_FIELD(ep_table->length, addr);
> -    ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
> -    ACPI_READ_FIELD(ep_table->smbios_minor_version, addr);
> -    ACPI_READ_FIELD(ep_table->max_structure_size, addr);
> -    ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
> -    ACPI_READ_ARRAY(ep_table->formatted_area, addr);
> -    ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->checksum, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->length, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->smbios_major_version, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->smbios_minor_version, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->max_structure_size, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->entry_point_revision, addr);
> +    ACPI_READ_ARRAY(global_qtest, ep_table->formatted_area, addr);
> +    ACPI_READ_ARRAY(global_qtest, ep_table->intermediate_anchor_string, addr);
>      if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
>          return false;
>      }
> -    ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
> -    ACPI_READ_FIELD(ep_table->structure_table_length, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->intermediate_checksum, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_length, addr);
>      if (ep_table->structure_table_length == 0) {
>          return false;
>      }
> -    ACPI_READ_FIELD(ep_table->structure_table_address, addr);
> -    ACPI_READ_FIELD(ep_table->number_of_structures, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_address, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->number_of_structures, addr);
>      if (ep_table->number_of_structures == 0) {
>          return false;
>      }
> -    ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
> +    ACPI_READ_FIELD(global_qtest, ep_table->smbios_bcd_revision, addr);
>      if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
>          acpi_calc_checksum((uint8_t *)ep_table + 0x10,
>                             sizeof *ep_table - 0x10)) {
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index 4bdc8a15e7..73473162d0 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -50,15 +50,15 @@ static uint32_t acpi_find_vgia(void)
>      boot_sector_test(global_qtest);
> 
>      /* Tables should be initialized now. */
> -    rsdp_offset = acpi_find_rsdp_address();
> +    rsdp_offset = acpi_find_rsdp_address(global_qtest);
> 
>      g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
> 
> -    acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
> +    acpi_parse_rsdp_table(global_qtest, rsdp_offset, &rsdp_table);
> 
>      rsdt = rsdp_table.rsdt_physical_address;
>      /* read the header */
> -    ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
> +    ACPI_READ_TABLE_HEADER(global_qtest, &rsdt_table, rsdt);
>      ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
> 
>      /* compute the table entries in rsdt */
> @@ -68,21 +68,21 @@ static uint32_t acpi_find_vgia(void)
> 
>      /* get the addresses of the tables pointed by rsdt */
>      tables = g_new0(uint32_t, tables_nr);
> -    ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
> +    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, rsdt);
> 
>      for (i = 0; i < tables_nr; i++) {
> -        ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]);
> +        ACPI_READ_TABLE_HEADER(global_qtest, &ssdt_table, tables[i]);
>          if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
>              /* the first entry in the table should be VGIA
>               * That's all we need
>               */
> -            ACPI_READ_FIELD(vgid_table.name_op, tables[i]);
> +            ACPI_READ_FIELD(global_qtest, vgid_table.name_op, tables[i]);
>              g_assert(vgid_table.name_op == 0x08);  /* name */
> -            ACPI_READ_ARRAY(vgid_table.vgia, tables[i]);
> +            ACPI_READ_ARRAY(global_qtest, vgid_table.vgia, tables[i]);
>              g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
> -            ACPI_READ_FIELD(vgid_table.val_op, tables[i]);
> +            ACPI_READ_FIELD(global_qtest, vgid_table.val_op, tables[i]);
>              g_assert(vgid_table.val_op == 0x0C);  /* dword */
> -            ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]);
> +            ACPI_READ_FIELD(global_qtest, vgid_table.vgia_val, tables[i]);
>              /* The GUID is written at a fixed offset into the fw_cfg file
>               * in order to implement the "OVMF SDT Header probe suppressor"
>               * see docs/specs/vmgenid.txt for more details
> -- 
> 2.13.5
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [Qemu-devel] [PATCH v6 24/29] bios-tables-test: Drop dependence on global_qtest
  2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 24/29] bios-tables-test: " Eric Blake
  2017-09-05 10:59   ` Thomas Huth
@ 2017-09-08 12:49   ` Michael S. Tsirkin
  1 sibling, 0 replies; 99+ messages in thread
From: Michael S. Tsirkin @ 2017-09-08 12:49 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, pbonzini, Igor Mammedov, armbru

On Fri, Sep 01, 2017 at 01:03:35PM -0500, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  Although bios-tables-test does
> not maintain parallel qtest connections, it's just as easy to be
> explicit about the state; once all tests have been cleaned up, a
> later patch can then get rid of global_qtest and a layer of
> wrappers in libqtest.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  tests/bios-tables-test.c | 78 +++++++++++++++++++++++++-----------------------
>  1 file changed, 40 insertions(+), 38 deletions(-)
> 
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 75b29df493..976792f2c5 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -38,6 +38,7 @@ typedef struct {
>      struct smbios_21_entry_point smbios_ep_table;
>      uint8_t *required_struct_types;
>      int required_struct_types_len;
> +    QTestState *qts;
>  } test_data;
> 
>  static char disk[] = "tests/acpi-test-disk-XXXXXX";
> @@ -77,7 +78,7 @@ static void free_test_data(test_data *data)
> 
>  static void test_acpi_rsdp_address(test_data *data)
>  {
> -    uint32_t off = acpi_find_rsdp_address(global_qtest);
> +    uint32_t off = acpi_find_rsdp_address(data->qts);
>      g_assert_cmphex(off, <, 0x100000);
>      data->rsdp_addr = off;
>  }
> @@ -87,7 +88,7 @@ static void test_acpi_rsdp_table(test_data *data)
>      AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
>      uint32_t addr = data->rsdp_addr;
> 
> -    acpi_parse_rsdp_table(global_qtest, addr, rsdp_table);
> +    acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
> 
>      /* rsdp checksum is not for the whole table, but for the first 20 bytes */
>      g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
> @@ -102,7 +103,7 @@ static void test_acpi_rsdt_table(test_data *data)
>      uint8_t checksum;
> 
>      /* read the header */
> -    ACPI_READ_TABLE_HEADER(global_qtest, rsdt_table, addr);
> +    ACPI_READ_TABLE_HEADER(data->qts, rsdt_table, addr);
>      ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");
> 
>      /* compute the table entries in rsdt */
> @@ -112,7 +113,7 @@ static void test_acpi_rsdt_table(test_data *data)
> 
>      /* get the addresses of the tables pointed by rsdt */
>      tables = g_new0(uint32_t, tables_nr);
> -    ACPI_READ_ARRAY_PTR(global_qtest, tables, tables_nr, addr);
> +    ACPI_READ_ARRAY_PTR(data->qts, tables, tables_nr, addr);
> 
>      checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
>                 acpi_calc_checksum((uint8_t *)tables,
> @@ -128,7 +129,7 @@ static void test_acpi_fadt_table(test_data *data)
>  {
>      AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
>      uint32_t addr;
> -    QTestState *qts = global_qtest;
> +    QTestState *qts = data->qts;
> 
>      /* FADT table comes first */
>      addr = data->rsdt_tables_addr[0];
> @@ -196,26 +197,27 @@ static void test_acpi_facs_table(test_data *data)
>      AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
>      uint32_t addr = data->fadt_table.firmware_ctrl;
> 
> -    ACPI_READ_FIELD(global_qtest, facs_table->signature, addr);
> -    ACPI_READ_FIELD(global_qtest, facs_table->length, addr);
> -    ACPI_READ_FIELD(global_qtest, facs_table->hardware_signature, addr);
> -    ACPI_READ_FIELD(global_qtest, facs_table->firmware_waking_vector, addr);
> -    ACPI_READ_FIELD(global_qtest, facs_table->global_lock, addr);
> -    ACPI_READ_FIELD(global_qtest, facs_table->flags, addr);
> -    ACPI_READ_ARRAY(global_qtest, facs_table->resverved3, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->signature, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->length, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->hardware_signature, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->firmware_waking_vector, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->global_lock, addr);
> +    ACPI_READ_FIELD(data->qts, facs_table->flags, addr);
> +    ACPI_READ_ARRAY(data->qts, facs_table->resverved3, addr);
> 
>      ACPI_ASSERT_CMP(facs_table->signature, "FACS");
>  }
> 
> -static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
> +static void test_dst_table(test_data *data, AcpiSdtTable *sdt_table,
> +                           uint32_t addr)
>  {
>      uint8_t checksum;
> 
> -    ACPI_READ_TABLE_HEADER(global_qtest, &sdt_table->header, addr);
> +    ACPI_READ_TABLE_HEADER(data->qts, &sdt_table->header, addr);
> 
>      sdt_table->aml_len = sdt_table->header.length - sizeof(AcpiTableHeader);
>      sdt_table->aml = g_malloc0(sdt_table->aml_len);
> -    ACPI_READ_ARRAY_PTR(global_qtest, sdt_table->aml, sdt_table->aml_len, addr);
> +    ACPI_READ_ARRAY_PTR(data->qts, sdt_table->aml, sdt_table->aml_len, addr);
> 
>      checksum = acpi_calc_checksum((uint8_t *)sdt_table,
>                                    sizeof(AcpiTableHeader)) +
> @@ -232,7 +234,7 @@ static void test_acpi_dsdt_table(test_data *data)
>      memset(&dsdt_table, 0, sizeof(dsdt_table));
>      data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> 
> -    test_dst_table(&dsdt_table, addr);
> +    test_dst_table(data, &dsdt_table, addr);
>      ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT");
> 
>      /* Place DSDT first */
> @@ -249,7 +251,7 @@ static void test_acpi_tables(test_data *data)
> 
>          memset(&ssdt_table, 0, sizeof(ssdt_table));
>          uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
> -        test_dst_table(&ssdt_table, addr);
> +        test_dst_table(data, &ssdt_table, addr);
>          g_array_append_val(data->tables, ssdt_table);
>      }
>  }
> @@ -493,32 +495,32 @@ static bool smbios_ep_table_ok(test_data *data)
>      struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
>      uint32_t addr = data->smbios_ep_addr;
> 
> -    ACPI_READ_ARRAY(global_qtest, ep_table->anchor_string, addr);
> +    ACPI_READ_ARRAY(data->qts, ep_table->anchor_string, addr);
>      if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
>          return false;
>      }
> -    ACPI_READ_FIELD(global_qtest, ep_table->checksum, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->length, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->smbios_major_version, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->smbios_minor_version, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->max_structure_size, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->entry_point_revision, addr);
> -    ACPI_READ_ARRAY(global_qtest, ep_table->formatted_area, addr);
> -    ACPI_READ_ARRAY(global_qtest, ep_table->intermediate_anchor_string, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->checksum, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->length, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->smbios_major_version, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->smbios_minor_version, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->max_structure_size, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->entry_point_revision, addr);
> +    ACPI_READ_ARRAY(data->qts, ep_table->formatted_area, addr);
> +    ACPI_READ_ARRAY(data->qts, ep_table->intermediate_anchor_string, addr);
>      if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
>          return false;
>      }
> -    ACPI_READ_FIELD(global_qtest, ep_table->intermediate_checksum, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_length, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->intermediate_checksum, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->structure_table_length, addr);
>      if (ep_table->structure_table_length == 0) {
>          return false;
>      }
> -    ACPI_READ_FIELD(global_qtest, ep_table->structure_table_address, addr);
> -    ACPI_READ_FIELD(global_qtest, ep_table->number_of_structures, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->structure_table_address, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->number_of_structures, addr);
>      if (ep_table->number_of_structures == 0) {
>          return false;
>      }
> -    ACPI_READ_FIELD(global_qtest, ep_table->smbios_bcd_revision, addr);
> +    ACPI_READ_FIELD(data->qts, ep_table->smbios_bcd_revision, addr);
>      if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
>          acpi_calc_checksum((uint8_t *)ep_table + 0x10,
>                             sizeof *ep_table - 0x10)) {
> @@ -537,7 +539,7 @@ static void test_smbios_entry_point(test_data *data)
>          int i;
> 
>          for (i = 0; i < sizeof sig - 1; ++i) {
> -            sig[i] = readb(off + i);
> +            sig[i] = qtest_readb(data->qts, off + i);
>          }
> 
>          if (!memcmp(sig, "_SM_", sizeof sig)) {
> @@ -580,9 +582,9 @@ static void test_smbios_structs(test_data *data)
>      for (i = 0; i < ep_table->number_of_structures; i++) {
> 
>          /* grab type and formatted area length from struct header */
> -        type = readb(addr);
> +        type = qtest_readb(data->qts, addr);
>          g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
> -        len = readb(addr + 1);
> +        len = qtest_readb(data->qts, addr + 1);
> 
>          /* single-instance structs must not have been encountered before */
>          if (smbios_single_instance(type)) {
> @@ -594,7 +596,7 @@ static void test_smbios_structs(test_data *data)
>          prv = crt = 1;
>          while (prv || crt) {
>              prv = crt;
> -            crt = readb(addr + len);
> +            crt = qtest_readb(data->qts, addr + len);
>              len++;
>          }
> 
> @@ -631,9 +633,9 @@ static void test_acpi_one(const char *params, test_data *data)
>                             data->machine, "kvm:tcg",
>                             params ? params : "", disk);
> 
> -    qtest_start(args);
> +    data->qts = qtest_init(args);
> 
> -    boot_sector_test(global_qtest);
> +    boot_sector_test(data->qts);
> 
>      test_acpi_rsdp_address(data);
>      test_acpi_rsdp_table(data);
> @@ -654,7 +656,7 @@ static void test_acpi_one(const char *params, test_data *data)
>      test_smbios_entry_point(data);
>      test_smbios_structs(data);
> 
> -    qtest_quit(global_qtest);
> +    qtest_quit(data->qts);
>      g_free(args);
>  }
> 
> -- 
> 2.13.5
> 

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2017-09-08 12:49 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 18:03 [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 01/29] tests: Improve .gitignore for tests/multiboot Eric Blake
2017-09-04 14:03   ` Thomas Huth
2017-09-06 19:33     ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 02/29] tests: Sort .gitignore Eric Blake
2017-09-05  7:20   ` Thomas Huth
2017-09-05  9:53     ` Markus Armbruster
2017-09-05  9:58       ` Thomas Huth
2017-09-05 10:10       ` Daniel P. Berrange
2017-09-05 10:44         ` Thomas Huth
2017-09-05 14:22         ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 03/29] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
2017-09-05  7:43   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 04/29] qtest: Don't perform side effects inside assertion Eric Blake
2017-09-04 14:06   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 05/29] numa-test: Use hmp() Eric Blake
2017-09-05  7:44   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 06/29] tests: Clean up wait for event Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 07/29] libqtest: Remove dead qtest_instances variable Eric Blake
2017-09-04 17:02   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 08/29] libqtest: Let socket_send() compute length Eric Blake
2017-09-05  8:12   ` Thomas Huth
2017-09-05  9:54     ` Markus Armbruster
2017-09-05 22:20       ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 09/29] libqtest: Use qemu_strtoul() Eric Blake
2017-09-05  9:11   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 10/29] libqtest: Topologically sort functions Eric Blake
2017-09-05  9:22   ` Thomas Huth
2017-09-05 10:01     ` Markus Armbruster
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 11/29] libqtest: Inline qtest_query_target_endianness() Eric Blake
2017-09-02  0:10   ` Philippe Mathieu-Daudé
2017-09-05  9:25   ` Thomas Huth
2017-09-06 20:12     ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 12/29] libqos: Track QTestState with QPCIBus Eric Blake
2017-09-01 19:20   ` Philippe Mathieu-Daudé
2017-09-06 20:48     ` Eric Blake
2017-09-01 23:06   ` John Snow
2017-09-05  9:36   ` Thomas Huth
2017-09-06 21:00     ` Eric Blake
2017-09-07  5:35       ` Thomas Huth
2017-09-07 13:32         ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 13/29] libqos: Use explicit QTestState for pci operations Eric Blake
2017-09-01 19:22   ` Philippe Mathieu-Daudé
2017-09-05 10:03   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 14/29] libqos: Use explicit QTestState for fw_cfg operations Eric Blake
2017-09-01 19:21   ` [Qemu-devel] [PATCH v6 14.5/29] fixup! " Eric Blake
2017-09-01 19:24   ` [Qemu-devel] [PATCH v6 14/29] " Philippe Mathieu-Daudé
2017-09-01 23:06   ` John Snow
2017-09-05 10:12   ` Thomas Huth
2017-09-05 11:03     ` Thomas Huth
2017-09-06 21:10       ` Eric Blake
2017-09-06 21:25         ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 15/29] libqos: Use explicit QTestState for rtas operations Eric Blake
2017-09-05 10:16   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations Eric Blake
2017-09-05 10:26   ` Thomas Huth
2017-09-05 12:43     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-09-06 21:42       ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 17/29] ahci-test: Drop dependence on global_qtest Eric Blake
2017-09-01 23:11   ` John Snow
2017-09-05 10:32   ` Thomas Huth
2017-09-07 20:19     ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 18/29] ivshmem-test: " Eric Blake
2017-09-05 10:36   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 19/29] postcopy-test: " Eric Blake
2017-09-05 10:41   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 20/29] vhost-user-test: " Eric Blake
2017-09-05 10:49   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 21/29] qmp-test: " Eric Blake
2017-09-05  7:11   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: " Eric Blake
2017-09-05  7:04   ` Thomas Huth
2017-09-08 12:48   ` Michael S. Tsirkin
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 23/29] tests/acpi-utils: " Eric Blake
2017-09-05 10:57   ` Thomas Huth
2017-09-08 12:48   ` Michael S. Tsirkin
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 24/29] bios-tables-test: " Eric Blake
2017-09-05 10:59   ` Thomas Huth
2017-09-07 21:30     ` Eric Blake
2017-09-08 12:49   ` Michael S. Tsirkin
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 25/29] wdt_ib700-test: " Eric Blake
2017-09-05 11:01   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: " Eric Blake
2017-09-02  0:07   ` Philippe Mathieu-Daudé
2017-09-05 11:05   ` Thomas Huth
2017-09-06 21:45     ` Eric Blake
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept format string Eric Blake
2017-09-05 12:46   ` Thomas Huth
2017-09-07 18:00     ` Eric Blake
2017-09-07 19:07       ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts Eric Blake
2017-09-01 23:16   ` John Snow
2017-09-05 13:06   ` Thomas Huth
2017-09-01 18:03 ` [Qemu-devel] [PATCH v6 29/29] libqtest: Rename qtest_init() to qtest_start() Eric Blake
2017-09-01 23:17   ` John Snow
2017-09-05 13:10   ` Thomas Huth
2017-09-07  2:57     ` Eric Blake
2017-09-01 18:31 ` [Qemu-devel] [PATCH v6 00/29] Preliminary libqtest cleanups no-reply
2017-09-01 18:44   ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.