package documentation

KVM hypervisor

Module kvm_runtime No module docstring; 0/7 constant, 1/1 function, 0/1 class documented
Module kvm_utils No module docstring; 0/2 constant, 5/5 functions documented
Module monitor Qemu monitor control classes
Module netdev KVM hypervisor tap device helpers
Module validation KVM hypervisor parameter/syntax validation helpers

From __init__.py:

Class HeadRequest Undocumented
Class KVMHypervisor KVM hypervisor interface
Variable psutil Undocumented
Variable psutil_err Undocumented
Function _CheckUrl Check if a given URL exists on the server
Function _GenerateDeviceHVInfo Helper function to generate hvinfo of a device (disk, NIC)
Function _GenerateDeviceHVInfoStr Construct the -device option string for hvinfo dict
Function _GenerateDeviceKVMId Helper function to generate a unique device name used by KVM
Function _GetDriveURI Helper function to get the drive uri to be used in -blockdev kvm option
Function _GetExistingDeviceInfo Helper function to get an existing device inside the runtime file
Function _with_qmp Wrapper used on hotplug related methods
Constant _DEVICE_BUS Undocumented
Constant _DEVICE_DRIVER Undocumented
Constant _DEVICE_RUNTIME_INDEX Undocumented
Constant _DEVICE_TYPE Undocumented
Constant _FIND_RUNTIME_ENTRY Undocumented
Constant _HOTPLUGGABLE_DEVICE_TYPES Undocumented
Constant _KVM_DISKS_RUNTIME_INDEX Undocumented
Constant _KVM_NETWORK_SCRIPT Undocumented
Constant _KVM_NICS_RUNTIME_INDEX Undocumented
Constant _KVM_START_PAUSED_FLAG Undocumented
Constant _MIGRATION_CAPS_DELIM Undocumented
Constant _PCI_BUS Undocumented
Constant _POSTCOPY_SYNC_COUNT_THRESHOLD Undocumented
Constant _RUNTIME_DEVICE Undocumented
Constant _RUNTIME_ENTRY Undocumented
Constant _SCSI_BUS Undocumented
psutil =

Undocumented

psutil_err =

Undocumented

def _CheckUrl(url):

Check if a given URL exists on the server

def _GenerateDeviceHVInfo(dev_type, kvm_devid, hv_dev_type, bus_slots):

Helper function to generate hvinfo of a device (disk, NIC)

hvinfo will hold all necessary info for generating the -device QEMU option. We have two main buses: a PCI bus and a SCSI bus (created by a SCSI controller on the PCI bus).

In case of PCI devices we add them on a free PCI slot (addr) on the first PCI bus (pci.0), and in case of SCSI devices we decide to put each disk on a different SCSI target (scsi-id) on the first SCSI bus (scsi.0).

Parameters
dev_type:stringeither HOTPLUG_TARGET_DISK or HOTPLUG_TARGET_NIC
kvm_devid:stringthe id of the device
hv_dev_type:stringeither disk_type or nic_type hvparam
bus_slots:dictthe current slots of the first PCI and SCSI buses
Returns
dictdict including all necessary info (driver, id, bus and bus location) for generating a -device QEMU option for either a disk or a NIC
def _GenerateDeviceHVInfoStr(hvinfo):

Construct the -device option string for hvinfo dict

PV disk: virtio-blk-pci,id=disk-1234,bus=pci.0,addr=0x9 PV NIC: virtio-net-pci,id=nic-1234,bus=pci.0,addr=0x9 SG disk: scsi-generic,id=disk-1234,bus=scsi.0,channel=0,scsi-id=1,lun=0

Parameters
hvinfo:dictdictionary created by _GenerateDeviceHVInfo()
Returns
stringThe constructed string to be passed along with a -device option
def _GenerateDeviceKVMId(dev_type, dev):

Helper function to generate a unique device name used by KVM

QEMU monitor commands use names to identify devices. Since the UUID is too long for a device ID (36 chars vs. 30), we choose to use only the part until the third '-' with a disk/nic prefix. For example if a disk has UUID '932df160-7a22-4067-a566-7e0ca8386133' the resulting device ID would be 'disk-932df160-7a22-4067'.

Parameters
dev_type:stringdevice type of param dev (HOTPLUG_TARGET_DISK|NIC)
dev:objects.Disk or objects.NICthe device object for which we generate a kvm name
def _GetDriveURI(disk, link, uri):

Helper function to get the drive uri to be used in -blockdev 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.DiskA disk configuration object
link:stringThe device link as returned by _SymlinkBlockDev()
uri:stringThe drive uri as returned by _CalculateDeviceURI()
Returns
The drive uri to use in kvm option
def _GetExistingDeviceInfo(dev_type, device, runtime):

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:stingdevice type of param dev
device:objects.Disk or objects.NICthe 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.HotplugErrorin case the requested device does not exist (e.g. device has been added without --hotplug option)
def _with_qmp(fn):

Wrapper used on hotplug related methods

_DEVICE_BUS =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda _: _PCI_BUS),
 constants.HOTPLUG_TARGET_DISK: (lambda ht: _SCSI_BUS if ht in constants.HT_SCSI
_DEVICE_TYPES else _PCI_BUS)}
_DEVICE_DRIVER =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda ht: 'virtio-net-pci' if ht == constants.H
T_NIC_PARAVIRTUAL else ht),
 constants.HOTPLUG_TARGET_DISK: (lambda ht: 'virtio-blk-pci' if ht == constants.
HT_DISK_PARAVIRTUAL else ht)}
_DEVICE_TYPE =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda hvp: hvp[constants.HV_NIC_TYPE]),
 constants.HOTPLUG_TARGET_DISK: (lambda hvp: hvp[constants.HV_DISK_TYPE])}
_FIND_RUNTIME_ENTRY =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda nic, kvm_nics: [n for n in kvm_nics 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])}
_KVM_DISKS_RUNTIME_INDEX: int =

Undocumented

Value
3
_KVM_NETWORK_SCRIPT =

Undocumented

Value
pathutils.CONF_DIR + '/kvm-vif-bridge'
_KVM_NICS_RUNTIME_INDEX: int =

Undocumented

Value
1
_KVM_START_PAUSED_FLAG: str =

Undocumented

Value
'-S'
_MIGRATION_CAPS_DELIM: str =

Undocumented

Value
':'
_PCI_BUS: str =

Undocumented

Value
'pci.0'
_POSTCOPY_SYNC_COUNT_THRESHOLD: int =

Undocumented

Value
2
_RUNTIME_DEVICE =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda d: d),
 constants.HOTPLUG_TARGET_DISK: (lambda d_e_x: d_e_x[0])}
_RUNTIME_ENTRY =

Undocumented

Value
{constants.HOTPLUG_TARGET_NIC: (lambda d, e: d),
 constants.HOTPLUG_TARGET_DISK: (lambda d, e: (d, e[0], e[1]))}
_SCSI_BUS: str =

Undocumented

Value
'scsi.0'