[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/39] device-plug-test: use qtest_qmp to send the device_del comm
From: |
Paolo Bonzini |
Subject: |
[PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command |
Date: |
Sat, 10 Oct 2020 03:57:25 -0400 |
Simplify the code now that events are buffered. There is no need
anymore to separate sending the command and retrieving the response.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/qtest/device-plug-test.c | 32 +++++++++-----------------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index a2247856be..559d47727a 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -15,26 +15,17 @@
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
-static void device_del_start(QTestState *qtest, const char *id)
+static void device_del(QTestState *qtest, const char *id)
{
- qtest_qmp_send(qtest,
- "{'execute': 'device_del', 'arguments': { 'id': %s } }",
id);
-}
+ QDict *resp;
-static void device_del_finish(QTestState *qtest)
-{
- QDict *resp = qtest_qmp_receive_dict(qtest);
+ resp = qtest_qmp(qtest,
+ "{'execute': 'device_del', 'arguments': { 'id': %s } }",
id);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
}
-static void device_del_request(QTestState *qtest, const char *id)
-{
- device_del_start(qtest, id);
- device_del_finish(qtest);
-}
-
static void system_reset(QTestState *qtest)
{
QDict *resp;
@@ -79,7 +70,7 @@ static void test_pci_unplug_request(void)
* be processed. However during system reset, the removal will be
* handled, removing the device.
*/
- device_del_request(qtest, "dev0");
+ device_del(qtest, "dev0");
system_reset(qtest);
wait_device_deleted_event(qtest, "dev0");
@@ -90,13 +81,8 @@ static void test_ccw_unplug(void)
{
QTestState *qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
- /*
- * The DEVICE_DELETED events will be sent before the command
- * completes.
- */
- device_del_start(qtest, "dev0");
+ device_del(qtest, "dev0");
wait_device_deleted_event(qtest, "dev0");
- device_del_finish(qtest);
qtest_quit(qtest);
}
@@ -109,7 +95,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_request(qtest, "dev0");
+ device_del(qtest, "dev0");
system_reset(qtest);
wait_device_deleted_event(qtest, "dev0");
@@ -125,7 +111,7 @@ static void test_spapr_memory_unplug_request(void)
"-device pc-dimm,id=dev0,memdev=mem0");
/* similar to test_pci_unplug_request */
- device_del_request(qtest, "dev0");
+ device_del(qtest, "dev0");
system_reset(qtest);
wait_device_deleted_event(qtest, "dev0");
@@ -139,7 +125,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_request(qtest, "dev0");
+ device_del(qtest, "dev0");
system_reset(qtest);
wait_device_deleted_event(qtest, "dev0");
--
2.26.2
- [PULL 16/39] docs/devel/qtest: Include protocol spec in document, (continued)
- [PULL 16/39] docs/devel/qtest: Include protocol spec in document, Paolo Bonzini, 2020/10/10
- [PULL 06/39] io: Move the creation of the library to the main meson.build, Paolo Bonzini, 2020/10/10
- [PULL 09/39] qom: Move the creation of the library to the main meson.build, Paolo Bonzini, 2020/10/10
- [PULL 07/39] crypto: Move the creation of the library to the main meson.build, Paolo Bonzini, 2020/10/10
- [PULL 11/39] softmmu: move more files to softmmu/, Paolo Bonzini, 2020/10/10
- [PULL 13/39] qom: fix objects with improper parent type, Paolo Bonzini, 2020/10/10
- [PULL 19/39] docs/devel: update instruction on how to add new unit tests, Paolo Bonzini, 2020/10/10
- [PULL 14/39] configure: fix performance regression due to PIC objects, Paolo Bonzini, 2020/10/10
- [PULL 17/39] docs/devel/qtest: Include libqtest API reference, Paolo Bonzini, 2020/10/10
- [PULL 12/39] exec: split out non-softmmu-specific parts, Paolo Bonzini, 2020/10/10
- [PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command,
Paolo Bonzini <=
- [PULL 22/39] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict, Paolo Bonzini, 2020/10/10
- [PULL 20/39] build-sys: fix git version from -version, Paolo Bonzini, 2020/10/10
- [PULL 18/39] qtest: unify extra_qtest_srcs and extra_qtest_deps, Paolo Bonzini, 2020/10/10
- [PULL 26/39] qtest: switch users back to qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 24/39] qtest: remove qtest_qmp_receive_success, Paolo Bonzini, 2020/10/10
- [PULL 29/39] qdev: add "check if address free" callback for buses, Paolo Bonzini, 2020/10/10
- [PULL 23/39] qtest: Reintroduce qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 21/39] meson.build: Re-enable KVM support for MIPS, Paolo Bonzini, 2020/10/10
- [PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find, Paolo Bonzini, 2020/10/10
- [PULL 27/39] qtest: check that drives are really appearing and disappearing, Paolo Bonzini, 2020/10/10