Add supports_remote_managed_ports capability

In order to support remote-managed ports the following is needed:

* Nova compute driver needs to support this feature;
* For the Libvirt compute driver, a given host needs to have the right
  version of Libvirt - the one which supports PCI VPD (7.9.0
  https://libvirt.org/news.html#v7-9-0-2021-11-01).

Therefore, this change introduces a new capability to track driver
support for remote-managed ports.

Change-Id: I7ea96fd85d2607e0af0f6918b0b45c58e8bec058
This commit is contained in:
Dmitrii Shcherbakov 2022-02-04 13:40:00 +03:00
parent 6294c144e7
commit d1e9ecb443
13 changed files with 58 additions and 0 deletions

View File

@ -110,6 +110,10 @@ class PciDeviceStats(object):
fields.PciDeviceType.SRIOV_PF, fields.PciDeviceType.SRIOV_PF,
fields.PciDeviceType.VDPA): fields.PciDeviceType.VDPA):
return return
# A tag is added here rather than at the client side to avoid an
# issue with having objects without this tag specified during an
# upgrade to the first version that supports handling this tag.
if pool.get(PCI_REMOTE_MANAGED_TAG) is None: if pool.get(PCI_REMOTE_MANAGED_TAG) is None:
# NOTE: tags are compared as strings case-insensitively, see # NOTE: tags are compared as strings case-insensitively, see
# pci_device_prop_match in nova/pci/utils.py. # pci_device_prop_match in nova/pci/utils.py.

View File

@ -45,6 +45,7 @@ class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
os_traits.COMPUTE_VOLUME_EXTEND, os_traits.COMPUTE_VOLUME_EXTEND,
os_traits.COMPUTE_VOLUME_MULTI_ATTACH, os_traits.COMPUTE_VOLUME_MULTI_ATTACH,
os_traits.COMPUTE_TRUSTED_CERTS, os_traits.COMPUTE_TRUSTED_CERTS,
os_traits.COMPUTE_REMOTE_MANAGED_PORTS,
] ]
]) ])

View File

