diff --git a/lib/constants.py b/lib/constants.py index 0c44675a8d6aee0acf68493ea2a2cd26b149dd76..9d85e61931643cce6fbab11aaef3437231738182 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -287,6 +287,7 @@ HV_ACPI = "acpi" HV_PAE = "pae" HV_KERNEL_PATH = "kernel_path" HV_INITRD_PATH = "initrd_path" +HV_ROOT_PATH = "root_path" HVS_PARAMETERS = frozenset([ HV_BOOT_ORDER, @@ -298,6 +299,7 @@ HVS_PARAMETERS = frozenset([ HV_PAE, HV_KERNEL_PATH, HV_INITRD_PATH, + HV_ROOT_PATH, ]) # BE parameter names @@ -426,6 +428,7 @@ HVC_DEFAULTS = { HT_XEN_PVM: { HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU", HV_INITRD_PATH: None, + HV_ROOT_PATH: '/dev/sda', }, HT_XEN_HVM: { HV_BOOT_ORDER: "cd", @@ -439,6 +442,7 @@ HVC_DEFAULTS = { HT_KVM: { HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU", HV_INITRD_PATH: None, + HV_ROOT_PATH: '/dev/vda', HV_ACPI: True, }, HT_FAKE: { diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 0316b1ba58221fe35853ebc717deef4137e226d2..22cbdc5c914ef53e1d3817c33854e710d449bd8b 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -51,6 +51,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): PARAMETERS = [ constants.HV_KERNEL_PATH, constants.HV_INITRD_PATH, + constants.HV_ROOT_PATH, constants.HV_ACPI, ] @@ -240,7 +241,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): if initrd_path: kvm_cmd.extend(['-initrd', initrd_path]) - kvm_cmd.extend(['-append', 'console=ttyS0,38400 root=/dev/vda']) + root_path = instance.hvparams[constants.HV_ROOT_PATH] + kvm_cmd.extend(['-append', 'console=ttyS0,38400 root=%s ro' % root_path]) #"hvm_boot_order", #"hvm_cdrom_image_path", @@ -626,6 +628,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]): raise errors.HypervisorError("The kernel path must be an absolute path") + if not hvparams[constants.HV_ROOT_PATH]: + raise errors.HypervisorError("Need a root partition for the instance") + if hvparams[constants.HV_INITRD_PATH]: if not os.path.isabs(hvparams[constants.HV_INITRD_PATH]): raise errors.HypervisorError("The initrd path must be an absolute path" diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index f92b2fe6e5b1a92b7b325d7e68b1e287520f6286..5b71ff234b7ac8fdd441c4ffdf423ee4a0811be8 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -364,6 +364,7 @@ class XenPvmHypervisor(XenHypervisor): PARAMETERS = [ constants.HV_KERNEL_PATH, constants.HV_INITRD_PATH, + constants.HV_ROOT_PATH, ] @classmethod @@ -386,6 +387,9 @@ class XenPvmHypervisor(XenHypervisor): if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]): raise errors.HypervisorError("The kernel path must be an absolute path") + if not hvparams[constants.HV_ROOT_PATH]: + raise errors.HypervisorError("Need a root partition for the instance") + if hvparams[constants.HV_INITRD_PATH]: if not os.path.isabs(hvparams[constants.HV_INITRD_PATH]): raise errors.HypervisorError("The initrd path must be an absolute path" @@ -443,7 +447,9 @@ class XenPvmHypervisor(XenHypervisor): config.write("disk = [%s]\n" % ",".join( cls._GetConfigFileDiskData(instance.disk_template, block_devices))) - config.write("root = '/dev/sda ro'\n") + + rpath = instance.hvparams[constants.HV_ROOT_PATH] + config.write("root = '%s ro'\n" % rpath) config.write("on_poweroff = 'destroy'\n") config.write("on_reboot = 'restart'\n") config.write("on_crash = 'restart'\n")