]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Sync caps data even when SKIP_OSTYPE_CHECKS
authorCole Robinson <crobinso@redhat.com>
Tue, 24 Jul 2018 20:54:51 +0000 (16:54 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 26 Jul 2018 14:13:00 +0000 (10:13 -0400)
We should still make an effort to fill in data, just not raise
an error if say an ostype/virttype combo disappeared from caps.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2argvdata/missing-machine.xml
tests/qemuxml2argvtest.c

index 9f6fd8505841aacb263a220c4e2b9adb687aa728..bad56aa1465006582f3ab3e9cdaed6a7d183724d 100644 (file)
@@ -19178,18 +19178,19 @@ virDomainDefParseCaps(virDomainDefPtr def,
         goto cleanup;
     }
 
-    if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
-        if (!(capsdata = virCapabilitiesDomainDataLookup(caps,
-                def->os.type, def->os.arch, def->virtType,
-                NULL, NULL)))
+    if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
+                                                     def->os.arch,
+                                                     def->virtType,
+                                                     NULL, NULL))) {
+        if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS))
             goto cleanup;
-
+        virResetLastError();
+    } else {
         if (!def->os.arch)
             def->os.arch = capsdata->arch;
         if ((!def->os.machine &&
-             VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)) {
+             VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0))
             goto cleanup;
-        }
     }
 
     ret = 0;
index 4ce7b377a526b371cd502e7f83af3b54241ba726..2900baec908ddcdd555f379a7535eb38002c37e8 100644 (file)
@@ -6,7 +6,7 @@
   <currentMemory unit='KiB'>219100</currentMemory>
   <vcpu placement='static' cpuset='1'>1</vcpu>
   <os>
-    <type arch='i686'>hvm</type>
+    <type arch='alpha'>hvm</type>
     <boot dev='hd'/>
   </os>
   <clock offset='utc'/>
index 1a936faef1fa1dcac8449cda315d210dd526ef3a..03b6d92912e3c726e0b233cdc61d97e68cebb8f9 100644 (file)
@@ -2773,6 +2773,9 @@ mymain(void)
             QEMU_CAPS_OBJECT_GPEX,
             QEMU_CAPS_NEC_USB_XHCI);
 
+    /* VM XML has invalid arch/ostype/virttype combo, but the SKIP flag
+     * will avoid the error. Still, we expect qemu driver to complain about
+     * missing machine error, and not crash */
     DO_TEST_PARSE_FLAGS_ERROR("missing-machine",
                               VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS,
                               NONE);