diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2012-07-25 13:32:28 +0100 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2012-07-25 17:19:13 +0100 |
| commit | eb074328041b5f8b4f5a109794c54a9bd4e245ed (patch) | |
| tree | 0d1da907a20f2bcde7809c855cc2c60ab1038275 /nova/virt | |
| parent | b8aedb281f8e6cc8b1583640c31f5d52ce5e4eac (diff) | |
Define cross-driver standardized vm_mode values
Currently the XenAPI driver allows for a 'vm_mode' parameter to
be set against an instance to determine whether it is launched
a paravirt or fullvirt domain. This allows the values 'pv', 'hv'
and 'hvm'.
The libvirt driver also needs to be extended to allow a 'vm_mode'
parameter, and to facilitate deployment of heterogeneous Nova
compute farms, it is desirable to have standardization of the
VM mode values across all drivers.
To address this, the nova.compute.vm_mode module is introduced
which defines a set of constants. The constants provide four
possible vm modes:
- vm_mode.XEN = 'xen' - for Xen 3.0 paravirt ABI
- vm_mode.HVM = 'hvm' - for native ABI
- vm_mode.UML = 'uml' - for User Mode Linux paravirt ABI
- vm_mode.EXE = 'exe' - for container virt executable ABI
The existing 'pv' value from XenAPI is deprecated, because it
is ambiguous - both Xen and UML are paravirt, and other
paravirt hypervisor ABIs also exist
The existing 'hv' value is also deprecated since it duplicates
the other existing 'hvm' value.
The 'vm_mode.get_from_instance' method will extract the
vm_mode value for an instance. It normalizes the value to
all lower case, translates 'hv' and 'pv' into the new
values for back compat, and validates that the value
matches one of the defined constants
The XenAPI and libvirt drivers are then updated to use the
nova.compute.vm_mode constants instead of bare strings.
The test_xenapi.py test case is updated to set 'vm_mode'
to exercise the new codepaths. A new test_vmmode.py
case is also written to fully exercise the logic
NB, previously the libvirt driver would set 'guest.os_type'
to 'linux' to request Xen paravirt. This is a legacy value,
with libvirt preferring the string 'xen'. So although the
new code sets a different value for Xen paravirt os_type,
the functional result is unchanged.
DocImpact
blueprint hypervisor-code-consolidation
Change-Id: I23efc5dc1528b0d8472d752a8a30f55c85310b21
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt/driver.py | 9 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 14 |
2 files changed, 12 insertions, 11 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index e9c7754b1..d84388be0 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -57,6 +57,7 @@ from xml.dom import minidom from nova import block_device from nova.compute import instance_types from nova.compute import power_state +from nova.compute import vm_mode from nova import context as nova_context from nova import db from nova import exception @@ -1712,19 +1713,19 @@ class LibvirtDriver(driver.ComputeDriver): {'root_device_name': '/dev/' + self.default_root_device}) if FLAGS.libvirt_type == "lxc": - guest.os_type = "exe" + guest.os_type = vm_mode.EXE guest.os_init_path = "/sbin/init" guest.os_cmdline = "console=ttyS0" elif FLAGS.libvirt_type == "uml": - guest.os_type = "uml" + guest.os_type = vm_mode.UML guest.os_kernel = "/usr/bin/linux" guest.os_root = root_device_name or "/dev/ubda" else: if FLAGS.libvirt_type == "xen": - guest.os_type = "linux" + guest.os_type = vm_mode.XEN guest.os_root = root_device_name or "/dev/xvda" else: - guest.os_type = "hvm" + guest.os_type = vm_mode.HVM if rescue: if rescue.get('kernel_id'): diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 785cd614c..4a51010e6 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -31,6 +31,7 @@ import netaddr from nova.compute import api as compute from nova.compute import power_state +from nova.compute import vm_mode from nova import context as nova_context from nova import db from nova import exception @@ -381,21 +382,20 @@ class VMOps(object): disk_image_type = vm_utils.determine_disk_image_type(image_meta) - vm_mode = instance.vm_mode and instance.vm_mode.lower() - if vm_mode == 'pv': + mode = vm_mode.get_from_instance(instance) + if mode == vm_mode.XEN: use_pv_kernel = True - elif vm_mode in ('hv', 'hvm'): + elif mode == vm_mode.HVM: use_pv_kernel = False - vm_mode = 'hvm' # Normalize else: use_pv_kernel = vm_utils.determine_is_pv(self._session, vdis['root']['ref'], disk_image_type, instance.os_type) - vm_mode = use_pv_kernel and 'pv' or 'hvm' + mode = use_pv_kernel and vm_mode.XEN or vm_mode.HVM - if instance.vm_mode != vm_mode: + if instance.vm_mode != mode: # Update database with normalized (or determined) value db.instance_update(nova_context.get_admin_context(), - instance['uuid'], {'vm_mode': vm_mode}) + instance['uuid'], {'vm_mode': mode}) vm_ref = vm_utils.create_vm( self._session, instance, kernel_file, ramdisk_file, |
