Re: [PATCH 8/9] util: provide non-netlink/libnl alternative for virNetDevGetMaster()

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

 



On 10/1/20 1:14 AM, Laine Stump wrote:
Lack of this one function (which is called for each active tap device
every time libvirtd is started) is the one thing preventing a
"WITHOUT_LIBNL" build of libvirt from being useful. With this
alternate implementation, guests using standard tap devices will work
properly.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
  src/util/virnetdev.c | 23 ++++++++++++++++++++++-
  1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 5221bada7b..c43823c747 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -915,9 +915,30 @@ virNetDevGetMaster(const char *ifname, char **master)
      return 0;
  }
+#elif defined(__linux__) -#else
+/* libnl isn't available, so we can't use netlink.
+ * Fall back to using sysfs
+ */
+int
+virNetDevGetMaster(const char *ifname, char **master)
+{
+    g_autofree char *path = NULL;
+    g_autofree char *canonical = NULL;
+
+    if (virNetDevSysfsFile(&path, ifname, "master") < 0)
+        return -1;
+ if (!(canonical = virFileCanonicalizePath(path)))
+        return -1;
+
+    *master = g_path_get_basename(canonical);
+
+    VIR_DEBUG("IFLA_MASTER for %s is %s", ifname, *master ? *master : "(none)");
+    return 0;
+}
+
+#else
int
  virNetDevGetMaster(const char *ifname G_GNUC_UNUSED,


Whoa, building without LIBNL should fail, n'est-ce pas? I'm not saying your patch is wrong, it's just that I'm surprised we haven't caught this earlier.

Michal




[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