--- tests/qemuhotplugtest.c | 29 +++++++++++++++++++++++------ tests/qemumonitortestutils.c | 2 ++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 6fa331e..4901178 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -21,6 +21,7 @@ #include "qemu/qemu_conf.h" #include "qemu/qemu_hotplug.h" +#include "qemu/qemu_hotplugpriv.h" #include "qemumonitortestutils.h" #include "testutils.h" #include "testutilsqemu.h" @@ -47,12 +48,14 @@ struct qemuHotplugTestData { int action; bool keep; virDomainObjPtr vm; + bool deviceDeletedEvent; }; static int qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virDomainObjPtr *vm, - const char *domxml) + const char *domxml, + bool event) { int ret = -1; qemuDomainObjPrivatePtr priv = NULL; @@ -74,6 +77,9 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, /* for attach & detach qemu must support -device */ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DRIVE); + if (event) + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); if (qemuDomainAssignPCIAddresses((*vm)->def, priv->qemuCaps, *vm) < 0) goto cleanup; @@ -227,7 +233,8 @@ testQemuHotplug(const void *data) if (test->vm) { vm = test->vm; } else { - if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml) < 0) + if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml, + test->deviceDeletedEvent) < 0) goto cleanup; } @@ -345,7 +352,10 @@ mymain(void) if (!(driver.securityManager = virSecurityManagerNewStack(mgr))) return EXIT_FAILURE; -#define DO_TEST(file, ACTION, dev, fial, kep, ...) \ + /* wait only 100ms for DEVICE_DELETED event */ + qemuDomainRemoveDeviceWaitTime = 100; + +#define DO_TEST(file, ACTION, dev, event, fial, kep, ...) \ do { \ const char *my_mon[] = { __VA_ARGS__, NULL}; \ const char *name = file " " #ACTION " " dev; \ @@ -355,18 +365,25 @@ mymain(void) data.fail = fial; \ data.mon = my_mon; \ data.keep = kep; \ + data.deviceDeletedEvent = event; \ if (virtTestRun(name, 1, testQemuHotplug, &data) < 0) \ ret = -1; \ } while (0) #define DO_TEST_ATTACH(file, dev, fial, kep, ...) \ - DO_TEST(file, ATTACH, dev, fial, kep, __VA_ARGS__) + DO_TEST(file, ATTACH, dev, false, fial, kep, __VA_ARGS__) #define DO_TEST_DETACH(file, dev, fial, kep, ...) \ - DO_TEST(file, DETACH, dev, fial, kep, __VA_ARGS__) + DO_TEST(file, DETACH, dev, false, fial, kep, __VA_ARGS__) + +#define DO_TEST_ATTACH_EVENT(file, dev, fial, kep, ...) \ + DO_TEST(file, ATTACH, dev, true, fial, kep, __VA_ARGS__) + +#define DO_TEST_DETACH_EVENT(file, dev, fial, kep, ...) \ + DO_TEST(file, DETACH, dev, true, fial, kep, __VA_ARGS__) #define DO_TEST_UPDATE(file, dev, fial, kep, ...) \ - DO_TEST(file, UPDATE, dev, fial, kep, __VA_ARGS__) + DO_TEST(file, UPDATE, dev, false, fial, kep, __VA_ARGS__) #define QMP_OK "{\"return\": {}}" diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 1857cfd..2322c08 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -27,6 +27,7 @@ #include "qemumonitortestutils.h" #include "virthread.h" +#include "qemu/qemu_processpriv.h" #include "qemu/qemu_monitor.h" #include "qemu/qemu_agent.h" #include "rpc/virnetsocket.h" @@ -725,6 +726,7 @@ qemuMonitorTestErrorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED, static qemuMonitorCallbacks qemuMonitorTestCallbacks = { .eofNotify = qemuMonitorTestEOFNotify, .errorNotify = qemuMonitorTestErrorNotify, + .domainDeviceDeleted = qemuProcessHandleDeviceDeleted, }; -- 1.8.3.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list