mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cmdDomIfAddr: Move domain lookup down a few lines
The 'domifaddr' command accepts several arguments. Let's validate them first and look up domain to work with only after to save some RPC cycles should validation fail. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
13fa7b587f
commit
44791eaf8b
@ -2377,20 +2377,20 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *sourcestr = NULL;
|
const char *sourcestr = NULL;
|
||||||
int source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
|
int source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (sourcestr &&
|
if (sourcestr &&
|
||||||
(source = virshDomainInterfaceAddressesSourceTypeFromString(sourcestr)) < 0) {
|
(source = virshDomainInterfaceAddressesSourceTypeFromString(sourcestr)) < 0) {
|
||||||
vshError(ctl, _("Unknown data source '%s'"), sourcestr);
|
vshError(ctl, _("Unknown data source '%s'"), sourcestr);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
|
if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
|
||||||
vshError(ctl, _("Failed to query for interfaces addresses"));
|
vshError(ctl, _("Failed to query for interfaces addresses"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user