mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virnetdevtap: add virNetDevTapGetName
This will be used on a tap file descriptor returned by the bridge helper to populate the <target> element, because the helper does not provide the interface name. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a12475bd44
commit
740d98a17d
@ -1533,6 +1533,7 @@ virNetDevOpenvswitchSetMigrateData;
|
|||||||
virNetDevTapCreate;
|
virNetDevTapCreate;
|
||||||
virNetDevTapCreateInBridgePort;
|
virNetDevTapCreateInBridgePort;
|
||||||
virNetDevTapDelete;
|
virNetDevTapDelete;
|
||||||
|
virNetDevTapGetName;
|
||||||
|
|
||||||
|
|
||||||
# util/virnetdevveth.h
|
# util/virnetdevveth.h
|
||||||
|
@ -42,6 +42,40 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virNetDevTapGetName:
|
||||||
|
* @tapfd: a tun/tap file descriptor
|
||||||
|
* @ifname: a pointer that will receive the interface name
|
||||||
|
*
|
||||||
|
* Retrieve the interface name given a file descriptor for a tun/tap
|
||||||
|
* interface.
|
||||||
|
*
|
||||||
|
* Returns 0 if the interface name is successfully queried, -1 otherwise
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virNetDevTapGetName(int tapfd, char **ifname)
|
||||||
|
{
|
||||||
|
#ifdef TUNGETIFF
|
||||||
|
struct ifreq ifr;
|
||||||
|
|
||||||
|
if (ioctl(tapfd, TUNGETIFF, &ifr) < 0) {
|
||||||
|
virReportSystemError(errno, "%s",
|
||||||
|
_("Unable to query tap interface name"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ifname = strdup(ifr.ifr_name);
|
||||||
|
if (*ifname == NULL) {
|
||||||
|
virReportOOMError();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virNetDevProbeVnetHdr:
|
* virNetDevProbeVnetHdr:
|
||||||
* @tapfd: a tun/tap file descriptor
|
* @tapfd: a tun/tap file descriptor
|
||||||
|
@ -35,6 +35,9 @@ int virNetDevTapCreate(char **ifname,
|
|||||||
int virNetDevTapDelete(const char *ifname)
|
int virNetDevTapDelete(const char *ifname)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
|
int virNetDevTapGetName(int tapfd, char **ifname)
|
||||||
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_NETDEV_TAP_CREATE_NONE = 0,
|
VIR_NETDEV_TAP_CREATE_NONE = 0,
|
||||||
/* Bring the interface up */
|
/* Bring the interface up */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user