[libvirt] [PATCH 1/2] virsh: Accept iface alias for domifstats too

Michal Privoznik mprivozn at redhat.com
Wed Jun 7 15:41:29 UTC 2017


https://bugzilla.redhat.com/show_bug.cgi?id=1459091

Not every interface has a name (for instance, vhostuser
interfaces might not have one). However, all interfaces have
aliases. We can accept those to uniquely identify interfaces.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_driver.c       | 6 ++++--
 tools/virsh-domain-monitor.c | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f0cdea659..0634d9e5a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10753,8 +10753,10 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 
     /* Check the path is one of the domain's network interfaces. */
     for (i = 0; i < vm->def->nnets; i++) {
-        if (STREQ_NULLABLE(vm->def->nets[i]->ifname, path)) {
-            net = vm->def->nets[i];
+        virDomainNetDefPtr tmp = vm->def->nets[i];
+        if (STREQ_NULLABLE(tmp->ifname, path) ||
+            STREQ(tmp->info.alias, path)) {
+            net = tmp;
             break;
         }
     }
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0ca53e438..313a6d2f0 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -614,7 +614,8 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
                                 "|./source/@network"
                                 "|./source/@name)", ctxt);
 
-        target = virXPathString("string(./target/@dev)", ctxt);
+        target = virXPathString("string(./target/@dev"
+                                "|./alias/@name)", ctxt);
         model = virXPathString("string(./model/@type)", ctxt);
         mac = virXPathString("string(./mac/@address)", ctxt);
 
-- 
2.13.0




More information about the libvir-list mailing list