This fixes Issue 225. Signed-off-by: Guido Trotter <ultrot...@google.com> --- lib/constants.py | 3 +++ lib/hypervisor/hv_kvm.py | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/lib/constants.py b/lib/constants.py index b24c055..2547cda 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -834,9 +834,11 @@ HV_SOUNDHW = "soundhw" HV_USB_DEVICES = "usb_devices" HV_VGA = "vga" HV_KVM_EXTRA = "kvm_extra" +HV_KVM_PATH = "kvm_path" HVS_PARAMETER_TYPES = { + HV_KVM_PATH: VTYPE_STRING, HV_BOOT_ORDER: VTYPE_STRING, HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING, HV_CDROM_IMAGE_PATH: VTYPE_STRING, @@ -1918,6 +1920,7 @@ HVC_DEFAULTS = { HV_CPU_WEIGHT: 256, }, HT_KVM: { + HV_KVM_PATH: KVM_PATH, HV_KERNEL_PATH: KVM_KERNEL, HV_INITRD_PATH: "", HV_KERNEL_ARGS: "ro", diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 24023ba..277d525 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -460,6 +460,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): _CHROOT_DIR, _CHROOT_QUARANTINE_DIR, _KEYMAP_DIR] PARAMETERS = { + constants.HV_KVM_PATH: hv_base.REQ_FILE_CHECK, constants.HV_KERNEL_PATH: hv_base.OPT_FILE_CHECK, constants.HV_INITRD_PATH: hv_base.OPT_FILE_CHECK, constants.HV_ROOT_PATH: hv_base.NO_CHECK, @@ -1024,9 +1025,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): hvp = instance.hvparams pidfile = self._InstancePidFile(instance.name) - kvm = constants.KVM_PATH + kvm = hvp[constants.HV_KVM_PATH] kvm_cmd = [kvm] - kvm_cmd.extend(["-M", self._GetDefaultMachineVersion(constants.KVM_PATH)]) + kvm_cmd.extend(["-M", self._GetDefaultMachineVersion(kvm)]) # used just by the vnc server, if enabled kvm_cmd.extend(["-name", instance.name]) kvm_cmd.extend(["-m", instance.beparams[constants.BE_MAXMEM]]) @@ -1451,6 +1452,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): kvm_cmd, kvm_nics, up_hvp = kvm_runtime up_hvp = objects.FillDict(conf_hvp, up_hvp) + # Replace kvm command with the newest configured one. + kvm_cmd[0] = conf_hvp[constants.HV_KVM_PATH] + _, v_major, v_min, _ = self._ParseKVMVersion(kvmhelp) # We know it's safe to run as a different user upon migration, so we'll use @@ -1632,7 +1636,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ self._CheckDown(instance.name) - kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH) + kvmpath = instance.hvparams[constants.HV_KVM_PATH] + kvmhelp = self._GetKVMHelpOutput(kvmpath) kvm_runtime = self._GenerateKVMRuntime(instance, block_devices, startup_paused, kvmhelp) self._SaveKVMRuntime(instance, kvm_runtime) @@ -1762,7 +1767,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): self.StopInstance(instance, force=True) # ...and finally we can save it again, and execute it... self._SaveKVMRuntime(instance, kvm_runtime) - kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH) + kvmpath = instance.hvparams[constants.HV_KVM_PATH] + kvmhelp = self._GetKVMHelpOutput(kvmpath) self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp) def MigrationInfo(self, instance): @@ -1789,7 +1795,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info) incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT]) - kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH) + kvmpath = instance.hvparams[constants.HV_KVM_PATH] + kvmhelp = self._GetKVMHelpOutput(kvmpath) self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp, incoming=incoming_address) @@ -1938,6 +1945,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ result = self.GetLinuxNodeInfo() + # FIXME: this is the global kvm version, but the actual version can be + # customized as an hv parameter. we should use the nodegroup's default kvm + # path parameter here. _, v_major, v_min, v_rev = self._GetKVMVersion(constants.KVM_PATH) result[constants.HV_NODEINFO_KEY_VERSION] = (v_major, v_min, v_rev) return result @@ -1986,6 +1996,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): Check that the binary exists. """ + # FIXME: this is the global kvm version, but the actual version can be + # customized as an hv parameter. we should use the nodegroup's default kvm + # path parameter here. if not os.path.exists(constants.KVM_PATH): return "The kvm binary ('%s') does not exist." % constants.KVM_PATH if not os.path.exists(constants.SOCAT_PATH): @@ -2093,7 +2106,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): " given time.") # check that KVM supports spice - kvmhelp = cls._GetKVMHelpOutput(constants.KVM_PATH) + kvmhelp = cls._GetKVMHelpOutput(hvparams[constants.HV_KVM_PATH]) if not cls._SPICE_RE.search(kvmhelp): raise errors.HypervisorError("spice is configured, but it is not" " supported according to kvm --help") -- 1.7.10.4