qemu: add disk post parse to qemublocktest

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@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Or Ozeri 2021-10-24 04:51:26 -05:00 committed by Peter Krempa
parent 9ff311f105
commit 9696427ad6
3 changed files with 16 additions and 18 deletions

View File

@ -5218,7 +5218,7 @@ qemuDomainDeviceDiskDefPostParseRestoreSecAlias(virDomainDiskDef *disk,
}
static int
int
qemuDomainDeviceDiskDefPostParse(virDomainDiskDef *disk,
unsigned int parseFlags)
{

View File

@ -857,6 +857,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);

View File

@ -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 (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0)
return NULL;
if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef,
VIR_DOMAIN_DEF_PARSE_STATUS,
xmlopt) == 0)
ret = g_steal_pointer(&diskdef->src);
virDomainSnapshotDiskDefFree(diskdef);
return ret;
return disk->src;
}