QMP

QEMU's machine protocol, by its command and event names. Every command of QEMU 11.1's schema for aarch64 is known; this page lists what each does here.

QMP is QEMU's JSON protocol for controlling a machine. WEMU speaks it by QEMU's names: every command of QEMU 11.1's aarch64 schema is known, and what this machine has no counterpart for is answered as QEMU answers on a machine without it.

Using QMP

From JavaScript

vm.qmp() runs a command and resolves with its return value; errors reject with a QmpError. vm.qmpJson() takes and returns JSON text, and vm.on() delivers events. No negotiation is needed.

await vm.qmp("stop");
const { status } = await vm.qmp("query-status");   // "paused"
vm.on("RESUME", () => console.log("running again"));
await vm.qmp("cont");

Over a socket

Start wemu-system-aarch64 with a QMP server and connect any QMP client, such as QEMU's qmp-shell or socat:

wemu-system-aarch64 -m 1G -kernel vmlinuz-virt -initrd initramfs-virt -nographic \
  -qmp unix:/tmp/wemu.sock,server,nowait
socat - UNIX-CONNECT:/tmp/wemu.sock
{"QMP": {"version": {"wemu": {"major": 11, "minor": 1, "micro": 50}, "package": "warm64 0.1.0"}, "capabilities": ["oob"]}}
{"execute": "qmp_capabilities"}
{"return": {}}
{"execute": "query-status", "id": 1}
{"return": {"status": "running", "singlestep": false, "running": true}, "id": 1}
  • The server sends a greeting; the client answers with qmp_capabilities before anything else. Until then every command is refused with CommandNotFound.
  • Requests may span lines. Replies are one line each, echoing the request's id.
  • Events go to every client that has negotiated.
  • exec-oob is accepted and runs as an ordinary command.
  • Several clients may connect at once, and -qmp may be given more than once. See -qmp for the endpoints.

Errors

An error reply has QEMU's shape: {"error": {"class": "...", "desc": "..."}}. The classes are GenericError, CommandNotFound, DeviceNotFound and DeviceNotActive.

SituationError
Unknown commandCommandNotFound: The command NAME has not been found
Missing argumentGenericError: Parameter 'NAME' is missing
Unknown device or nodeDeviceNotFound: Device 'ID' not found
Adding or removing devices while runninghot-plug is not available on this machine: name the device on the command line
Writing a file on a host without writeFilethe host cannot write files here

Run state

CommandArgumentsDescription
query-status{status, running, singlestep}. See run states.
stopPauses the machine. Emits STOP.
contResumes it. Emits RESUME. Refused after a guest power-off with -no-shutdown (Resetting the Virtual Machine is required) and before migrate-incoming.
system_resetResets the machine. Emits RESET. A kernel boot reloads its kernel and initrd.
system_powerdownPresses the power button: the guest shuts down cleanly. Emits POWERDOWN.
quitStops and releases the machine. Emits SHUTDOWN.
set-actionshutdown, reboot, panicAs -action.

Information

CommandReturns
query-version{"wemu": {"major": 11, "minor": 1, "micro": 50}, "package": "warm64 0.1.0"}
query-name, query-uuidThe -name and -uuid.
query-target{"arch": "aarch64"}
query-machinesThe virt board, cpu-max 8.
query-kvm{"enabled": false, "present": false}
query-accelerators{"enabled": "tcg", "present": ["tcg"]}
query-cpus-fast, query-hotpluggable-cpusOne entry per core.
query-cpu-definitionsThe CPU models -cpu accepts.
query-cpu-model-expansionA model's pauth, sve and mte settings.
query-gic-capabilitiesGIC versions 2 and 3, emulated.
query-memory-size-summary{"base-memory": BYTES, "plugged-memory": 0}
query-commands, query-events, query-qmp-schemaWhat this machine knows.
x-accel-statsInstructions run, and how many ran in compiled code.
x-query-jitThe JIT's counters.
human-monitor-commandRuns a monitor command (command-line) and returns its text.

Memory and dumps

CommandArgumentsDescription
memsaveval, size, filenameSaves guest virtual memory, as core 0 sees it, to a file.
pmemsaveval, size, filenameSaves guest physical memory (RAM) to a file.
dump-guest-memoryprotocol: "file:PATH", formatWrites an ELF core of the guest's RAM and core 0's registers. format is elf (the default; others are refused), and paging dumps are refused. Emits DUMP_COMPLETED.
query-dumpThe last dump's progress.
dumpdtbfilenameWrites the device tree the guest booted with.

