libvirt: pass log_path to _create_pty_device for non-kvm/qemu

log_path is required in _create_pty_device if:

1. serial consoles are disabled
2. libvirt/qemu are new enough that they support virtlogd

This was working fine for kvm and qemu since _create_consoles_s390x
and _create_consoles_qemu_kvm pass in the log_path, but for the
non-kvm/qemu cases, like xen, the log_path wasn't provided.

This wasn't caught by the XenProject CI since it's using libvirt
1.3.1 which does not have virtlogd support so this path was
not exercised and apparently not unit tested either.

A release note is provided since this is a pretty severe bug if
you're running new enough libvirt/qemu and not using kvm/qemu as
the virt type because CONF.serial_console.enabled is False by
default so you're going to have failed server creates immediately
upon upgrading to Ocata.

Change-Id: I7f60db1d243a75b90e3c0e53201cb6000ee95778
Closes-Bug: #1670522
This commit is contained in:
Matt Riedemann 2017-03-06 19:00:31 -05:00
parent c3bfbcf5cc
commit ac61abb7c7
3 changed files with 18 additions and 3 deletions

View File

@ -3803,13 +3803,14 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
def _test_consoles(arch_to_mock, serial_enabled,
expected_device_type, expected_device_cls):
expected_device_type, expected_device_cls,
virt_type='qemu'):
guest_cfg = vconfig.LibvirtConfigGuest()
mock_get_arch.return_value = arch_to_mock
self.flags(enabled=serial_enabled, group='serial_console')
instance = objects.Instance(**self.test_instance)
drvr._create_consoles("qemu", guest_cfg, instance=instance,
drvr._create_consoles(virt_type, guest_cfg, instance=instance,
flavor=None, image_meta=None)
self.assertEqual(1, len(guest_cfg.devices))
@ -3819,6 +3820,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.assertIsInstance(device.log,
vconfig.LibvirtConfigGuestCharDeviceLog)
self.assertEqual("off", device.log.append)
self.assertIsNotNone(device.log.file)
self.assertTrue(device.log.file.endswith("console.log"))
_test_consoles(fields.Architecture.X86_64, True,
@ -3829,6 +3831,8 @@ class LibvirtConnTestCase(test.NoDBTestCase):
"tcp", vconfig.LibvirtConfigGuestConsole)
_test_consoles(fields.Architecture.S390X, False,
"pty", vconfig.LibvirtConfigGuestConsole)
_test_consoles(fields.Architecture.X86_64, False,
"pty", vconfig.LibvirtConfigGuestConsole, 'xen')
@mock.patch('nova.console.serial.acquire_port')
def test_get_guest_config_serial_console_through_port_rng_exhausted(

View File

@ -4401,8 +4401,10 @@ class LibvirtDriver(driver.ComputeDriver):
if virt_type == 'parallels':
pass
elif virt_type not in ("qemu", "kvm"):
log_path = self._get_console_log_path(instance)
self._create_pty_device(guest_cfg,
vconfig.LibvirtConfigGuestConsole)
vconfig.LibvirtConfigGuestConsole,
log_path=log_path)
elif (virt_type in ("qemu", "kvm") and
self._is_s390x_guest(image_meta)):
self._create_consoles_s390x(guest_cfg, instance,

View File

@ -0,0 +1,9 @@
---
fixes:
- |
Fixes `bug 1670522`_ which was a regression in the 15.0.0 Ocata release.
For compute nodes running the libvirt driver with ``virt_type`` not set to
"kvm" or "qemu", i.e. "xen", creating servers will fail by default if
libvirt >= 1.3.3 and QEMU >= 2.7.0 without this fix.
.. _bug 1670522: https://bugs.launchpad.net/nova/+bug/1670522