ganeti :: hypervisor :: hv_kvm :: KVMHypervisor :: Class KVMHypervisor
[hide private]
[frames] | no frames]

Class KVMHypervisor

source code


KVM hypervisor interface

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
dictionary of int:int
_GetVcpuThreadIds(self, instance_name)
Get a mapping of vCPU no.
source code
 
_ExecuteCpuAffinity(self, instance_name, cpu_mask)
Complete CPU pinning.
source code
 
ListInstances(self, hvparams=None)
Get the list of running instances.
source code
tuple of strings
GetInstanceInfo(self, instance_name, hvparams=None)
Get instance properties.
source code
(string, string, int, int, HvInstanceState, int)
GetAllInstancesInfo(self, hvparams=None)
Get properties of all instances.
source code
list
_GenerateKVMBlockDevicesOptions(self, up_hvp, kvm_disks, kvmhelp, devlist)
Generate KVM options regarding instance's block devices.
source code
 
_GenerateKVMRuntime(self, instance, block_devices, startup_paused, kvmhelp)
Generate KVM information to start an instance.
source code
 
_WriteKVMRuntime(self, instance_name, data)
Write an instance's KVM runtime
source code
 
_ReadKVMRuntime(self, instance_name)
Read an instance's KVM runtime
source code
 
_SaveKVMRuntime(self, instance, kvm_runtime)
Save an instance's KVM runtime
source code
 
_LoadKVMRuntime(self, instance, serialized_runtime=None)
Load an instance's KVM runtime
source code
 
_RunKVMCmd(self, name, kvm_cmd, tap_fds=None)
Run the KVM cmd and check for errors
source code
(dict, str, str) tuple
_GetNetworkDeviceFeatures(self, up_hvp, devlist, kvmhelp)
Get network device options to properly enable supported features.
source code
 
_ExecuteKVMRuntime(self, instance, kvm_runtime, kvmhelp, incoming=None)
Execute a KVM cmd, after completing it with some last minute data.
source code
 
StartInstance(self, instance, block_devices, startup_paused)
Start an instance.
source code
 
VerifyHotplugSupport(self, instance, action, dev_type)
Verifies that hotplug is supported.
source code
 
HotplugSupported(self, instance)
Checks if hotplug is generally supported.
source code
 
_GetBusSlots(self, hvp=None, runtime=None)
Helper function to get the slots of PCI and SCSI QEMU buses.
source code
 
_VerifyHotplugCommand(self, _instance, kvm_devid, should_exist)
Checks if a previous hotplug command has succeeded.
source code
 
HotAddDevice(self, instance, dev_type, device, extra, seq)
Helper method to hot-add a new device
source code
 
HotDelDevice(self, instance, dev_type, device, _, seq)
Helper method for hot-del device
source code
 
HotModDevice(self, instance, dev_type, device, _, seq)
Helper method for hot-mod device
source code
 
StopInstance(self, instance, force=False, retry=False, name=None, timeout=None)
Stop an instance.
source code
 
CleanupInstance(self, instance_name)
Cleanup after a stopped instance
source code
 
RebootInstance(self, instance)
Reboot an instance.
source code
string
MigrationInfo(self, instance)
Get instance information to perform a migration.
source code
 
AcceptInstance(self, instance, info, target)
Prepare to accept an instance.
source code
 
FinalizeMigrationDst(self, instance, info, success)
Finalize the instance migration on the target node.
source code
 
MigrateInstance(self, cluster_name, instance, target, live)
Migrate an instance to a target node.
source code
 
FinalizeMigrationSource(self, instance, success, live)
Finalize the instance migration on the source node.
source code
objects.MigrationStatus
GetMigrationStatus(self, instance)
Get the migration status
source code
 
BalloonInstanceMemory(self, instance, mem)
Balloon an instance memory to a certain value.
source code
 
GetNodeInfo(self, hvparams=None)
Return information about the node.
source code
 
Verify(self, hvparams=None)
Verify the hypervisor.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_InstancePidFile(cls, instance_name)
Returns the instance pidfile.
source code
 
_InstanceUidFile(cls, instance_name)
Returns the instance uidfile.
source code
tuple
_InstancePidInfo(cls, pid)
Check pid file for instance information.
source code
tuple
_InstancePidAlive(cls, instance_name)
Returns the instance pidfile, pid, and liveness.
source code
 
