All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/9] qtest fixes and improvements
@ 2021-12-22 11:32 Thomas Huth
  2021-12-22 11:32 ` [PULL 1/9] failover: Silence warning messages during qtest Thomas Huth
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

 Hi!

The following changes since commit 8c5f94cd4182753959c8be8de415120dc879d8f0:

  Merge tag 'pull-loong-20211221-2' of https://gitlab.com/rth7680/qemu into staging (2021-12-21 13:30:35 -0800)

are available in the Git repository at:

  https://gitlab.com/thuth/qemu.git tags/pull-request-2021-12-22

for you to fetch changes up to e63ed64c6d10768b3a41c3337226372a9664ef6f:

  tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file (2021-12-22 09:37:14 +0100)

----------------------------------------------------------------
* Fixes for the virtio-net-failover test
* Silence warnings in the boot-serial-test
* Make qtests more flexible wrt missing machines and devices

----------------------------------------------------------------
Laurent Vivier (1):
      failover: Silence warning messages during qtest

Thomas Huth (7):
      tests/qtest/boot-serial-test: Silence the warning about deprecated sga device
      tests/qtest: Make the filter tests independent from a specific NIC
      tests/qtest: Add a function that checks whether a device is available
      tests/qtest: Improve endianness-test to work with missing machines and devices
      tests/qtest/cdrom-test: Check whether devices are available before using them
      tests/qtest/boot-order-test: Check whether machines are available
      tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file

Zhang Chen (1):
      MAINTAINERS: Update COLO Proxy section

 MAINTAINERS                          |  1 +
 hw/net/virtio-net.c                  |  7 ++++-
 migration/migration.c                |  4 ++-
 tests/qtest/boot-order-test.c        |  5 +++
 tests/qtest/boot-serial-test.c       | 10 +++---
 tests/qtest/cdrom-test.c             | 60 +++++++++++++++++++++++-------------
 tests/qtest/endianness-test.c        |  5 ++-
 tests/qtest/libqos/libqtest.h        |  8 +++++
 tests/qtest/libqtest.c               | 44 ++++++++++++++++++++++++++
 tests/qtest/meson.build              | 40 ++++++++++++++++++------
 tests/qtest/test-filter-mirror.c     | 10 ++----
 tests/qtest/test-filter-redirector.c | 20 +++---------
 tests/qtest/test-netfilter.c         |  8 +----
 tests/qtest/virtio-net-failover.c    |  8 +++--
 14 files changed, 158 insertions(+), 72 deletions(-)



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

* [PULL 1/9] failover: Silence warning messages during qtest
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 2/9] tests/qtest/boot-serial-test: Silence the warning about deprecated sga device Thomas Huth
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Philippe Mathieu-Daudé,
	Jason Wang, Richard Henderson

From: Laurent Vivier <lvivier@redhat.com>

virtio-net-failover test tries several device combinations that produces
some expected warnings.
These warning can be confusing, so we disable them during the qtest
sequence.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20211220145314.390697-1-lvivier@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
[thuth: Fix memory leak by using error_free()]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/net/virtio-net.c   | 7 ++++++-
 migration/migration.c | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f2014d5ea0..cf8ab0f8af 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -44,6 +44,7 @@
 #include "hw/pci/pci.h"
 #include "net_rx_pkt.h"
 #include "hw/virtio/vhost.h"
+#include "sysemu/qtest.h"
 
 #define VIRTIO_NET_VM_VERSION    11
 
@@ -926,7 +927,11 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
         qatomic_set(&n->failover_primary_hidden, false);
         failover_add_primary(n, &err);
         if (err) {
-            warn_report_err(err);
+            if (!qtest_enabled()) {
+                warn_report_err(err);
+            } else {
+                error_free(err);
+            }
         }
     }
 }
diff --git a/migration/migration.c b/migration/migration.c
index 3de11ae921..0652165610 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -60,6 +60,7 @@
 #include "qemu/yank.h"
 #include "sysemu/cpus.h"
 #include "yank_functions.h"
+#include "sysemu/qtest.h"
 
 #define MAX_THROTTLE  (128 << 20)      /* Migration transfer speed throttling */
 
@@ -3766,7 +3767,8 @@ static void qemu_savevm_wait_unplug(MigrationState *s, int old_state,
             while (timeout-- && qemu_savevm_state_guest_unplug_pending()) {
                 qemu_sem_timedwait(&s->wait_unplug_sem, 250);
             }
-            if (qemu_savevm_state_guest_unplug_pending()) {
+            if (qemu_savevm_state_guest_unplug_pending() &&
+                !qtest_enabled()) {
                 warn_report("migration: partially unplugged device on "
                             "failure");
             }
-- 
2.27.0



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

* [PULL 2/9] tests/qtest/boot-serial-test: Silence the warning about deprecated sga device
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
  2021-12-22 11:32 ` [PULL 1/9] failover: Silence warning messages during qtest Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 3/9] tests/qtest: Make the filter tests independent from a specific NIC Thomas Huth
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson

