module documentation

KVM hypervisor tap device helpers

Function OpenTap Open a new tap device and return its file descriptor.
Constant IFF_MULTI_QUEUE Undocumented
Constant IFF_NO_PI Undocumented
Constant IFF_ONE_QUEUE Undocumented
Constant IFF_TAP Undocumented
Constant IFF_VNET_HDR Undocumented
Constant TUNGETFEATURES Undocumented
Constant TUNGETIFF Undocumented
Constant TUNSETIFF Undocumented
Function _GetTunFeatures Retrieves supported TUN features from file descriptor.
Function _ProbeTapMqVirtioNet Check whether to enable the IFF_MULTI_QUEUE flag.
Function _ProbeTapVnetHdr Check whether to enable the IFF_VNET_HDR flag.
def OpenTap(name='', features=None):

Open a new tap device and return its file descriptor.

This is intended to be used by a qemu-type hypervisor together with the -net tap,fd=<fd> or -net tap,fds=x:y:...:z command line parameter.

Parameters
name:stringname for the TAP interface being created; if an empty string is passed, the OS will generate a unique name
features:dictA dict denoting whether vhost, vnet_hdr, mq netdev features are enabled or not.
Returns
tuple(ifname, [tapfds], [vhostfds])
IFF_MULTI_QUEUE: int =

Undocumented

Value
256
IFF_NO_PI: int =

Undocumented

Value
4096
IFF_ONE_QUEUE: int =

Undocumented

Value
8192
IFF_TAP: int =

Undocumented

Value
2
IFF_VNET_HDR: int =

Undocumented

Value
16384
TUNGETFEATURES: int =

Undocumented

Value
2147767503
TUNGETIFF: int =

Undocumented

Value
2147767506
TUNSETIFF: int =

Undocumented

Value
1074025674
def _GetTunFeatures(fd, _ioctl=fcntl.ioctl):

Retrieves supported TUN features from file descriptor.

See Also
_ProbeTapVnetHdr
def _ProbeTapMqVirtioNet(fd, _features_fn=_GetTunFeatures):

Check whether to enable the IFF_MULTI_QUEUE flag.

This flag was introduced in Linux kernel 3.8.

Parameters
fd:intthe file descriptor of /dev/net/tun
_features_fnUndocumented
def _ProbeTapVnetHdr(fd, _features_fn=_GetTunFeatures):

Check whether to enable the IFF_VNET_HDR flag.

To do this, _all_ of the following conditions must be met:

  1. TUNGETFEATURES ioctl() *must* be implemented
  2. TUNGETFEATURES ioctl() result *must* contain the IFF_VNET_HDR flag
  3. TUNGETIFF ioctl() *must* be implemented; reading the kernel code in drivers/net/tun.c there is no way to test this until after the tap device has been created using TUNSETIFF, and there is no way to change the IFF_VNET_HDR flag after creating the interface, catch-22! However both TUNGETIFF and TUNGETFEATURES were introduced in kernel version 2.6.27, thus we can expect TUNGETIFF to be present if TUNGETFEATURES is.
Parameters
fd:intthe file descriptor of /dev/net/tun
_features_fnUndocumented