From ac61abb7c74f1a8e3e9134bc045455fd9fdac0fa Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 6 Mar 2017 19:00:31 -0500 Subject: [PATCH] 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 --- nova/tests/unit/virt/libvirt/test_driver.py | 8 ++++++-- nova/virt/libvirt/driver.py | 4 +++- releasenotes/notes/bug-1670522-0a9f20e05e531c7a.yaml | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1670522-0a9f20e05e531c7a.yaml diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index ca1a7c00fbd6..6481f2c6f635 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -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( diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 1f7f1d4b108e..a9bae4e7614a 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -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, diff --git a/releasenotes/notes/bug-1670522-0a9f20e05e531c7a.yaml b/releasenotes/notes/bug-1670522-0a9f20e05e531c7a.yaml new file mode 100644 index 000000000000..89e132af0d5d --- /dev/null +++ b/releasenotes/notes/bug-1670522-0a9f20e05e531c7a.yaml @@ -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 \ No newline at end of file