Skip to content

Conversation

@scholzp
Copy link
Contributor

@scholzp scholzp commented Nov 27, 2025

This test adds checks for verifying correct BDF assignment through libvirt and that CHV respects those assignments, even after live migration. Moreover, this test ensures that BDFs can be freed and reused when de-/attaching devices (might be more of a theoretical feature?).

For further details, see the test description.

Related to https://github.com/cobaltcore-dev/cobaltcore/issues/287.

@scholzp scholzp self-assigned this Nov 27, 2025
Copy link
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

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

Generally great work! Left a few remarks

@scholzp scholzp force-pushed the bdf_tests branch 3 times, most recently from b23fb51 to 4aac2f1 Compare November 27, 2025 17:17
@tpressure
Copy link
Contributor

tpressure commented Nov 27, 2025

This is great work, can we also add 2 hotplug devices:

  • 1 network dev with specific bdf
  • 1 disk with dev specific bdf?

Copy link
Collaborator

@hertrste hertrste left a comment

Choose a reason for hiding this comment

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

We well written test case 👍

Copy link
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

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

I like the direction into that we are going here - good work! I left a few remarks

@scholzp scholzp force-pushed the bdf_tests branch 6 times, most recently from 8089e2d to 9b27e1b Compare December 5, 2025 07:54
Copy link
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

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

LGTM but I left a few remarks. I'm already approving.

@phip1611
Copy link
Member

phip1611 commented Dec 5, 2025

You need to rebase your PR.

@scholzp scholzp force-pushed the bdf_tests branch 3 times, most recently from 240f603 to 8654c40 Compare December 5, 2025 14:07
tests/common.nix Outdated
<target dev='tap0'/>
<model type='virtio'/>
<driver queues='1'/>
all_static_bdf ? false
Copy link
Member

Choose a reason for hiding this comment

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

all_static_bdf ? false

this looks lile a oopsie and will land as is in the XML string.

It surprises me that libvirt doesnt fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good Catch! Fixed.

@tpressure tpressure self-requested a review December 5, 2025 14:14
@tpressure
Copy link
Contributor

@scholzp please resolve conflicts

We don't use the DHCP anymore, so we can deactivate it.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
We need to specify slot IDs in the XML from which the VM config for CHV
is created. This is in preparation for testing BDF fixing.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
When evaluating PCI BDF assignment we need a way to query these
information from a test VM. This commit adds a handy way to obtain all
BDFs with their assigned devices.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
Some test, as the anticipated tests for BDF assignment might need to do
some additional cleanup after terminating that is specific for this test
only. This also needs to work reliably in case of tests failing. This
commit therefore introduces infrastructure that allows to define some
'guard', that once garbage collected, executes the cleanup routines.

Signed-off-by: Pascal Scholz pascal.scholz@cyberus-technology.de
On-behalf-of: SAP pascal.scholz@sap.com
@phip1611
Copy link
Member

Please fix the ci.

Are all issues in the corresponding libvirt pr now resolved?

@scholzp scholzp force-pushed the bdf_tests branch 2 times, most recently from c038d6b to 68b98a1 Compare December 10, 2025 10:25
@scholzp
Copy link
Contributor Author

scholzp commented Dec 10, 2025

Please fix the ci.

Are all issues in the corresponding libvirt pr now resolved?

Yes, they are.
The CI should now be fixed for all commits that I intent to keep.

The added tests checks that libvirt and CHV assigned and propagate PCI
BDF correctly to the guest's PCI devices. It furthermore ensures, that
these assignment stay valid even after live migration.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
We test that the persistent config stores the correct BDF.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
This test ensures that BDFs stored in the live and the persistent
config don't go out of sync when transiently removing a device.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
We need to test that an invalid BDF results in an error from libvirt
and does not crash CHV.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
We need a negative test that shows, that adding a function ID when
entering a BDF result in libvirt generating a failure and CHV not
crashing.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
@scholzp
Copy link
Contributor Author

scholzp commented Dec 12, 2025

I just added negative tests for:

  • libvirt receives an invalid device ID in a BDF
  • libvirt receives a function ID in a BDF

Both are expected to be blocked and errrored upon by libvirt.

@phip1611
Copy link
Member

Great work!

Test that a BDFs containing a function ID leads to errors.
"""
# We don't support multi function devices currently
controllerVM.fail("virsh define /etc/domain-chv-static-bdf-with-function.xml")
Copy link
Member

Choose a reason for hiding this comment

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

this file doesn't exist?!

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