When running the qtests, there are currently a bunch of warnings about
the deprecated sga device during the boot-serial-test. Switch to
"-M graphics=off" to silence these warnings.

Message-Id: <20211220164042.397028-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/boot-serial-test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index 4d8e1343bd..d72a82d629 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -157,11 +157,11 @@ static testdef_t tests[] = {
     { "ppc64", "powernv8", "", "OPAL" },
     { "ppc64", "powernv9", "", "OPAL" },
     { "ppc64", "sam460ex", "-device e1000", "8086  100e" },
-    { "i386", "isapc", "-cpu qemu32 -device sga", "SGABIOS" },
-    { "i386", "pc", "-device sga", "SGABIOS" },
-    { "i386", "q35", "-device sga", "SGABIOS" },
-    { "x86_64", "isapc", "-cpu qemu32 -device sga", "SGABIOS" },
-    { "x86_64", "q35", "-device sga", "SGABIOS" },
+    { "i386", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
+    { "i386", "pc", "-M graphics=off", "SeaBIOS" },
+    { "i386", "q35", "-M graphics=off", "SeaBIOS" },
+    { "x86_64", "isapc", "-cpu qemu32 -M graphics=off", "SeaBIOS" },
+    { "x86_64", "q35", "-M graphics=off", "SeaBIOS" },
     { "sparc", "LX", "", "TMS390S10" },
     { "sparc", "SS-4", "", "MB86904" },
     { "sparc", "SS-600MP", "", "TMS390Z55" },
-- 
2.27.0



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

* [PULL 3/9] tests/qtest: Make the filter tests independent from a specific NIC
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
  2021-12-22 11:32 ` [PULL 1/9] failover: Silence warning messages during qtest Thomas Huth
  2021-12-22 11:32 ` [PULL 2/9] tests/qtest/boot-serial-test: Silence the warning about deprecated sga device Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 4/9] MAINTAINERS: Update COLO Proxy section Thomas Huth
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Zhang Chen, Richard Henderson

These filter tests need a NIC, no matter which one, so they use a common
NIC by default. However, these common NIC models might not always have
been compiled into the QEMU target binary, so assuming that a certain NIC
is available is a bad idea. Since the exact type of NIC does not really
matter for these tests, let's switch to "-nic" instead of "-netdev" so
that QEMU can simply pick a default NIC for us.
This way we can now run the tests on other targets that have a default
machine with an on-board/default NIC, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20211220103025.311759-1-thuth@redhat.com>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/meson.build              | 40 +++++++++++++++++++++-------
 tests/qtest/test-filter-mirror.c     | 10 ++-----
 tests/qtest/test-filter-redirector.c | 20 +++-----------
 tests/qtest/test-netfilter.c         |  8 +-----
 4 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 1b2bde6660..37e1eaa449 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -47,7 +47,6 @@ qtests_i386 = \
   (have_tools ? ['ahci-test'] : []) +                                                       \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +           \
   (config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) +                  \
-  (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['test-filter-redirector'] : []) +    \
   (config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) +            \
   (config_host.has_key('CONFIG_LINUX') and                                                  \
    config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) +              \
@@ -90,7 +89,9 @@ qtests_i386 = \
    'vmgenid-test',
    'migration-test',
    'test-x86-cpuid-compat',
-   'numa-test']
+   'numa-test',
+   'test-filter-redirector'
+  ]
 
 if dbus_display
   qtests_i386 += ['dbus-display-test']
