]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cmdDomIfAddr: Move domain lookup down a few lines
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 Jan 2020 15:50:02 +0000 (16:50 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 7 Jan 2020 15:12:55 +0000 (16:12 +0100)
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>
tools/virsh-domain-monitor.c

index 97301f71f9e0b9c13255ce3b7d3869a233510990..e357635757002c54859be993c7211d69762cc505 100644 (file)
@@ -2377,20 +2377,20 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
     const char *sourcestr = NULL;
     int source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
-        return false;
-
     if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0)
-        goto cleanup;
+        return false;
     if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
-        goto cleanup;
+        return false;
 
     if (sourcestr &&
         (source = virshDomainInterfaceAddressesSourceTypeFromString(sourcestr)) < 0) {
         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) {
         vshError(ctl, _("Failed to query for interfaces addresses"));
         goto cleanup;