diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 22cbdc5c914ef53e1d3817c33854e710d449bd8b..13bc8d4ab6e5e0b730ad313d022ec613405ee058 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -222,6 +222,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): boot_drive = True for cfdev, dev_path in block_devices: + if cfdev.mode != constants.DISK_RDWR: + raise errors.HypervisorError("Instance has read-only disks which" + " are not supported by KVM") # TODO: handle FD_LOOP and FD_BLKTAP (?) if boot_drive: boot_val = ',boot=on' diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 506f200b1125d1c5ea12d3eea54efe3e26808d86..c8dd58107128074323c0e83cf5463848a3316d5a 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -277,11 +277,15 @@ class XenHypervisor(hv_base.BaseHypervisor): # directly export their info (currently HVM will just sed this info) namespace = ["sd" + chr(i + ord('a')) for i in range(24)] for sd_name, (cfdev, dev_path) in zip(namespace, block_devices): + if cfdev.mode == constants.DISK_RDWR: + mode = "w" + else: + mode = "r" if cfdev.dev_type == constants.LD_FILE: - line = "'%s:%s,%s,w'" % (FILE_DRIVER_MAP[cfdev.physical_id[0]], - dev_path, sd_name) + line = "'%s:%s,%s,%s'" % (FILE_DRIVER_MAP[cfdev.physical_id[0]], + dev_path, sd_name, mode) else: - line = "'phy:%s,%s,w'" % (dev_path, sd_name) + line = "'phy:%s,%s,%s'" % (dev_path, sd_name, mode) disk_data.append(line) return disk_data