qemuxml2argvtest: Parse 'arch' from XML early

If we want to provide correct (fake) caps already for the XML parser we
need to be able to parse the arch early so that we can properly
initialize the caps cache prior to calling the XML parser.

This patch adds code which parses the arch and updates the caps cache
prior to the parse step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-09 15:18:41 +02:00
parent 75d18dbd03
commit 86c1fcf7cd

View File

@ -353,13 +353,13 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
static int
testUpdateQEMUCaps(const struct testQemuInfo *info,
virDomainObjPtr vm,
virArch arch,
virCapsPtr caps)
{
if (!caps)
return -1;
virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
virQEMUCapsSetArch(info->qemuCaps, arch);
virQEMUCapsInitQMPBasicArch(info->qemuCaps);
@ -648,6 +648,8 @@ testCompareXMLToArgv(const void *data)
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr root;
g_autofree char *archstr = NULL;
virArch arch = VIR_ARCH_NONE;
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
qemuTestSetHostArch(&driver, info->arch);
@ -686,6 +688,17 @@ testCompareXMLToArgv(const void *data)
ctxt->node = root;
if ((archstr = virXPathString("string(./os/type[1]/@arch)", ctxt))) {
if ((arch = virArchFromString(archstr)) == VIR_ARCH_NONE) {
arch = virArchFromHost();
}
}
if (!(info->flags & FLAG_REAL_CAPS)) {
if (testUpdateQEMUCaps(info, arch, driver.caps) < 0)
goto cleanup;
}
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
goto cleanup;
@ -739,7 +752,7 @@ testCompareXMLToArgv(const void *data)
goto cleanup;
if (!(info->flags & FLAG_REAL_CAPS)) {
if (testUpdateQEMUCaps(info, vm, driver.caps) < 0)
if (testUpdateQEMUCaps(info, vm->def->os.arch, driver.caps) < 0)
goto cleanup;
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
goto cleanup;