Repository navigation
Conversation
Signed-off-by: Leechael Yim <yanleech@gmail.com>
…nning QEMU Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
… overlapping buses Signed-off-by: Leechael Yim <yanleech@gmail.com>
Leechael
force-pushed
the
feat/gpu-host-slot
branch
2 times, most recently
from
December 2, 2026 18:05
ae0023e to
79ca0d3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Guest GPU telemetry and host GPU telemetry cannot be joined.
00000000:01:00.0).0001:1a:00.0).The VMM is the only party that knows both sides. Each
vfio-pci,host=<host BDF>it puts on the QEMU command line hangs off its ownpcie-root-port, and the guest firmware numbers those root-port buses in a fixed order.Fix
Read the pairing from the command line of the running QEMU, and hand it out on two paths.
vmm/src/app/passthrough.rsparses-devicearguments into(guest BDF, host BDF)pairs. The QEMU arguments come from the supervisor process, or from thevm-launcherspec file when the VM runs under the launcher.pcie.0get buses 1, 2, ... in command order. Root ports on apxb-pciegetbus_nr + 1,bus_nr + 2, ...addr=, a root port on an unknown bus, root ports onpcie.0that run into the first expander's bus, or two devices on one guest address. The result is then no pairing rather than a guessed one.ProxiedGuestApi.GpuInfo(the control plane's path) setsGpuDevice.host_pci_bus_idfrom its own reading. It always replaces what the guest sent, because the control plane must not take a card's identity from the guest it is monitoring. A disagreement is logged. This works with every existing guest image, because only the VMM changes.HostApi.GpuTopologylets the guest agent ask for the table itself over vsock. The guest agent then fillshost_pci_bus_idin its ownGpuInfo, which is what in-guest callers of/var/run/dstack.socksee. It also publishes a newdstack_gpu_info{index, uuid, pci_bus_id, host_pci_bus_id} 1series.cvm.gpu.share_host_address, defaultfalse. The address is not secret, but it is host topology a guest otherwise never sees, and/metricsis public when the app setspublic_sysinfo.lspci::normalize_bdfgives one spelling,dddd:bb:dd.f. The same card arrives as1b:00.0(manifest, QEMUhost=),0000:1b:00.0(lspci -D, sysfs) and00000000:1b:00.0(NVML).host_pci_bus_idis documented in both protos as host-reported. It is for labelling telemetry and never for a security decision.Compatibility
host_pci_bus_id. The guest's own API and/metricsare unchanged./metrics. The relay still overwrites it with the VMM's own reading and logs any disagreement.GpuTopologyerrors. The guest leaves the field empty, logs at debug level and retries every 5 minutes, so a VMM upgraded under a running guest is picked up. The call has a 3 s timeout and only runs inside the background GPU sample, never on a request or boot path.VmConfigfield or app-compose field changes, so RTMR0,os_image_hashand KMS checks are untouched.12onGpuDeviceand a new RPC. Nothing is renumbered. The generated serde code has#[serde(default)], so JSON from an older agent still parses.dstack_gpu_*series keep their exact label set. The host address is only on the newdstack_gpu_info, so upgrading does not split their history. Join with* on(index) group_left(host_pci_bus_id) dstack_gpu_info.GpuDevice { .. }without..Default::default()need the new field. The 4 such literals in this repo are updated.Alternatives considered
vfio-pcian explicitid=oraddr=. This changes the QEMU command line:addr=reshapes the guest's ACPI and therefore RTMR0. Rejected; the root ports already carryid=pci.N.VmConfig/ sys-config at boot.VmConfigfeeds KMS and measurement checks and its serialized form is a cache key. Rejected.query-pci. This would read the bus numbers the firmware actually assigned, instead of the rule above. The VMM has no QMP client today, and the socket is single-client. Left as a follow-up if the rule ever proves wrong.Verification
pxb-pciehugepage layout.pcie.0reaching an expander at bus 5. With the overlap check disabled, that test fails./metricslabel split each have a test.cargo fmt --check,cargo check --workspace --all-features --tests, andcargo clippy -D warningspluscargo teston the touched crates (lspci,guest-api,host-api,dstack-util,dstack-guest-agent,dstack-vmm).Not yet verified on hardware: that guest bus N maps to root port N when the slot list is not in ascending host order, and in hugepage (
pxb-pcie) mode. The CVMs checked so far all had their slots already sorted and used the flat layout, so they cannot tell list order from sorted order. To check it: boot a test CVM with the slots listed out of order, plus a hugepage one, and comparenvidia-smi --query-gpu=index,uuid,pci.bus_idin the guest against the host'slspci -vvvDevice Serial Number. Until that is done, treat the pairing as derived from the layout rule, not observed.