On Tue, Sep 15, 2015 at 10:05:19AM +0200, Ján Tomko wrote:
From: Pavel Fedin <p.fedin@xxxxxxxxxxx> Two utility functions are introduced for proper initialization and cleanup of the driver. Signed-off-by: Pavel Fedin <p.fedin@xxxxxxxxxxx> Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- tests/domainsnapshotxml2xmltest.c | 10 +++------- tests/qemuagenttest.c | 11 ++++++----- tests/qemuargv2xmltest.c | 12 ++---------- tests/qemuhotplugtest.c | 9 ++------- tests/qemuxml2argvtest.c | 11 ++--------- tests/qemuxml2xmltest.c | 8 +++----- tests/qemuxmlnstest.c | 11 +++-------- tests/testutilsqemu.c | 30 ++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 2 ++ 9 files changed, 53 insertions(+), 51 deletions(-) diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index 3955a19..b66af3e 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -152,13 +152,10 @@ 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;
Why is this needed?
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5a20ebc..3552309 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -302,11 +302,10 @@ 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;
same here
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index a2f4299..84dfa75 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -526,4 +526,34 @@ qemuTestParseCapabilities(const char *capsFile) xmlXPathFreeContext(ctxt); return NULL; } + +int qemuTestDriverInit(virQEMUDriver *driver) +{ + driver->config = virQEMUDriverConfigNew(false); + if (!driver->config) + return -ENOMEM; + + driver->caps = testQemuCapsInit(); + if (!driver->caps) + goto error; + + driver->xmlopt = virQEMUDriverCreateXMLConf(driver); + if (!driver->xmlopt) + goto error; + + return 0; + + error: + virObjectUnref(driver->caps); + virObjectUnref(driver->config); + virObjectUnref(driver->xmlopt);
qemuTestDriverFree would be nicer
+ return -ENOMEM;
also -1 would do here.
+} + +void qemuTestDriverFree(virQEMUDriver *driver) +{ + virObjectUnref(driver->xmlopt); + virObjectUnref(driver->caps); + virObjectUnref(driver->config); +} #endif
ACK with allowDiskFormatProbing removed and the two mentioned nits fixed, otherwise please explain the format probing if you want that it too.
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list