« Previous | Next » 

Revision 2becae3f

ID2becae3fca1a47358f76245f54225bc0b99d20ac

Added by Dimitris Aragiorgis almost 9 years ago

Hotplug: KVM support

KVM >= 1.0 is needed.

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

Only paravirtual devices are hotplug-able. QEMU monitor expects them
to be uniquely named. For newly added devices Hypervisor parses
existing PCI allocations (via info pci monitor command) and decides
the PCI slot to plug in the device. For this reason
_AnnotateFreePCISlot() is used. Note that this is used during
instance startup as well but reservations derive from KVM default
setup, that allocates 4 slots for devices other than disks and NICs.
The pci info is used for device naming and is stored in runtime files
in order device names can be reproduce-able when we want to remove
them.

If no hotplug takes place (old KVM, not paravirtual device, or
existing device with no pci info inside runtime file)
modifications will take place after reboot.

Device ids derive from the following function:
kvm_devid = <device_type>-pci-<pci_slot>

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.

Do not try hotplug in some cases

In case fdsend module is not installed NIC hotplug is not
supported.
In case of chroot and security model other than None disk
hotplug is not supported.

Signed-off-by: Dimitris Aragiorgis <>

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences