[libvirt] [PATCH] Add error message when the invalid XML file is defined.

Hiroyuki Kaguchi fj7025cf at aa.jp.fujitsu.com
Fri May 30 09:06:38 UTC 2008


Hi,

When cpuset that is the attribute of vcpu tag of the XML file is the invalid
string, "virsh define" succeeds.
(Ex. <vcpu cpuset='aaa'>4</vcpu>
     <vcpu cpuset=' '>4</vcpu>
     <vcpu cpuset=',,,'>4</vcpu> )
The patch changes policy that the definition is failed and shows error message.

Thanks,
Signed-off-by: Hiroyuki Kaguchi <fj7025cf at aa.jp.fujitsu.com>

Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.79
diff -u -p -r1.79 xm_internal.c
--- src/xm_internal.c	29 May 2008 19:20:23 -0000	1.79
+++ src/xm_internal.c	30 May 2008 05:27:35 -0000
@@ -2004,20 +2004,15 @@ virConfPtr xenXMParseXMLToConfig(virConn
         char *ranges;

         ranges = virConvertCpuSet(conn, cpus, 0);
-        if (ranges != NULL) {
-            VIR_FREE(cpus);
-            if (xenXMConfigSetString(conf, "cpus", ranges) < 0) {
-                VIR_FREE(ranges);
-                goto error;
-            }
+        VIR_FREE(cpus);
+        if (ranges == NULL) {
+            goto error;
+        }
+        if (xenXMConfigSetString(conf, "cpus", ranges) < 0) {
             VIR_FREE(ranges);
-        } else {
-            if (xenXMConfigSetString(conf, "cpus", cpus) < 0) {
-                VIR_FREE(cpus);
-                goto error;
-            }
-            VIR_FREE(cpus);
+            goto error;
         }
+        VIR_FREE(ranges);
     }

     obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);




More information about the libvir-list mailing list