]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: cpu: Fix parsing of vendor_id
authorKen ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
Mon, 17 Dec 2012 08:05:59 +0000 (17:05 +0900)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 17 Dec 2012 15:55:54 +0000 (16:55 +0100)
This patch fixes a problem that vendor_id attribute can not be defined
when fallback attribute is not defined.

If I define domain xml like below:
<domain>
  <cpu>
    <model vendor_id='aaaabbbbcccc'>core2duo</model>
  </cpu>
</domain>

In dumpxml, vendor_id is not reflected:
<domain>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>core2duo</model>
  </cpu>
</domain>

The expected output is:
<domain>
  <cpu mode='custom' match='exact'>
    <model fallback='allow' vendor_id='aaaabbbbcccc'>core2duo</model>
  </cpu>
</domain>

If the fallback attribute and vendor_id attribute is defined at the same
time, it's reflected as expected.

Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
src/conf/cpu_conf.c

index 8cb54a3fd53860712594f22c3d755b4444a0f5cd..6157ed74afde130da61c02a664574dc47086633e 100644 (file)
@@ -300,32 +300,32 @@ virCPUDefParseXML(const xmlNodePtr node,
                     goto error;
                 }
             }
+        }
 
-            if (virXPathBoolean("boolean(./model[1]/@vendor_id)", ctxt)) {
-                char *vendor_id;
-
-                vendor_id = virXPathString("string(./model[1]/@vendor_id)",
-                                           ctxt);
-                if (!vendor_id ||
-                    strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) {
-                    virReportError(VIR_ERR_XML_ERROR,
-                                   _("vendor_id must be exactly"
-                                     " %d characters long"),
-                                   VIR_CPU_VENDOR_ID_LENGTH);
+        if (virXPathBoolean("boolean(./model[1]/@vendor_id)", ctxt)) {
+            char *vendor_id;
+
+            vendor_id = virXPathString("string(./model[1]/@vendor_id)",
+                                       ctxt);
+            if (!vendor_id ||
+                strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("vendor_id must be exactly"
+                                 " %d characters long"),
+                               VIR_CPU_VENDOR_ID_LENGTH);
+                VIR_FREE(vendor_id);
+                goto error;
+            }
+            /* ensure that the string can be passed to qemu*/
+            for (i = 0; i < strlen(vendor_id); i++) {
+                if (vendor_id[i]==',') {
+                    virReportError(VIR_ERR_XML_ERROR, "%s",
+                                   _("vendor id is invalid"));
                     VIR_FREE(vendor_id);
                     goto error;
                 }
-                /* ensure that the string can be passed to qemu*/
-                for (i = 0; i < strlen(vendor_id); i++) {
-                    if (vendor_id[i]==',') {
-                        virReportError(VIR_ERR_XML_ERROR, "%s",
-                                       _("vendor id is invalid"));
-                        VIR_FREE(vendor_id);
-                        goto error;
-                    }
-                }
-                def->vendor_id = vendor_id;
             }
+            def->vendor_id = vendor_id;
         }
     }