Skip to content

Commit

Permalink
libvirt: enable apic setting for Xen or KVM guest.
Browse files Browse the repository at this point in the history
Bug 1086352

Currently, nova doesn't enable apic setting for Xen or KVM guest
in its libvirt driver. Windows guests would not boot successful in
such case. This patch adds apic setting in libvirt driver for Xen
or KVM guest, which would fix this problem. A check is also added
to libvirt guest config test case for this patch.

Change-Id: Ie213c9d086f77faf0cdc5a32337c5bf4b828cf5f
  • Loading branch information
yufang521247 committed Dec 10, 2012
1 parent ca1a256 commit d0e930b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions nova/tests/test_libvirt.py
Expand Up @@ -652,6 +652,7 @@ def test_get_guest_config(self):
_fake_network_info(self.stubs, 1),
None, None)
self.assertEquals(cfg.acpi, True)
self.assertEquals(cfg.apic, True)
self.assertEquals(cfg.memory, 1024 * 1024 * 2)
self.assertEquals(cfg.vcpus, 1)
self.assertEquals(cfg.os_type, vm_mode.HVM)
Expand Down
12 changes: 12 additions & 0 deletions nova/tests/test_libvirt_config.py
Expand Up @@ -632,6 +632,8 @@ def test_config_xen_hvm(self):
obj.os_loader = '/usr/lib/xen/boot/hvmloader'
obj.os_root = "root=xvda"
obj.os_cmdline = "console=xvc0"
obj.acpi = True
obj.apic = True

disk = config.LibvirtConfigGuestDisk()
disk.source_type = "file"
Expand All @@ -654,6 +656,10 @@ def test_config_xen_hvm(self):
<cmdline>console=xvc0</cmdline>
<root>root=xvda</root>
</os>
<features>
<acpi/>
<apic/>
</features>
<devices>
<disk type="file" device="disk">
<source file="/tmp/img"/>
Expand All @@ -671,6 +677,8 @@ def test_config_kvm(self):
obj.uuid = "b38a3f43-4be2-4046-897f-b67c2f5e0147"
obj.os_type = "linux"
obj.os_boot_dev = "hd"
obj.acpi = True
obj.apic = True

disk = config.LibvirtConfigGuestDisk()
disk.source_type = "file"
Expand All @@ -691,6 +699,10 @@ def test_config_kvm(self):
<type>linux</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<devices>
<disk type="file" device="disk">
<source file="/tmp/img"/>
Expand Down
8 changes: 6 additions & 2 deletions nova/virt/libvirt/config.py
Expand Up @@ -587,6 +587,7 @@ def __init__(self, **kwargs):
self.vcpus = 1
self.cpu = None
self.acpi = False
self.apic = False
self.clock = None
self.os_type = None
self.os_loader = None
Expand Down Expand Up @@ -624,9 +625,12 @@ def _format_os(self, root):
root.append(os)

def _format_features(self, root):
if self.acpi:
if self.acpi or self.apic:
features = etree.Element("features")
features.append(etree.Element("acpi"))
if self.acpi:
features.append(etree.Element("acpi"))
if self.apic:
features.append(etree.Element("apic"))
root.append(features)

def _format_devices(self, root):
Expand Down
1 change: 1 addition & 0 deletions nova/virt/libvirt/driver.py
Expand Up @@ -1795,6 +1795,7 @@ def get_guest_config(self, instance, network_info, image_meta, rescue=None,

if CONF.libvirt_type != "lxc" and CONF.libvirt_type != "uml":
guest.acpi = True
guest.apic = True

clk = vconfig.LibvirtConfigGuestClock()
clk.offset = "utc"
Expand Down

0 comments on commit d0e930b

Please sign in to comment.