Hi
When the option which should set a number is set a character
which is not a number, the value is changed into 0 in libvirt.
It causes the movement not expected.
ex)
# virsh vcpupin dom_name A 0,1
=> VCPU0 is pinned without the command becoming the error.
This patch fixes it by checking the value in vshCommandOptInt().
Signed-off-by: Masayuki Sunou <fj1826dm(a)aa.jp.fujitsu.com>
Thanks,
Masayuki Sunou.
----------------------------------------------------------------------
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.95
diff -u -p -r1.95 virsh.c
--- src/virsh.c 14 Aug 2007 07:07:57 -0000 1.95
+++ src/virsh.c 16 Aug 2007 07:13:46 -0000
@@ -3699,12 +3699,16 @@ static int
vshCommandOptInt(vshCmd * cmd, const char *name, int *found)
{
vshCmdOpt *arg = vshCommandOpt(cmd, name);
- int res = 0;
+ int res = 0, num_found = TRUE;
+ char *end_p=NULL;
if (arg)
- res = atoi(arg->data);
+ res = strtol(arg->data, &end_p, 10);
+ if (arg->data == end_p) {
+ num_found = FALSE;
+ }
if (found)
- *found = arg ? TRUE : FALSE;
+ *found = (arg && num_found) ? TRUE : FALSE;
return res;
}
----------------------------------------------------------------------