This fixes Issue 225.

Signed-off-by: Guido Trotter <ultrot...@google.com>
---
 lib/constants.py         |    3 +++
 lib/hypervisor/hv_kvm.py |   21 +++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index bfe2046..02614b4 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -813,9 +813,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,
@@ -1897,6 +1899,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 3621382..01103da 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -1035,9 +1035,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]])
@@ -1641,7 +1641,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)
@@ -1771,7 +1772,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):
@@ -1798,7 +1800,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, incoming=incoming_address,
                             kvmhelp)
 
@@ -1947,6 +1950,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
@@ -1995,6 +2001,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):
@@ -2099,7 +2108,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
                                      " given time.")
 
       # check that KVM supports spice
-      kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
+      kvmhelp = self._GetKVMHelpOutput(hvparams[constants.HV_KVM_PATH])
       if not self._SPICE_RE.search(kvmhelp):
         raise errors.HypervisorError("spice is configured, but it is not"
                                      " supported according to kvm --help")
-- 
1.7.10.4

Reply via email to