@ -885,6 +885,22 @@ class LibvirtConnTestCase(test.NoDBTestCase,
) )
mock_supports.assert_called_once_with() mock_supports.assert_called_once_with()
@mock.patch.object(
libvirt_driver.LibvirtDriver, '_register_instance_machine_type',
new=mock.Mock())
@mock.patch.object(
host.Host, 'supports_remote_managed_ports',
new_callable=mock.PropertyMock)
def test_driver_capabilities_remote_managed_ports(self, mock_supports):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
drvr.init_host("dummyhost")
self.assertTrue(
drvr.capabilities['supports_remote_managed_ports'],
"Driver capabilities for 'supports_remote_managed_ports' "
"is invalid when host should support this feature"
)
mock_supports.assert_called_once_with()
def test_driver_raises_on_non_linux_platform(self): def test_driver_raises_on_non_linux_platform(self):
with utils.temporary_mutation(sys, platform='darwin'): with utils.temporary_mutation(sys, platform='darwin'):
self.assertRaises( self.assertRaises(

View File

@ -1816,6 +1816,16 @@ cg /cgroup/memory cg opt1,opt2 0 0
""" """
self.assertTrue(self.host.supports_secure_boot) self.assertTrue(self.host.supports_secure_boot)
@mock.patch.object(fakelibvirt.virConnect, "getLibVersion")
def test_supports_remote_managed_ports__true(self, mock_libversion):
mock_libversion.return_value = 7009000
self.assertTrue(self.host.supports_remote_managed_ports)
@mock.patch.object(fakelibvirt.virConnect, "getLibVersion")
def test_supports_remote_managed_ports__false(self, mock_libversion):
mock_libversion.return_value = 7008000
self.assertFalse(self.host.supports_remote_managed_ports)
@mock.patch.object(host.Host, 'loaders', new_callable=mock.PropertyMock) @mock.patch.object(host.Host, 'loaders', new_callable=mock.PropertyMock)
@mock.patch.object(host.Host, 'get_canonical_machine_type') @mock.patch.object(host.Host, 'get_canonical_machine_type')
def test_get_loader(self, mock_get_mtype, mock_loaders): def test_get_loader(self, mock_get_mtype, mock_loaders):

View File

@ -126,6 +126,7 @@ CAPABILITY_TRAITS_MAP = {
"supports_secure_boot": os_traits.COMPUTE_SECURITY_UEFI_SECURE_BOOT, "supports_secure_boot": os_traits.COMPUTE_SECURITY_UEFI_SECURE_BOOT,
"supports_socket_pci_numa_affinity": "supports_socket_pci_numa_affinity":
os_traits.COMPUTE_SOCKET_PCI_NUMA_AFFINITY, os_traits.COMPUTE_SOCKET_PCI_NUMA_AFFINITY,
"supports_remote_managed_ports": os_traits.COMPUTE_REMOTE_MANAGED_PORTS,
} }
@ -194,6 +195,7 @@ class ComputeDriver(object):
"supports_vtpm": False, "supports_vtpm": False,
"supports_secure_boot": False, "supports_secure_boot": False,
"supports_socket_pci_numa_affinity": False, "supports_socket_pci_numa_affinity": False,
"supports_remote_managed_ports": False,
# Image type support flags # Image type support flags
"supports_image_type_aki": False, "supports_image_type_aki": False,

View File

@ -116,6 +116,7 @@ class FakeDriver(driver.ComputeDriver):
"supports_trusted_certs": True, "supports_trusted_certs": True,
"supports_pcpus": False, "supports_pcpus": False,
"supports_accelerators": True, "supports_accelerators": True,
"supports_remote_managed_ports": True,
# Supported image types # Supported image types
"supports_image_type_raw": True, "supports_image_type_raw": True,

View File

@ -103,6 +103,7 @@ class HyperVDriver(driver.ComputeDriver):
"supports_pcpus": False, "supports_pcpus": False,
"supports_accelerators": False, "supports_accelerators": False,
"supports_secure_boot": True, "supports_secure_boot": True,
"supports_remote_managed_ports": False,
# Supported image types # Supported image types
"supports_image_type_vhd": True, "supports_image_type_vhd": True,

View File

@ -164,6 +164,7 @@ class IronicDriver(virt_driver.ComputeDriver):
"supports_trusted_certs": False, "supports_trusted_certs": False,
"supports_pcpus": False, "supports_pcpus": False,
"supports_accelerators": False, "supports_accelerators": False,
"supports_remote_managed_ports": False,
# Image type support flags # Image type support flags
"supports_image_type_aki": False, "supports_image_type_aki": False,

View File

@ -812,6 +812,8 @@ class LibvirtDriver(driver.ComputeDriver):
# or UEFI bootloader support in this manner # or UEFI bootloader support in this manner
self.capabilities.update({ self.capabilities.update({
'supports_secure_boot': self._host.supports_secure_boot, 'supports_secure_boot': self._host.supports_secure_boot,
'supports_remote_managed_ports':
self._host.supports_remote_managed_ports
}) })
def _register_instance_machine_type(self): def _register_instance_machine_type(self):

View File

@ -1701,6 +1701,23 @@ class Host(object):
LOG.debug("No AMD SEV support detected for any (arch, machine_type)") LOG.debug("No AMD SEV support detected for any (arch, machine_type)")
return self._supports_amd_sev return self._supports_amd_sev
@property
def supports_remote_managed_ports(self) -> bool:
"""Determine if the host supports remote managed ports.
Returns a boolean indicating whether remote managed ports are
possible to use on this host.
The check is based on a Libvirt version which added support for
parsing and exposing PCI VPD since a card serial number (if present in
the VPD) since the use of remote managed ports depends on this.
https://libvirt.org/news.html#v7-9-0-2021-11-01
The actual presence of a card serial number for a particular device
is meant to be checked elsewhere.
"""
return self.has_min_version(lv_ver=(7, 9, 0))
@property @property
def loaders(self) -> ty.List[dict]: def loaders(self) -> ty.List[dict]:
"""Retrieve details of loader configuration for the host. """Retrieve details of loader configuration for the host.

View File

@ -82,6 +82,7 @@ class PowerVMDriver(driver.ComputeDriver):
'supports_vtpm': False, 'supports_vtpm': False,
'supports_secure_boot': False, 'supports_secure_boot': False,
'supports_socket_pci_numa_affinity': False, 'supports_socket_pci_numa_affinity': False,
'supports_remote_managed_ports': False,
# Supported image types # Supported image types
"supports_image_type_aki": False, "supports_image_type_aki": False,

View File

@ -72,6 +72,7 @@ class VMwareVCDriver(driver.ComputeDriver):
"supports_trusted_certs": False, "supports_trusted_certs": False,
"supports_pcpus": False, "supports_pcpus": False,
"supports_accelerators": False, "supports_accelerators": False,
"supports_remote_managed_ports": False,
# Image type support flags # Image type support flags
"supports_image_type_aki": False, "supports_image_type_aki": False,

View File

@ -46,6 +46,7 @@ class ZVMDriver(driver.ComputeDriver):
"""z/VM implementation of ComputeDriver.""" """z/VM implementation of ComputeDriver."""
capabilities = { capabilities = {
"supports_pcpus": False, "supports_pcpus": False,
"supports_remote_managed_ports": False,
# Image type support flags # Image type support flags
"supports_image_type_aki": False, "supports_image_type_aki": False,