[libvirt] [PATCH] nodedev: Fix missing network devices

John Ferlan posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20171010133055.6594-1-jferlan@redhat.com
src/util/virnetdev.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
[libvirt] [PATCH] nodedev: Fix missing network devices
Posted by John Ferlan 6 years, 6 months ago
Commit id '8708ca01c' added a check to determine whether the NIC had
Switchdev capabilities; however, in doing so inadvertently would cause
network devices without a PCI device to not be added to the node device
database. Thus, network devices having a "computer" as a parent, such
as "net_lo*", "net_virbr*", "net_tun*", "net_vnet*", etc. were not added.

Alter the check to not even check for Switchdev bits if no PCI device found.

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

 Found this gem while running the Avocado test suite while doing some
 other work. It's only 3.8.0 that'll have the missing devices.

 src/util/virnetdev.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 5060d051dc..41ef65d882 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3236,6 +3236,14 @@ virNetDevSwitchdevFeature(const char *ifname,
     if (is_vf == 1 && virNetDevGetPhysicalFunction(ifname, &pfname) < 0)
         goto cleanup;
 
+    pci_device_ptr = pfname ? virNetDevGetPCIDevice(pfname) :
+                              virNetDevGetPCIDevice(ifname);
+    /* No PCI device, then no feature bit to check/add */
+    if (pci_device_ptr == NULL) {
+        ret = 0;
+        goto cleanup;
+    }
+
     if (!(nl_msg = nlmsg_alloc_simple(family_id,
                                       NLM_F_REQUEST | NLM_F_ACK))) {
         virReportOOMError();
@@ -3248,11 +3256,6 @@ virNetDevSwitchdevFeature(const char *ifname,
     gmsgh->cmd = DEVLINK_CMD_ESWITCH_GET;
     gmsgh->version = DEVLINK_GENL_VERSION;
 
-    pci_device_ptr = pfname ? virNetDevGetPCIDevice(pfname) :
-                              virNetDevGetPCIDevice(ifname);
-    if (pci_device_ptr == NULL)
-        goto cleanup;
-
     pci_name = virPCIDeviceGetName(pci_device_ptr);
 
     if (nla_put(nl_msg, DEVLINK_ATTR_BUS_NAME, strlen("pci")+1, "pci") < 0 ||
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nodedev: Fix missing network devices
Posted by Michal Privoznik 6 years, 6 months ago
On 10/10/2017 06:30 AM, John Ferlan wrote:
> Commit id '8708ca01c' added a check to determine whether the NIC had
> Switchdev capabilities; however, in doing so inadvertently would cause
> network devices without a PCI device to not be added to the node device
> database. Thus, network devices having a "computer" as a parent, such
> as "net_lo*", "net_virbr*", "net_tun*", "net_vnet*", etc. were not added.
> 
> Alter the check to not even check for Switchdev bits if no PCI device found.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
> 
>  Found this gem while running the Avocado test suite while doing some
>  other work. It's only 3.8.0 that'll have the missing devices.
> 
>  src/util/virnetdev.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 

ACK

Michal

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