Skip to content

[pciehp 2/4] Add PCIe root port device model and port provisioning - #6227

Open
ilstam wants to merge 9 commits into
ilstam-hotplug-1from
ilstam-hotplug-2
Open

ilstam wants to merge 9 commits into
ilstam-hotplug-1from
ilstam-hotplug-2

Conversation

@ilstam

@ilstam ilstam commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a new PCIe root port device model and a way for the user to provision root ports.

Introduce PciExpressCap modelling the PCI Express Capability along with
a ctor for a root port device.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
PciConfiguration only supported Type 0 headers until now. Add
new_type1() for PCI-to-PCI bridges such as PCIe root ports.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a hot-plug capable PCIe root port model: a Type 1 header with a PCI
Express Capability advertising a hot-plug capable slot, plus a
one-vector MSI-X capability for delivering hot-plug events.

This patch only defines the device model, no root ports are introduced
in the topology yet.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add unit tests that cover the root port's configuration header and PCI
Express Capability, the Slot Control / Slot Status register semantics,
hot-plug interrupt gating and the power-indicator-off acknowledgement.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a machine-config option for the number of PCIe root ports to create.
Each port accepts a single hot-plugged device, so this is the maximum
number of devices that can be hot-plugged into the VM.

Setting the option does not modify the PCI bus topology yet.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Create the number of PCI root ports the user has requested and attach
them to the primary PCI bus.

The root ports are provisioned after the boot devices have been
attached, so they take the root bus slots that follow them.

Secondary bus numbers are handed out by port index rather than by the
slot each port ended up in so they stay contiguous starting from 1.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add unit tests for root port provisioning and move the mock PCI device
out of test_next_device_bdf() to module scope so that other tests can
use it.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
@ilstam ilstam changed the title [pciehp 2/4] Add a PCIe root port device model and provision hot-plug ports [pciehp 2/4] Add PCIe root port device model and provisioning Sep 17, 2026
@ilstam ilstam changed the title [pciehp 2/4] Add PCIe root port device model and provisioning [pciehp 2/4] Add PCIe root port device model and port provisioning Sep 17, 2026
@ilstam
ilstam marked this pull request as ready for review September 17, 2026 17:15
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.80952% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.99%. Comparing base (93557a0) to head (81b9cb4).

Files with missing lines Patch % Lines
src/vmm/src/devices/pci/root_port.rs 56.99% 83 Missing ⚠️
src/vmm/src/builder.rs 50.00% 2 Missing ⚠️
src/vmm/src/devices/pci/pci_segment.rs 96.15% 2 Missing ⚠️
src/vmm/src/persist.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           ilstam-hotplug-1    #6227      +/-   ##
====================================================
- Coverage             83.07%   82.99%   -0.09%     
====================================================
  Files                   277      279       +2     
  Lines                 31508    31826     +318     
====================================================
+ Hits                  26176    26414     +238     
- Misses                 5332     5412      +80     
Flag Coverage Δ
5.10-m5n.metal 83.21% <73.65%> (-0.10%) ⬇️
5.10-m6a.metal 82.60% <73.65%> (-0.09%) ⬇️
5.10-m6g.metal 80.08% <73.65%> (-0.07%) ⬇️
5.10-m6i.metal 83.21% <73.65%> (-0.09%) ⬇️
5.10-m7a.metal-48xl 82.59% <73.65%> (-0.09%) ⬇️
5.10-m7g.metal 80.08% <73.65%> (-0.07%) ⬇️
5.10-m7i.metal-24xl 83.19% <73.65%> (-0.09%) ⬇️
5.10-m7i.metal-48xl 83.19% <73.65%> (-0.10%) ⬇️
5.10-m8g.metal-24xl 80.08% <73.65%> (-0.07%) ⬇️
5.10-m8g.metal-48xl 80.08% <73.65%> (-0.07%) ⬇️
5.10-m8i.metal-48xl 83.19% <73.65%> (-0.09%) ⬇️
5.10-m8i.metal-96xl 83.20% <73.65%> (-0.09%) ⬇️
5.10-m9g.metal-48xl 80.08% <73.65%> (-0.07%) ⬇️
6.1-m5n.metal 83.24% <73.65%> (-0.10%) ⬇️
6.1-m6a.metal 82.62% <73.65%> (-0.10%) ⬇️
6.1-m6g.metal 80.08% <73.65%> (-0.06%) ⬇️
6.1-m6i.metal 83.24% <73.65%> (-0.10%) ⬇️
6.1-m7a.metal-48xl 82.61% <73.65%> (-0.10%) ⬇️
6.1-m7g.metal 80.08% <73.65%> (-0.07%) ⬇️
6.1-m7i.metal-24xl 83.25% <73.65%> (-0.10%) ⬇️
6.1-m7i.metal-48xl 83.25% <73.65%> (-0.10%) ⬇️
6.1-m8g.metal-24xl 80.08% <73.65%> (-0.07%) ⬇️
6.1-m8g.metal-48xl 80.08% <73.65%> (-0.06%) ⬇️
6.1-m8i.metal-48xl 83.25% <73.65%> (-0.10%) ⬇️
6.1-m8i.metal-96xl 83.25% <73.65%> (-0.10%) ⬇️
6.1-m9g.metal-48xl 80.08% <73.65%> (-0.08%) ⬇️
6.18-m5n.metal 83.24% <73.65%> (-0.10%) ⬇️
6.18-m6a.metal 82.62% <73.65%> (-0.09%) ⬇️
6.18-m6g.metal 80.18% <73.65%> (-0.07%) ⬇️
6.18-m6i.metal 83.24% <73.65%> (-0.10%) ⬇️
6.18-m7a.metal-48xl 82.61% <73.65%> (-0.09%) ⬇️
6.18-m7g.metal 80.19% <73.65%> (-0.07%) ⬇️
6.18-m7i.metal-24xl 83.25% <73.65%> (-0.10%) ⬇️
6.18-m7i.metal-48xl 83.26% <73.65%> (-0.10%) ⬇️
6.18-m8g.metal-24xl 80.18% <73.65%> (-0.08%) ⬇️
6.18-m8g.metal-48xl 80.19% <73.65%> (-0.07%) ⬇️
6.18-m8i.metal-48xl 83.25% <73.65%> (-0.10%) ⬇️
6.18-m8i.metal-96xl 83.25% <73.65%> (-0.10%) ⬇️
6.18-m9g.metal-48xl 80.18% <73.65%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ilstam
ilstam added this pull request to stack #6230 September 17, 2026 17:16
This will allow hot-plugging test to allocate the necessary number of
ports using @pin_hotplug_ports(n).

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a new test_pci_topology.py file with tests about the PCI topology
when root ports are and are not provisioned.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
@ilstam ilstam added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting review Indicates that a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant