KVM: actually support different disk types
authorGuido Trotter <ultrotter@google.com>
Mon, 9 Feb 2009 15:16:20 +0000 (15:16 +0000)
committerGuido Trotter <ultrotter@google.com>
Mon, 9 Feb 2009 15:16:20 +0000 (15:16 +0000)
By passing the relevant if= value to the disk we support different disk
types. The only change is that we'll translate "paravirtual" to
"virtio" to keep only one "paravirtualized" value, around ganeti. The
if= value is calculated outside the disks loop, as it's the same for all
disks (as currently ganeti doesn't support per-disk params).

Reviewed-by: iustinp

lib/hypervisor/hv_kvm.py

index dd60fbe..3ba7529 100644 (file)
@@ -236,6 +236,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     boot_disk = (instance.hvparams[constants.HV_BOOT_ORDER] == "disk")
     boot_cdrom = (instance.hvparams[constants.HV_BOOT_ORDER] == "cdrom")
+
+    disk_type = instance.hvparams[constants.HV_DISK_TYPE]
+    if disk_type == constants.HT_DISK_PARAVIRTUAL:
+      if_val = ',if=virtio'
+    else:
+      if_val = ',if=%s' % disk_type
     for cfdev, dev_path in block_devices:
       if cfdev.mode != constants.DISK_RDWR:
         raise errors.HypervisorError("Instance has read-only disks which"
@@ -248,9 +254,6 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       else:
         boot_val = ''
 
-      # TODO: handle different if= types
-      if_val = ',if=virtio'
-
       drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
       kvm_cmd.extend(['-drive', drive_val])