]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Error out if iothread id is missing in iothreadpin
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Apr 2015 17:52:02 +0000 (19:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 14 Apr 2015 07:23:23 +0000 (09:23 +0200)
Defining a domain with the following config:

<domain ...>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin cpuset='1'/>

will result in the following config formatted back:
<domain type='kvm'>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin iothread='0' cpuset='1'/>

After restart the VM would vanish. Since our schema requires the
@iothread field to be present in <iothreadpin> make it required by the
code too.

src/conf/domain_conf.c

index b17295a35fc95d775f8fe0ccc764c7a98e7708d5..39eb050b32d3d44964f00f15e85b90a4fcbead7a 100644 (file)
@@ -13253,31 +13253,35 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 
     ctxt->node = node;
 
-    if ((tmp = virXPathString("string(./@iothread)", ctxt))) {
-        if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("invalid setting for iothread '%s'"), tmp);
-            goto error;
-        }
-        VIR_FREE(tmp);
+    if (!(tmp = virXPathString("string(./@iothread)", ctxt))) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("missing iothread id in iothreadpin"));
+        goto error;
+    }
 
-        if (iothreadid == 0) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("zero is an invalid iothread id value"));
-            goto error;
-        }
+    if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("invalid setting for iothread '%s'"), tmp);
+        goto error;
+    }
+    VIR_FREE(tmp);
 
-        /* IOThreads are numbered "iothread1...iothread<n>", where
-         * "n" is the iothreads value */
-        if (iothreadid > iothreads) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("iothread id must not exceed iothreads"));
-            goto error;
-        }
+    if (iothreadid == 0) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("zero is an invalid iothread id value"));
+        goto error;
+    }
 
-        def->id = iothreadid;
+    /* IOThreads are numbered "iothread1...iothread<n>", where
+     * "n" is the iothreads value */
+    if (iothreadid > iothreads) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("iothread id must not exceed iothreads"));
+        goto error;
     }
 
+    def->id = iothreadid;
+
     if (!(tmp = virXMLPropString(node, "cpuset"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("missing cpuset for iothreadpin"));