Skip to content

Commit 9149ac6

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "workarounds: Add libvirt_disable_apic"
2 parents f372c84 + ec48e15 commit 9149ac6

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

nova/conf/workarounds.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,16 @@
353353
* :oslo.config:option:`DEFAULT.instances_path`
354354
* :oslo.config:option:`image_cache.subdirectory_name`
355355
* :oslo.config:option:`update_resources_interval`
356+
"""),
357+
cfg.BoolOpt('libvirt_disable_apic',
358+
default=False,
359+
help="""
360+
With some kernels initializing the guest apic can result in a kernel hang that
361+
renders the guest unusable. This happens as a result of a kernel bug. In most
362+
cases the correct fix it to update the guest image kernel to one that is
363+
patched however in some cases this is not possible. This workaround allows the
364+
emulation of an apic to be disabled per host however it is not recommended to
365+
use outside of a CI or developer cloud.
356366
"""),
357367
]
358368

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4917,6 +4917,37 @@ def _test_get_guest_config_windows_hyperv(
49174917
self.assertTrue(cfg.features[2].vapic)
49184918
self.assertEqual(hvid_hidden, cfg.features[2].vendorid_spoof)
49194919

4920+
@mock.patch.object(host.Host, 'has_min_version',
4921+
new=mock.Mock(return_value=True))
4922+
def test_get_guest_config_apic_workaround(self):
4923+
self.flags(virt_type='qemu', group='libvirt')
4924+
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
4925+
instance_ref = objects.Instance(**self.test_instance)
4926+
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
4927+
disk_info = blockinfo.get_disk_info(
4928+
CONF.libvirt.virt_type, instance_ref, image_meta)
4929+
4930+
cfg = drvr._get_guest_config(
4931+
instance_ref, _fake_network_info(self), image_meta, disk_info)
4932+
4933+
self.assertEqual(3, len(cfg.features))
4934+
self.assertIsInstance(
4935+
cfg.features[0], vconfig.LibvirtConfigGuestFeatureACPI)
4936+
self.assertIsInstance(
4937+
cfg.features[1], vconfig.LibvirtConfigGuestFeatureAPIC)
4938+
self.assertIsInstance(
4939+
cfg.features[2], vconfig.LibvirtConfigGuestFeatureVMCoreInfo)
4940+
4941+
self.flags(libvirt_disable_apic=True, group='workarounds')
4942+
cfg = drvr._get_guest_config(
4943+
instance_ref, _fake_network_info(self), image_meta, disk_info)
4944+
4945+
self.assertEqual(2, len(cfg.features))
4946+
self.assertIsInstance(
4947+
cfg.features[0], vconfig.LibvirtConfigGuestFeatureACPI)
4948+
self.assertIsInstance(
4949+
cfg.features[1], vconfig.LibvirtConfigGuestFeatureVMCoreInfo)
4950+
49204951
def test_get_guest_config_windows_hyperv_feature2(self):
49214952
self._test_get_guest_config_windows_hyperv()
49224953

nova/virt/libvirt/driver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5858,7 +5858,8 @@ def _set_features(self, guest, os_type, image_meta, flavor):
58585858

58595859
if CONF.libvirt.virt_type in ('qemu', 'kvm'):
58605860
guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
5861-
guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
5861+
if not CONF.workarounds.libvirt_disable_apic:
5862+
guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
58625863

58635864
if CONF.libvirt.virt_type in ('qemu', 'kvm') and os_type == 'windows':
58645865
hv = vconfig.LibvirtConfigGuestFeatureHyperV()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
issues:
3+
- |
4+
Linux guest images that have known kernel bugs related to virtualized apic
5+
initialization previously would sporadically hang. For images where the
6+
kernel cannot be upgraded, a ``[workarounds]`` config option has been
7+
introduced:
8+
9+
``[workarounds]libvirt_disable_apic``
10+
11+
This option is primarily intended for CI and development clouds as a bridge
12+
for operators to mitigate the issue while they work with their upstream
13+
image vendors.

0 commit comments

Comments
 (0)