]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxml2argvtest: Update qemuCaps after parsing domain XML
authorJiri Denemark <jdenemar@redhat.com>
Wed, 3 Aug 2016 10:21:19 +0000 (12:21 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 22 Sep 2016 13:40:08 +0000 (15:40 +0200)
Some parts of qemuCaps depend on guest architecture, machine type, and
possibly other things that we know only once the domain XML has been
parsed. Let's move all these updates into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
tests/qemuxml2argvtest.c

index 6c7bc4b1eb53988f3c456710954aba2cb7892dd8..0790843d82aafb1bf39bf19c6983fd043ce12ec2 100644 (file)
@@ -272,6 +272,7 @@ struct testInfo {
     int migrateFd;
     unsigned int flags;
     unsigned int parseFlags;
+    bool skipLegacyCPUs;
 };
 
 
@@ -305,17 +306,15 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
 
 
 static int
-testPrepareExtraFlags(struct testInfo *info,
-                      bool skipLegacyCPUs,
-                      int gic)
+testInitQEMUCaps(struct testInfo *info,
+                 int gic)
 {
     int ret = -1;
 
     if (!(info->qemuCaps = virQEMUCapsNew()))
         goto cleanup;
 
-    if (testAddCPUModels(info->qemuCaps, skipLegacyCPUs) < 0)
-        goto cleanup;
+    virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_NO_ACPI);
 
     if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
         goto cleanup;
@@ -327,6 +326,27 @@ testPrepareExtraFlags(struct testInfo *info,
 }
 
 
+static int
+testUpdateQEMUCaps(const struct testInfo *info,
+                   virDomainObjPtr vm)
+{
+    int ret = -1;
+
+    if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
+        goto cleanup;
+
+    virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
+
+    if (ARCH_IS_X86(vm->def->os.arch))
+        virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
+
+    ret = 0;
+
+ cleanup:
+    return ret;
+}
+
+
 static int
 testCompareXMLToArgv(const void *data)
 {
@@ -400,10 +420,6 @@ testCompareXMLToArgv(const void *data)
     if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
         goto cleanup;
 
-    virQEMUCapsSetList(info->qemuCaps,
-                       QEMU_CAPS_NO_ACPI,
-                       QEMU_CAPS_LAST);
-
     if (STREQ(vm->def->os.machine, "pc") &&
         STREQ(vm->def->emulator, "/usr/bin/qemu-system-x86_64")) {
         VIR_FREE(vm->def->os.machine);
@@ -411,17 +427,13 @@ testCompareXMLToArgv(const void *data)
             goto cleanup;
     }
 
-    virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
+    if (testUpdateQEMUCaps(info, vm) < 0)
+        goto cleanup;
 
     log = virTestLogContentAndReset();
     VIR_FREE(log);
     virResetLastError();
 
-    if (vm->def->os.arch == VIR_ARCH_X86_64 ||
-        vm->def->os.arch == VIR_ARCH_I686) {
-        virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
-    }
-
     for (i = 0; i < vm->def->nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
 
@@ -536,9 +548,11 @@ mymain(void)
                       parseFlags, gic, ...)                              \
     do {                                                                 \
         static struct testInfo info = {                                  \
-            name, NULL, migrateFrom, migrateFd, (flags), parseFlags      \
+            name, NULL, migrateFrom, migrateFd, (flags), parseFlags,     \
+            false                                                        \
         };                                                               \
-        if (testPrepareExtraFlags(&info, skipLegacyCPUs, gic) < 0)       \
+        info.skipLegacyCPUs = skipLegacyCPUs;                            \
+        if (testInitQEMUCaps(&info, gic) < 0)                            \
             return EXIT_FAILURE;                                         \
         virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST);  \
         if (virTestRun("QEMU XML-2-ARGV " name,                          \