[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 1/5] tests/x86: Add subtest with 'q35' machine type to device-
From: |
Michael Labiuk |
Subject: |
[PATCH v3 1/5] tests/x86: Add subtest with 'q35' machine type to device-plug-test |
Date: |
Thu, 15 Sep 2022 16:14:03 +0300 |
Configure pci bridge setting to plug pci device and unplug.
Move common code for device removing to function.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
---
tests/qtest/device-plug-test.c | 83 ++++++++++++++++++++++++----------
1 file changed, 58 insertions(+), 25 deletions(-)
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index a1fb99c8ff..d66c386ef4 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -61,6 +61,18 @@ static void wait_device_deleted_event(QTestState *qtest,
const char *id)
}
}
+static void process_device_remove(QTestState *qtest, const char *id)
+{
+ /*
+ * Request device removal. As the guest is not running, the request won't
+ * be processed. However during system reset, the removal will be
+ * handled, removing the device.
+ */
+ device_del(qtest, id);
+ system_reset(qtest);
+ wait_device_deleted_event(qtest, id);
+}
+
static void test_pci_unplug_request(void)
{
const char *arch = qtest_get_arch();
@@ -73,14 +85,20 @@ static void test_pci_unplug_request(void)
QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
+
+ qtest_quit(qtest);
+}
+
+static void test_q35_pci_unplug_request(void)
+{
+
+ QTestState *qtest = qtest_initf("-machine q35 "
+ "-device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-device virtio-mouse-pci,bus=b1,id=dev0");
+
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -98,14 +116,28 @@ static void test_pci_unplug_json_request(void)
"%s -device \"{'driver': 'virtio-mouse-pci', 'id': 'dev0'}\"",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
+
+ qtest_quit(qtest);
+}
+
+static void test_q35_pci_unplug_json_request(void)
+{
+ const char *port = "-device '{\"driver\": \"pcie-root-port\", "
+ "\"id\": \"p1\"}'";
+
+ const char *bridge = "-device '{\"driver\": \"pcie-pci-bridge\", "
+ "\"id\": \"b1\", "
+ "\"bus\": \"p1\"}'";
+
+ const char *device = "-device '{\"driver\": \"virtio-mouse-pci\", "
+ "\"bus\": \"b1\", "
+ "\"id\": \"dev0\"}'";
+
+ QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
+ port, bridge, device);
+
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -128,9 +160,7 @@ static void test_spapr_cpu_unplug_request(void)
"-device
power9_v2.0-spapr-cpu-core,core-id=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -144,9 +174,7 @@ static void test_spapr_memory_unplug_request(void)
"-device pc-dimm,id=dev0,memdev=mem0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -158,9 +186,7 @@ static void test_spapr_phb_unplug_request(void)
qtest = qtest_initf("-device spapr-pci-host-bridge,index=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -195,5 +221,12 @@ int main(int argc, char **argv)
test_spapr_phb_unplug_request);
}
+ if (!strcmp(arch, "x86_64")) {
+ qtest_add_func("/device-plug/q35-pci-unplug-request",
+ test_q35_pci_unplug_request);
+ qtest_add_func("/device-plug/q35-pci-unplug-json-request",
+ test_q35_pci_unplug_json_request);
+ }
+
return g_test_run();
}
--
2.34.1