]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: report errors for empty strings
authorJán Tomko <jtomko@redhat.com>
Thu, 3 Dec 2015 12:42:35 +0000 (13:42 +0100)
committerCole Robinson <crobinso@redhat.com>
Wed, 23 Dec 2015 23:31:03 +0000 (18:31 -0500)
Several callers were using vshCommandOptString without setting an error.
Use vshCommandOptStringReq which sets the error.

https://bugzilla.redhat.com/show_bug.cgi?id=1281707
(cherry picked from commit 45138725cf2a14575aa5204fe55efd6668b9b03a)

tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh-network.c

index 1d4dc25cf6889f9b7e941b3e92d2c5908418d865..fc3046ae9698757a2b14da2ddeffb9f83cc61321 100644 (file)
@@ -2237,9 +2237,9 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (vshCommandOptString(ctl, cmd, "interface", &ifacestr) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0)
         goto cleanup;
-    if (vshCommandOptString(ctl, cmd, "source", &sourcestr) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
         goto cleanup;
 
     if (sourcestr) {
index 43a1fbee6a1f7b3d5c2336e55e9930169771b084..b4c11918c6e28b23e78a6f5ef40d95481f090b73 100644 (file)
@@ -2275,11 +2275,11 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
         return false;
-    if (vshCommandOptString(ctl, cmd, "dest", &dest) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "dest", &dest) < 0)
         return false;
-    if (vshCommandOptString(ctl, cmd, "xml", &xml) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0)
         return false;
-    if (vshCommandOptString(ctl, cmd, "format", &format) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0)
         return false;
     /* XXX: Parse bandwidth as scaled input, rather than forcing
      * MiB/s, and either reject negative input or treat it as 0 rather
@@ -9146,7 +9146,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
     data.count = 0;
     if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
         return false;
-    if (vshCommandOptString(ctl, cmd, "event", &event) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "event", &event) < 0)
         return false;
 
     if (vshCommandOptBool(cmd, "domain"))
@@ -12368,7 +12368,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
     if (eventName) {
         for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
index 66123c4e745915ca60060f87258d701a5f71fca4..da5cf594b52086cfc1fb6e0605baf061fd200e5f 100644 (file)
@@ -1256,7 +1256,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
     if (!eventName) {
         vshError(ctl, "%s", _("either --list or event type is required"));
@@ -1366,7 +1366,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     virNetworkPtr network = NULL;
 
-    if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0)
+    if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
         return false;
 
     if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))