Device adapters
This page is the single source of truth for device and host adapter launch contracts: adapter kinds, kind names, parameters, rendered argv and readiness probe order are defined here. Hardware behaviour lives in chapter 4; this page covers the launch interface only.
Adapter inventory
The repository ships two device adapters plus a template adapter for declared custom devices; the host side has a single qemu-vhost adapter.
Adapter |
Kind |
Model |
Program |
Readiness |
Notes |
|---|---|---|---|---|---|
|
built-in |
gem5 |
|
log marker, then the vfio-user socket |
one GPU per process |
|
built-in |
QEMU |
|
optional log marker, then socket, then QMP |
|
Template device |
declared under |
|
|
log marker, then socket |
|
gem5-mi300x
gem5-mi300x starts one gem5 MI300X GPU per process; the YAML path hard-codes --num-gpus=1, and multiple GPUs are multiple device processes.
Field |
Required |
Default |
Notes |
|---|---|---|---|
|
yes |
— |
points to |
|
no |
|
relative to the workspace root, or searched in |
|
yes |
— |
exactly one region named |
|
no |
— |
when set it must equal |
|
no |
|
1 to 1024 |
|
no |
|
gem5 debug flags written to |
|
no |
|
arguments appended to the |
|
no |
the default listener line |
replaces the log marker used by the readiness probe |
|
no |
— |
recorded in the plan; the launcher does not execute it |
Rendered command:
gem5.opt --outdir=<node>/m5out [--debug-flags=<csv>] --listener-mode=off \
<config> --socket-path=<device.sock> --shared-pool=<pool> \
--pool-vram-offset=<offset> --dgpu-mem-size=<size>B \
--mem-size=<ram>B --host-memory-ranges=<json> \
--num-compute-units=<n> --num-gpus=1 [extra...]
Probes run in order: wait for the default log marker MI300XVfioUser: listening on <socket> (vfio-user protocol) (or the ready_log override), then confirm that the socket exists. A machine with a gem5-mi300x device requires a host memory_map.
qemu-device
qemu-device starts QEMU with -machine x-remote,vfio-user=on,auto-shutdown=off and exports one PCI device through the x-vfio-user-server object. The only shipped sample is edu.
Field |
Required |
Default |
Notes |
|---|---|---|---|
|
yes |
— |
must be a QEMU built with |
|
yes |
— |
QEMU |
|
no |
|
arguments appended to the QEMU command line |
|
no |
— |
rejected; device properties belong in |
|
no |
— |
private memory regions are rejected; use a runtime command template instead |
|
no |
none |
optional log marker; when set it becomes the first probe |
Rendered command:
<qemu-system-<arch>> -machine x-remote,vfio-user=on,auto-shutdown=off -nodefaults \
-display none -qmp unix:<qmp>,server=on,wait=off \
-device '<args.device JSON>' \
-object '{"qom-type":"x-vfio-user-server","id":"vfio0","socket":{"type":"unix","path":"<socket>"},"device":"<device.id>"}'
Probes run in order: the optional log marker, socket existence, then QMP negotiation. This device needs a QEMU build with --enable-vfio-user-server.
Template devices and custom commands
Declare a kind under kinds with role: device and provide argv or command to attach a custom model; the two are mutually exclusive and the device must declare ready_log. runtime.argv or runtime.command overrides any device command and also requires ready_log.
Template device context variables:
Variable |
Meaning |
|---|---|
|
device identifier |
|
owning machine identifier |
|
vfio-user socket path served to the host |
|
memory pool file path of the machine |
|
guest RAM region ( |
|
private regions of this device, indexed by name |
|
guest physical ranges used for |
|
device |
|
device |
|
device model, |
|
session run directory |
|
working directory of the device node |
The rendered result must be a non-empty argument vector; undefined variables are errors. Probes are the log marker followed by the socket.
vHost adapter contract
A vHost kind must declare role: vhost and model: qemu and provide argv or command; max_devices applies to vHost kinds only (64 for qemu-vhost). The qemu-vhost command template allocates a PCIe root port per device first, attaches disks next, and appends vhost.args last.
vHost template context variables:
Variable |
Meaning |
|---|---|
|
validated vHost object with |
|
machine identifier |
|
memory pool file path |
|
guest RAM region |
|
guest physical ranges |
|
direct-boot configuration from the vHost, possibly empty |
|
rendered disk list with |
|
device endpoint list with |
|
QMP socket, serial socket and serial log paths |
|
The vHost's |
|
session run directory and the working directory of this vHost node |
A vHost program must stay in the foreground, keep resource users in its process group and keep inherited descriptors open; QEMU -daemonize is rejected.
Readiness probes and timeouts
After a process starts, probes run in order and the process is ready when all pass; every probe must succeed within --ready-timeout (120 seconds by default). serial.timeout gives the serial marker its own 1 to 86400 second deadline. Devices become ready before the vHost, and the vHost stops before devices.
Probe |
Passing condition |
Used by |
|---|---|---|
|
the process output log contains the given marker |
custom device commands; the optional host |
|
the Unix socket path exists |
gem5 devices, template devices, the host serial socket |
|
the QMP server completes capabilities negotiation |
|
Sources and maintenance
Contract definitions and adapter implementations:
crates/cosim-topology/src/adapter/mod.rs:Adapter,Launch,Probeand template contexts.crates/cosim-topology/src/adapter/gem5.rs:gem5-mi300xparameters and argv.crates/cosim-topology/src/adapter/qemu_device.rs:qemu-deviceparameters and argv.crates/cosim-topology/src/adapter/template.rs: template devices and command rendering.resources/devices/: device template samples;resources/vhosts/qemu.yaml: host command template.
After a change, run:
just run-topology resources/machines/qemu-device.yaml --dry-run
just run-cli validate resources/machines/single-gpu.yaml --assets
just check-cosim