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

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

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

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
participants (2)
-
John Ferlan
-
Michal Privoznik