@@ -113,31 +114,49 @@ endif
 
 qtests_x86_64 = qtests_i386
 
-qtests_alpha = [ 'boot-serial-test' ] +                                                      \
+qtests_alpha = ['boot-serial-test'] + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
 qtests_avr = [ 'boot-serial-test' ]
 
-qtests_hppa = [ 'boot-serial-test' ] +                                                       \
+qtests_hppa = ['boot-serial-test'] + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
-qtests_m68k = [ 'boot-serial-test' ]
-qtests_microblaze = [ 'boot-serial-test' ]
+qtests_m68k = ['boot-serial-test'] + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : [])
+
+qtests_microblaze = ['boot-serial-test'] + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : [])
+
 qtests_microblazeel = qtests_microblaze
 
 qtests_mips = \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
 qtests_mips64 = \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
 qtests_mips64el = \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
 
 qtests_ppc = \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : []) + \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
   (config_all_devices.has_key('CONFIG_M48T59') ? ['m48t59-test'] : []) +                     \
   ['boot-order-test', 'prom-env-test', 'boot-serial-test']                 \
@@ -147,19 +166,22 @@ qtests_ppc64 = \
   (config_all_devices.has_key('CONFIG_PSERIES') ? ['device-plug-test'] : []) +               \
   (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-xscom-test'] : []) +                 \
   (config_all_devices.has_key('CONFIG_PSERIES') ? ['rtas-test'] : []) +                      \
-  (slirp.found() ? ['pxe-test', 'test-netfilter'] : []) +              \
+  (slirp.found() ? ['pxe-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +             \
   (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) +         \
-  (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) +                      \
   qtests_pci + ['migration-test', 'numa-test', 'cpu-plug-test', 'drive_del-test']
 
 qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
 qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
 
-qtests_sparc = ['prom-env-test', 'm48t59-test', 'boot-serial-test']
+qtests_sparc = ['prom-env-test', 'm48t59-test', 'boot-serial-test'] + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
+  (slirp.found() ? ['test-netfilter'] : [])
 
 qtests_sparc64 = \
   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
+  (slirp.found() ? ['test-netfilter'] : []) + \
+  ['test-filter-mirror', 'test-filter-redirector'] + \
   ['prom-env-test', 'boot-serial-test']
 
 qtests_npcm7xx = \
diff --git a/tests/qtest/test-filter-mirror.c b/tests/qtest/test-filter-mirror.c
index bc0dee64dd..95367d14d3 100644
--- a/tests/qtest/test-filter-mirror.c
+++ b/tests/qtest/test-filter-mirror.c
@@ -28,13 +28,8 @@ static void test_mirror(void)
     char *recv_buf;
     uint32_t size = sizeof(send_buf);
     size = htonl(size);
-    const char *devstr = "e1000";
     QTestState *qts;
 
-    if (g_str_equal(qtest_get_arch(), "s390x")) {
-        devstr = "virtio-net-ccw";
-    }
-
     ret = socketpair(PF_UNIX, SOCK_STREAM, 0, send_sock);
     g_assert_cmpint(ret, !=, -1);
 
@@ -42,11 +37,10 @@ static void test_mirror(void)
     g_assert_cmpint(ret, !=, -1);
 
     qts = qtest_initf(
-        "-netdev socket,id=qtest-bn0,fd=%d "
-        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-nic socket,id=qtest-bn0,fd=%d "
         "-chardev socket,id=mirror0,fd=%d "
         "-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
-        , send_sock[1], devstr, recv_sock[1]);
+        , send_sock[1], recv_sock[1]);
 
     struct iovec iov[] = {
         {
diff --git a/tests/qtest/test-filter-redirector.c b/tests/qtest/test-filter-redirector.c
index 4269b2cdd9..4f3f59cba8 100644
--- a/tests/qtest/test-filter-redirector.c
+++ b/tests/qtest/test-filter-redirector.c
@@ -62,16 +62,6 @@
 /* TODO actually test the results and get rid of this */
 #define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARGS__))
 
-static const char *get_devstr(void)
-{
-    if (g_str_equal(qtest_get_arch(), "s390x")) {
-        return "virtio-net-ccw";
-    }
-
-    return "rtl8139";
-}
-
-
 static void test_redirector_tx(void)
 {
     int backend_sock[2], recv_sock;
@@ -93,8 +83,7 @@ static void test_redirector_tx(void)
     g_assert_cmpint(ret, !=, -1);
 
     qts = qtest_initf(
-        "-netdev socket,id=qtest-bn0,fd=%d "
-        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-nic socket,id=qtest-bn0,fd=%d "
         "-chardev socket,id=redirector0,path=%s,server=on,wait=off "
         "-chardev socket,id=redirector1,path=%s,server=on,wait=off "
         "-chardev socket,id=redirector2,path=%s "
@@ -103,7 +92,7 @@ static void test_redirector_tx(void)
         "-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(),
+        "queue=tx,outdev=redirector1 ", backend_sock[1],
         sock_path0, sock_path1, sock_path0);
 
     recv_sock = unix_connect(sock_path1, NULL);
@@ -163,8 +152,7 @@ static void test_redirector_rx(void)
     g_assert_cmpint(ret, !=, -1);
 
     qts = qtest_initf(
-        "-netdev socket,id=qtest-bn0,fd=%d "
-        "-device %s,netdev=qtest-bn0,id=qtest-e0 "
+        "-nic socket,id=qtest-bn0,fd=%d "
         "-chardev socket,id=redirector0,path=%s,server=on,wait=off "
         "-chardev socket,id=redirector1,path=%s,server=on,wait=off "
         "-chardev socket,id=redirector2,path=%s "
@@ -173,7 +161,7 @@ static void test_redirector_rx(void)
         "-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(),
+        "queue=rx,indev=redirector1 ", backend_sock[1],
         sock_path0, sock_path1, sock_path0);
 
     struct iovec iov[] = {
diff --git a/tests/qtest/test-netfilter.c b/tests/qtest/test-netfilter.c
index 785b6f3226..b09ef7fae9 100644
--- a/tests/qtest/test-netfilter.c
+++ b/tests/qtest/test-netfilter.c
@@ -178,11 +178,6 @@ int main(int argc, char **argv)
 {
     int ret;
     char *args;
-    const char *devstr = "e1000";
-
-    if (g_str_equal(qtest_get_arch(), "s390x")) {
-        devstr = "virtio-net-ccw";
-    }
 
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/netfilter/addremove_one", add_one_netfilter);
@@ -192,8 +187,7 @@ 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);
+    args = g_strdup_printf("-nic user,id=qtest-bn0");
     qtest_start(args);
     ret = g_test_run();
 
-- 
2.27.0



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

* [PULL 4/9] MAINTAINERS: Update COLO Proxy section
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (2 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 3/9] tests/qtest: Make the filter tests independent from a specific NIC Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 5/9] tests/qtest: Add a function that checks whether a device is available Thomas Huth
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Zhang Chen, Richard Henderson, Philippe Mathieu-Daudé

From: Zhang Chen <chen.zhang@intel.com>

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
Message-Id: <20211221080400.1492980-1-chen.zhang@intel.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5dcefc0d01..5456536805 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2987,6 +2987,7 @@ F: docs/colo-proxy.txt
 F: net/colo*
 F: net/filter-rewriter.c
 F: net/filter-mirror.c
+F: tests/qtest/test-filter*
 
 Record/replay
 M: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
-- 
2.27.0



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

* [PULL 5/9] tests/qtest: Add a function that checks whether a device is available
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (3 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 4/9] MAINTAINERS: Update COLO Proxy section Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 6/9] tests/qtest: Improve endianness-test to work with missing machines and devices Thomas Huth
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

Devices might not always be compiled into the QEMU target binaries.
We already have the libqos framework that is good for handling such
situations, but some of the qtests are not a real good fit for the
libqos framework. Let's add a qtest_has_device() function for such
tests instead.

Message-Id: <20211220081054.151515-2-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/libqos/libqtest.h |  8 +++++++
 tests/qtest/libqtest.c        | 44 +++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h
index a6d38d7ef7..cf38d273f5 100644
--- a/tests/qtest/libqos/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
@@ -718,6 +718,14 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
  */
 bool qtest_has_machine(const char *machine);
 
+/**
+ * qtest_has_device:
+ * @device: The device to look for
+ *
+ * Returns: true if the device is available in the target binary.
+ */
+bool qtest_has_device(const char *device);
+
 /**
  * qtest_qmp_device_add_qdict:
  * @qts: QTestState instance to operate on
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index a68326caae..41f4da4e54 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -1418,6 +1418,50 @@ bool qtest_has_machine(const char *machine)
     return false;
 }
 
+bool qtest_has_device(const char *device)
+{
+    static QList *list;
+    const QListEntry *p;
+    QObject *qobj;
+    QString *qstr;
+    QDict *devinfo;
+    int idx;
+
+    if (!list) {
+        QDict *resp;
+        QDict *args;
+        QTestState *qts = qtest_init("-machine none");
+
+        args = qdict_new();
+        qdict_put_bool(args, "abstract", false);
+        qdict_put_str(args, "implements", "device");
+
+        resp = qtest_qmp(qts, "{'execute': 'qom-list-types', 'arguments': %p }",
+                         args);
+        g_assert(qdict_haskey(resp, "return"));
+        list = qdict_get_qlist(resp, "return");
+        qobject_ref(list);
+        qobject_unref(resp);
+
+        qtest_quit(qts);
+    }
+
+    for (p = qlist_first(list), idx = 0; p; p = qlist_next(p), idx++) {
+        devinfo = qobject_to(QDict, qlist_entry_obj(p));
+        g_assert(devinfo);
+
+        qobj = qdict_get(devinfo, "name");
+        g_assert(qobj);
+        qstr = qobject_to(QString, qobj);
+        g_assert(qstr);
+        if (g_str_equal(qstring_get_str(qstr), device)) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 /*
  * Generic hot-plugging test via the device_add QMP commands.
  */
-- 
2.27.0



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

* [PULL 6/9] tests/qtest: Improve endianness-test to work with missing machines and devices
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (4 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 5/9] tests/qtest: Add a function that checks whether a device is available Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 7/9] tests/qtest/cdrom-test: Check whether devices are available before using them Thomas Huth
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

The users might have built QEMU with less machines or without the
i82378 superio device. Add some checks to the endianess-test so that
it is able to deal with such stripped down QEMU versions, too.

Message-Id: <20211220081054.151515-3-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/endianness-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/endianness-test.c b/tests/qtest/endianness-test.c
index 09ecb531f1..9c03b72dc9 100644
--- a/tests/qtest/endianness-test.c
+++ b/tests/qtest/endianness-test.c
@@ -281,7 +281,10 @@ int main(int argc, char **argv)
 
     for (i = 0; test_cases[i].arch; i++) {
         gchar *path;
-        if (strcmp(test_cases[i].arch, arch) != 0) {
+
+        if (!g_str_equal(test_cases[i].arch, arch) ||
+            !qtest_has_machine(test_cases[i].machine) ||
+            (test_cases[i].superio && !qtest_has_device(test_cases[i].superio))) {
             continue;
         }
         path = g_strdup_printf("endianness/%s",
-- 
2.27.0



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

* [PULL 7/9] tests/qtest/cdrom-test: Check whether devices are available before using them
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (5 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 6/9] tests/qtest: Improve endianness-test to work with missing machines and devices Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 8/9] tests/qtest/boot-order-test: Check whether machines are available Thomas Huth
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

Downstream users might want to disable legacy devices in their binaries,
so we should not blindly assume that they are available. Add some proper
checks before using them.

Message-Id: <20211220081054.151515-4-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/cdrom-test.c | 60 ++++++++++++++++++++++++++--------------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index c1fcac5c45..cfca24fa94 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -142,21 +142,36 @@ static void add_x86_tests(void)
         qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
                             "-drive if=ide,media=cdrom,file=", test_cdboot);
     }
-    qtest_add_data_func("cdrom/boot/am53c974",
-                        "-device am53c974 -device scsi-cd,drive=cd1 "
-                        "-drive if=none,id=cd1,format=raw,file=", test_cdboot);
-    qtest_add_data_func("cdrom/boot/dc390",
-                        "-device dc390 -device scsi-cd,drive=cd1 "
-                        "-blockdev file,node-name=cd1,filename=", test_cdboot);
-    qtest_add_data_func("cdrom/boot/lsi53c895a",
-                        "-device lsi53c895a -device scsi-cd,drive=cd1 "
-                        "-blockdev file,node-name=cd1,filename=", test_cdboot);
-    qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
-                        "-device megasas -device scsi-cd,drive=cd1 "
-                        "-blockdev file,node-name=cd1,filename=", test_cdboot);
-    qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
-                        "-device megasas-gen2 -device scsi-cd,drive=cd1 "
-                        "-blockdev file,node-name=cd1,filename=", test_cdboot);
+    if (qtest_has_device("am53c974")) {
+        qtest_add_data_func("cdrom/boot/am53c974",
+                            "-device am53c974 -device scsi-cd,drive=cd1 "
+                            "-drive if=none,id=cd1,format=raw,file=",
+                            test_cdboot);
+    }
+    if (qtest_has_device("dc390")) {
+        qtest_add_data_func("cdrom/boot/dc390",
+                            "-device dc390 -device scsi-cd,drive=cd1 "
+                            "-blockdev file,node-name=cd1,filename=",
+                            test_cdboot);
+    }
+    if (qtest_has_device("lsi53c895a")) {
+        qtest_add_data_func("cdrom/boot/lsi53c895a",
+                            "-device lsi53c895a -device scsi-cd,drive=cd1 "
+                            "-blockdev file,node-name=cd1,filename=",
+                            test_cdboot);
+    }
+    if (qtest_has_device("megasas")) {
+        qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
+                            "-device megasas -device scsi-cd,drive=cd1 "
+                            "-blockdev file,node-name=cd1,filename=",
+                            test_cdboot);
+    }
+    if (qtest_has_device("megasas-gen2")) {
+        qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
+                            "-device megasas-gen2 -device scsi-cd,drive=cd1 "
+                            "-blockdev file,node-name=cd1,filename=",
+                            test_cdboot);
+    }
 }
 
 static void add_s390x_tests(void)
