[RFC PATCH 18/43] qemuxml2argvtest: Parse 'arch' from XML early

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tests/qemuxml2argvtest.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index aa6ae9bb4b..eb1bec88f2 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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;
-- 
2.30.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux