class KVMHypervisor(hv_base.BaseHypervisor):
KVM hypervisor interface
Class Method |
|
Check the given parameters for validity. |
Class Method |
|
Return a command for connecting to the console of an instance. |
Class Method |
|
KVM powercycle, just a wrapper over Linux powercycle. |
Class Method |
|
Check the given parameters for validity. |
Static Method |
|
Predict if migration is safe between those versions |
Method | __init__ |
Undocumented |
Method |
|
Prepare to accept an instance. |
Method |
|
Balloon an instance memory to a certain value. |
Method |
|
Cleanup after a stopped instance |
Method |
|
Finalize the instance migration on the target node. |
Method |
|
Finalize the instance migration on the source node. |
Method |
|
Get properties of all instances. |
Method |
|
Get instance properties. |
Method |
|
Get the migration status |
Method |
|
Return information about the node. |
Method |
|
Helper method to hot-add a new device |
Method |
|
Helper method for hot-del device |
Method |
|
Helper method for hot-mod device |
Method |
|
Checks if hotplug is generally supported. |
Method |
|
Get the list of running instances. |
Method |
|
Migrate an instance to a target node. |
Method |
|
Get instance information to perform a migration. |
Method |
|
Reboot an instance. |
Method |
|
Start an instance. |
Method |
|
Stop an instance. |
Method |
|
Verify the hypervisor. |
Method |
|
Verifies that hotplug is supported. |
Constant | ANCILLARY |
Undocumented |
Constant | ANCILLARY |
Undocumented |
Constant | CAN |
Undocumented |
Constant | PARAMETERS |
Undocumented |
Instance Variable | qmp |
Undocumented |
Class Method | _ |
Change CPU affinity for running VM according to given CPU mask. |
Class Method | _ |
Invoke a command on the instance monitor. |
Class Method | _ |
Raises an error unless the given instance is down. |
Class Method | _ |
Undocumented |
Class Method | _ |
Return the default hardware revision (e.g. pc-1.1) |
Class Method | _ |
Return the output of a kvm invocation |
Class Method | _ |
Return the installed KVM version. |
Class Method | _ |
Returns the name of the KVM chroot dir of the instance |
Class Method | _ |
Returns the instance kvm daemon socket name |
Class Method | _ |
Returns the instance KVM runtime filename |
Class Method | _ |
Returns the instance monitor socket name |
Class Method | _ |
Returns the name of the directory holding the tap device files for a given instance. |
Class Method | _ |
Returns the name of the file containing the tap device for a given NIC |
Class Method | _ |
Returns the instance pidfile, pid, and liveness. |
Class Method | _ |
Returns the instance pidfile. |
Class Method | _ |
Check pid file for instance information. |
Class Method | _ |
Returns the instance serial QEMU Guest Agent socket name |
Class Method | _ |
Returns the instance serial QMP socket name |
Class Method | _ |
Returns the instance serial socket name |
Class Method | _ |
Returns the instance QMP output filename |
Class Method | _ |
Returns the instance uidfile. |
Class Method | _ |
Undocumented |
Class Method | _ |
Parse the KVM version from the --help output. |
Class Method | _ |
Removes an instance's rutime sockets/files/dirs. |
Class Method | _ |
Sets the affinity of a process to the given CPUs. |
Class Method | _ |
Try to read a uid file |
Static Method | _ |
Extends kvm_cmd with the '-drive' option for a cdrom, and optionally the '-boot' option. |
Static Method | _ |
Run the network configuration script for a specified NIC |
Static Method | _ |
Generate appropriate aio/cache parameters for QEMU |
Static Method | _ |
Generate a TAP network interface name for a NIC. |
Static Method | _ |
Returns the correct parameters for socat |
Static Method | _ |
Ensure that the Kvm daemon is running. |
Method | _ |
Clear all migration capabilities configured for an instance |
Method | _ |
Configures all NICs in routed mode |
Method | _ |
Complete CPU pinning. |
Method | _ |
Execute a KVM cmd, after completing it with some last minute data. |
Method | _ |
Generate KVM options regarding instance's block devices. |
Method | _ |
Generate KVM information to start an instance. |
Method | _ |
Helper function to get the slots of PCI and SCSI QEMU buses. |
Method | _ |
Get network device options to properly enable supported features. |
Method | _ |
Get a mapping of vCPU no. to thread IDs for the instance |
Method | _ |
Load an instance's KVM runtime |
Method | _ |
Read an instance's KVM runtime |
Method | _ |
Run the KVM cmd and check for errors |
Method | _ |
Save an instance's KVM runtime |
Method | _ |
Set all migration capabilities configured for an instance |
Method | _ |
Stop an instance. |
Method | _ |
Checks if a previous hotplug command has succeeded. |
Method | _ |
Write an instance's KVM runtime |
Constant | _AUTO |
Undocumented |
Constant | _BOOT |
Undocumented |
Constant | _CHROOT |
Undocumented |
Constant | _CHROOT |
Undocumented |
Constant | _CONF |
Undocumented |
Constant | _CTRL |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEFAULT |
Undocumented |
Constant | _DEVICE |
Undocumented |
Constant | _DIRS |
Undocumented |
Constant | _DISABLE |
Undocumented |
Constant | _DISPLAY |
Undocumented |
Constant | _ENABLE |
Undocumented |
Constant | _KVMOPT |
Undocumented |
Constant | _KVMOPT |
Undocumented |
Constant | _KVMOPT |
Undocumented |
Constant | _KVMOPTS |
Undocumented |
Constant | _MACHINE |
Undocumented |
Constant | _MIGRATION |
Undocumented |
Constant | _MIGRATION |
Undocumented |
Constant | _NETDEV |
Undocumented |
Constant | _NICS |
Undocumented |
Constant | _PIDS |
Undocumented |
Constant | _QMP |
Undocumented |
Constant | _ROOT |
Undocumented |
Constant | _UIDS |
Undocumented |
Constant | _UUID |
Undocumented |
Constant | _VERSION |
Undocumented |
Constant | _VHOST |
Undocumented |
Constant | _VIRTIO |
Undocumented |
Constant | _VIRTIO |
Undocumented |
Constant | _VIRTIO |
Undocumented |
Constant | _VIRTIO |
Undocumented |
Inherited from BaseHypervisor
:
Class Method |
|
Return a list of ancillary files to be copied to all nodes as ancillary configuration files. |
Class Method |
|
Linux-specific powercycle method. |
Static Method |
|
For linux systems, return actual OS information. |
Method |
|
Fixup running instance's (config) state. |
Method |
|
Verify if running instance (config) is in correct state. |
Class Method | _ |
Check if the parameter value is a kind of value meaning unspecified. |
Static Method | _ |
Formats the verification results, given a list of errors. |
Method | _ |
Get the correct startup memory for an instance |
Check the given parameters for validity.
Parameters | |
hvparams:dict of strings | hypervisor parameters |
Raises | |
errors.HypervisorError | when a parameter is not valid |
KVM powercycle, just a wrapper over Linux powercycle.
Parameters | |
hvparams:dict of strings | hypervisor parameters to be used on this node |
Check the given parameters for validity.
Parameters | |
hvparams:dict of strings | hypervisor parameters |
Raises | |
errors.HypervisorError | when a parameter is not valid |
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 |
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 |
Finalize the instance migration on the target node.
Stop the incoming mode KVM.
Parameters | |
instance:objects.Instance | instance whose migration is being finalized |
info | Undocumented |
success | Undocumented |
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 |
_ | Undocumented |
Get properties of all instances.
Parameters | |
hvparams:dict of strings | hypervisor parameters |
Returns | |
list of tuples (name, id, memory, vcpus, stat, times) |
Get instance properties.
Parameters | |
instance | 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) |
Get the migration status
Parameters | |
instance:objects.Instance | the instance that is being migrated |
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 |
Return information about the node.
Parameters | |
hvparams:dict of strings | hypervisor parameters, not used in this class |
Returns | |
a dict as returned by
|
Helper method to hot-add a new device
It generates the device ID and hvinfo, and invokes the device-specific method.
Helper method for hot-del device
It gets device info from runtime file, generates the device name and invokes the device-specific method.
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
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 | |
errors.HypervisorError | in one of the previous cases |
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.
Migrate an instance to a target node.
The migration will not be attempted if the instance is not currently running.
Parameters | |
cluster | name of the cluster |
instance:objects.Instance | the instance to be migrated |
target:string | ip address of the target node |
live | perform a live migration |
Get instance information to perform a migration.
Parameters | |
instance:objects.Instance | instance to be migrated |
Returns | |
string | content of the KVM runtime file |
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 |
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
Raises | |
errors.HypervisorError | if one of the above applies |
Undocumented
Change CPU affinity for running VM according to given CPU mask.
Parameters | |
cpu | CPU mask as given by the user. e.g. "0-2,4:all:1,3" |
process | process ID of KVM process. Used to pin entire VM to physical CPUs. |
thread | map of virtual CPUs to KVM thread IDs |
Return the output of a kvm invocation
Parameters | |
kvm | 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 | |
errors.HypervisorError | when the KVM help output cannot be retrieved |
Return the installed KVM version.
Returns | |
(version, v_maj, v_min, v_rev) | |
Raises | |
errors.HypervisorError | when the KVM version cannot be retrieved |
Returns the instance pidfile, pid, and liveness.
Parameters | |
instance | instance name |
Returns | |
tuple | (pid file name, pid, liveness) |
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 | |
errors.HypervisorError | when an instance cannot be found |
Parse the KVM version from the --help output.
Parameters | |
text:string | output of kvm --help |
Returns | |
(version, v_maj, v_min, v_rev) | |
Raises | |
errors.HypervisorError | when the KVM version cannot be retrieved |
Sets the affinity of a process to the given CPUs.
Parameters | |
process | Undocumented |
cpus:list of int | The list of CPUs the process ID may use. |
def _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.
Example: -drive file=cdrom.iso,media=cdrom,format=raw,if=ide -boot order=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 | KVM command line |
cdrom | |
cdrom | |
cdrom | |
needs |
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 |
Generate appropriate aio/cache parameters for QEMU
Parameters | |
disk | the instance's AIO parameter |
disk | the instance's disk cache parameter |
dev | the disk type in use |
Returns | |
string | parameter string suitable for QEMU drive parameters |
Generate a TAP network interface name for a NIC.
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 |
Returns the correct parameters for socat
If we have a new-enough socat we can use raw mode with an escape character.
Clear all migration capabilities configured for an instance
Parameters | |
instance:objects.Instance object | the VM this command acts upon |
Configures all NICs in routed mode
Parameters | |
instance:objects.Instance | the instance to be configured |
info:string | serialized KVM runtime info |
Complete CPU pinning.
Parameters | |
instance:objects.Instance object | instance in question |
cpu | CPU pinning mask as entered by user |
Execute a KVM cmd, after completing it with some last minute data.
Parameters | |
instance:objects.Instance object | the VM this command acts upon |
kvmobjects.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)..]) |
kvmhelp:string | output of kvm --help |
incoming:tuple of strings | (target_host_ip, port) for migration. |
Generate KVM options regarding instance's block devices.
Parameters | |
up | the instance's runtime hypervisor parameters |
kvm | 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 |
Generate KVM information to start an instance.
Parameters | |
instance | Undocumented |
block | Undocumented |
startup | Undocumented |
kvmhelp:string | output of kvm --help |
Unknown Field: 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 |
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.
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 |
Get a mapping of vCPU no. to thread IDs for the instance
Parameters | |
instance:objects.Instance object | instance in question |
Returns | |
dictionary of int:int | a dictionary mapping vCPU numbers to thread IDs |
Run the KVM cmd and check for errors
Parameters | |
name:string | instance name |
kvm | runcmd input for kvm |
tap | fds of tap devices opened by Ganeti |
Set all migration capabilities configured for an instance
Parameters | |
instance:objects.Instance object | the VM this command acts upon |
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.
Raises | |
errors.HypervisorError | if result is not the expected one |
Undocumented
Value |
|
Undocumented
Value |
|
Undocumented
Value |
|