@@ -171,12 +186,15 @@ static void add_s390x_tests(void)
                         "-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
                         "-device virtio-blk,drive=d2,bootindex=1 "
                         "-drive if=none,id=d2,media=cdrom,file=", test_cdboot);
-    qtest_add_data_func("cdrom/boot/without-bootindex",
-                        "-device virtio-scsi -device virtio-serial "
-                        "-device x-terminal3270 -device virtio-blk,drive=d1 "
-                        "-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
-                        "-device virtio-blk,drive=d2 "
-                        "-drive if=none,id=d2,media=cdrom,file=", test_cdboot);
+    if (qtest_has_device("x-terminal3270")) {
+        qtest_add_data_func("cdrom/boot/without-bootindex",
+                            "-device virtio-scsi -device virtio-serial "
+                            "-device x-terminal3270 -device virtio-blk,drive=d1 "
+                            "-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
+                            "-device virtio-blk,drive=d2 "
+                            "-drive if=none,id=d2,media=cdrom,file=",
+                            test_cdboot);
+    }
 }
 
 int main(int argc, char **argv)
-- 
2.27.0



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

* [PULL 8/9] tests/qtest/boot-order-test: Check whether machines are available
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (6 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 7/9] tests/qtest/cdrom-test: Check whether devices are available before using them Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 11:32 ` [PULL 9/9] tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file Thomas Huth
  2021-12-22 18:00 ` [PULL 0/9] qtest fixes and improvements Richard Henderson
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