Block devices

CommandArgumentsDescription
query-blockEvery virtio disk: its file, whether it's read-only, and its size.
query-blockstatsPer-disk counters.
query-named-block-nodesThe block nodes.

Disks are fixed while the machine runs: block_resize, eject, change and the other removable-media commands are refused (Device 'ID' is not removable), and so are backing chains, block jobs, NBD and I/O throttling, in QEMU's words for a raw image.

The refused commands still look up the disk they name first, so a name that isn't a disk gets QMP's DeviceNotFound (Device 'ID' not found) rather than the refusal. A disk's name is its drive id (virtio0, drive0… when none is given). They read it from:

CommandsArgument
block_resizedevice or node-name
eject, blockdev-open-tray, blockdev-close-tray, blockdev-remove-medium, blockdev-insert-medium, blockdev-change-mediumdevice or id
block-commit, block-stream, blockdev-backup, blockdev-create, blockdev-mirror, blockdev-reopen, blockdev-snapshot, blockdev-snapshot-sync, blockdev-snapshot-internal-sync, blockdev-snapshot-delete-internal-sync, change-backing-file, drive-backup, drive-mirror, x-blockdev-amend, x-blockdev-changedevice, else node-name, else job-id
block-dirty-bitmap-add, block-dirty-bitmap-remove, block-dirty-bitmap-clear, block-dirty-bitmap-enable, block-dirty-bitmap-disable, block-dirty-bitmap-merge, x-debug-block-dirty-bitmap-sha256node; the refusal names the bitmap from name, else target
block-set-write-thresholdnode-name (then returns {})
block-latency-histogram-setid (then returns {})
block_set_io_throttledevice or id

Snapshots and migration

CommandArgumentsDescription
snapshot-savejob-id, tagSaves the whole machine under tag, as a job. Emits JOB_STATUS_CHANGE.
snapshot-loadjob-id, tagRestores a snapshot.
snapshot-deletejob-id, tagDeletes one.
query-jobsThe jobs above. A job's failure is in its error.
job-dismiss, job-finalizeidjob-dismiss removes a concluded job from query-jobs; job-finalize returns {}. An unknown id is Job not found.
migrateuri: "file:PATH", or channelsWrites the machine's state to a file and leaves it paused (postmigrate). Instead of uri, channels may give one {"addr": {"transport": "file", "filename": PATH}}. Emits MIGRATION.
migrate-incominguri: "file:PATH"Loads a state into a machine started with -incoming defer.
query-migrateThe last migration's status.
migrate-set-capabilitiescapabilities: [{capability, state}]Stored, and shown by query-migrate-capabilities. An unknown capability is Invalid parameter 'capability'.
migrate-set-parametersAccepted and stored.

Only migration to and from a file exists. See Snapshots.

Character devices

CommandArgumentsDescription
query-chardev, query-chardev-backendsThe character devices.
ringbuf-writedevice, data, format (utf8 or base64)Sends data to the guest through a serial port bound to a ring buffer.
ringbuf-readdevice, size, formatReads and removes what the guest wrote, oldest first.
chardev-send-breakidSends a serial break (on serial0).

A console a script drives without a terminal:

wemu-system-aarch64 ... -chardev ringbuf,id=con,size=1M -serial chardev:con -display none
await vm.qmp("ringbuf-write", { device: "con", data: "uname -a\n" });
const text = await vm.qmp("ringbuf-read", { device: "con", size: 65536 });

Input

CommandArgumentsDescription
send-keykeys, hold-time (ms, default 100)Presses the keys in order, holds them, and releases them in reverse. Keys are {"type": "qcode", "data": "ctrl"}.
input-send-eventeventsKey presses, buttons, and pointer moves: key, btn (left, right, middle, wheel-up, wheel-down), abs (x or y, 0 to 32767) and rel.
query-miceThe pointing devices.

The pointer is an absolute tablet; rel moves are applied to it. Input needs a keyboard and tablet on the command line, such as -device virtio-keyboard-pci. See Display and input.