_CheckDown(cls, instance_name)
Raises an error unless the given instance is down.
source code
 
_InstanceMonitor(cls, instance_name)
Returns the instance monitor socket name
source code
 
_InstanceSerial(cls, instance_name)
Returns the instance serial socket name
source code
 
_InstanceQmpMonitor(cls, instance_name)
Returns the instance serial QMP socket name
source code
 
_InstanceKvmdMonitor(cls, instance_name)
Returns the instance kvm daemon socket name
source code
 
_InstanceShutdownMonitor(cls, instance_name)
Returns the instance QMP output filename
source code
 
_InstanceKVMRuntime(cls, instance_name)
Returns the instance KVM runtime filename
source code
 
_InstanceChrootDir(cls, instance_name)
Returns the name of the KVM chroot dir of the instance
source code
 
_InstanceNICDir(cls, instance_name)
Returns the name of the directory holding the tap device files for a given instance.
source code
 
_InstanceNICFile(cls, instance_name, seq)
Returns the name of the file containing the tap device for a given NIC
source code
 
_InstanceKeymapFile(cls, instance_name)
Returns the name of the file containing the keymap for a given instance
source code
 
_TryReadUidFile(cls, uid_file)
Try to read a uid file
source code
 
_RemoveInstanceRuntimeFiles(cls, pidfile, instance_name)
Removes an instance's rutime sockets/files/dirs.
source code
 
_SetProcessAffinity(cls, process_id, cpus)
Sets the affinity of a process to the given CPUs.
source code
 
_AssignCpuAffinity(cls, cpu_mask, process_id, thread_dict)
Change CPU affinity for running VM according to given CPU mask.
source code
 
_IsUserShutdown(cls, instance_name) source code
 
_ClearUserShutdown(cls, instance_name) source code
 
_CallMonitorCommand(cls, instance_name, command, timeout=None)
Invoke a command on the instance monitor.
source code
 
_ParseKVMVersion(cls, text)
Parse the KVM version from the --help output.
source code
 
_GetKVMOutput(cls, kvm_path, option)
Return the output of a kvm invocation
source code
 
_GetKVMVersion(cls, kvm_path)
Return the installed KVM version.
source code
 
