diff options
author | David Hildenbrand <david@redhat.com> | 2019-02-18 10:22:00 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-02-26 09:21:25 +1100 |
commit | 613ebbec647d6d159a2fc81b4c34290765901de3 (patch) | |
tree | a4ba1fa76655a30ae71e5f2545c2a5a309d45604 | |
parent | 0d9d4872e54945c161933f1c1f6eddf1f18dfc90 (diff) | |
download | qemu-613ebbec647d6d159a2fc81b4c34290765901de3.zip |
tests/device-plug: Add CCW unplug test for s390x
As CCW unplugs are surprise removals without asking the guest first,
we can test this without any guest interaction.
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190218092202.26683-5-david@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | tests/device-plug-test.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c index cd9ada539d..d1a6c94af2 100644 --- a/tests/device-plug-test.c +++ b/tests/device-plug-test.c @@ -15,17 +15,26 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -static void device_del_request(QTestState *qtest, const char *id) +static void device_del_start(QTestState *qtest, const char *id) { - QDict *resp; + qtest_qmp_send(qtest, + "{'execute': 'device_del', 'arguments': { 'id': %s } }", id); +} + +static void device_del_finish(QTestState *qtest) +{ + QDict *resp = qtest_qmp_receive(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; @@ -77,8 +86,25 @@ static void test_pci_unplug_request(void) qtest_quit(qtest); } +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"); + wait_device_deleted_event(qtest, "dev0"); + device_del_finish(qtest); + + qtest_quit(qtest); +} + int main(int argc, char **argv) { + const char *arch = qtest_get_arch(); + g_test_init(&argc, &argv, NULL); /* @@ -89,5 +115,10 @@ int main(int argc, char **argv) qtest_add_func("/device-plug/pci-unplug-request", test_pci_unplug_request); + if (!strcmp(arch, "s390x")) { + qtest_add_func("/device-plug/ccw-unplug", + test_ccw_unplug); + } + return g_test_run(); } |