Skip to content

Fix non-deterministic PCI topology across VM stop/start cycles - #1091

Draft
jamepark4 wants to merge 1 commit into
HCK-CI:masterfrom
jamepark4:recalculate-pci-root
Draft

Fix non-deterministic PCI topology across VM stop/start cycles#1091
jamepark4 wants to merge 1 commit into
HCK-CI:masterfrom
jamepark4:recalculate-pci-root

Conversation

@jamepark4

@jamepark4 jamepark4 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PciManager counters (pci_slot, pci_chassis, pci_addr) were initialized once in QemuMachine.initialize but never reset between runs. When process_device_commands was called on VM restart, the counters continued from where they left off, producing different slot/chassis/addr assignments — and therefore different bus names (e.g., root5 on first boot, root11 on second boot).

This caused two problems after clean_boot (stop + restart):

  • Spare PCIe root port bus names (@spare_pcie_root_port_N@) changed, breaking hotplug tests that reference them
  • Network/storage devices landed on different PCI slots, causing Windows to treat them as new hardware and lose network configuration

Fix: Extract counter initialization into PciManager#reset and call it at the start of process_device_commands, matching the existing pattern of resetting @device_commands. This makes PCI allocation deterministic across restarts.

Copilot AI 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.

Pull request overview

Refreshes QEMU replacement mappings after Functest VM reboot and snapshot operations.

Changes:

  • Exposes the current VM replacement map.
  • Refreshes mappings after VM recreation.

Reviewed changes

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

File Description
lib/setupmanagers/qemuhck/qemuhck.rb Exposes VM mappings.
lib/setupmanagers/functest_client.rb Refreshes mappings after reboot/snapshot operations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/setupmanagers/functest_client.rb Outdated
end

def refresh_replacement_map
@replacement_map = @project.project_replacement_map.merge(@setup_manager.client_vm_replacement_map(@name))
@kostyanf14

Copy link
Copy Markdown
Contributor

In the event that a testcase uses clean_boot: true along with pcie-spare-root-ports, the new VM's allocated PCI devices get new bus name calculations.

This is a bug. We can create wrong network connections too.

In this case, the recalculation mask issue.
Stop/Start should not change the topology of any device, not only the PCI bus

@jamepark4
jamepark4 marked this pull request as draft August 10, 2026 18:57
@jamepark4

Copy link
Copy Markdown
Contributor Author

In the event that a testcase uses clean_boot: true along with pcie-spare-root-ports, the new VM's allocated PCI devices get new bus name calculations.

This is a bug. We can create wrong network connections too.

In this case, the recalculation mask issue. Stop/Start should not change the topology of any device, not only the PCI bus

I'll try and retool this to address the underlying issue.

Signed-off-by: jamepark4 <jparker@redhat.com>
@jamepark4
jamepark4 force-pushed the recalculate-pci-root branch from 547cf91 to 2e4ba18 Compare August 10, 2026 19:09
@jamepark4 jamepark4 changed the title Recalculate replacement_map when doing reboot_clean, reboot_from_snapshot, or save_snapshot Fix non-deterministic PCI topology across VM stop/start cycles Aug 10, 2026
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