提交 68d6f66e 编写于 作者: J Jiri Denemark

qemuhotplugtest: Add support for DEVICE_DELETED event

上级 419489e6
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "qemu/qemu_conf.h" #include "qemu/qemu_conf.h"
#include "qemu/qemu_hotplug.h" #include "qemu/qemu_hotplug.h"
#include "qemu/qemu_hotplugpriv.h"
#include "qemumonitortestutils.h" #include "qemumonitortestutils.h"
#include "testutils.h" #include "testutils.h"
#include "testutilsqemu.h" #include "testutilsqemu.h"
...@@ -47,12 +48,14 @@ struct qemuHotplugTestData { ...@@ -47,12 +48,14 @@ struct qemuHotplugTestData {
int action; int action;
bool keep; bool keep;
virDomainObjPtr vm; virDomainObjPtr vm;
bool deviceDeletedEvent;
}; };
static int static int
qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr *vm, virDomainObjPtr *vm,
const char *domxml) const char *domxml,
bool event)
{ {
int ret = -1; int ret = -1;
qemuDomainObjPrivatePtr priv = NULL; qemuDomainObjPrivatePtr priv = NULL;
...@@ -76,6 +79,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, ...@@ -76,6 +79,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DRIVE); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DRIVE);
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE);
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_NET_NAME); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_NET_NAME);
if (event)
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
if (qemuDomainAssignPCIAddresses((*vm)->def, priv->qemuCaps, *vm) < 0) if (qemuDomainAssignPCIAddresses((*vm)->def, priv->qemuCaps, *vm) < 0)
goto cleanup; goto cleanup;
...@@ -232,7 +237,8 @@ testQemuHotplug(const void *data) ...@@ -232,7 +237,8 @@ testQemuHotplug(const void *data)
if (test->vm) { if (test->vm) {
vm = test->vm; vm = test->vm;
} else { } else {
if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml) < 0) if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml,
test->deviceDeletedEvent) < 0)
goto cleanup; goto cleanup;
} }
...@@ -350,7 +356,10 @@ mymain(void) ...@@ -350,7 +356,10 @@ mymain(void)
if (!(driver.securityManager = virSecurityManagerNewStack(mgr))) if (!(driver.securityManager = virSecurityManagerNewStack(mgr)))
return EXIT_FAILURE; 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 { \ do { \
const char *my_mon[] = { __VA_ARGS__, NULL}; \ const char *my_mon[] = { __VA_ARGS__, NULL}; \
const char *name = file " " #ACTION " " dev; \ const char *name = file " " #ACTION " " dev; \
...@@ -360,18 +369,25 @@ mymain(void) ...@@ -360,18 +369,25 @@ mymain(void)
data.fail = fial; \ data.fail = fial; \
data.mon = my_mon; \ data.mon = my_mon; \
data.keep = kep; \ data.keep = kep; \
data.deviceDeletedEvent = event; \
if (virtTestRun(name, 1, testQemuHotplug, &data) < 0) \ if (virtTestRun(name, 1, testQemuHotplug, &data) < 0) \
ret = -1; \ ret = -1; \
} while (0) } while (0)
#define DO_TEST_ATTACH(file, dev, fial, kep, ...) \ #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, ...) \ #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, ...) \ #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\": {}}" #define QMP_OK "{\"return\": {}}"
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "qemumonitortestutils.h" #include "qemumonitortestutils.h"
#include "virthread.h" #include "virthread.h"
#include "qemu/qemu_processpriv.h"
#include "qemu/qemu_monitor.h" #include "qemu/qemu_monitor.h"
#include "qemu/qemu_agent.h" #include "qemu/qemu_agent.h"
#include "rpc/virnetsocket.h" #include "rpc/virnetsocket.h"
...@@ -725,6 +726,7 @@ qemuMonitorTestErrorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED, ...@@ -725,6 +726,7 @@ qemuMonitorTestErrorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
static qemuMonitorCallbacks qemuMonitorTestCallbacks = { static qemuMonitorCallbacks qemuMonitorTestCallbacks = {
.eofNotify = qemuMonitorTestEOFNotify, .eofNotify = qemuMonitorTestEOFNotify,
.errorNotify = qemuMonitorTestErrorNotify, .errorNotify = qemuMonitorTestErrorNotify,
.domainDeviceDeleted = qemuProcessHandleDeviceDeleted,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册