_GetDefaultMachineVersion(cls, kvm_path)
Return the default hardware revision (e.g.
source code
 
_StopInstance(cls, instance, force=False, name=None, timeout=None)
Stop an instance.
source code
 
GetInstanceConsole(cls, instance, primary_node, node_group, hvparams, beparams)
Return a command for connecting to the console of an instance.
source code
 
CheckParameterSyntax(cls, hvparams)
Check the given parameters for validity.
source code
 
ValidateParameters(cls, hvparams)
Check the given parameters for validity.
source code
 
PowercycleNode(cls, hvparams=None)
KVM powercycle, just a wrapper over Linux powercycle.
source code

Inherited from hv_base.BaseHypervisor: GetAncillaryFiles, LinuxPowercycle

Static Methods [hide private]
 
VersionsSafeForMigration(src, target)
Predict if migration is safe between those versions
source code
 
_SocatUnixConsoleParams()
Returns the correct parameters for socat
source code
 
_ConfigureNIC(instance, seq, nic, tap)
Run the network configuration script for a specified NIC
source code
 
_CdromOption(kvm_cmd, cdrom_disk_type, cdrom_image, cdrom_boot, needs_boot_flag)
Extends kvm_cmd with the '-drive' option for a cdrom, and optionally the '-boot' option.
source code
string
_GenerateKvmTapName(nic)
Generate a TAP network interface name for a NIC.
source code
 
_StartKvmd(hvparams)
Ensure that the Kvm daemon is running.
source code

Inherited from hv_base.BaseHypervisor: GetLinuxNodeInfo

Inherited from hv_base.BaseHypervisor (private): _FormatVerifyResults

Class Variables [hide private]
boolean CAN_MIGRATE = True
whether this hypervisor can do migration (either live or non-live)
  _ROOT_DIR = pathutils.RUN_DIR+ "/kvm-hypervisor"
  _PIDS_DIR = _ROOT_DIR+ "/pid"
  _UIDS_DIR = _ROOT_DIR+ "/uid"
  _CTRL_DIR = _ROOT_DIR+ "/ctrl"
  _CONF_DIR = _ROOT_DIR+ "/conf"
  _NICS_DIR = _ROOT_DIR+ "/nic"
  _KEYMAP_DIR = _ROOT_DIR+ "/keymap"
  _CHROOT_DIR = _ROOT_DIR+ "/chroot"
  _CHROOT_QUARANTINE_DIR = _ROOT_DIR+ "/chroot-quarantine"
  _DIRS = [_ROOT_DIR, _PIDS_DIR, _UIDS_DIR, _CTRL_DIR, _CONF_DIR...
  PARAMETERS = {constants.HV_KVM_PATH: hv_base.REQ_FILE_CHECK, c...
a dict of parameter name: check type; the check type is a five-tuple containing:
  _VIRTIO = "virtio"
  _VIRTIO_NET_PCI = "virtio-net-pci"
  _VIRTIO_BLK_PCI = "virtio-blk-pci"
  _MIGRATION_STATUS_RE = re.compile(r"Migration\s+status:\s+(\w+...
  _MIGRATION_PROGRESS_RE = re.compile(r"\s*transferred\s+ram:\s+...
  _MIGRATION_INFO_MAX_BAD_ANSWERS = 5
  _MIGRATION_INFO_RETRY_DELAY = 2
  _VERSION_RE = re.compile(r"\b(\d+)\.(\d+)(\.(\d+))?\b")
  _CPU_INFO_RE = re.compile(r"cpu\s+\#(\d+).*thread_id\s*=\s*(\d...
  _CPU_INFO_CMD = "info cpus"
  _CONT_CMD = "cont"
  _DEFAULT_MACHINE_VERSION_RE = re.compile(r"^(\S+).*\(default\)...
  _CHECK_MACHINE_VERSION_RE = staticmethod(lambda x: re.compile(...
  _QMP_RE = re.compile(r"^-qmp\s", re.M)
  _SPICE_RE = re.compile(r"^-spice\s", re.M)
  _VHOST_RE = re.compile(r"^-net\s.*,vhost=on|off", re.M)
  _VIRTIO_NET_QUEUES_RE = re.compile(r"^-net\s.*,fds=x:y:...:z",...
  _ENABLE_KVM_RE = re.compile(r"^-enable-kvm\s", re.M)
  _DISABLE_KVM_RE = re.compile(r"^-disable-kvm\s", re.M)
  _NETDEV_RE = re.compile(r"^-netdev\s", re.M)
  _DISPLAY_RE = re.compile(r"^-display\s", re.M)
  _MACHINE_RE = re.compile(r"^-machine\s", re.M)
  _DEVICE_DRIVER_SUPPORTED = staticmethod(lambda drv, devlist: r...
  _BOOT_RE = re.compile(r"^-drive\s([^-]|(?<!^)-)*,boot=on\|off"...
  _UUID_RE = re.compile(r"^-uuid\s", re.M)
  _INFO_VERSION_RE = re.compile(r'^QEMU (\d+)\.(\d+)(\.(\d+))?.*...
  _INFO_VERSION_CMD = "info version"
  _DEFAULT_PCI_RESERVATIONS = "11111111111100000000000000000000"
  _DEFAULT_SCSI_RESERVATIONS = "0000000000000000"
  ANCILLARY_FILES = [_KVM_NETWORK_SCRIPT,]
  ANCILLARY_FILES_OPT = [_KVM_NETWORK_SCRIPT,]
  _KVMOPT_HELP = "help"
  _KVMOPT_MLIST = "mlist"
  _KVMOPT_DEVICELIST = "devicelist"
  _KVMOPTS_CMDS = {_KVMOPT_HELP:(["--help"], False), _KVMOPT_MLI...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

VersionsSafeForMigration(src, target)
Static Method

source code 

Predict if migration is safe between those versions

Overrides: hv_base.BaseHypervisor.VersionsSafeForMigration

_InstancePidInfo(cls, pid)
Class Method

source code 

Check pid file for instance information.

Check that a pid file is associated with an instance, and retrieve information from its command line.

Parameters:
  • pid (string or int) - process id of the instance to check
Returns: tuple
(instance_name, memory, vcpus)
Raises:

_InstancePidAlive(cls, instance_name)
Class Method

source code 

Returns the instance pidfile, pid, and liveness.

Parameters:
  • instance_name (string) - instance name
Returns: tuple
(pid file name, pid, liveness)

_SocatUnixConsoleParams()
Static Method

source code 

Returns the correct parameters for socat

If we have a new-enough socat we can use raw mode with an escape character.

_ConfigureNIC(instance, seq, nic, tap)
Static Method

source code 

Run the network configuration script for a specified NIC

See hv_base.ConfigureNIC.

Parameters:
  • instance (instance object) - instance we're acting on
  • seq (int) - nic sequence number
  • nic (nic object) - nic we're acting on
  • tap (str) - the host's tap interface this NIC corresponds to

_SetProcessAffinity(cls, process_id, cpus)
Class Method

source code 

Sets the affinity of a process to the given CPUs.

Parameters:
  • cpus (list of int) - The list of CPUs the process ID may use.
  • process_id (int)

_AssignCpuAffinity(cls, cpu_mask, process_id, thread_dict)
Class Method

source code 

Change CPU affinity for running VM according to given CPU mask.

Parameters:
  • cpu_mask (string) - CPU mask as given by the user. e.g. "0-2,4:all:1,3"
  • process_id (int) - process ID of KVM process. Used to pin entire VM to physical CPUs.
  • thread_dict (dict int:int) - map of virtual CPUs to KVM thread IDs

_GetVcpuThreadIds(self, instance_name)

source code 

Get a mapping of vCPU no. to thread IDs for the instance

Parameters:
  • instance_name (string) - instance in question
Returns: dictionary of int:int
a dictionary mapping vCPU numbers to thread IDs

_ExecuteCpuAffinity(self, instance_name, cpu_mask)

source code 

Complete CPU pinning.

Parameters:
  • instance_name (string) - name of instance
  • cpu_mask (string) - CPU pinning mask as entered by user

ListInstances(self, hvparams=None)

source code 

Get the list of running instances.

We can do this by listing our live instances directory and checking whether the associated kvm process is still alive.

Overrides: hv_base.BaseHypervisor.ListInstances

GetInstanceInfo(self, instance_name, hvparams=None)

source code 

Get instance properties.

Parameters:
  • instance_name (string) - the instance name
  • hvparams (dict of strings) - hypervisor parameters to be used with this instance
Returns: tuple of strings
(name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetInstanceInfo

GetAllInstancesInfo(self, hvparams=None)

source code 

Get properties of all instances.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters
Returns: (string, string, int, int, HvInstanceState, int)
list of tuples (name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetAllInstancesInfo

_GenerateKVMBlockDevicesOptions(self, up_hvp, kvm_disks, kvmhelp, devlist)

source code 

Generate KVM options regarding instance's block devices.

Parameters:
  • up_hvp (dict) - the instance's runtime hypervisor parameters
  • kvm_disks (list of tuples) - list of tuples [(disk, link_name, uri)..]
  • kvmhelp (string) - output of kvm --help
  • devlist (string) - output of kvm -device ?
Returns: list
list of command line options eventually used by kvm executable

_CdromOption(kvm_cmd, cdrom_disk_type, cdrom_image, cdrom_boot, needs_boot_flag)
Static Method

source code 

Extends kvm_cmd with the '-drive' option for a cdrom, and optionally the '-boot' option.

Example: -drive file=cdrom.iso,media=cdrom,format=raw,if=ide -boot d

Example: -drive file=cdrom.iso,media=cdrom,format=raw,if=ide,boot=on

Example: -drive file=http://hostname.com/cdrom.iso,media=cdrom

Parameters:
  • kvm_cmd (string) - KVM command line
  • cdrom_disk_type ()
  • cdrom_image ()
  • cdrom_boot ()
  • needs_boot_flag ()

_GenerateKVMRuntime(self, instance, block_devices, startup_paused, kvmhelp)

source code 

Generate KVM information to start an instance.

Parameters:
  • kvmhelp (string) - output of kvm --help

Attention: this function must not have any side-effects; for example, it must not write to the filesystem, or read values from the current system the are expected to differ between nodes, since it is only run once at instance startup; actions/kvm arguments that can vary between systems should be done in _ExecuteKVMRuntime

_RunKVMCmd(self, name, kvm_cmd, tap_fds=None)

source code 

Run the KVM cmd and check for errors

Parameters:
  • name (string) - instance name
  • kvm_cmd (list of strings) - runcmd input for kvm
  • tap_fds (list of int) - fds of tap devices opened by Ganeti

_GenerateKvmTapName(nic)
Static Method

source code 

Generate a TAP network interface name for a NIC.

See hv_base.GenerateTapName.

For the case of the empty string, see OpenTap

Parameters:
  • nic (ganeti.objects.NIC) - NIC object for the name should be generated
Returns: string
TAP network interface name, or the empty string if the NIC is not used in instance communication

_GetNetworkDeviceFeatures(self, up_hvp, devlist, kvmhelp)

source code 

Get network device options to properly enable supported features.

Return a dict of supported and enabled tap features with nic_model along with the extra strings to be appended to the --netdev and --device options. This function is called before opening a new tap device.

Currently the features_dict includes the following attributes:

  • vhost (boolean)
  • vnet_hdr (boolean)
  • mq (boolean, int)
Returns: (dict, str, str) tuple
The supported features, the string to be appended to the --netdev option, the string to be appended to the --device option

_ExecuteKVMRuntime(self, instance, kvm_runtime, kvmhelp, incoming=None)

source code 

Execute a KVM cmd, after completing it with some last minute data.

Parameters:
  • instance (objects.Instance object) - the VM this command acts upon
  • kvm_runtime (tuple of (list of str, list of objects.NIC objects, dict of hypervisor options, list of tuples (objects.Disk, str, str)) - (kvm command, NICs of the instance, options at startup of the instance, [(disk, link_name, uri)..])
  • incoming (tuple of strings) - (target_host_ip, port) for migration.
  • kvmhelp (string) - output of kvm --help

_StartKvmd(hvparams)
Static Method

source code 

Ensure that the Kvm daemon is running.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters

StartInstance(self, instance, block_devices, startup_paused)

source code 

Start an instance.

Overrides: hv_base.BaseHypervisor.StartInstance

VerifyHotplugSupport(self, instance, action, dev_type)

source code 

Verifies that hotplug is supported.

Hotplug is not supported if:

  • the instance is not running
  • the device type is not hotplug-able
  • the QMP version does not support the corresponding commands
Parameters:
  • instance - the instance object
  • action - one of the supported hotplug commands
  • dev_type - one of the supported device types to hotplug
Decorators:
  • @_with_qmp
Raises:
Overrides: hv_base.BaseHypervisor.VerifyHotplugSupport

HotplugSupported(self, instance)

source code 

Checks if hotplug is generally supported.

Hotplug is *not* supported in case of:

  • qemu versions < 1.7 (where all qmp related commands are supported)
  • for stopped instances
Raises:
Overrides: hv_base.BaseHypervisor.HotplugSupported

_GetBusSlots(self, hvp=None, runtime=None)

source code 

Helper function to get the slots of PCI and SCSI QEMU buses.

This will return the status of the first PCI and SCSI buses. By default QEMU boots with one PCI bus (pci.0) and occupies the first 3 PCI slots. If a SCSI disk is found then a SCSI controller is added on the PCI bus and a SCSI bus (scsi.0) is created.

During hotplug we could query QEMU via info qtree HMP command but parsing the result is too complicated. Instead we use the info stored in runtime files. We parse NIC and disk entries and based on their hvinfo we reserve the corresponding slots.

The runtime argument is a tuple as returned by _LoadKVMRuntime(). Obtain disks and NICs from it. In case a runtime file is not available (see _GenerateKVMRuntime()) we return the bus slots that QEMU boots with by default.

_VerifyHotplugCommand(self, _instance, kvm_devid, should_exist)

source code 

Checks if a previous hotplug command has succeeded.

Depending on the should_exist value, verifies that an entry identified by device ID is present or not.

Decorators:
  • @_with_qmp
Raises:

HotAddDevice(self, instance, dev_type, device, extra, seq)

source code 

Helper method to hot-add a new device

It generates the device ID and hvinfo, and invokes the device-specific method.

Decorators:
  • @_with_qmp
Overrides: hv_base.BaseHypervisor.HotAddDevice

HotDelDevice(self, instance, dev_type, device, _, seq)

source code 

Helper method for hot-del device

It gets device info from runtime file, generates the device name and invokes the device-specific method.

Decorators:
  • @_with_qmp
Overrides: hv_base.BaseHypervisor.HotDelDevice

HotModDevice(self, instance, dev_type, device, _, seq)

source code 

Helper method for hot-mod device

It gets device info from runtime file, generates the device name and invokes the device-specific method. Currently only NICs support hot-mod

Overrides: hv_base.BaseHypervisor.HotModDevice

_ParseKVMVersion(cls, text)
Class Method

source code 

Parse the KVM version from the --help output.

Parameters:
  • text (string) - output of kvm --help
Returns:
(version, v_maj, v_min, v_rev)
Raises:

_GetKVMOutput(cls, kvm_path, option)
Class Method

source code 

Return the output of a kvm invocation

Parameters:
  • kvm_path (string) - path to the kvm executable
  • option (a key of _KVMOPTS_CMDS) - kvm option to fetch the output from
Returns:
output a supported kvm invocation
Raises:

_GetKVMVersion(cls, kvm_path)
Class Method

source code 

Return the installed KVM version.

Returns:
(version, v_maj, v_min, v_rev)
Raises:

_GetDefaultMachineVersion(cls, kvm_path)
Class Method

source code 

Return the default hardware revision (e.g. pc-1.1)

StopInstance(self, instance, force=False, retry=False, name=None, timeout=None)

source code 

Stop an instance.

Parameters:
  • instance - instance to stop
  • force - whether to do a "hard" stop (destroy)
  • retry - whether this is just a retry call
  • name - if this parameter is passed, the the instance object should not be used (will be passed as None), and the shutdown must be done by name only
  • timeout - if the parameter is not None, a soft shutdown operation will be killed after the specified number of seconds. A hard (forced) shutdown cannot have a timeout
Raises:
Overrides: hv_base.BaseHypervisor.StopInstance

CleanupInstance(self, instance_name)

source code 

Cleanup after a stopped instance

Parameters:
  • instance_name - instance name to cleanup after
Overrides: hv_base.BaseHypervisor.CleanupInstance

RebootInstance(self, instance)

source code 

Reboot an instance.

Overrides: hv_base.BaseHypervisor.RebootInstance

MigrationInfo(self, instance)

source code 

Get instance information to perform a migration.

Parameters:
Returns: string
content of the KVM runtime file
Overrides: hv_base.BaseHypervisor.MigrationInfo

AcceptInstance(self, instance, info, target)

source code 

Prepare to accept an instance.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • info (string) - content of the KVM runtime file on the source node
  • target (string) - target host (usually ip), on this node
Overrides: hv_base.BaseHypervisor.AcceptInstance

FinalizeMigrationDst(self, instance, info, success)

source code 

Finalize the instance migration on the target node.

Stop the incoming mode KVM.

Parameters:
Overrides: hv_base.BaseHypervisor.FinalizeMigrationDst

MigrateInstance(self, cluster_name, instance, target, live)

source code 

Migrate an instance to a target node.

The migration will not be attempted if the instance is not currently running.

Parameters:
  • cluster_name (string) - name of the cluster
  • instance (objects.Instance) - the instance to be migrated
  • target (string) - ip address of the target node
  • live (boolean) - perform a live migration
Overrides: hv_base.BaseHypervisor.MigrateInstance

FinalizeMigrationSource(self, instance, success, live)

source code 

Finalize the instance migration on the source node.

Parameters:
  • instance (objects.Instance) - the instance that was migrated
  • success (bool) - whether the migration succeeded or not
  • live (bool) - whether the user requested a live migration or not
Overrides: hv_base.BaseHypervisor.FinalizeMigrationSource

GetMigrationStatus(self, instance)

source code 

Get the migration status

Parameters:
Returns: objects.MigrationStatus
the status of the current migration (one of constants.HV_MIGRATION_VALID_STATUSES), plus any additional progress info that can be retrieved from the hypervisor
Overrides: hv_base.BaseHypervisor.GetMigrationStatus

BalloonInstanceMemory(self, instance, mem)

source code 

Balloon an instance memory to a certain value.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • mem (int) - actual memory size to use for instance runtime
Overrides: hv_base.BaseHypervisor.BalloonInstanceMemory

GetNodeInfo(self, hvparams=None)

source code 

Return information about the node.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters, not used in this class
Returns:
a dict as returned by BaseHypervisor.GetLinuxNodeInfo plus the following keys:
  • hv_version: the hypervisor version in the form (major, minor, revision)
Overrides: hv_base.BaseHypervisor.GetNodeInfo

GetInstanceConsole(cls, instance, primary_node, node_group, hvparams, beparams)
Class Method

source code 

Return a command for connecting to the console of an instance.

Overrides: hv_base.BaseHypervisor.GetInstanceConsole

Verify(self, hvparams=None)

source code 

Verify the hypervisor.

Check that the required binaries exist.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters to be verified against, not used here
Returns:
Problem description if something is wrong, None otherwise
Overrides: hv_base.BaseHypervisor.Verify

CheckParameterSyntax(cls, hvparams)
Class Method

source code 

Check the given parameters for validity.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters
Raises:
Overrides: hv_base.BaseHypervisor.CheckParameterSyntax

ValidateParameters(cls, hvparams)
Class Method

source code 

Check the given parameters for validity.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters
Raises:
Overrides: hv_base.BaseHypervisor.ValidateParameters

PowercycleNode(cls, hvparams=None)
Class Method

source code 

KVM powercycle, just a wrapper over Linux powercycle.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters to be used on this node
Overrides: hv_base.BaseHypervisor.PowercycleNode

Class Variable Details [hide private]

_DIRS

Value:
[_ROOT_DIR, _PIDS_DIR, _UIDS_DIR, _CTRL_DIR, _CONF_DIR, _NICS_DIR, _CH\
ROOT_DIR, _CHROOT_QUARANTINE_DIR, _KEYMAP_DIR]

PARAMETERS

a dict of parameter name: check type; the check type is a five-tuple containing:
  • the required flag (boolean)
  • a function to check for syntax, that will be used in CheckParameterSyntax, in the master daemon process
  • an error message for the above function
  • a function to check for parameter validity on the remote node, in the ValidateParameters function
  • an error message for the above function
Value:
{constants.HV_KVM_PATH: hv_base.REQ_FILE_CHECK, constants.HV_KERNEL_PA\
TH: hv_base.OPT_FILE_CHECK, constants.HV_INITRD_PATH: hv_base.OPT_FILE\
_CHECK, constants.HV_ROOT_PATH: hv_base.NO_CHECK, constants.HV_KERNEL_\
ARGS: hv_base.NO_CHECK, constants.HV_ACPI: hv_base.NO_CHECK, constants\
.HV_SERIAL_CONSOLE: hv_base.NO_CHECK, constants.HV_SERIAL_SPEED: hv_ba\
se.NO_CHECK, constants.HV_VNC_BIND_ADDRESS: hv_base.NO_CHECK, constant\
s.HV_VNC_TLS: hv_base.NO_CHECK, constants.HV_VNC_X509: hv_base.OPT_DIR\
_CHECK, constants.HV_VNC_X509_VERIFY: hv_base.NO_CHECK, constants.HV_V\
...

_MIGRATION_STATUS_RE

Value:
re.compile(r"Migration\s+status:\s+(\w+)", re.M | re.I)

_MIGRATION_PROGRESS_RE

Value:
re.compile(r"\s*transferred\s+ram:\s+(?P<transferred>\d+)\s+kbytes\s*\\
n" r"\s*remaining\s+ram:\s+(?P<remaining>\d+)\s+kbytes\s*\n" r"\s*tota\
l\s+ram:\s+(?P<total>\d+)\s+kbytes\s*\n", re.I)

_CPU_INFO_RE

Value:
re.compile(r"cpu\s+\#(\d+).*thread_id\s*=\s*(\d+)", re.I)

_DEFAULT_MACHINE_VERSION_RE

Value:
re.compile(r"^(\S+).*\(default\)", re.M)

_CHECK_MACHINE_VERSION_RE

Value:
staticmethod(lambda x: re.compile(r"^(%s)[ ]+.*PC" % x, re.M))

_VIRTIO_NET_QUEUES_RE

Value:
re.compile(r"^-net\s.*,fds=x:y:...:z", re.M)

_DEVICE_DRIVER_SUPPORTED

Value:
staticmethod(lambda drv, devlist: re.compile(r"^name \"%s\"" % drv, re\
.M).search(devlist))

_BOOT_RE

Value:
re.compile(r"^-drive\s([^-]|(?<!^)-)*,boot=on\|off", re.M | re.S)

_INFO_VERSION_RE

Value:
re.compile(r'^QEMU (\d+)\.(\d+)(\.(\d+))?.*monitor.*', re.M)

_KVMOPTS_CMDS

Value:
{_KVMOPT_HELP:(["--help"], False), _KVMOPT_MLIST:(["-M", "?"], False),\
 _KVMOPT_DEVICELIST:(["-device", "?"], True),}