Module hv_kvm
source code
KVM hypervisor
|
affinity = None
|
|
fdsend = None
|
|
_KVM_NETWORK_SCRIPT = pathutils.CONF_DIR+ "/kvm-vif-bridge"
|
|
_KVM_START_PAUSED_FLAG = "-S"
|
|
TUNSETIFF = 0x400454ca
|
|
TUNGETIFF = 0x800454d2
|
|
TUNGETFEATURES = 0x800454cf
|
|
IFF_TAP = 0x0002
|
|
IFF_NO_PI = 0x1000
|
|
IFF_ONE_QUEUE = 0x2000
|
|
IFF_VNET_HDR = 0x4000
|
|
_SPICE_ADDITIONAL_PARAMS = frozenset([constants.HV_KVM_SPICE_I...
SPICE parameters which depend on constants.HV_KVM_SPICE_BIND
|
|
_AVAILABLE_PCI_SLOT = bitarray("0")
|
|
_KVM_NICS_RUNTIME_INDEX = 1
|
|
_KVM_DISKS_RUNTIME_INDEX = 3
|
|
_DEVICE_RUNTIME_INDEX = {constants.HOTPLUG_TARGET_DISK: _KVM_D...
|
|
_FIND_RUNTIME_ENTRY = {constants.HOTPLUG_TARGET_NIC: lambda ni...
|
|
_RUNTIME_DEVICE = {constants.HOTPLUG_TARGET_NIC: lambda d: d, ...
|
|
_RUNTIME_ENTRY = {constants.HOTPLUG_TARGET_NIC: lambda d, e: d...
|
Imports:
errno,
os,
re,
tempfile,
time,
logging,
pwd,
struct,
fcntl,
shutil,
socket,
stat,
StringIO,
bitarray,
utils,
constants,
errors,
serializer,
objects,
uidpool,
ssconf,
netutils,
pathutils,
hv_base,
utils_wrapper
Helper function to get the drive uri to be used in --drive kvm
option
- Parameters:
disk (objects.Disk) - A disk configuration object
link (string) - The device link as returned by _SymlinkBlockDev()
uri (string) - The drive uri as returned by _CalculateDeviceURI()
|
Helper function to generate a unique device name used by KVM
QEMU monitor commands use names to identify devices. Here we use their
pci slot and a part of their UUID to name them. dev.pci might be None for
old devices in the cluster.
- Parameters:
dev_type (sting) - device type of param dev
dev (objects.Disk or objects.NIC) - the device object for which we generate a kvm name
- Raises:
|
_GetFreeSlot(slots,
slot=None,
reserve=False)
| source code
|
Helper method to get first available slot in a bitarray
- Parameters:
slots (bitarray) - the bitarray to operate on
slot (integer) - if given we check whether the slot is free
reserve (boolean) - whether to reserve the first available slot or not
- Returns:
- the idx of the (first) available slot
- Raises:
|
_GetExistingDeviceInfo(dev_type,
device,
runtime)
| source code
|
Helper function to get an existing device inside the runtime file
Used when an instance is running. Load kvm runtime file and search for
a device based on its type and uuid.
- Parameters:
dev_type (sting) - device type of param dev
device (objects.Disk or objects.NIC) - the device object for which we generate a kvm name
runtime (tuple (cmd, nics, hvparams, disks)) - the runtime data to search for the device
- Raises:
errors.HotplugError - in case the requested device does not exist (e.g. device has been
added without --hotplug option) or device info has not pci slot
(e.g. old devices in the cluster)
|
_UpgradeSerializedRuntime(serialized_runtime)
| source code
|
Upgrade runtime data
Remove any deprecated fields or change the format of the data. The
runtime files are not upgraded when Ganeti is upgraded, so the required
modification have to be performed here.
- Parameters:
serialized_runtime (string) - raw text data read from actual runtime file
- Returns: tuple
- (cmd, nic dicts, hvparams, bdev dicts)
|
_AnalyzeSerializedRuntime(serialized_runtime)
| source code
|
Return runtime entries for a serialized runtime file
- Parameters:
serialized_runtime (string) - raw text data read from actual runtime file
- Returns: tuple
- (cmd, nics, hvparams, bdevs)
|
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:
-
TUNGETFEATURES ioctl() *must* be implemented
-
TUNGETFEATURES ioctl() result *must* contain the IFF_VNET_HDR flag
-
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
|
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> command line parameter.
- Parameters:
vnet_hdr (boolean) - Enable the VNET Header
- Returns: tuple
- (ifname, tapfd)
|
_DEVICE_RUNTIME_INDEX
- Value:
{constants.HOTPLUG_TARGET_DISK: _KVM_DISKS_RUNTIME_INDEX, constants.HO
TPLUG_TARGET_NIC: _KVM_NICS_RUNTIME_INDEX}
|
|
_FIND_RUNTIME_ENTRY
- Value:
{constants.HOTPLUG_TARGET_NIC: lambda nic, kvm_nics: [n for n in kvm_n
ics if n.uuid== nic.uuid], constants.HOTPLUG_TARGET_DISK: lambda disk,
kvm_disks: [(d, l, u) for(d, l, u) in kvm_disks if d.uuid== disk.uuid
]}
|
|
_RUNTIME_DEVICE
- Value:
{constants.HOTPLUG_TARGET_NIC: lambda d: d, constants.HOTPLUG_TARGET_D
ISK: lambda(d, e, _): d}
|
|
_RUNTIME_ENTRY
- Value:
{constants.HOTPLUG_TARGET_NIC: lambda d, e: d, constants.HOTPLUG_TARGE
T_DISK: lambda d, e:(d, e [0], e [1])}
|
|