Commit d34b16d7 authored by Iustin Pop's avatar Iustin Pop
Browse files

Actually mark drives as read-only if so configured

This patch correctly marks the drives as read-only for Xen, and raises
and exception for KVM since it doesn't support read-only drives.

Reviewed-by: ultrotter
parent df0fb067
......@@ -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'
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment