Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronise 2023.1 with upstream #147

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions nova/tests/unit/virt/libvirt/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,48 @@ def test_tpool_list_all_connections(self):
self.assertIsInstance(domain, tpool.Proxy)
self.assertIn(domain.UUIDString(), (uuids.vm1, uuids.vm2))

def _add_fake_host_devices(self):
self.conn._obj.pci_info = fakelibvirt.HostPCIDevicesInfo(
num_pci=1, num_pfs=2, num_vfs=2, num_mdevcap=3)
mdevs = {
'mdev_4b20d080_1b54_4048_85b3_a6a62d165c01':
fakelibvirt.FakeMdevDevice(
dev_name='mdev_4b20d080_1b54_4048_85b3_a6a62d165c01',
type_id=fakelibvirt.NVIDIA_11_VGPU_TYPE,
parent=fakelibvirt.MDEVCAP_DEV1_PCI_ADDR),
}
self.conn._obj.mdev_info = fakelibvirt.HostMdevDevicesInfo(
devices=mdevs)

def test_tpool_list_all_devices(self):
self._add_fake_host_devices()
devs = self.host.list_all_devices(
fakelibvirt.VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV)
self.assertEqual(8, len(devs))
for dev in devs:
self.assertIsInstance(dev, tpool.Proxy)

def test_tpool_list_pci_devices(self):
self._add_fake_host_devices()
devs = self.host.list_pci_devices()
self.assertEqual(8, len(devs))
for dev in devs:
self.assertIsInstance(dev, tpool.Proxy)

def test_tpool_list_mdev_capable_devices(self):
self._add_fake_host_devices()
devs = self.host.list_mdev_capable_devices()
self.assertEqual(3, len(devs))
for dev in devs:
self.assertIsInstance(dev, tpool.Proxy)

def test_tpool_list_mediated_devices(self):
self._add_fake_host_devices()
devs = self.host.list_mediated_devices()
self.assertEqual(1, len(devs))
for dev in devs:
self.assertIsInstance(dev, tpool.Proxy)


class LoadersTestCase(test.NoDBTestCase):

Expand Down
9 changes: 7 additions & 2 deletions nova/virt/libvirt/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,9 @@ def _list_devices(self, cap, flags=0):
:returns: a list of virNodeDevice instance
"""
try:
return self.get_connection().listDevices(cap, flags)
devs = [self._wrap_libvirt_proxy(dev)
for dev in self.get_connection().listDevices(cap, flags)]
return devs
except libvirt.libvirtError as ex:
error_code = ex.get_error_code()
if error_code == libvirt.VIR_ERR_NO_SUPPORT:
Expand All @@ -1612,7 +1614,10 @@ def list_all_devices(
:returns: a list of virNodeDevice xml strings.
"""
try:
return self.get_connection().listAllDevices(flags) or []
alldevs = [
self._wrap_libvirt_proxy(dev)
for dev in self.get_connection().listAllDevices(flags)] or []
return alldevs
except libvirt.libvirtError as ex:
LOG.warning(ex)
return []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fixes:
- |
`Bug #2091033`_: Fixed calls to libvirt ``listDevices()`` and
``listAllDevices()`` from potentially blocking all other greenthreads
in ``nova-compute``. Under certain circumstances, it was possible for
the ``nova-compute`` service to freeze with all other greenthreads
blocked and unable to perform any other activities including logging.
This issue has been fixed by wrapping the libvirt ``listDevices()``
and ``listAllDevices()`` calls with ``eventlet.tpool.Proxy``.

.. _Bug #2091033: https://bugs.launchpad.net/nova/+bug/2091033