Use the new API in order to correctly add capability sets to the cache before parsing XML files Signed-off-by: Pavel Fedin <p.fedin@xxxxxxxxxxx> --- tests/domainsnapshotxml2xmltest.c | 15 ++++++++------- tests/qemuagenttest.c | 18 +++++++++++++----- tests/qemuargv2xmltest.c | 19 +++++++++---------- tests/qemuhotplugtest.c | 32 +++++++++++++++++--------------- tests/qemuxml2argvtest.c | 17 ++++++++--------- tests/qemuxml2xmltest.c | 16 +++++++++++----- tests/qemuxmlnstest.c | 17 +++++++++-------- 7 files changed, 75 insertions(+), 59 deletions(-) mode change 100644 => 100755 tests/qemuagenttest.c mode change 100644 => 100755 tests/qemuargv2xmltest.c mode change 100644 => 100755 tests/qemuhotplugtest.c mode change 100644 => 100755 tests/qemuxml2argvtest.c mode change 100644 => 100755 tests/qemuxml2xmltest.c mode change 100644 => 100755 tests/qemuxmlnstest.c diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index 3955a19..9f4486d 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -152,13 +152,15 @@ mymain(void) { int ret = 0; - if ((driver.caps = testQemuCapsInit()) == NULL) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) { - virObjectUnref(driver.caps); - return EXIT_FAILURE; - } + driver.config->allowDiskFormatProbing = true; + + qemuTestCapsName = "empty"; + ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, "empty", NULL); + if (ret < 0) + goto cleanup; if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0) goto cleanup; @@ -227,8 +229,7 @@ mymain(void) if (testSnapshotXMLVariableLineRegex) regfree(testSnapshotXMLVariableLineRegex); VIR_FREE(testSnapshotXMLVariableLineRegex); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c old mode 100644 new mode 100755 index 52cc834..bc2fabc --- 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) { @@ -909,7 +911,6 @@ static int mymain(void) { int ret = 0; - virDomainXMLOptionPtr xmlopt; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); @@ -917,13 +918,19 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) + qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; + /* We use a single empty capability set for all tests here */ + qemuTestCapsName = "empty"; + ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, "empty", NULL); + if (ret < 0) + goto cleanup; + virEventRegisterDefaultImpl(); -#define DO_TEST(name) \ - if (virtTestRun(# name, testQemuAgent ## name, xmlopt) < 0) \ +#define DO_TEST(name) \ + if (virtTestRun(# name, testQemuAgent ## name, driver.xmlopt) < 0) \ ret = -1 DO_TEST(FSFreeze); @@ -938,7 +945,8 @@ mymain(void) DO_TEST(Timeout); /* Timeout should always be called last */ - virObjectUnref(xmlopt); +cleanup: + qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c old mode 100644 new mode 100755 index ea85913..bc20431 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -145,15 +145,15 @@ mymain(void) { int ret = 0; - driver.config = virQEMUDriverConfigNew(false); - if (driver.config == NULL) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; - if ((driver.caps = testQemuCapsInit()) == NULL) - return EXIT_FAILURE; - - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) - return EXIT_FAILURE; + /* We use a single empty capability set for all tests here */ + qemuTestCapsName = "empty"; + ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, "empty", + NULL); + if (ret < 0) + goto cleanup; # define DO_TEST_FULL(name, flags) \ do { \ @@ -298,9 +298,8 @@ mymain(void) DO_TEST("machine-deakeywrap-off-argv"); DO_TEST("machine-keywrap-none-argv"); - virObjectUnref(driver.config); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); +cleanup: + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c old mode 100644 new mode 100755 index 368a5e7..109d820 --- 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,18 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); + qemuTestCapsName = testname; + ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, testname, + priv->qemuCaps); + if (ret < 0) + 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 +249,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; } @@ -338,14 +345,11 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(driver.caps = testQemuCapsInit()) || - !(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) + qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; virEventRegisterDefaultImpl(); - if (!(driver.config = virQEMUDriverConfigNew(false))) - return EXIT_FAILURE; VIR_FREE(driver.config->spiceListen); VIR_FREE(driver.config->vncListen); /* some dummy values from 'config file' */ @@ -486,9 +490,7 @@ mymain(void) "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, "human-monitor-command", HMP("")); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); - virObjectUnref(driver.config); + qemuTestDriverFree(&driver); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c old mode 100644 new mode 100755 index d4432df..1fc767e --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -423,6 +423,12 @@ testCompareXMLToArgvHelper(const void *data) if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_ENABLE_FIPS)) flags |= FLAG_FIPS; + qemuTestCapsName = info->name; + result = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name, + info->extraFlags); + if (result < 0) + goto cleanup; + result = testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom, info->migrateFd, flags); @@ -483,8 +489,7 @@ mymain(void) return EXIT_FAILURE; } - driver.config = virQEMUDriverConfigNew(false); - if (driver.config == NULL) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; driver.privileged = true; @@ -499,10 +504,6 @@ mymain(void) if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0) return EXIT_FAILURE; - if ((driver.caps = testQemuCapsInit()) == NULL) - return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) - return EXIT_FAILURE; VIR_FREE(driver.config->stateDir); if (VIR_STRDUP_QUIET(driver.config->stateDir, "/nowhere") < 0) return EXIT_FAILURE; @@ -1761,9 +1762,7 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); - virObjectUnref(driver.config); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c old mode 100644 new mode 100755 index 5a20ebc..176e97a --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -302,11 +302,17 @@ mymain(void) int ret = 0; struct testInfo info; - if ((driver.caps = testQemuCapsInit()) == NULL) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) - return EXIT_FAILURE; + driver.config->allowDiskFormatProbing = true; + + /* We use a single empty capability set for all tests here */ + qemuTestCapsName = "empty"; + ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, "empty", + NULL); + if (ret < 0) + goto cleanup; # define DO_TEST_FULL(name, is_different, when) \ do { \ @@ -631,8 +637,8 @@ mymain(void) DO_TEST("memory-hotplug-dimm"); DO_TEST("net-udp"); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); +cleanup: + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c old mode 100644 new mode 100755 index a68e762..65bf1d3 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -179,6 +179,12 @@ testCompareXMLToArgvHelper(const void *data) abs_srcdir, info->name) < 0) goto cleanup; + qemuTestCapsName = info->name; + result = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name, + info->extraFlags); + if (result < 0) + goto cleanup; + result = testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom, info->migrateFd, info->json, info->expectError); @@ -201,15 +207,12 @@ mymain(void) if (!abs_top_srcdir) abs_top_srcdir = abs_srcdir "/.."; - if (!(driver.config = virQEMUDriverConfigNew(false))) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; + VIR_FREE(driver.config->libDir); if (VIR_STRDUP_QUIET(driver.config->libDir, "/tmp") < 0) return EXIT_FAILURE; - if ((driver.caps = testQemuCapsInit()) == NULL) - return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) - return EXIT_FAILURE; # define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...) \ do { \ @@ -251,9 +254,7 @@ mymain(void) DO_TEST("qemu-ns-commandline-ns0", false, NONE); DO_TEST("qemu-ns-commandline-ns1", false, NONE); - virObjectUnref(driver.config); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list