Machines might not always be compiled into the QEMU binary, so
we should skip the test instead of failing if it is not available.

Message-Id: <20211220081054.151515-5-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/boot-order-test.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/qtest/boot-order-test.c b/tests/qtest/boot-order-test.c
index fac580d6c4..f1f59b1261 100644
--- a/tests/qtest/boot-order-test.c
+++ b/tests/qtest/boot-order-test.c
@@ -34,6 +34,11 @@ static void test_a_boot_order(const char *machine,
     uint64_t actual;
     QTestState *qts;
 
+    if (machine && !qtest_has_machine(machine)) {
+        g_test_skip("Machine is not available");
+        return;
+    }
+
     qts = qtest_initf("-nodefaults%s%s %s", machine ? " -M " : "",
                       machine ?: "", test_args);
     actual = read_boot_order(qts);
-- 
2.27.0



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

* [PULL 9/9] tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (7 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 8/9] tests/qtest/boot-order-test: Check whether machines are available Thomas Huth
@ 2021-12-22 11:32 ` Thomas Huth
  2021-12-22 18:00 ` [PULL 0/9] qtest fixes and improvements Richard Henderson
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2021-12-22 11:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson

g_test_rand_int() must not be called before g_test_init(), otherwise
the glib will show a "g_rand_int: assertion 'rand != NULL' failed"
message in the log. So we could change the order here, but actually,
it's safer to use g_file_open_tmp() anyway, so let's use that function
now instead.

Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211222083652.776592-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/virtio-net-failover.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c
index 4b2ba8a106..22ad54bb95 100644
--- a/tests/qtest/virtio-net-failover.c
+++ b/tests/qtest/virtio-net-failover.c
@@ -1306,13 +1306,15 @@ static void test_multi_in(gconstpointer opaque)
 
 int main(int argc, char **argv)
 {
-    const gchar *tmpdir = g_get_tmp_dir();
-    gchar *tmpfile = g_strdup_printf("%s/failover_test_migrate-%u-%u",
-                                     tmpdir, getpid(), g_test_rand_int());
+    gchar *tmpfile;
     int ret;
 
     g_test_init(&argc, &argv, NULL);
 
+    ret = g_file_open_tmp("failover_test_migrate-XXXXXX", &tmpfile, NULL);
+    g_assert_true(ret >= 0);
+    close(ret);
+
     qtest_add_func("failover-virtio-net/params/error/id", test_error_id);
     qtest_add_func("failover-virtio-net/params/error/pcie", test_error_pcie);
     qtest_add_func("failover-virtio-net/params/on", test_on);
-- 
2.27.0



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

* Re: [PULL 0/9] qtest fixes and improvements
  2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
                   ` (8 preceding siblings ...)
  2021-12-22 11:32 ` [PULL 9/9] tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file Thomas Huth
@ 2021-12-22 18:00 ` Richard Henderson
  9 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2021-12-22 18:00 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel

On 12/22/21 3:32 AM, Thomas Huth wrote:
>   Hi!
> 
> The following changes since commit 8c5f94cd4182753959c8be8de415120dc879d8f0:
> 
>    Merge tag 'pull-loong-20211221-2' of https://gitlab.com/rth7680/qemu into staging (2021-12-21 13:30:35 -0800)
> 
> are available in the Git repository at:
> 
>    https://gitlab.com/thuth/qemu.git tags/pull-request-2021-12-22
> 
> for you to fetch changes up to e63ed64c6d10768b3a41c3337226372a9664ef6f:
> 
>    tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file (2021-12-22 09:37:14 +0100)
> 
> ----------------------------------------------------------------
> * Fixes for the virtio-net-failover test
> * Silence warnings in the boot-serial-test
> * Make qtests more flexible wrt missing machines and devices
> 
> ----------------------------------------------------------------
> Laurent Vivier (1):
>        failover: Silence warning messages during qtest
> 
> Thomas Huth (7):
>        tests/qtest/boot-serial-test: Silence the warning about deprecated sga device
>        tests/qtest: Make the filter tests independent from a specific NIC
>        tests/qtest: Add a function that checks whether a device is available
>        tests/qtest: Improve endianness-test to work with missing machines and devices
>        tests/qtest/cdrom-test: Check whether devices are available before using them
>        tests/qtest/boot-order-test: Check whether machines are available
>        tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file
> 
> Zhang Chen (1):
>        MAINTAINERS: Update COLO Proxy section
> 
>   MAINTAINERS                          |  1 +
>   hw/net/virtio-net.c                  |  7 ++++-
>   migration/migration.c                |  4 ++-
>   tests/qtest/boot-order-test.c        |  5 +++
>   tests/qtest/boot-serial-test.c       | 10 +++---
>   tests/qtest/cdrom-test.c             | 60 +++++++++++++++++++++++-------------
>   tests/qtest/endianness-test.c        |  5 ++-
>   tests/qtest/libqos/libqtest.h        |  8 +++++
>   tests/qtest/libqtest.c               | 44 ++++++++++++++++++++++++++
>   tests/qtest/meson.build              | 40 ++++++++++++++++++------
>   tests/qtest/test-filter-mirror.c     | 10 ++----
>   tests/qtest/test-filter-redirector.c | 20 +++---------
>   tests/qtest/test-netfilter.c         |  8 +----
>   tests/qtest/virtio-net-failover.c    |  8 +++--
>   14 files changed, 158 insertions(+), 72 deletions(-)

Applied, thanks.

r~



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

end of thread, other threads:[~2021-12-22 18:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 11:32 [PULL 0/9] qtest fixes and improvements Thomas Huth
2021-12-22 11:32 ` [PULL 1/9] failover: Silence warning messages during qtest Thomas Huth
2021-12-22 11:32 ` [PULL 2/9] tests/qtest/boot-serial-test: Silence the warning about deprecated sga device Thomas Huth
2021-12-22 11:32 ` [PULL 3/9] tests/qtest: Make the filter tests independent from a specific NIC Thomas Huth
2021-12-22 11:32 ` [PULL 4/9] MAINTAINERS: Update COLO Proxy section Thomas Huth
2021-12-22 11:32 ` [PULL 5/9] tests/qtest: Add a function that checks whether a device is available Thomas Huth
2021-12-22 11:32 ` [PULL 6/9] tests/qtest: Improve endianness-test to work with missing machines and devices Thomas Huth
2021-12-22 11:32 ` [PULL 7/9] tests/qtest/cdrom-test: Check whether devices are available before using them Thomas Huth
2021-12-22 11:32 ` [PULL 8/9] tests/qtest/boot-order-test: Check whether machines are available Thomas Huth
2021-12-22 11:32 ` [PULL 9/9] tests/qtest/virtio-net-failover: Use g_file_open_tmp() to create temporary file Thomas Huth
2021-12-22 18:00 ` [PULL 0/9] qtest fixes and improvements Richard Henderson

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.