qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test


From: Thomas Huth
Subject: Re: [PATCH v4 3/7] tests/x86: Add 'q35' machine type to ivshmem-test
Date: Tue, 27 Sep 2022 12:57:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 20/09/2022 12.48, Michael Labiuk wrote:
Configure pci bridge setting to test ivshmem on 'q35'.

Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
  tests/qtest/ivshmem-test.c | 30 ++++++++++++++++++++++++++++++
  1 file changed, 30 insertions(+)

diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
index 9611d05eb5..0f9755abc6 100644
--- a/tests/qtest/ivshmem-test.c
+++ b/tests/qtest/ivshmem-test.c
@@ -378,6 +378,32 @@ static void test_ivshmem_server(void)
      close(thread.pipe[0]);
  }
+static void device_del(QTestState *qtest, const char *id)
+{
+    QDict *resp;
+
+    resp = qtest_qmp(qtest,
+                     "{'execute': 'device_del',"
+                     " 'arguments': { 'id': %s } }", id);
+
+    g_assert(qdict_haskey(resp, "return"));
+    qobject_unref(resp);
+}

Uh, this made me realize that we have lots of similar, yet quite different device_del functions around in the qtests... could we maybe unify them a little bit?

What about if you add your function above as qtest_qmp_device_del_nowait() in libqtest.c (in a separate patch) and change qtest_qmp_device_del() to call your new function before doing the qtest_qmp_eventwait() ? A similar change could then be done to qpci_unplug_acpi_device_test() in tests/qtest/libqos/pci-pc.c and to device_del() in tests/qtest/drive_del-test.c ... ?

+static void test_ivshmem_hotplug_q35(void)
+{
+    QTestState *qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1 "
+                                 "-device pcie-root-port,id=p1 "
+                                 "-device pcie-pci-bridge,bus=p1,id=b1 "
+                                 "-machine q35");
+
+    qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
+                         "{'memdev': 'mb1', 'bus': 'b1'}");
+    device_del(qts, "iv1");
+
+    qtest_quit(qts);
+}
+
  #define PCI_SLOT_HP             0x06
static void test_ivshmem_hotplug(void)
@@ -469,6 +495,7 @@ int main(int argc, char **argv)
  {
      int ret, fd;
      gchar dir[] = "/tmp/ivshmem-test.XXXXXX";
+    const char *arch = qtest_get_arch();
g_test_init(&argc, &argv, NULL); @@ -494,6 +521,9 @@ int main(int argc, char **argv)
          qtest_add_func("/ivshmem/pair", test_ivshmem_pair);
          qtest_add_func("/ivshmem/server", test_ivshmem_server);
      }
+    if (!strcmp(arch, "x86_64")) {

I'd suggest to use qtest_has_machine("q35") instead.

+        qtest_add_func("/ivshmem/hotplug-q35", test_ivshmem_hotplug_q35);
+    }
out:
      ret = g_test_run();

 Thomas




reply via email to

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