« Previous | Next » 

Revision 6bf6870b

ID6bf6870ba2c904d9eeafc509e1fb2909e0fca29b

Added by Dimitris Aragiorgis over 10 years ago

Hotplug: KVM support

Hotplug will not be supported for:
- KVM < 1.0
- existing devices in the cluster
- python-fdsend module is not installed (NIC hotplug)
- chroot (Disk hotplug)
- security mode other than None (Disk hotplug)
If no hotplug takes place modifications will take place after reboot.

New methods:
Introduce new method HotplugDevice() and HotAddNic/HotDelNic,
HotAddDisk/HotDelDisk helper methods that eventually make use of
QEMU monitor interface for hotpluging.

Device naming:
QEMU monitor expects devices to be uniquely named. Device ids derive
from the following function:
kvm_devid = <device_type>-<part of uuid>-pci-<pci_slot>
Device ids must be reproduce-able when we want to remove them.
For that reason we store the pci slot inside the runtime file and
in case we want to remove a device we obtain its pci slot by
parsing the corresponding runtime enrty and matching the device
by its uuid.

Finding the PCI slot:
For newly added devices Hypervisor parses existing PCI allocations
(via _AnnotateFreePCISlot() and eventually ``info pci`` monitor
command) and decides the PCI slot to plug in the device. During
instance startup hypervisor invokes _UpdatePCISlots() for every
device of the instance. Initial PCI reservations derive from KVM
default setup, that allocates 4 slots for devices other than disks
and NICs.

NIC hotplug:
- open a tap and get its file descriptor.
- pass fd with SCM rights (using python-fdsend) via monitor socket
- create netdev and device with id=kvm_devid and proper pci info

Disk hotplug:
- create drive with id=kvm_devid
- create device with id=kvm_devid and corresponding pci info

In order to migrate a VM, an identical VM should be booted with
exactly the same pci configuration (and with -incoming option). PCI
info is passed via runtime file. To this end every time a hotplug
takes place runtime file must be updated.

Introduce _GenerateKVMBlockDevicesOptions():
The runtime file contains one more field: block_devices. kvm_cmd is extended
with block device options during _ExecuteKVMRuntime().

Handle old style format of runtime files:
In case block_devices are already encapsulated inside kvm_cmd
and runtime files have only 3 entries, set block_devices to [].
This way migration will not fail and hotplug will succeed for
new disks only.

Signed-off-by: Dimitris Aragiorgis <>

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences