summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorChristoph Thiel <cthiel@suse.com>2012-07-26 00:07:24 +0200
committerChristoph Thiel <cthiel@suse.com>2012-07-26 11:03:00 +0200
commit158d821204d2f79cc06c1443562b3ce9bbe7cb9f (patch)
tree05bbdfa33d47d048ff5e5c23e82b9636108503e7 /nova/virt
parente238e07692c747ddcb0c70452578a812836cea67 (diff)
libvirt driver: set os_type to support xen hvm/pv
Generate libvirt config for xen hvm and pv guests based on instance vm_mode. The vm_mode can be set via the vm_mode image property. Use hvmloader for vm_mode.HVM guests. libvirt_type xen still defaults to vm_mode.XEN (pv), to not change any behavior. Change-Id: I5f92bedf6588ab2674d784772a5ecdb895fabe40
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/libvirt/config.py3
-rw-r--r--nova/virt/libvirt/driver.py18
2 files changed, 19 insertions, 2 deletions
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py
index da55dc234..a53ed640f 100644
--- a/nova/virt/libvirt/config.py
+++ b/nova/virt/libvirt/config.py
@@ -575,6 +575,7 @@ class LibvirtConfigGuest(LibvirtConfigObject):
self.acpi = False
self.clock = None
self.os_type = None
+ self.os_loader = None
self.os_kernel = None
self.os_initrd = None
self.os_cmdline = None
@@ -594,6 +595,8 @@ class LibvirtConfigGuest(LibvirtConfigObject):
os.append(self._text_node("type", self.os_type))
if self.os_kernel is not None:
os.append(self._text_node("kernel", self.os_kernel))
+ if self.os_loader is not None:
+ os.append(self._text_node("loader", self.os_loader))
if self.os_initrd is not None:
os.append(self._text_node("initrd", self.os_initrd))
if self.os_cmdline is not None:
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index f0ffa895c..9fcb61c3e 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -1713,6 +1713,21 @@ class LibvirtDriver(driver.ComputeDriver):
nova_context.get_admin_context(), instance['uuid'],
{'root_device_name': '/dev/' + self.default_root_device})
+ guest.os_type = vm_mode.get_from_instance(instance)
+
+ if guest.os_type is None:
+ if FLAGS.libvirt_type == "lxc":
+ guest.os_type = vm_mode.EXE
+ elif FLAGS.libvirt_type == "uml":
+ guest.os_type = vm_mode.UML
+ elif FLAGS.libvirt_type == "xen":
+ guest.os_type = vm_mode.XEN
+ else:
+ guest.os_type = vm_mode.HVM
+
+ if FLAGS.libvirt_type == "xen" and guest.os_type == vm_mode.HVM:
+ guest.os_loader = '/usr/lib/xen/boot/hvmloader'
+
if FLAGS.libvirt_type == "lxc":
guest.os_type = vm_mode.EXE
guest.os_init_path = "/sbin/init"
@@ -1723,7 +1738,6 @@ class LibvirtDriver(driver.ComputeDriver):
guest.os_root = root_device_name or "/dev/ubda"
else:
if FLAGS.libvirt_type == "xen":
- guest.os_type = vm_mode.XEN
guest.os_root = root_device_name or "/dev/xvda"
else:
guest.os_type = vm_mode.HVM
@@ -1808,7 +1822,7 @@ class LibvirtDriver(driver.ComputeDriver):
guest.add_device(consolepty)
if FLAGS.vnc_enabled and FLAGS.libvirt_type not in ('lxc', 'uml'):
- if FLAGS.use_usb_tablet:
+ if FLAGS.use_usb_tablet and guest.os_type == vm_mode.HVM:
tablet = config.LibvirtConfigGuestInput()
tablet.type = "tablet"
tablet.bus = "usb"