aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/device-plug-test.c
diff options
context:
space:
mode:
authorMichael Labiuk <michael.labiuk@virtuozzo.com>2022-09-20 13:48:36 +0300
committerThomas Huth <thuth@redhat.com>2022-09-27 20:51:21 +0200
commit9bcc0f7de7a6a04bd184ac4a1dbcbc3ccd53a6c0 (patch)
tree556ed1f8e7fbd6aefce0f3e7a5dcaa6e3297934f /tests/qtest/device-plug-test.c
parent3070eeba8510ce755d6cd75e761126c01f065a24 (diff)
downloadqemu-9bcc0f7de7a6a04bd184ac4a1dbcbc3ccd53a6c0.zip
qemu-9bcc0f7de7a6a04bd184ac4a1dbcbc3ccd53a6c0.tar.gz
qemu-9bcc0f7de7a6a04bd184ac4a1dbcbc3ccd53a6c0.tar.bz2
tests/x86: Move common code to function in device-plug-test
Move common code for device removing to function. Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com> Message-Id: <20220920104842.605530-2-michael.labiuk@virtuozzo.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/qtest/device-plug-test.c')
-rw-r--r--tests/qtest/device-plug-test.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index a1fb99c..e595b45 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,7 @@ 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);
}
@@ -98,14 +103,7 @@ 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);
}
@@ -128,9 +126,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 +140,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 +152,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);
}