[libvirt] [PATCH] virDomainInterfaceStats: Accept MAC addresses properly

Michal Privoznik posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/fc7eccdbf74e71b3611eae577b834077274b7730.1507937543.git.mprivozn@redhat.com
src/libxl/libxl_driver.c   | 2 +-
src/lxc/lxc_driver.c       | 2 +-
src/openvz/openvz_driver.c | 2 +-
src/qemu/qemu_driver.c     | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
[libvirt] [PATCH] virDomainInterfaceStats: Accept MAC addresses properly
Posted by Michal Privoznik 6 years, 5 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1497396

In 0d3d020ba6c4f I've added capability to accept MAC addresses
for the API too. However, the implementation was faulty. It needs
to lookup the corresponding interface in the domain definition
and pass the ifname instead of MAC address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/libxl/libxl_driver.c   | 2 +-
 src/lxc/lxc_driver.c       | 2 +-
 src/openvz/openvz_driver.c | 2 +-
 src/qemu/qemu_driver.c     | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 08b0f0317..2230343b0 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4982,7 +4982,7 @@ libxlDomainInterfaceStats(virDomainPtr dom,
     if (!(net = virDomainNetFind(vm->def, device)))
         goto endjob;
 
-    if (virNetDevTapInterfaceStats(device, stats,
+    if (virNetDevTapInterfaceStats(net->ifname, stats,
                                    !virDomainNetTypeSharesHostView(net)) < 0)
         goto endjob;
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 6cf499367..b3f6f064f 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2875,7 +2875,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
     if (!(net = virDomainNetFind(vm->def, device)))
         goto endjob;
 
-    if (virNetDevTapInterfaceStats(device, stats,
+    if (virNetDevTapInterfaceStats(net->ifname, stats,
                                    !virDomainNetTypeSharesHostView(net)) < 0)
         goto endjob;
 
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index ffd64da04..9bd73d85c 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2009,7 +2009,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
     if (!(net = virDomainNetFind(vm->def, device)))
         goto cleanup;
 
-    if (virNetDevTapInterfaceStats(device, stats,
+    if (virNetDevTapInterfaceStats(net->ifname, stats,
                                    !virDomainNetTypeSharesHostView(net)) < 0)
         goto cleanup;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7b79c0950..260184ce8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11044,10 +11044,10 @@ qemuDomainInterfaceStats(virDomainPtr dom,
         goto cleanup;
 
     if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
-        if (virNetDevOpenvswitchInterfaceStats(device, stats) < 0)
+        if (virNetDevOpenvswitchInterfaceStats(net->ifname, stats) < 0)
             goto cleanup;
     } else {
-        if (virNetDevTapInterfaceStats(device, stats,
+        if (virNetDevTapInterfaceStats(net->ifname, stats,
                                        !virDomainNetTypeSharesHostView(net)) < 0)
             goto cleanup;
     }
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virDomainInterfaceStats: Accept MAC addresses properly
Posted by John Ferlan 6 years, 5 months ago

On 10/13/2017 07:32 PM, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1497396
> 
> In 0d3d020ba6c4f I've added capability to accept MAC addresses
> for the API too. However, the implementation was faulty. It needs
> to lookup the corresponding interface in the domain definition
> and pass the ifname instead of MAC address.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/libxl/libxl_driver.c   | 2 +-
>  src/lxc/lxc_driver.c       | 2 +-
>  src/openvz/openvz_driver.c | 2 +-
>  src/qemu/qemu_driver.c     | 4 ++--
>  4 files changed, 5 insertions(+), 5 deletions(-)
> 

face-palm - so much for my assumptions

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virDomainInterfaceStats: Accept MAC addresses properly
Posted by Michal Privoznik 6 years, 5 months ago
On 10/13/2017 05:44 PM, John Ferlan wrote:
> 
> 
> On 10/13/2017 07:32 PM, Michal Privoznik wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1497396
>>
>> In 0d3d020ba6c4f I've added capability to accept MAC addresses
>> for the API too. However, the implementation was faulty. It needs
>> to lookup the corresponding interface in the domain definition
>> and pass the ifname instead of MAC address.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> ---
>>  src/libxl/libxl_driver.c   | 2 +-
>>  src/lxc/lxc_driver.c       | 2 +-
>>  src/openvz/openvz_driver.c | 2 +-
>>  src/qemu/qemu_driver.c     | 4 ++--
>>  4 files changed, 5 insertions(+), 5 deletions(-)
>>
> 
> face-palm - so much for my assumptions

Yeah, I facepalmed too when noticing this. Fortunately, the patch is
pretty simple.

> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>
> 

Pushed. Thanks.

Michal

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