Skip to content

Commit f08b71f

Browse files
stephenfinricolin
authored andcommitted
libvirt: Remove unnecessary TODO
The 'guest.os_mach_type' property is set to the value returned by 'libvirt.utils.get_machine_type'. This will attempt to pull a machine type from image metadata and fallback to a sensible default. As such, we never need to worry about 'guest.os_mach_type' being unset on x86 hosts. Change-Id: Ibc6d3dcaaa704599b7963bf97bdd901788f5af45 Signed-off-by: Stephen Finucane <[email protected]>
1 parent f708fee commit f08b71f

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

nova/virt/libvirt/driver.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6811,38 +6811,28 @@ def _guest_needs_pcie(self, guest):
68116811
"""
68126812
caps = self._host.get_capabilities()
68136813

6814-
# TODO(kchamart) In the third 'if' conditional below, for 'x86'
6815-
# arch, we're assuming: when 'os_mach_type' is 'None', you'll
6816-
# have "pc" machine type. That assumption, although it is
6817-
# correct for the "forseeable future", it will be invalid when
6818-
# libvirt / QEMU changes the default machine types.
6819-
#
6820-
# From libvirt 4.7.0 onwards (September 2018), it will ensure
6821-
# that *if* 'pc' is available, it will be used as the default --
6822-
# to not break existing applications. (Refer:
6823-
# https://libvirt.org/git/?p=libvirt.git;a=commit;h=26cfb1a3
6824-
# --"qemu: ensure default machine types don't change if QEMU
6825-
# changes").
6826-
#
6827-
# But even if libvirt (>=v4.7.0) handled the default case,
6828-
# relying on such assumptions is not robust. Instead we should
6829-
# get the default machine type for a given architecture reliably
6830-
# -- by Nova setting it explicitly (we already do it for Arm /
6831-
# AArch64 & s390x). A part of this bug is being tracked here:
6832-
# https://bugs.launchpad.net/nova/+bug/1780138).
6833-
68346814
# Add PCIe root port controllers for PCI Express machines
68356815
# but only if their amount is configured
68366816

68376817
if not CONF.libvirt.num_pcie_ports:
68386818
return False
6839-
if (caps.host.cpu.arch == fields.Architecture.AARCH64 and
6840-
guest.os_mach_type.startswith('virt')):
6819+
6820+
# Only certain architectures and machine types can handle PCIe ports;
6821+
# the latter will be handled by libvirt.utils.get_machine_type
6822+
6823+
if (
6824+
caps.host.cpu.arch == fields.Architecture.AARCH64 and
6825+
guest.os_mach_type.startswith('virt')
6826+
):
68416827
return True
6842-
if (caps.host.cpu.arch == fields.Architecture.X86_64 and
6843-
guest.os_mach_type is not None and
6844-
'q35' in guest.os_mach_type):
6828+
6829+
if (
6830+
caps.host.cpu.arch == fields.Architecture.X86_64 and
6831+
guest.os_mach_type is not None and
6832+
'q35' in guest.os_mach_type
6833+
):
68456834
return True
6835+
68466836
return False
68476837

68486838
def _get_guest_config(self, instance, network_info, image_meta,

0 commit comments

Comments
 (0)