await vm.qmp("send-key", { keys: [{ type: "qcode", data: "ctrl" }, { type: "qcode", data: "alt" }, { type: "qcode", data: "f2" }] });
await vm.qmp("input-send-event", { events: [
  { type: "abs", data: { axis: "x", value: 16384 } },
  { type: "abs", data: { axis: "y", value: 16384 } },
  { type: "btn", data: { down: true, button: "left" } },
  { type: "btn", data: { down: false, button: "left" } },
] });

Display

CommandArgumentsDescription
screendumpfilename, format (ppm or png)Saves the screen. Needs a display device.
query-display-optionsThe display type.

Network

CommandArgumentsDescription
set_linkname, upTakes a network card's link down or up. name is the device's id.
query-rx-filterEach network card's receive filter.
announce-selfAccepted.

Devices and objects

CommandArgumentsDescription
query-pciThe PCI functions, when the machine uses PCI.
qom-listpathThe children of /, /machine or /machine/peripheral (the devices given an id). /objects, /chardevs, /machine/peripheral-anon and /machine/unattached are empty; any other path is DeviceNotFound.
qom-getpath, propertytype, gic-version and virtualization of /machine, and type of /. Anything else is DeviceNotFound.
qom-list-typesimplementsThe device drivers, the machine and the CPU models. implements: "machine" or "device" narrows the list; other values don't.
qom-list-getpathsOne empty property list per path.
device-list-propertiestypename[] for a driver this machine has; Device 'NAME' not found otherwise.

Properties can't be changed while the machine runs: qom-set is refused.

Events

EventDataEmitted when
STOPThe machine pauses: stop, migrate, a snapshot, a guest panic.
RESUMEIt resumes after a pause.
RESETguest, reasonsystem_reset or a guest reboot.
POWERDOWNsystem_powerdown.
SHUTDOWNguest, reasonThe guest powers off, or the machine quits.
GUEST_PANICKEDaction (pause, poweroff or run), infoThe guest stops in a way it can't recover from. info is {"type": "hyper-v", "arg1": 0, "arg2": 0, "arg3": 0, "arg4": 0, "arg5": 0, "desc": TEXT}: the five arguments are always 0, and desc says what stopped it.
MIGRATIONstatusA migration changes state.
JOB_STATUS_CHANGEid, statusA snapshot job moves on.
DUMP_COMPLETEDresult: {status, completed, total}dump-guest-memory finishes. completed and total are bytes, both the RAM size.

Every command

Every command of QEMU 11.1's aarch64 schema is known. Those not in the tables above fall into these groups.

More information commands

CommandReturns
query-current-machine{"wakeup-suspend-support": false}
query-audiodevsEach -audiodev: {id, driver}.
query-dump-guest-memory-capability{"formats": ["elf"]}
query-migrate-capabilities, query-migrate-parametersThe values stored by the matching set commands.
query-replay{"mode": "none", "icount": -1}
query-dirty-rate{"status": "unstarted", ...}
query-colo-status{"mode": "none", "last-mode": "none", "reason": "none"}
query-xen-replication-status{"error": false}
query-vnc, query-spice{"enabled": false, ...}
qom-list-properties, qom-list-getEmpty property lists.
x-query-interrupt-controllers, x-query-irq, x-query-network, x-query-numa, x-query-ramblock, x-query-roms, x-query-usb, x-query-usernet, x-query-virtioText or lists describing the machine, as info prints them.
x-debug-query-block-graphThe disks as block nodes.

Empty results

These return [], the answer for a machine with none of the thing asked about: query-acpi-ospm-status, query-block-exports, query-block-jobs, query-command-line-options, query-cryptodev, query-fdsets, query-iothreads, query-memdev, query-memory-devices, query-pr-managers, query-rocker-ports, query-stats, query-stats-schemas, query-tpm, query-tpm-models, query-tpm-types, query-vcpu-dirty-limit, query-vnc-servers, query-yank, trace-event-get-state.

Accepted, with no effect

These return {}: announce-self, block-latency-histogram-set, block-set-write-threshold, blockdev-set-active, calc-dirty-rate, migrate_cancel, migrate-set-capabilities, migrate-set-parameters (both stored), nbd-server-stop, transaction (with no actions), watchdog-set-action, yank (with no instances).

Refused

