]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: Improve handling of send-process-signal --pid.
authorAndrea Bolognani <abologna@redhat.com>
Fri, 15 May 2015 16:14:41 +0000 (18:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 May 2015 08:50:06 +0000 (10:50 +0200)
Use vshCommandOptLongLong() instead of retrieving the value as a
string and converting it to a number manually.

tools/virsh-domain.c

index 10d01b61cc339b6f9ae70f65e392ef49487eeedc..36f3e6c7699aac5cb61ed6b8ad2f0723181eff78 100644 (file)
@@ -8262,7 +8262,6 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
     bool ret = false;
-    const char *pidstr;
     const char *signame;
     long long pid_value;
     int signum;
@@ -8270,17 +8269,16 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (vshCommandOptStringReq(ctl, cmd, "pid", &pidstr) < 0)
+    if (vshCommandOptLongLong(cmd, "pid", &pid_value) < 0) {
+        vshError(ctl,
+                 _("Numeric value for <%s> option is malformed or out of range"),
+                 "pid");
         goto cleanup;
+    }
 
     if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0)
         goto cleanup;
 
-    if (virStrToLong_ll(pidstr, NULL, 10, &pid_value) < 0) {
-        vshError(ctl, _("malformed PID value: %s"), pidstr);
-        goto cleanup;
-    }
-
     if ((signum = getSignalNumber(ctl, signame)) < 0) {
         vshError(ctl, _("malformed signal name: %s"), signame);
         goto cleanup;