The post parse callback is part of the real (non-test) processing flow. This commit adds it (for disks) to the qemublocktest flow as well. Specifically, this will be needed for tests that use luks encryption, so that the default encryption engine (which is added in an upcoming commit) will be overridden by qemu. Signed-off-by: Or Ozeri <oro@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_domain.h | 3 +++ tests/qemublocktest.c | 29 ++++++++++++----------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a755f8678e..288a40bca6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5259,7 +5259,7 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDef *disk, } -static int +int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk, unsigned int parseFlags) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 64f92988b7..0642e44fbc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -872,6 +872,9 @@ int qemuDomainSecretPrepare(virQEMUDriver *driver, int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk, virQEMUCaps *qemuCaps); +int qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk, + unsigned int parseFlags); + int qemuDomainPrepareChannel(virDomainChrDef *chr, const char *domainChannelTargetDir) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 3e61e923a9..0176fbd3f4 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -276,6 +276,9 @@ testQemuDiskXMLToProps(const void *opaque) VIR_DOMAIN_DEF_PARSE_STATUS))) return -1; + if (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0) + return -1; + if (!(vmdef = virDomainDefNew(data->driver->xmlopt))) return -1; @@ -470,32 +473,24 @@ testQemuImageCreateLoadDiskXML(const char *name, virDomainXMLOption *xmlopt) { - virDomainSnapshotDiskDef *diskdef = NULL; - g_autoptr(xmlDoc) doc = NULL; - g_autoptr(xmlXPathContext) ctxt = NULL; - xmlNodePtr node; + virDomainDiskDef *disk = NULL; g_autofree char *xmlpath = NULL; - virStorageSource *ret = NULL; + g_autofree char *xmlstr = NULL; xmlpath = g_strdup_printf("%s%s.xml", testQemuImageCreatePath, name); - if (!(doc = virXMLParseFileCtxt(xmlpath, &ctxt))) + if (virTestLoadFile(xmlpath, &xmlstr) < 0) return NULL; - if (!(node = virXPathNode("//disk", ctxt))) { - VIR_TEST_VERBOSE("failed to find <source> element\n"); + /* qemu stores node names in the status XML portion */ + if (!(disk = virDomainDiskDefParse(xmlstr, xmlopt, + VIR_DOMAIN_DEF_PARSE_STATUS))) return NULL; - } - diskdef = g_new0(virDomainSnapshotDiskDef, 1); - - if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef, - VIR_DOMAIN_DEF_PARSE_STATUS, - xmlopt) == 0) - ret = g_steal_pointer(&diskdef->src); + if (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0) + return NULL; - virDomainSnapshotDiskDefFree(diskdef); - return ret; + return disk->src; } -- 2.25.1