[PATCH 3/4] virsh: Deal with multiple matching devices in domif-getlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The command tries to match interface in domain definition by MAC
address or interface name. However, since it's possible to
configure two interfaces with the same MAC address, it may
happen that the XPath returns two or more nodes. We should check
for that.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virsh-domain-monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0ca53e438..4c50155e1 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -707,13 +707,16 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (ninterfaces != 1) {
+    if (ninterfaces < 1) {
         if (macstr[0])
             vshError(ctl, _("Interface (mac: %s) not found."), macstr);
         else
             vshError(ctl, _("Interface (dev: %s) not found."), iface);
 
         goto cleanup;
+    } else if (ninterfaces > 1) {
+        vshError(ctl, _("multiple matching interfaces found"));
+        goto cleanup;
     }
 
     ctxt->node = interfaces[0];
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux