From 1213604d604c19e58c058b0ba435ab66941a489f Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 9 Feb 2009 15:16:20 +0000 Subject: [PATCH] KVM: actually support different disk types 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index dd60fbe9f..3ba752936 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -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]) -- GitLab