mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: provide non-netlink/libnl alternative for virNetDevGetMaster()
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 even when libvirt is built without libnl support. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
717615856c
commit
49a58cb9c9
@ -915,10 +915,31 @@ virNetDevGetMaster(const char *ifname, char **master)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
/* 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,
|
||||
char **master G_GNUC_UNUSED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user