Package ganeti :: Package hypervisor :: Package hv_kvm :: Module netdev
[hide private]
[frames] | no frames]

Module netdev

source code

KVM hypervisor tap device helpers

Functions [hide private]
 
_GetTunFeatures(fd, _ioctl=fcntl.ioctl)
Retrieves supported TUN features from file descriptor.
source code
 
_ProbeTapVnetHdr(fd, _features_fn=_GetTunFeatures)
Check whether to enable the IFF_VNET_HDR flag.
source code
 
_ProbeTapMqVirtioNet(fd, _features_fn=_GetTunFeatures)
Check whether to enable the IFF_MULTI_QUEUE flag.
source code
tuple
OpenTap(vnet_hdr=True, virtio_net_queues=1, name="")
Open a new tap device and return its file descriptor.
source code
Variables [hide private]
  TUNSETIFF = 0x400454ca
  TUNGETIFF = 0x800454d2
  TUNGETFEATURES = 0x800454cf
  IFF_TAP = 0x0002
  IFF_NO_PI = 0x1000
  IFF_ONE_QUEUE = 0x2000
  IFF_VNET_HDR = 0x4000
  IFF_MULTI_QUEUE = 0x0100

Imports: os, logging, struct, fcntl, errors


Function Details [hide private]

_GetTunFeatures(fd, _ioctl=fcntl.ioctl)

source code 

Retrieves supported TUN features from file descriptor.

See Also: _ProbeTapVnetHdr

_ProbeTapVnetHdr(fd, _features_fn=_GetTunFeatures)

source code 

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 (int) - the file descriptor of /dev/net/tun

_ProbeTapMqVirtioNet(fd, _features_fn=_GetTunFeatures)

source code 

Check whether to enable the IFF_MULTI_QUEUE flag.

This flag was introduced in Linux kernel 3.8.

Parameters:
  • fd (int) - the file descriptor of /dev/net/tun

OpenTap(vnet_hdr=True, virtio_net_queues=1, name="")

source code 

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:
  • vnet_hdr (boolean) - Enable the VNET Header
  • virtio_net_queues (int) - Set number of tap queues but not more than 8, queues only work with virtio-net device; disabled by default (one queue).
  • name (string) - name for the TAP interface being created; if an empty string is passed, the OS will generate a unique name
Returns: tuple
(ifname, [tapfds])