CommandsAnswer
device_add, device_del, blockdev-add, blockdev-del, netdev_add, netdev_del, chardev-add, object-addhot-plug is not available on this machine: name the device on the command line
object-delobject 'ID' not found
chardev-change, chardev-removeChardev 'ID' is busy for a chardev that exists (by id), Chardev 'ID' not found otherwise.
eject, blockdev-open-tray, blockdev-close-tray, blockdev-remove-medium, blockdev-insert-medium, blockdev-change-mediumDevice 'ID' is not removable
block_resizeCannot resize: the virtio disk's capacity is fixed while the machine runs
blockdev-snapshot-sync, blockdev-snapshot, blockdev-snapshot-internal-sync, blockdev-snapshot-delete-internal-sync, change-backing-file, block-commit, block-stream, drive-backup, blockdev-backup, drive-mirror, blockdev-mirror, blockdev-reopen, blockdev-create, x-blockdev-amend, x-blockdev-changeRaw images have no backing chains, internal snapshots or jobs; savevm and snapshot-save keep the whole machine.
block-dirty-bitmap-add, block-dirty-bitmap-remove, block-dirty-bitmap-clear, block-dirty-bitmap-enable, block-dirty-bitmap-disable, block-dirty-bitmap-merge, x-debug-block-dirty-bitmap-sha256Dirty bitmap 'NAME' not found
block-job-set-speed, block-job-cancel, block-job-pause, block-job-resume, block-job-complete, block-job-dismiss, block-job-finalize, block-job-changeBlock job 'ID' not found
job-pause, job-resume, job-cancel, job-completeFor the job named by id: Job 'ID' in state 'concluded' cannot accept command verb 'VERB', since a snapshot job has concluded when its command returns. An unknown id is Job not found.
block_set_io_throttleI/O throttling is not available on this machine's disks
x-blockdev-set-iothreadIOThreads are not available here
x-wemu-io, x-qemu-iowemu-io is not available here (the disks are the host's images)
nbd-server-start, nbd-server-add, nbd-server-remove, block-export-add, block-export-delNBD server not running
migrate-start-postcopy, migrate-continue, migrate-recover, migrate-pausePostcopy migration isn't available.
set-vcpu-dirty-limit, cancel-vcpu-dirty-limitdirty page limit not supported (it needs KVM's dirty ring)
system_wakeupwake-up from suspend is not supported by this guest
inject-nmimachine does not provide NMIs
inject-ghes-v2-errorGHES is not enabled on this machine (it boots with a device tree, not ACPI)
set-numa-node, x-exit-preconfigThe command is permitted only in 'preconfig' state
query-balloon, balloonNo balloon device has been activated
query-hv-balloon-status-reportno Hyper-V dynamic memory device present
query-vm-generation-idVM Generation ID device not found
query-firmware-logfirmware log buffer not found
query-cpu-model-comparison, query-cpu-model-baselineNot supported on this target.
getfd, add-fdNo file descriptor supplied via SCM_RIGHTS
closefd, remove-fdThe file descriptor isn't found.
add_clientProtocol 'NAME' is invalid
set_password, expire_password, change-vnc-passwordThere's no VNC or SPICE server to set a password on.
client_migrate_infospice is not enabled
display-reload, display-updateThe display has nothing to reload or update.
request-ebpfRSS eBPF program is not available here
device-sync-configNot supported for the device.
qom-setProperty 'NAME' is read-only on this machine
trace-event-set-stateNo trace events found matching 'NAME'
replay-break, replay-delete-break, replay-seekreplay is disabled
query-rocker, query-rocker-of-dpa-flows, query-rocker-of-dpa-groupsrocker NAME not found
x-query-virtio-status, x-query-virtio-queue-status, x-query-virtio-vhost-queue-status, x-query-virtio-queue-elementPath PATH is not a VirtIODevice
cxl-add-dynamic-capacity, cxl-release-dynamic-capacity, cxl-inject-poison, cxl-inject-general-media-event, cxl-inject-dram-event, cxl-inject-memory-module-event, cxl-inject-correctable-error, cxl-inject-uncorrectable-errorsUnable to resolve path: PATH (there's no CXL)
dump-skeysdump-skeys is only for s390x guests
x-colo-lost-heartbeatVM is not in COLO mode
xen-save-devices-state, xen-load-devices-state, xen-set-global-dirty-log, xen-set-replication, xen-colo-do-checkpointthis command is only supported with Xen

See also