4 This document describes all commands currently supported by QMP.
6 Most of the time their usage is exactly the same as in the user Monitor, this
7 means that any other document which also describe commands (the manpage,
8 QEMU's manual, etc) can and should be consulted.
10 QMP has two types of commands: regular and query commands. Regular commands
11 usually change the Virtual Machine's state someway, while query commands just
12 return information. The sections below are divided accordingly.
14 It's important to observe that all communication examples are formatted in
15 a reader-friendly way, so that they're easier to understand. However, in real
16 protocol usage, they're emitted as a single line.
18 Also, the following notation is used to denote data flow:
20 -> data issued by the Client
21 <- Server data response
23 Please, refer to the QMP specification (docs/qmp-spec.txt) for detailed
24 information on the Server command and response formats.
26 NOTE: This document is temporary and will be replaced soon.
28 1. Stability Considerations
29 ===========================
31 The current QMP command set (described in this file) may be useful for a
32 number of use cases, however it's limited and several commands have bad
33 defined semantics, specially with regard to command completion.
35 These problems are going to be solved incrementally in the next QEMU releases
36 and we're going to establish a deprecation policy for badly defined commands.
38 If you're planning to adopt QMP, please observe the following:
40 1. The deprecation policy will take effect and be documented soon, please
41 check the documentation of each used command as soon as a new release of
44 2. DO NOT rely on anything which is not explicit documented
46 3. Errors, in special, are not documented. Applications should NOT check
47 for specific errors classes or data (it's strongly recommended to only
48 check for the "error" key)
53 Server's responses in the examples below are always a success response, please
54 refer to the QMP specification for more details on error responses.
59 Eject a removable medium.
63 - "force": force ejection (json-bool, optional)
64 - "device": block device name (deprecated, use @id instead)
65 (json-string, optional)
66 - "id": the name or QOM path of the guest device (json-string, optional)
70 -> { "execute": "eject", "arguments": { "id": "ide0-1-0" } }
73 Note: The "force" argument defaults to false.
82 - "driver": the name of the new device's driver (json-string)
83 - "bus": the device's parent bus (device tree path, json-string, optional)
84 - "id": the device's ID, must be unique (json-string)
89 -> { "execute": "device_add", "arguments": { "driver": "e1000", "id": "net1" } }
94 (1) For detailed information about this command, please refer to the
95 'docs/qdev-device-use.txt' file.
97 (2) It's possible to list device properties by running QEMU with the
98 "-device DEVICE,\?" command-line argument, where DEVICE is the device's name
107 - "index": the CPU's index (json-int)
111 -> { "execute": "cpu", "arguments": { "index": 0 } }
114 Note: CPUs' indexes are obtained with the 'query-cpus' command.
116 xen-load-devices-state
117 ----------------------
119 Load the state of all devices from file. The RAM and the block devices
120 of the VM are not loaded by this command.
124 - "filename": the file to load the state of the devices from as binary
125 data. See xen-save-devices-state.txt for a description of the binary
130 -> { "execute": "xen-load-devices-state",
131 "arguments": { "filename": "/tmp/resume" } }
134 migrate-set-cache-size
135 ----------------------
137 Set cache size to be used by XBZRLE migration, the cache size will be rounded
138 down to the nearest power of 2
142 - "value": cache size in bytes (json-int)
146 -> { "execute": "migrate-set-cache-size", "arguments": { "value": 536870912 } }
149 x-colo-lost-heartbeat
152 Tell COLO that heartbeat is lost, a failover or takeover is needed.
156 -> { "execute": "x-colo-lost-heartbeat" }
162 Query background dump status.
168 -> { "execute": "query-dump" }
169 <- { "return": { "status": "active", "completed": 1024000,
172 blockdev-snapshot-internal-sync
173 -------------------------------
175 Synchronously take an internal snapshot of a block device when the format of
176 image used supports it. If the name is an empty string, or a snapshot with
177 name already exists, the operation will fail.
181 - "device": the device name or node-name of a root node to snapshot
183 - "name": name of the new snapshot (json-string)
187 -> { "execute": "blockdev-snapshot-internal-sync",
188 "arguments": { "device": "ide-hd0",
189 "name": "snapshot0" }
193 blockdev-snapshot-delete-internal-sync
194 --------------------------------------
196 Synchronously delete an internal snapshot of a block device when the format of
197 image used supports it. The snapshot is identified by name or id or both. One
198 of name or id is required. If the snapshot is not found, the operation will
203 - "device": the device name or node-name of a root node (json-string)
204 - "id": ID of the snapshot (json-string, optional)
205 - "name": name of the snapshot (json-string, optional)
209 -> { "execute": "blockdev-snapshot-delete-internal-sync",
210 "arguments": { "device": "ide-hd0",
211 "name": "snapshot0" }
227 Start mirroring a block device's writes to another block device. target
228 specifies the target of mirror operation.
232 - "job-id": Identifier for the newly-created block job. If omitted,
233 the device name will be used. (json-string, optional)
234 - "device": The device name or node-name of a root node whose writes should be
235 mirrored (json-string)
236 - "target": device name to mirror to (json-string)
237 - "replaces": the block driver node name to replace when finished
238 (json-string, optional)
239 - "speed": maximum speed of the streaming job, in bytes per second
241 - "granularity": granularity of the dirty bitmap, in bytes (json-int, optional)
242 - "buf_size": maximum amount of data in flight from source to target, in bytes
243 (json-int, default 10M)
244 - "sync": what parts of the disk image should be copied to the destination;
245 possibilities include "full" for all the disk, "top" for only the sectors
246 allocated in the topmost image, or "none" to only replicate new I/O
248 - "on-source-error": the action to take on an error on the source
249 (BlockdevOnError, default 'report')
250 - "on-target-error": the action to take on an error on the target
251 (BlockdevOnError, default 'report')
253 The default value of the granularity is the image cluster size clamped
254 between 4096 and 65536, if the image format defines one. If the format
255 does not define a cluster size, the default value of the granularity
260 -> { "execute": "blockdev-mirror", "arguments": { "device": "ide-hd0",
268 Enable QMP capabilities.
274 -> { "execute": "qmp_capabilities" }
277 Note: This command must be issued before issuing any other command.
288 Return a json-object with the following information:
290 - "qemu": A json-object containing three integer values:
291 - "major": QEMU's major version (json-int)
292 - "minor": QEMU's minor version (json-int)
293 - "micro": QEMU's micro version (json-int)
294 - "package": package's version (json-string)
298 -> { "execute": "query-version" }
313 List QMP available commands.
315 Each command is represented by a json-object, the returned value is a json-array
318 Each json-object contain:
320 - "name": command's name (json-string)
324 -> { "execute": "query-commands" }
328 "name":"query-balloon"
331 "name":"system_powerdown"
336 Note: This example has been shortened as the real response is too long.
341 Return the QMP wire schema. The returned value is a json-array of
342 named schema entities. Entities are commands, events and various
343 types. See docs/qapi-code-gen.txt for information on their structure
350 Deletes a block device that has been added using blockdev-add.
351 The command will fail if the node is attached to a device or is
352 otherwise being used.
354 This command is still a work in progress and is considered
355 experimental. Stay away from it unless you want to help with its
360 - "node-name": Name of the graph node to delete (json-string)
364 -> { "execute": "blockdev-add",
367 "node-name": "node0",
370 "filename": "test.qcow2"
377 -> { "execute": "x-blockdev-del",
378 "arguments": { "node-name": "node0" }
385 Opens a block device's tray. If there is a block driver state tree inserted as a
386 medium, it will become inaccessible to the guest (but it will remain associated
387 to the block device, so closing the tray will make it accessible again).
389 If the tray was already open before, this will be a no-op.
391 Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
392 which no such event will be generated, these include:
393 - if the guest has locked the tray, @force is false and the guest does not
394 respond to the eject request
395 - if the BlockBackend denoted by @device does not have a guest device attached
397 - if the guest device does not have an actual tray and is empty, for instance
398 for floppy disk drives
402 - "device": block device name (deprecated, use @id instead)
403 (json-string, optional)
404 - "id": the name or QOM path of the guest device (json-string, optional)
405 - "force": if false (the default), an eject request will be sent to the guest if
406 it has locked the tray (and the tray will not be opened immediately);
407 if true, the tray will be opened regardless of whether it is locked
408 (json-bool, optional)
412 -> { "execute": "blockdev-open-tray",
413 "arguments": { "id": "ide0-1-0" } }
415 <- { "timestamp": { "seconds": 1418751016,
416 "microseconds": 716996 },
417 "event": "DEVICE_TRAY_MOVED",
418 "data": { "device": "ide1-cd0",
420 "tray-open": true } }
427 Closes a block device's tray. If there is a block driver state tree associated
428 with the block device (which is currently ejected), that tree will be loaded as
431 If the tray was already closed before, this will be a no-op.
435 - "device": block device name (deprecated, use @id instead)
436 (json-string, optional)
437 - "id": the name or QOM path of the guest device (json-string, optional)
441 -> { "execute": "blockdev-close-tray",
442 "arguments": { "id": "ide0-1-0" } }
444 <- { "timestamp": { "seconds": 1418751345,
445 "microseconds": 272147 },
446 "event": "DEVICE_TRAY_MOVED",
447 "data": { "device": "ide1-cd0",
449 "tray-open": false } }
453 x-blockdev-remove-medium
454 ------------------------
456 Removes a medium (a block driver state tree) from a block device. That block
457 device's tray must currently be open (unless there is no attached guest device).
459 If the tray is open and there is no medium inserted, this will be a no-op.
461 This command is still a work in progress and is considered experimental.
462 Stay away from it unless you want to help with its development.
466 - "device": block device name (deprecated, use @id instead)
467 (json-string, optional)
468 - "id": the name or QOM path of the guest device (json-string, optional)
472 -> { "execute": "x-blockdev-remove-medium",
473 "arguments": { "id": "ide0-1-0" } }
475 <- { "error": { "class": "GenericError",
476 "desc": "Tray of device 'ide0-1-0' is not open" } }
478 -> { "execute": "blockdev-open-tray",
479 "arguments": { "id": "ide0-1-0" } }
481 <- { "timestamp": { "seconds": 1418751627,
482 "microseconds": 549958 },
483 "event": "DEVICE_TRAY_MOVED",
484 "data": { "device": "ide1-cd0",
486 "tray-open": true } }
490 -> { "execute": "x-blockdev-remove-medium",
491 "arguments": { "device": "ide0-1-0" } }
495 x-blockdev-insert-medium
496 ------------------------
498 Inserts a medium (a block driver state tree) into a block device. That block
499 device's tray must currently be open (unless there is no attached guest device)
500 and there must be no medium inserted already.
502 This command is still a work in progress and is considered experimental.
503 Stay away from it unless you want to help with its development.
507 - "device": block device name (deprecated, use @id instead)
508 (json-string, optional)
509 - "id": the name or QOM path of the guest device (json-string, optional)
510 - "node-name": root node of the BDS tree to insert into the block device
514 -> { "execute": "blockdev-add",
515 "arguments": { { "node-name": "node0",
517 "file": { "driver": "file",
518 "filename": "fedora.iso" } } }
522 -> { "execute": "x-blockdev-insert-medium",
523 "arguments": { "id": "ide0-1-0",
524 "node-name": "node0" } }
531 Dynamically reconfigure the block driver state graph. It can be used
532 to add, remove, insert or replace a graph node. Currently only the
533 Quorum driver implements this feature to add or remove its child. This
534 is useful to fix a broken quorum child.
536 If @node is specified, it will be inserted under @parent. @child
537 may not be specified in this case. If both @parent and @child are
538 specified but @node is not, @child will be detached from @parent.
541 - "parent": the id or name of the parent node (json-string)
542 - "child": the name of a child under the given parent node (json-string, optional)
543 - "node": the name of the node that will be added (json-string, optional)
545 Note: this command is experimental, and not a stable API. It doesn't
546 support all kinds of operations, all kinds of children, nor all block
549 Warning: The data in a new quorum child MUST be consistent with that of
550 the rest of the array.
554 Add a new node to a quorum
555 -> { "execute": "blockdev-add",
556 "arguments": { "driver": "raw",
557 "node-name": "new_node",
558 "file": { "driver": "file",
559 "filename": "test.raw" } } }
561 -> { "execute": "x-blockdev-change",
562 "arguments": { "parent": "disk1",
563 "node": "new_node" } }
566 Delete a quorum's node
567 -> { "execute": "x-blockdev-change",
568 "arguments": { "parent": "disk1",
569 "child": "children.1" } }
572 blockdev-change-medium
573 ----------------------
575 Changes the medium inserted into a block device by ejecting the current medium
576 and loading a new image file which is inserted as the new medium.
580 - "device": block device name (deprecated, use @id instead)
581 (json-string, optional)
582 - "id": the name or QOM path of the guest device (json-string, optional)
583 - "filename": filename of the new image (json-string)
584 - "format": format of the new image (json-string, optional)
585 - "read-only-mode": new read-only mode (json-string, optional)
586 - Possible values: "retain" (default), "read-only", "read-write"
590 1. Change a removable medium
592 -> { "execute": "blockdev-change-medium",
593 "arguments": { "id": "ide0-1-0",
594 "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
598 2. Load a read-only medium into a writable drive
600 -> { "execute": "blockdev-change-medium",
601 "arguments": { "id": "floppyA",
602 "filename": "/srv/images/ro.img",
604 "read-only-mode": "retain" } }
607 { "class": "GenericError",
608 "desc": "Could not open '/srv/images/ro.img': Permission denied" } }
610 -> { "execute": "blockdev-change-medium",
611 "arguments": { "id": "floppyA",
612 "filename": "/srv/images/ro.img",
614 "read-only-mode": "read-only" } }
618 trace-event-get-state
619 ---------------------
621 Query the state of events.
625 - "name": Event name pattern (json-string).
626 - "vcpu": The vCPU to query, any vCPU by default (json-int, optional).
628 An event is returned if:
629 - its name matches the "name" pattern, and
630 - if "vcpu" is given, the event has the "vcpu" property.
632 Therefore, if "vcpu" is given, the operation will only match per-vCPU events,
633 returning their state on the specified vCPU. Special case: if "name" is an exact
634 match, "vcpu" is given and the event does not have the "vcpu" property, an error
639 -> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } }
640 <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] }
642 trace-event-set-state
643 ---------------------
645 Set the state of events.
649 - "name": Event name pattern (json-string).
650 - "enable": Whether to enable or disable the event (json-bool).
651 - "ignore-unavailable": Whether to ignore errors for events that cannot be
652 changed (json-bool, optional).
653 - "vcpu": The vCPU to act upon, all vCPUs by default (json-int, optional).
655 An event's state is modified if:
656 - its name matches the "name" pattern, and
657 - if "vcpu" is given, the event has the "vcpu" property.
659 Therefore, if "vcpu" is given, the operation will only match per-vCPU events,
660 setting their state on the specified vCPU. Special case: if "name" is an exact
661 match, "vcpu" is given and the event does not have the "vcpu" property, an error
666 -> { "execute": "trace-event-set-state", "arguments": { "name": "qemu_memalign", "enable": "true" } }
669 block-set-write-threshold
672 Change the write threshold for a block drive. The threshold is an offset,
673 thus must be non-negative. Default is no write threshold.
674 Setting the threshold to zero disables it.
678 - "node-name": the node name in the block driver state graph (json-string)
679 - "write-threshold": the write threshold in bytes (json-int)
683 -> { "execute": "block-set-write-threshold",
684 "arguments": { "node-name": "mydev",
685 "write-threshold": 17179869184 } }
693 - "name": switch name
697 -> { "execute": "query-rocker", "arguments": { "name": "sw1" } }
698 <- { "return": {"name": "sw1", "ports": 2, "id": 1327446905938}}
700 Show rocker switch ports
701 ------------------------
705 - "name": switch name
709 -> { "execute": "query-rocker-ports", "arguments": { "name": "sw1" } }
710 <- { "return": [ {"duplex": "full", "enabled": true, "name": "sw1.1",
711 "autoneg": "off", "link-up": true, "speed": 10000},
712 {"duplex": "full", "enabled": true, "name": "sw1.2",
713 "autoneg": "off", "link-up": true, "speed": 10000}
716 Show rocker switch OF-DPA flow tables
717 -------------------------------------
721 - "name": switch name
722 - "tbl-id": (optional) flow table ID
726 -> { "execute": "query-rocker-of-dpa-flows", "arguments": { "name": "sw1" } }
727 <- { "return": [ {"key": {"in-pport": 0, "priority": 1, "tbl-id": 0},
730 "action": {"goto-tbl": 10},
731 "mask": {"in-pport": 4294901760}
736 Show rocker OF-DPA group tables
737 -------------------------------
741 - "name": switch name
742 - "type": (optional) group type
746 -> { "execute": "query-rocker-of-dpa-groups", "arguments": { "name": "sw1" } }
747 <- { "return": [ {"type": 0, "out-pport": 2, "pport": 2, "vlan-id": 3841,
748 "pop-vlan": 1, "id": 251723778},
749 {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3841,
750 "pop-vlan": 1, "id": 251723776},
751 {"type": 0, "out-pport": 1, "pport": 1, "vlan-id": 3840,
752 "pop-vlan": 1, "id": 251658241},
753 {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840,
754 "pop-vlan": 1, "id": 251658240}
757 query-gic-capabilities
760 Return a list of GICCapability objects, describing supported GIC
761 (Generic Interrupt Controller) versions.
767 -> { "execute": "query-gic-capabilities" }
768 <- { "return": [{ "version": 2, "emulated": true, "kernel": false },
769 { "version": 3, "emulated": false, "kernel": true } ] }
771 Show existing/possible CPUs
772 ---------------------------
776 Example for pseries machine type started with
777 -smp 2,cores=2,maxcpus=4 -cpu POWER8:
779 -> { "execute": "query-hotpluggable-cpus" }
781 { "props": { "core-id": 8 }, "type": "POWER8-spapr-cpu-core",
783 { "props": { "core-id": 0 }, "type": "POWER8-spapr-cpu-core",
784 "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"}
787 Example for pc machine type started with
789 -> { "execute": "query-hotpluggable-cpus" }
792 "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
793 "props": {"core-id": 0, "socket-id": 1, "thread-id": 0}
796 "qom-path": "/machine/unattached/device[0]",
797 "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
798 "props": {"core-id": 0, "socket-id": 0, "thread-id": 0}