[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] [PATCH] Fix parameter validation of virsh schedinfo



Hi

User cannot judge whether virsh schedinfo successes or fails,
because it does not become error when character string is set to an option.

--------------------------------------------------
# virsh schedinfo 0 --weight aaa
Scheduler      : credit
weight         : 256
cap            : 0
--------------------------------------------------

This patch fixes to become error when character string is set.

Signed-off-by: Masayuki Sunou <fj1826dm aa jp fujitsu com>

Thanks,
Masayuki Sunou.


--------------------------------------------------------------------------------
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.104
diff -u -p -r1.104 virsh.c
--- src/virsh.c	30 Sep 2007 13:22:16 -0000	1.104
+++ src/virsh.c	5 Nov 2007 06:26:52 -0000
@@ -1149,11 +1149,25 @@ cmdSchedinfo(vshControl * ctl, vshCmd * 
         return FALSE;
 
     /* Currently supports Xen Credit only */
-    weight = vshCommandOptInt(cmd, "weight", &weightfound);
-    if (weightfound) nr_inputparams++;
-            
-    cap    = vshCommandOptInt(cmd, "cap", &capfound);
-    if (capfound) nr_inputparams++;
+    if(vshCommandOptBool(cmd, "weight")) {
+        weight = vshCommandOptInt(cmd, "weight", &weightfound);
+        if (!weightfound) {
+            vshError(ctl, FALSE, _("Invalid value of weight"));
+            goto cleanup;
+        } else {
+            nr_inputparams++;
+        }
+    }
+
+    if(vshCommandOptBool(cmd, "cap")) {
+        cap = vshCommandOptInt(cmd, "cap", &capfound);
+        if (!capfound) {
+            vshError(ctl, FALSE, _("Invalid value of cap"));
+            goto cleanup;
+        } else {
+            nr_inputparams++;
+        }
+    }
 
     params = vshMalloc(ctl, sizeof (virSchedParameter) * nr_inputparams);
     if (params == NULL) {
--------------------------------------------------------------------------------


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]