Don't add ",boot=on" to disks on kvm >= 0.14
authorGuido Trotter <ultrotter@google.com>
Thu, 9 Jun 2011 09:01:30 +0000 (09:01 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 23 Jun 2011 13:51:42 +0000 (14:51 +0100)
Under newer kvm this prevents the vm from starting.
Ah, change!

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/hypervisor/hv_kvm.py

index 6df67df..e65d330 100644 (file)
@@ -506,6 +506,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     """Generate KVM information to start an instance.
 
     """
+    kvm_version = self._GetKVMVersion()
+    if kvm_version:
+      _, v_major, v_min, _ = kvm_version
+    else:
+      raise errors.HypervisorError("Unable to get KVM version")
+
     pidfile  = self._InstancePidFile(instance.name)
     kvm = constants.KVM_PATH
     kvm_cmd = [kvm]
@@ -548,16 +554,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
         raise errors.HypervisorError("Instance has read-only disks which"
                                      " are not supported by KVM")
       # TODO: handle FD_LOOP and FD_BLKTAP (?)
+      boot_val = ""
       if boot_disk:
         kvm_cmd.extend(['-boot', 'c'])
-        if disk_type != constants.HT_DISK_IDE:
-          boot_val = ',boot=on'
-        else:
-          boot_val = ''
-        # We only boot from the first disk
         boot_disk = False
-      else:
-        boot_val = ''
+        if (v_major, v_min) < (0, 14) and disk_type != constants.HT_DISK_IDE:
+          boot_val = ",boot=on"
 
       drive_val = 'file=%s,format=raw%s%s%s' % (dev_path, if_val, boot_val,
                                                 cache_val)