Add KVM machine version as hv param
authorDimitris Aragiorgis <dimara@grnet.gr>
Tue, 15 Jan 2013 01:56:48 +0000 (03:56 +0200)
committerGuido Trotter <ultrotter@google.com>
Wed, 16 Jan 2013 11:06:46 +0000 (12:06 +0100)
This is needed in case an instance must be booted with an exact type of
machine version (due to e.g. outdated drivers). If this hv param
explicitly defined (during instance creation/modification) then the kvm
process will be started having this version for the -M option. Otherwise
the default (derived from _GetDefaultMachineVersion() will be used.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/constants.py
lib/hypervisor/hv_kvm.py
man/gnt-instance.rst

index b24c055..c036ba4 100644 (file)
@@ -834,6 +834,7 @@ HV_SOUNDHW = "soundhw"
 HV_USB_DEVICES = "usb_devices"
 HV_VGA = "vga"
 HV_KVM_EXTRA = "kvm_extra"
+HV_KVM_MACHINE_VERSION = "machine_version"
 
 
 HVS_PARAMETER_TYPES = {
@@ -901,6 +902,7 @@ HVS_PARAMETER_TYPES = {
   HV_USB_DEVICES: VTYPE_STRING,
   HV_VGA: VTYPE_STRING,
   HV_KVM_EXTRA: VTYPE_STRING,
+  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
   }
 
 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
@@ -1972,6 +1974,7 @@ HVC_DEFAULTS = {
     HV_USB_DEVICES: "",
     HV_VGA: "",
     HV_KVM_EXTRA: "",
+    HV_KVM_MACHINE_VERSION: "",
     },
   HT_FAKE: {},
   HT_CHROOT: {
index 16f105a..2e7fda4 100644 (file)
@@ -539,6 +539,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     constants.HV_USB_DEVICES: hv_base.NO_CHECK,
     constants.HV_VGA: hv_base.NO_CHECK,
     constants.HV_KVM_EXTRA: hv_base.NO_CHECK,
+    constants.HV_KVM_MACHINE_VERSION: hv_base.NO_CHECK,
     }
 
   _MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)",
@@ -1025,7 +1026,6 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     pidfile = self._InstancePidFile(instance.name)
     kvm = constants.KVM_PATH
     kvm_cmd = [kvm]
-    kvm_cmd.extend(["-M", self._GetDefaultMachineVersion()])
     # used just by the vnc server, if enabled
     kvm_cmd.extend(["-name", instance.name])
     kvm_cmd.extend(["-m", instance.beparams[constants.BE_MAXMEM]])
@@ -1049,6 +1049,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
         constants.INSTANCE_REBOOT_EXIT:
       kvm_cmd.extend(["-no-reboot"])
 
+    mversion = hvp[constants.HV_KVM_MACHINE_VERSION]
+    if not mversion:
+      mversion = self._GetDefaultMachineVersion()
+    kvm_cmd.extend(["-M", mversion])
+
     kernel_path = hvp[constants.HV_KERNEL_PATH]
     if kernel_path:
       boot_disk = boot_cdrom = boot_floppy = boot_network = False
index 0d6b931..c33c559 100644 (file)
@@ -674,6 +674,12 @@ kvm\_extra
     Any other option to the KVM hypervisor, useful tweaking anything
     that Ganeti doesn't support.
 
+machine\_version
+    Valid for the KVM hypervisor.
+
+    Use in case an instance must be booted with an exact type of
+    machine version (due to e.g. outdated drivers). In case it's not set
+    the default version supported by your version of kvm is used.
 
 The ``-O (--os-parameters)`` option allows customisation of the OS
 parameters. The actual parameter names and values depends on the OS