Skip to content

petri/vmm_tests: consolidate pcie topology construction and add more tests#3118

Merged
jackschefer-msft merged 15 commits intomicrosoft:mainfrom
jackschefer-msft:pcie-dev-tests
Mar 26, 2026
Merged

petri/vmm_tests: consolidate pcie topology construction and add more tests#3118
jackschefer-msft merged 15 commits intomicrosoft:mainfrom
jackschefer-msft:pcie-dev-tests

Conversation

@jackschefer-msft
Copy link
Copy Markdown
Contributor

@jackschefer-msft jackschefer-msft commented Mar 24, 2026

  • Adds petri support for pcie roots and switches
  • Adds tests for switches
  • Adds tests for devices plugged into root ports and switches
  • Adds tests for multiple segments topologies

Copilot AI review requested due to automatic review settings March 24, 2026 18:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes PCIe topology construction in the Petri OpenVMM backend and expands PCIe-related integration coverage by adding topology and device enumeration tests.

Changes:

  • Introduces PetriVmConfigOpenVmm::with_pcie_topology(...) plus helpers to attach PCIe NVMe and PCIe (MANA) NIC devices.
  • Refactors existing PCIe root emulation test to use the new topology helper and adds new PCIe device enumeration assertions.
  • Updates the burette network perf test to explicitly construct a PCIe topology and target a specific root port for virtio-net.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
vmm_tests/vmm_tests/tests/tests/multiarch/pcie.rs Switches tests to with_pcie_topology and adds a Linux PCIe device enumeration test (NVMe + NIC).
petri/src/vm/openvmm/modify.rs Adds PCIe topology/device builder helpers and changes with_virtio_nic to take a port_name.
petri/burette/src/tests/network.rs Updates virtio-net perf path to create a PCIe topology and attach the NIC to s0rc0rp0.

Comment on lines +238 to +240
let low_mmio_start = self.config.memory.mmio_gaps[0].start();
let high_mmio_end = self.config.memory.mmio_gaps[1].end();

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

with_pcie_topology uses mmio_gaps[1] for high_mmio_end. On configs with VTL2 enabled (3 MMIO gaps), index 1 is not the last gap, so the computed PCI high MMIO range can overlap the VTL2 MMIO gap and make the memory layout invalid. Use mmio_gaps.first()/last() (and handle missing gaps) when deriving these boundaries.

Suggested change
let low_mmio_start = self.config.memory.mmio_gaps[0].start();
let high_mmio_end = self.config.memory.mmio_gaps[1].end();
let mmio_gaps = &self.config.memory.mmio_gaps;
let Some(first_gap) = mmio_gaps.first() else {
// No MMIO gaps configured; cannot derive PCIe MMIO layout.
return self;
};
let last_gap = mmio_gaps.last().unwrap();
let low_mmio_start = first_gap.start();
let high_mmio_end = last_gap.end();

Copilot uses AI. Check for mistakes.
@jackschefer-msft jackschefer-msft changed the title petri/vmm_tests: consolidate pcie topology construction and add more tests [WIP] petri/vmm_tests: consolidate pcie topology construction and add more tests Mar 24, 2026
@jackschefer-msft jackschefer-msft marked this pull request as ready for review March 24, 2026 18:46
@jackschefer-msft jackschefer-msft requested a review from a team as a code owner March 24, 2026 18:46
Copilot AI review requested due to automatic review settings March 24, 2026 18:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

Copilot AI review requested due to automatic review settings March 24, 2026 19:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 24, 2026 19:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings March 25, 2026 21:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@jackschefer-msft jackschefer-msft changed the title [WIP] petri/vmm_tests: consolidate pcie topology construction and add more tests petri/vmm_tests: consolidate pcie topology construction and add more tests Mar 26, 2026
@jackschefer-msft
Copy link
Copy Markdown
Contributor Author

This is no longer WIP and is ready for review

Copy link
Copy Markdown
Member

@chris-oo chris-oo left a comment

Choose a reason for hiding this comment

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

nice work, just asking for some comments on the tests so you can tell at a glance what that testcase is testing

}

/// Add a PCIe NVMe device to the VM using the NVMe emulator.
pub fn with_pcie_nvme(mut self, port_name: &str, subsystem_id: Guid) -> Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this makes some changes i have for pcie + uefi support much easier... neat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I only added support for a small ramdisk because that seemed easiest for my needs, but should be extensible to actual backing disks

Copilot AI review requested due to automatic review settings March 26, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +279 to +283
index: index.try_into().unwrap(),
name,
segment: segment.try_into().unwrap(),
start_bus: start_bus.try_into().unwrap(),
end_bus: end_bus.try_into().unwrap(),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The try_into().unwrap() conversions for index/segment/start_bus/end_bus can panic on out-of-range inputs (e.g., large segment counts or RC counts). Since this is a public helper, prefer validating bounds up front (or returning a Result) and producing a clear error instead of panicking via unwrap().

Copilot uses AI. Check for mistakes.
@jackschefer-msft jackschefer-msft merged commit e5b29ad into microsoft:main Mar 26, 2026
84 of 87 checks passed
@jackschefer-msft jackschefer-msft deleted the pcie-dev-tests branch March 26, 2026 22:21
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.

3 participants