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

Package hv_kvm

source code

KVM hypervisor

Submodules [hide private]

Classes [hide private]
  HeadRequest
  KVMHypervisor
KVM hypervisor interface
Functions [hide private]
 
_with_qmp(fn)
Wrapper used on hotplug related methods
source code
 
_GetDriveURI(disk, link, uri)
Helper function to get the drive uri to be used in --drive kvm option
source code
 
_GenerateDeviceKVMId(dev_type, dev)
Helper function to generate a unique device name used by KVM
source code
 
_GetExistingDeviceInfo(dev_type, device, runtime)
Helper function to get an existing device inside the runtime file
source code
tuple
_UpgradeSerializedRuntime(serialized_runtime)
Upgrade runtime data
source code
tuple
_AnalyzeSerializedRuntime(serialized_runtime)
Return runtime entries for a serialized runtime file
source code
 
_CheckUrl(url)
Check if a given URL exists on the server
source code
Variables [hide private]
  psutil_err = "not found"
  psutil = None
hash(x)
  fdsend = None
hash(x)
  _KVM_NETWORK_SCRIPT = pathutils.CONF_DIR+ "/kvm-vif-bridge"
  _KVM_START_PAUSED_FLAG = "-S"
  _SPICE_ADDITIONAL_PARAMS = frozenset([constants.HV_KVM_SPICE_I...
SPICE parameters which depend on constants.HV_KVM_SPICE_BIND
  _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...
  _MIGRATION_CAPS_DELIM = ":"

Imports: errno, os, re, tempfile, time, logging, pwd, shutil, urllib2, bitarray, utils, constants, errors, serializer, objects, uidpool, ssconf, netutils, pathutils, hv_base, utils_wrapper, QmpConnection, QmpMessage, MonitorSocket, OpenTap


Function Details [hide private]

_GetDriveURI(disk, link, uri)

source code 

Helper function to get the drive uri to be used in --drive kvm option

Invoked during startup and disk hot-add. In latter case and if no userspace access mode is used it will be overriden with /dev/fdset/<fdset-id> (see HotAddDisk() and AddFd() of QmpConnection).

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()
Returns:
The drive uri to use in kvm option

_GenerateDeviceKVMId(dev_type, dev)

source code 

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:

_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)

Variables Details [hide private]

_SPICE_ADDITIONAL_PARAMS

SPICE parameters which depend on constants.HV_KVM_SPICE_BIND

Value:
frozenset([constants.HV_KVM_SPICE_IP_VERSION, constants.HV_KVM_SPICE_P\
ASSWORD_FILE, constants.HV_KVM_SPICE_LOSSLESS_IMG_COMPR, constants.HV_\
KVM_SPICE_JPEG_IMG_COMPR, constants.HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR, c\
onstants.HV_KVM_SPICE_STREAMING_VIDEO_DETECTION, constants.HV_KVM_SPIC\
E_USE_TLS,])

_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])}