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,
175 Copy data from a backing file into a block device.
179 - "job-id": Identifier for the newly-created block job. If omitted,
180 the device name will be used. (json-string, optional)
181 - "device": The device name or node-name of a root node (json-string)
182 - "base": The file name of the backing image above which copying starts.
183 It cannot be set if 'base-node' is also set (json-string, optional)
184 - "base-node": the node name of the backing image above which copying starts.
185 It cannot be set if 'base' is also set.
186 (json-string, optional) (Since 2.8)
187 - "backing-file": The backing file string to write into the active layer. This
188 filename is not validated.
190 If a pathname string is such that it cannot be resolved by
191 QEMU, that means that subsequent QMP or HMP commands must use
192 node-names for the image in question, as filename lookup
195 If not specified, QEMU will automatically determine the
196 backing file string to use, or error out if there is no
197 obvious choice. Care should be taken when specifying the
198 string, to specify a valid filename or protocol.
199 (json-string, optional) (Since 2.1)
200 - "speed": the maximum speed, in bytes per second (json-int, optional)
201 - "on-error": the action to take on an error (default 'report'). 'stop' and
202 'enospc' can only be used if the block device supports io-status.
203 (json-string, optional) (Since 2.1)
207 -> { "execute": "block-stream", "arguments": { "device": "virtio0",
208 "base": "/tmp/master.qcow2" } }
211 blockdev-snapshot-internal-sync
212 -------------------------------
214 Synchronously take an internal snapshot of a block device when the format of
215 image used supports it. If the name is an empty string, or a snapshot with
216 name already exists, the operation will fail.
220 - "device": the device name or node-name of a root node to snapshot
222 - "name": name of the new snapshot (json-string)
226 -> { "execute": "blockdev-snapshot-internal-sync",
227 "arguments": { "device": "ide-hd0",
228 "name": "snapshot0" }
232 blockdev-snapshot-delete-internal-sync
233 --------------------------------------
235 Synchronously delete an internal snapshot of a block device when the format of
236 image used supports it. The snapshot is identified by name or id or both. One
237 of name or id is required. If the snapshot is not found, the operation will
242 - "device": the device name or node-name of a root node (json-string)
243 - "id": ID of the snapshot (json-string, optional)
244 - "name": name of the snapshot (json-string, optional)
248 -> { "execute": "blockdev-snapshot-delete-internal-sync",
249 "arguments": { "device": "ide-hd0",
250 "name": "snapshot0" }
266 Start mirroring a block device's writes to another block device. target
267 specifies the target of mirror operation.
271 - "job-id": Identifier for the newly-created block job. If omitted,
272 the device name will be used. (json-string, optional)
273 - "device": The device name or node-name of a root node whose writes should be
274 mirrored (json-string)
275 - "target": device name to mirror to (json-string)
276 - "replaces": the block driver node name to replace when finished
277 (json-string, optional)
278 - "speed": maximum speed of the streaming job, in bytes per second
280 - "granularity": granularity of the dirty bitmap, in bytes (json-int, optional)
281 - "buf_size": maximum amount of data in flight from source to target, in bytes
282 (json-int, default 10M)
283 - "sync": what parts of the disk image should be copied to the destination;
284 possibilities include "full" for all the disk, "top" for only the sectors
285 allocated in the topmost image, or "none" to only replicate new I/O
287 - "on-source-error": the action to take on an error on the source
288 (BlockdevOnError, default 'report')
289 - "on-target-error": the action to take on an error on the target
290 (BlockdevOnError, default 'report')
292 The default value of the granularity is the image cluster size clamped
293 between 4096 and 65536, if the image format defines one. If the format
294 does not define a cluster size, the default value of the granularity
299 -> { "execute": "blockdev-mirror", "arguments": { "device": "ide-hd0",
307 Enable QMP capabilities.
313 -> { "execute": "qmp_capabilities" }
316 Note: This command must be issued before issuing any other command.
327 Return a json-object with the following information:
329 - "qemu": A json-object containing three integer values:
330 - "major": QEMU's major version (json-int)
331 - "minor": QEMU's minor version (json-int)
332 - "micro": QEMU's micro version (json-int)
333 - "package": package's version (json-string)
337 -> { "execute": "query-version" }
352 List QMP available commands.
354 Each command is represented by a json-object, the returned value is a json-array
357 Each json-object contain:
359 - "name": command's name (json-string)
363 -> { "execute": "query-commands" }
367 "name":"query-balloon"
370 "name":"system_powerdown"
375 Note: This example has been shortened as the real response is too long.
380 Return the QMP wire schema. The returned value is a json-array of
381 named schema entities. Entities are commands, events and various
382 types. See docs/qapi-code-gen.txt for information on their structure
390 This command is still a work in progress. It doesn't support all
391 block drivers among other things. Stay away from it unless you want
392 to help with its development.
394 For the arguments, see the QAPI schema documentation of BlockdevOptions.
398 -> { "execute": "blockdev-add",
399 "arguments": { "driver": "qcow2",
400 "file": { "driver": "file",
401 "filename": "test.qcow2" } } }
406 -> { "execute": "blockdev-add",
409 "node-name": "my_disk",
417 "filename": "/tmp/test.qcow2"
423 "filename": "/dev/fdset/4"
435 Deletes a block device that has been added using blockdev-add.
436 The command will fail if the node is attached to a device or is
437 otherwise being used.
439 This command is still a work in progress and is considered
440 experimental. Stay away from it unless you want to help with its
445 - "node-name": Name of the graph node to delete (json-string)
449 -> { "execute": "blockdev-add",
452 "node-name": "node0",
455 "filename": "test.qcow2"
462 -> { "execute": "x-blockdev-del",
463 "arguments": { "node-name": "node0" }
470 Opens a block device's tray. If there is a block driver state tree inserted as a
471 medium, it will become inaccessible to the guest (but it will remain associated
472 to the block device, so closing the tray will make it accessible again).
474 If the tray was already open before, this will be a no-op.
476 Once the tray opens, a DEVICE_TRAY_MOVED event is emitted. There are cases in
477 which no such event will be generated, these include:
478 - if the guest has locked the tray, @force is false and the guest does not
479 respond to the eject request
480 - if the BlockBackend denoted by @device does not have a guest device attached
482 - if the guest device does not have an actual tray and is empty, for instance
483 for floppy disk drives
487 - "device": block device name (deprecated, use @id instead)
488 (json-string, optional)
489 - "id": the name or QOM path of the guest device (json-string, optional)
490 - "force": if false (the default), an eject request will be sent to the guest if
491 it has locked the tray (and the tray will not be opened immediately);
492 if true, the tray will be opened regardless of whether it is locked
493 (json-bool, optional)
497 -> { "execute": "blockdev-open-tray",
498 "arguments": { "id": "ide0-1-0" } }
500 <- { "timestamp": { "seconds": 1418751016,
501 "microseconds": 716996 },
502 "event": "DEVICE_TRAY_MOVED",
503 "data": { "device": "ide1-cd0",
505 "tray-open": true } }
512 Closes a block device's tray. If there is a block driver state tree associated
513 with the block device (which is currently ejected), that tree will be loaded as
516 If the tray was already closed before, this will be a no-op.
520 - "device": block device name (deprecated, use @id instead)
521 (json-string, optional)
522 - "id": the name or QOM path of the guest device (json-string, optional)
526 -> { "execute": "blockdev-close-tray",
527 "arguments": { "id": "ide0-1-0" } }
529 <- { "timestamp": { "seconds": 1418751345,
530 "microseconds": 272147 },
531 "event": "DEVICE_TRAY_MOVED",
532 "data": { "device": "ide1-cd0",
534 "tray-open": false } }
538 x-blockdev-remove-medium
539 ------------------------
541 Removes a medium (a block driver state tree) from a block device. That block
542 device's tray must currently be open (unless there is no attached guest device).
544 If the tray is open and there is no medium inserted, this will be a no-op.
546 This command is still a work in progress and is considered experimental.
547 Stay away from it unless you want to help with its development.
551 - "device": block device name (deprecated, use @id instead)
552 (json-string, optional)
553 - "id": the name or QOM path of the guest device (json-string, optional)
557 -> { "execute": "x-blockdev-remove-medium",
558 "arguments": { "id": "ide0-1-0" } }
560 <- { "error": { "class": "GenericError",
561 "desc": "Tray of device 'ide0-1-0' is not open" } }
563 -> { "execute": "blockdev-open-tray",
564 "arguments": { "id": "ide0-1-0" } }
566 <- { "timestamp": { "seconds": 1418751627,
567 "microseconds": 549958 },
568 "event": "DEVICE_TRAY_MOVED",
569 "data": { "device": "ide1-cd0",
571 "tray-open": true } }
575 -> { "execute": "x-blockdev-remove-medium",
576 "arguments": { "device": "ide0-1-0" } }
580 x-blockdev-insert-medium
581 ------------------------
583 Inserts a medium (a block driver state tree) into a block device. That block
584 device's tray must currently be open (unless there is no attached guest device)
585 and there must be no medium inserted already.
587 This command is still a work in progress and is considered experimental.
588 Stay away from it unless you want to help with its development.
592 - "device": block device name (deprecated, use @id instead)
593 (json-string, optional)
594 - "id": the name or QOM path of the guest device (json-string, optional)
595 - "node-name": root node of the BDS tree to insert into the block device
599 -> { "execute": "blockdev-add",
600 "arguments": { { "node-name": "node0",
602 "file": { "driver": "file",
603 "filename": "fedora.iso" } } }
607 -> { "execute": "x-blockdev-insert-medium",
608 "arguments": { "id": "ide0-1-0",
609 "node-name": "node0" } }
616 Dynamically reconfigure the block driver state graph. It can be used
617 to add, remove, insert or replace a graph node. Currently only the
618 Quorum driver implements this feature to add or remove its child. This
619 is useful to fix a broken quorum child.
621 If @node is specified, it will be inserted under @parent. @child
622 may not be specified in this case. If both @parent and @child are
623 specified but @node is not, @child will be detached from @parent.
626 - "parent": the id or name of the parent node (json-string)
627 - "child": the name of a child under the given parent node (json-string, optional)
628 - "node": the name of the node that will be added (json-string, optional)
630 Note: this command is experimental, and not a stable API. It doesn't
631 support all kinds of operations, all kinds of children, nor all block
634 Warning: The data in a new quorum child MUST be consistent with that of
635 the rest of the array.
639 Add a new node to a quorum
640 -> { "execute": "blockdev-add",
641 "arguments": { "driver": "raw",
642 "node-name": "new_node",
643 "file": { "driver": "file",
644 "filename": "test.raw" } } }
646 -> { "execute": "x-blockdev-change",
647 "arguments": { "parent": "disk1",
648 "node": "new_node" } }
651 Delete a quorum's node
652 -> { "execute": "x-blockdev-change",
653 "arguments": { "parent": "disk1",
654 "child": "children.1" } }
657 blockdev-change-medium
658 ----------------------
660 Changes the medium inserted into a block device by ejecting the current medium
661 and loading a new image file which is inserted as the new medium.
665 - "device": block device name (deprecated, use @id instead)
666 (json-string, optional)
667 - "id": the name or QOM path of the guest device (json-string, optional)
668 - "filename": filename of the new image (json-string)
669 - "format": format of the new image (json-string, optional)
670 - "read-only-mode": new read-only mode (json-string, optional)
671 - Possible values: "retain" (default), "read-only", "read-write"
675 1. Change a removable medium
677 -> { "execute": "blockdev-change-medium",
678 "arguments": { "id": "ide0-1-0",
679 "filename": "/srv/images/Fedora-12-x86_64-DVD.iso",
683 2. Load a read-only medium into a writable drive
685 -> { "execute": "blockdev-change-medium",
686 "arguments": { "id": "floppyA",
687 "filename": "/srv/images/ro.img",
689 "read-only-mode": "retain" } }
692 { "class": "GenericError",
693 "desc": "Could not open '/srv/images/ro.img': Permission denied" } }
695 -> { "execute": "blockdev-change-medium",
696 "arguments": { "id": "floppyA",
697 "filename": "/srv/images/ro.img",
699 "read-only-mode": "read-only" } }
703 trace-event-get-state
704 ---------------------
706 Query the state of events.
710 - "name": Event name pattern (json-string).
711 - "vcpu": The vCPU to query, any vCPU by default (json-int, optional).
713 An event is returned if:
714 - its name matches the "name" pattern, and
715 - if "vcpu" is given, the event has the "vcpu" property.
717 Therefore, if "vcpu" is given, the operation will only match per-vCPU events,
718 returning their state on the specified vCPU. Special case: if "name" is an exact
719 match, "vcpu" is given and the event does not have the "vcpu" property, an error
724 -> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } }
725 <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] }
727 trace-event-set-state
728 ---------------------
730 Set the state of events.
734 - "name": Event name pattern (json-string).
735 - "enable": Whether to enable or disable the event (json-bool).
736 - "ignore-unavailable": Whether to ignore errors for events that cannot be
737 changed (json-bool, optional).
738 - "vcpu": The vCPU to act upon, all vCPUs by default (json-int, optional).
740 An event's state is modified if:
741 - its name matches the "name" pattern, and
742 - if "vcpu" is given, the event has the "vcpu" property.
744 Therefore, if "vcpu" is given, the operation will only match per-vCPU events,
745 setting their state on the specified vCPU. Special case: if "name" is an exact
746 match, "vcpu" is given and the event does not have the "vcpu" property, an error
751 -> { "execute": "trace-event-set-state", "arguments": { "name": "qemu_memalign", "enable": "true" } }
754 block-set-write-threshold
757 Change the write threshold for a block drive. The threshold is an offset,
758 thus must be non-negative. Default is no write threshold.
759 Setting the threshold to zero disables it.
763 - "node-name": the node name in the block driver state graph (json-string)
764 - "write-threshold": the write threshold in bytes (json-int)
768 -> { "execute": "block-set-write-threshold",
769 "arguments": { "node-name": "mydev",
770 "write-threshold": 17179869184 } }
778 - "name": switch name
782 -> { "execute": "query-rocker", "arguments": { "name": "sw1" } }
783 <- { "return": {"name": "sw1", "ports": 2, "id": 1327446905938}}
785 Show rocker switch ports
786 ------------------------
790 - "name": switch name
794 -> { "execute": "query-rocker-ports", "arguments": { "name": "sw1" } }
795 <- { "return": [ {"duplex": "full", "enabled": true, "name": "sw1.1",
796 "autoneg": "off", "link-up": true, "speed": 10000},
797 {"duplex": "full", "enabled": true, "name": "sw1.2",
798 "autoneg": "off", "link-up": true, "speed": 10000}
801 Show rocker switch OF-DPA flow tables
802 -------------------------------------
806 - "name": switch name
807 - "tbl-id": (optional) flow table ID
811 -> { "execute": "query-rocker-of-dpa-flows", "arguments": { "name": "sw1" } }
812 <- { "return": [ {"key": {"in-pport": 0, "priority": 1, "tbl-id": 0},
815 "action": {"goto-tbl": 10},
816 "mask": {"in-pport": 4294901760}
821 Show rocker OF-DPA group tables
822 -------------------------------
826 - "name": switch name
827 - "type": (optional) group type
831 -> { "execute": "query-rocker-of-dpa-groups", "arguments": { "name": "sw1" } }
832 <- { "return": [ {"type": 0, "out-pport": 2, "pport": 2, "vlan-id": 3841,
833 "pop-vlan": 1, "id": 251723778},
834 {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3841,
835 "pop-vlan": 1, "id": 251723776},
836 {"type": 0, "out-pport": 1, "pport": 1, "vlan-id": 3840,
837 "pop-vlan": 1, "id": 251658241},
838 {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840,
839 "pop-vlan": 1, "id": 251658240}
842 query-gic-capabilities
845 Return a list of GICCapability objects, describing supported GIC
846 (Generic Interrupt Controller) versions.
852 -> { "execute": "query-gic-capabilities" }
853 <- { "return": [{ "version": 2, "emulated": true, "kernel": false },
854 { "version": 3, "emulated": false, "kernel": true } ] }
856 Show existing/possible CPUs
857 ---------------------------
861 Example for pseries machine type started with
862 -smp 2,cores=2,maxcpus=4 -cpu POWER8:
864 -> { "execute": "query-hotpluggable-cpus" }
866 { "props": { "core-id": 8 }, "type": "POWER8-spapr-cpu-core",
868 { "props": { "core-id": 0 }, "type": "POWER8-spapr-cpu-core",
869 "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"}
872 Example for pc machine type started with
874 -> { "execute": "query-hotpluggable-cpus" }
877 "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
878 "props": {"core-id": 0, "socket-id": 1, "thread-id": 0}
881 "qom-path": "/machine/unattached/device[0]",
882 "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
883 "props": {"core-id": 0, "socket-id": 0, "thread-id": 0}