mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
util: new function virNetDevMacVLanIsMacvtap()
This function returns T if the given name is a macvtap device. This is determined by 1) getting the ifindex of the device with that name (if there is one), and 2) checking for existence of /dev/tapXX, where "XX" is the ifindex learned in (1). It's also possible to learn this by getting a netlink dump of the interface and parsing through it to look for some attributes, but that is complicated to figure out, takes longer to execute, and I'm lazy. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
4ef4ba4974
commit
1b46566eed
@ -2524,6 +2524,7 @@ virNetDevMacVLanCreate;
|
|||||||
virNetDevMacVLanCreateWithVPortProfile;
|
virNetDevMacVLanCreateWithVPortProfile;
|
||||||
virNetDevMacVLanDelete;
|
virNetDevMacVLanDelete;
|
||||||
virNetDevMacVLanDeleteWithVPortProfile;
|
virNetDevMacVLanDeleteWithVPortProfile;
|
||||||
|
virNetDevMacVLanIsMacvtap;
|
||||||
virNetDevMacVLanModeTypeFromString;
|
virNetDevMacVLanModeTypeFromString;
|
||||||
virNetDevMacVLanReleaseName;
|
virNetDevMacVLanReleaseName;
|
||||||
virNetDevMacVLanReserveName;
|
virNetDevMacVLanReserveName;
|
||||||
|
@ -278,6 +278,29 @@ virNetDevMacVLanReleaseName(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virNetDevMacVLanIsMacvtap:
|
||||||
|
* @ifname: Name of the interface
|
||||||
|
*
|
||||||
|
* Return T if the named netdev exists and is a macvtap device
|
||||||
|
* F in all other cases.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
virNetDevMacVLanIsMacvtap(const char *ifname)
|
||||||
|
{
|
||||||
|
int ifindex;
|
||||||
|
VIR_AUTOFREE(char *) tapname = NULL;
|
||||||
|
|
||||||
|
if (virNetDevGetIndex(ifname, &ifindex) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (virAsprintf(&tapname, "/dev/tap%d", ifindex) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return virFileExists(tapname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virNetDevMacVLanCreate:
|
* virNetDevMacVLanCreate:
|
||||||
*
|
*
|
||||||
|
@ -57,6 +57,9 @@ typedef enum {
|
|||||||
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
|
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
|
||||||
int virNetDevMacVLanReleaseName(const char *name);
|
int virNetDevMacVLanReleaseName(const char *name);
|
||||||
|
|
||||||
|
bool virNetDevMacVLanIsMacvtap(const char *ifname)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NOINLINE;
|
||||||
|
|
||||||
int virNetDevMacVLanCreate(const char *ifname,
|
int virNetDevMacVLanCreate(const char *ifname,
|
||||||
const char *type,
|
const char *type,
|
||||||
const virMacAddr *macaddress,
|
const virMacAddr *macaddress,
|
||||||
|
Loading…
Reference in New Issue
Block a user