Skip to content

Conversation

@nesteroff
Copy link
Contributor

@nesteroff nesteroff commented Dec 8, 2025

This change adds the ability to define PCIe root ports for QEMU virtual machines. These ports can be used for device hot-plugging, allowing vfio-pci devices to be attached dynamically.

In the current version, it's possible to create ports via extraArgs and set them in deviceExtraArgs but with recent changes (#437), this approach produces "bus not found" errors. There is likely a race condition between creating vfio-pci devices which are now placed at the beginning of the QEMU command and the PCIe ports that were appended at the end.

With this change, PCIe root ports are explicitly created before the vfio-pci devices that may use them.

"pcie-root-port,bus=${bus},id=${id},chassis=${toString chassis}"
]
) pcieRootPorts
)
Copy link
Member

Choose a reason for hiding this comment

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

The lines above now require two spaces of indentation.


qemu.pcieRootPorts = mkOption {
description = ''
A list of PCIe root ports that can be used for device hot-plugging or
Copy link
Member

Choose a reason for hiding this comment

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

Interesting feature. Can we add a link that explains how hot-plugging works?

Could we even generate some helper scripts for the user based on this configuration?

Copy link
Contributor

Choose a reason for hiding this comment

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

hotplug main feature
https://github.com/tiiuae/vhotplug

and the downstream PR, that uses this patch
tiiuae/ghaf#1624

overall we are quite heavy users of passthrough with microvm.
https://github.com/tiiuae/ghaf/blob/main/modules/hardware/common/devices.nix
https://github.com/tiiuae/ghaf/blob/main/modules/hardware/common/qemu.nix
https://github.com/tiiuae/ghaf/tree/main/modules/microvm
https://github.com/tiiuae/ghaf/tree/main/modules/hardware/passthrough

if there is appetite. I think that it could be great to move some of the functionality from Ghaf to microvm, so that it would be readily available to more folks.

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