Create capabilities cache using neq qemuTestMakeCapsCache() before parsing XML files Signed-off-by: Pavel Fedin <p.fedin@xxxxxxxxxxx> --- tests/qemuagenttest.c | 9 ++++++++- tests/qemuargv2xmltest.c | 5 +++++ tests/qemuhotplugtest.c | 23 +++++++++++++++-------- tests/qemuxml2argvtest.c | 5 +++++ tests/qemuxml2xmltest.c | 6 ++++++ tests/qemuxmlnstest.c | 5 +++++ 6 files changed, 44 insertions(+), 9 deletions(-) mode change 100644 => 100755 tests/qemuagenttest.c mode change 100644 => 100755 tests/qemuhotplugtest.c mode change 100644 => 100755 tests/qemuxml2xmltest.c diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c old mode 100644 new mode 100755 index 52cc834..729b82b --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -31,6 +31,8 @@ #define VIR_FROM_THIS VIR_FROM_NONE +static virQEMUDriver driver; + static int testQemuAgentFSFreeze(const void *data) { @@ -181,6 +183,10 @@ testQemuAgentGetFSInfo(const void *data) abs_srcdir) < 0) goto cleanup; + driver.qemuCapsCache = qemuTestMakeCapsCache("", NULL); + if (!driver.qemuCapsCache) + goto cleanup; + if (!(def = virDomainDefParseFile(domain_filename, caps, xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -293,6 +299,7 @@ testQemuAgentGetFSInfo(const void *data) virDomainFSInfoFree(info[i]); VIR_FREE(info); VIR_FREE(domain_filename); + virQEMUCapsCacheFree(driver.qemuCapsCache); virObjectUnref(caps); virDomainDefFree(def); qemuMonitorTestFree(test); @@ -917,7 +924,7 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) + !(xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index ea85913..348f2dc 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -130,9 +130,14 @@ testCompareXMLToArgvHelper(const void *data) abs_srcdir, info->name) < 0) goto cleanup; + driver.qemuCapsCache = qemuTestMakeCapsCache(info->name, NULL); + if (!driver.qemuCapsCache) + goto cleanup; + result = testCompareXMLToArgvFiles(xml, args, info->flags); cleanup: + virQEMUCapsCacheFree(driver.qemuCapsCache); VIR_FREE(xml); VIR_FREE(args); return result; diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c old mode 100644 new mode 100755 index 368a5e7..0f9932d --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -57,7 +57,7 @@ static int qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virDomainObjPtr *vm, const char *domxml, - bool event) + bool event, const char *testname) { int ret = -1; qemuDomainObjPrivatePtr priv = NULL; @@ -65,12 +65,6 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, if (!(*vm = virDomainObjNew(xmlopt))) goto cleanup; - if (!((*vm)->def = virDomainDefParseString(domxml, - driver.caps, - driver.xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE))) - goto cleanup; - priv = (*vm)->privateData; if (!(priv->qemuCaps = virQEMUCapsNew())) @@ -85,6 +79,16 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); + driver.qemuCapsCache = qemuTestMakeCapsCache(testname, priv->qemuCaps); + if (!driver.qemuCapsCache) + goto cleanup; + + if (!((*vm)->def = virDomainDefParseString(domxml, + driver.caps, + driver.xmlopt, + VIR_DOMAIN_DEF_PARSE_INACTIVE))) + goto cleanup; + if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0) goto cleanup; @@ -243,7 +247,8 @@ testQemuHotplug(const void *data) vm = test->vm; } else { if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml, - test->deviceDeletedEvent) < 0) + test->deviceDeletedEvent, + test->domain_filename) < 0) goto cleanup; } @@ -318,10 +323,12 @@ testQemuHotplug(const void *data) } else { virObjectUnref(vm); test->vm = NULL; + virQEMUCapsCacheFree(driver.qemuCapsCache); } virDomainDeviceDefFree(dev); virObjectUnref(caps); qemuMonitorTestFree(test_mon); + return ((ret < 0 && fail) || (!ret && !fail)) ? 0 : -1; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c2482e6..428204d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -423,11 +423,16 @@ testCompareXMLToArgvHelper(const void *data) if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_ENABLE_FIPS)) flags |= FLAG_FIPS; + driver.qemuCapsCache = qemuTestMakeCapsCache(info->name, info->extraFlags); + if (!driver.qemuCapsCache) + goto cleanup; + result = testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom, info->migrateFd, flags); cleanup: + virQEMUCapsCacheFree(driver.qemuCapsCache); VIR_FREE(xml); VIR_FREE(args); return result; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c old mode 100644 new mode 100755 index 5c1c2e9..aa8218c --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -216,6 +216,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque) static void testInfoFree(struct testInfo *info) { + virQEMUCapsCacheFree(driver.qemuCapsCache); + VIR_FREE(info->inName); VIR_FREE(info->inFile); @@ -240,6 +242,10 @@ testInfoSet(struct testInfo *info, if (virtTestLoadFile(info->inName, &info->inFile) < 0) goto error; + driver.qemuCapsCache = qemuTestMakeCapsCache(name, NULL); + if (!driver.qemuCapsCache) + goto error; + if (when & WHEN_INACTIVE) { if (different) { if (virAsprintf(&info->outInactiveName, diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 8eaab8a..8265d17 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -175,11 +175,16 @@ testCompareXMLToArgvHelper(const void *data) abs_srcdir, info->name) < 0) goto cleanup; + driver.qemuCapsCache = qemuTestMakeCapsCache(info->name, info->extraFlags); + if (!driver.qemuCapsCache) + goto cleanup; + result = testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom, info->migrateFd, info->json, info->expectError); cleanup: + virQEMUCapsCacheFree(driver.qemuCapsCache); VIR_FREE(xml); VIR_FREE(args); return result; -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list