mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
virsh: report errors for empty strings
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 45138725cf
)
This commit is contained in:
parent
7b977a87a7
commit
3e6e96f09a
@ -2237,9 +2237,9 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptString(ctl, cmd, "interface", &ifacestr) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (vshCommandOptString(ctl, cmd, "source", &sourcestr) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (sourcestr) {
|
if (sourcestr) {
|
||||||
|
@ -2275,11 +2275,11 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (vshCommandOptString(ctl, cmd, "dest", &dest) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "dest", &dest) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (vshCommandOptString(ctl, cmd, "xml", &xml) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (vshCommandOptString(ctl, cmd, "format", &format) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0)
|
||||||
return false;
|
return false;
|
||||||
/* XXX: Parse bandwidth as scaled input, rather than forcing
|
/* XXX: Parse bandwidth as scaled input, rather than forcing
|
||||||
* MiB/s, and either reject negative input or treat it as 0 rather
|
* 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;
|
data.count = 0;
|
||||||
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (vshCommandOptString(ctl, cmd, "event", &event) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "event", &event) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "domain"))
|
if (vshCommandOptBool(cmd, "domain"))
|
||||||
@ -12368,7 +12368,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (eventName) {
|
if (eventName) {
|
||||||
for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
|
for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
|
||||||
|
@ -1256,7 +1256,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vshCommandOptString(ctl, cmd, "event", &eventName) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (!eventName) {
|
if (!eventName) {
|
||||||
vshError(ctl, "%s", _("either --list or event type is required"));
|
vshError(ctl, "%s", _("either --list or event type is required"));
|
||||||
@ -1366,7 +1366,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
|
|||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
virNetworkPtr network = NULL;
|
virNetworkPtr network = NULL;
|
||||||
|
|
||||||
if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
|
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
|
||||||
|
Loading…
Reference in New Issue
Block a user