Skip to content

Backport libvirt listDevices() fixes to yoga - #4

Merged
Brittlejf merged 3 commits into
elastx/yogafrom
fix/libvirt-listdevices-return-type
Aug 24, 2026
Merged

Backport libvirt listDevices() fixes to yoga#4
Brittlejf merged 3 commits into
elastx/yogafrom
fix/libvirt-listdevices-return-type

Conversation

@Brittlejf

Copy link
Copy Markdown
Member

Backports three upstream OpenStack Nova libvirt fixes related to device listing to the elastx/yoga branch.

Commits

  1. Fix race condition in _get_pci_passthrough_devices (8534499) — cherry-picked cleanly.
  2. libvirt: Wrap un-proxied listDevices() and listAllDevices() (f304b9e) — cherry-picked cleanly.
  3. libvirt: Fix regression of listDevices() return type (2c07aa0) — partial revert of Add code for autostart tagged instances after hypervisor reboot #2; ensures listDevices() returns a list of name strings (not tpool.Proxy-wrapped objects) while listAllDevices() remains wrapped. Fixes TypeError: virNodeDeviceLookupByName() argument 2 must be str or None, not Proxy (Closes-Bug: #2098892).

Deviation from a straight cherry-pick

Commit #3 also modified nova/tests/functional/regressions/test_bug_2098892.py, a functional regression test that does not exist on elastx/yoga (it was introduced by a separate upstream commit not being backported). The test could not be carried over as-is because it depends on newer test infrastructure than this branch has (it calls self._run_periodics(raise_on_error=True), but on elastx/yoga _run_periodics takes no arguments). The test file was therefore dropped; the production fix in nova/virt/libvirt/host.py and nova/tests/fixtures/libvirt.py is fully applied.

mnaser and others added 3 commits August 24, 2026 09:13
The call to _get_pci_passthrough_devices could fail because a
network device could have disappeared which would cause a traceback
in the logs.

This wraps the function in a safe way to return an empty array
if it fails, which will clean-up the logs if the device disappears

Closes-Bug: #1972028
Change-Id: I46d3bbe122d9f8452f168286391bab67ecea3128
This is similar to change I668643c836d46a25df46d4c99a973af5e50a39db
where the objects returned in a list from a libvirt call were not
tpool.Proxy wrapped. Because the objects are not wrapped, calling
methods on them such as listCaps() can block all other greenthreads
and can cause nova-compute to freeze for hours in certain scenarios.

This adds the same wrapping to libvirt calls which return lists of
virNodeDevice.

Closes-Bug: #2091033

Change-Id: I60d6f04d374e9ede5895a43b7a75e955b0fea3c5
This a partial revert of change
I60d6f04d374e9ede5895a43b7a75e955b0fea3c5 which added tpool.Proxy
wrapping to the listDevices() and listAllDevices() methods.

The regression was caught during downstream testing with vGPUs and the
update_available_resource() periodic task was failing with:

  TypeError: virNodeDeviceLookupByName() argument 2 must be str or
    None, not Proxy

It turns out that while the listAllDevices() method returns a list of
virNodeDevice objects [1], the listDevices() method returns a list of
string names [2] and is generated from the corresponding function in C
[3].

The error was not caught by unit or functional testing because those
test environments intentionally do not import the libvirt Python
module -- so mocked code in the LibvirtFixture runs instead. Also, the
update_available_resource() method has a 'except Exception:' at the end
which logs an error but does not re-raise. So it would not cause a
functional test to fail.

This reverts the change that caused the regression, updates potentially
confusing docstrings, adds type annotations to the methods that use
listDevices(), and moves the nodeDeviceLookupByName type checking into
the LibvirtFixture.

Closes-Bug: #2098892

[1] https://github.com/libvirt/libvirt-python/blob/408815a/libvirt-override-virConnect.py#L520-L524
[2] https://github.com/libvirt/libvirt-python/blob/408815a/libvirt-override-api.xml#L448-L453
[3] https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeListDevices

Change-Id: Ib5befdd3c13367daa208ff969f66cba693ae2c76
@Brittlejf Brittlejf self-assigned this Aug 24, 2026
@Brittlejf
Brittlejf requested a review from a team August 24, 2026 09:32
@Brittlejf
Brittlejf marked this pull request as ready for review August 24, 2026 09:32

@foxelx foxelx left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Brittlejf
Brittlejf merged commit 226a42f into elastx/yoga Aug 24, 2026
@Brittlejf
Brittlejf deleted the fix/libvirt-listdevices-return-type branch August 24, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants