]> git.proxmox.com Git - qemu.git/blob - qmp-commands.hx
guest agent: use QERR_UNSUPPORTED for disabled RPCs
[qemu.git] / qmp-commands.hx
1 HXCOMM QMP dispatch table and documentation
2 HXCOMM Text between SQMP and EQMP is copied to the QMP documention file and
3 HXCOMM does not show up in the other formats.
4
5 SQMP
6 QMP Supported Commands
7 ----------------------
8
9 This document describes all commands currently supported by QMP.
10
11 Most of the time their usage is exactly the same as in the user Monitor, this
12 means that any other document which also describe commands (the manpage,
13 QEMU's manual, etc) can and should be consulted.
14
15 QMP has two types of commands: regular and query commands. Regular commands
16 usually change the Virtual Machine's state someway, while query commands just
17 return information. The sections below are divided accordingly.
18
19 It's important to observe that all communication examples are formatted in
20 a reader-friendly way, so that they're easier to understand. However, in real
21 protocol usage, they're emitted as a single line.
22
23 Also, the following notation is used to denote data flow:
24
25 -> data issued by the Client
26 <- Server data response
27
28 Please, refer to the QMP specification (QMP/qmp-spec.txt) for detailed
29 information on the Server command and response formats.
30
31 NOTE: This document is temporary and will be replaced soon.
32
33 1. Stability Considerations
34 ===========================
35
36 The current QMP command set (described in this file) may be useful for a
37 number of use cases, however it's limited and several commands have bad
38 defined semantics, specially with regard to command completion.
39
40 These problems are going to be solved incrementally in the next QEMU releases
41 and we're going to establish a deprecation policy for badly defined commands.
42
43 If you're planning to adopt QMP, please observe the following:
44
45 1. The deprecation policy will take efect and be documented soon, please
46 check the documentation of each used command as soon as a new release of
47 QEMU is available
48
49 2. DO NOT rely on anything which is not explicit documented
50
51 3. Errors, in special, are not documented. Applications should NOT check
52 for specific errors classes or data (it's strongly recommended to only
53 check for the "error" key)
54
55 2. Regular Commands
56 ===================
57
58 Server's responses in the examples below are always a success response, please
59 refer to the QMP specification for more details on error responses.
60
61 EQMP
62
63 {
64 .name = "quit",
65 .args_type = "",
66 .params = "",
67 .help = "quit the emulator",
68 .user_print = monitor_user_noop,
69 .mhandler.cmd_new = do_quit,
70 },
71
72 SQMP
73 quit
74 ----
75
76 Quit the emulator.
77
78 Arguments: None.
79
80 Example:
81
82 -> { "execute": "quit" }
83 <- { "return": {} }
84
85 EQMP
86
87 {
88 .name = "eject",
89 .args_type = "force:-f,device:B",
90 .params = "[-f] device",
91 .help = "eject a removable medium (use -f to force it)",
92 .user_print = monitor_user_noop,
93 .mhandler.cmd_new = do_eject,
94 },
95
96 SQMP
97 eject
98 -----
99
100 Eject a removable medium.
101
102 Arguments:
103
104 - force: force ejection (json-bool, optional)
105 - device: device name (json-string)
106
107 Example:
108
109 -> { "execute": "eject", "arguments": { "device": "ide1-cd0" } }
110 <- { "return": {} }
111
112 Note: The "force" argument defaults to false.
113
114 EQMP
115
116 {
117 .name = "change",
118 .args_type = "device:B,target:F,arg:s?",
119 .params = "device filename [format]",
120 .help = "change a removable medium, optional format",
121 .user_print = monitor_user_noop,
122 .mhandler.cmd_new = do_change,
123 },
124
125 SQMP
126 change
127 ------
128
129 Change a removable medium or VNC configuration.
130
131 Arguments:
132
133 - "device": device name (json-string)
134 - "target": filename or item (json-string)
135 - "arg": additional argument (json-string, optional)
136
137 Examples:
138
139 1. Change a removable medium
140
141 -> { "execute": "change",
142 "arguments": { "device": "ide1-cd0",
143 "target": "/srv/images/Fedora-12-x86_64-DVD.iso" } }
144 <- { "return": {} }
145
146 2. Change VNC password
147
148 -> { "execute": "change",
149 "arguments": { "device": "vnc", "target": "password",
150 "arg": "foobar1" } }
151 <- { "return": {} }
152
153 EQMP
154
155 {
156 .name = "screendump",
157 .args_type = "filename:F",
158 .params = "filename",
159 .help = "save screen into PPM image 'filename'",
160 .user_print = monitor_user_noop,
161 .mhandler.cmd_new = do_screen_dump,
162 },
163
164 SQMP
165 screendump
166 ----------
167
168 Save screen into PPM image.
169
170 Arguments:
171
172 - "filename": file path (json-string)
173
174 Example:
175
176 -> { "execute": "screendump", "arguments": { "filename": "/tmp/image" } }
177 <- { "return": {} }
178
179 EQMP
180
181 {
182 .name = "stop",
183 .args_type = "",
184 .params = "",
185 .help = "stop emulation",
186 .user_print = monitor_user_noop,
187 .mhandler.cmd_new = do_stop,
188 },
189
190 SQMP
191 stop
192 ----
193
194 Stop the emulator.
195
196 Arguments: None.
197
198 Example:
199
200 -> { "execute": "stop" }
201 <- { "return": {} }
202
203 EQMP
204
205 {
206 .name = "cont",
207 .args_type = "",
208 .params = "",
209 .help = "resume emulation",
210 .user_print = monitor_user_noop,
211 .mhandler.cmd_new = do_cont,
212 },
213
214 SQMP
215 cont
216 ----
217
218 Resume emulation.
219
220 Arguments: None.
221
222 Example:
223
224 -> { "execute": "cont" }
225 <- { "return": {} }
226
227 EQMP
228
229 {
230 .name = "system_reset",
231 .args_type = "",
232 .params = "",
233 .help = "reset the system",
234 .user_print = monitor_user_noop,
235 .mhandler.cmd_new = do_system_reset,
236 },
237
238 SQMP
239 system_reset
240 ------------
241
242 Reset the system.
243
244 Arguments: None.
245
246 Example:
247
248 -> { "execute": "system_reset" }
249 <- { "return": {} }
250
251 EQMP
252
253 {
254 .name = "system_powerdown",
255 .args_type = "",
256 .params = "",
257 .help = "send system power down event",
258 .user_print = monitor_user_noop,
259 .mhandler.cmd_new = do_system_powerdown,
260 },
261
262 SQMP
263 system_powerdown
264 ----------------
265
266 Send system power down event.
267
268 Arguments: None.
269
270 Example:
271
272 -> { "execute": "system_powerdown" }
273 <- { "return": {} }
274
275 EQMP
276
277 {
278 .name = "device_add",
279 .args_type = "device:O",
280 .params = "driver[,prop=value][,...]",
281 .help = "add device, like -device on the command line",
282 .user_print = monitor_user_noop,
283 .mhandler.cmd_new = do_device_add,
284 },
285
286 SQMP
287 device_add
288 ----------
289
290 Add a device.
291
292 Arguments:
293
294 - "driver": the name of the new device's driver (json-string)
295 - "bus": the device's parent bus (device tree path, json-string, optional)
296 - "id": the device's ID, must be unique (json-string)
297 - device properties
298
299 Example:
300
301 -> { "execute": "device_add", "arguments": { "driver": "e1000", "id": "net1" } }
302 <- { "return": {} }
303
304 Notes:
305
306 (1) For detailed information about this command, please refer to the
307 'docs/qdev-device-use.txt' file.
308
309 (2) It's possible to list device properties by running QEMU with the
310 "-device DEVICE,\?" command-line argument, where DEVICE is the device's name
311
312 EQMP
313
314 {
315 .name = "device_del",
316 .args_type = "id:s",
317 .params = "device",
318 .help = "remove device",
319 .user_print = monitor_user_noop,
320 .mhandler.cmd_new = do_device_del,
321 },
322
323 SQMP
324 device_del
325 ----------
326
327 Remove a device.
328
329 Arguments:
330
331 - "id": the device's ID (json-string)
332
333 Example:
334
335 -> { "execute": "device_del", "arguments": { "id": "net1" } }
336 <- { "return": {} }
337
338 EQMP
339
340 {
341 .name = "cpu",
342 .args_type = "index:i",
343 .params = "index",
344 .help = "set the default CPU",
345 .user_print = monitor_user_noop,
346 .mhandler.cmd_new = do_cpu_set,
347 },
348
349 SQMP
350 cpu
351 ---
352
353 Set the default CPU.
354
355 Arguments:
356
357 - "index": the CPU's index (json-int)
358
359 Example:
360
361 -> { "execute": "cpu", "arguments": { "index": 0 } }
362 <- { "return": {} }
363
364 Note: CPUs' indexes are obtained with the 'query-cpus' command.
365
366 EQMP
367
368 {
369 .name = "memsave",
370 .args_type = "val:l,size:i,filename:s",
371 .params = "addr size file",
372 .help = "save to disk virtual memory dump starting at 'addr' of size 'size'",
373 .user_print = monitor_user_noop,
374 .mhandler.cmd_new = do_memory_save,
375 },
376
377 SQMP
378 memsave
379 -------
380
381 Save to disk virtual memory dump starting at 'val' of size 'size'.
382
383 Arguments:
384
385 - "val": the starting address (json-int)
386 - "size": the memory size, in bytes (json-int)
387 - "filename": file path (json-string)
388
389 Example:
390
391 -> { "execute": "memsave",
392 "arguments": { "val": 10,
393 "size": 100,
394 "filename": "/tmp/virtual-mem-dump" } }
395 <- { "return": {} }
396
397 Note: Depends on the current CPU.
398
399 EQMP
400
401 {
402 .name = "pmemsave",
403 .args_type = "val:l,size:i,filename:s",
404 .params = "addr size file",
405 .help = "save to disk physical memory dump starting at 'addr' of size 'size'",
406 .user_print = monitor_user_noop,
407 .mhandler.cmd_new = do_physical_memory_save,
408 },
409
410 SQMP
411 pmemsave
412 --------
413
414 Save to disk physical memory dump starting at 'val' of size 'size'.
415
416 Arguments:
417
418 - "val": the starting address (json-int)
419 - "size": the memory size, in bytes (json-int)
420 - "filename": file path (json-string)
421
422 Example:
423
424 -> { "execute": "pmemsave",
425 "arguments": { "val": 10,
426 "size": 100,
427 "filename": "/tmp/physical-mem-dump" } }
428 <- { "return": {} }
429
430 EQMP
431
432 {
433 .name = "inject-nmi",
434 .args_type = "",
435 .params = "",
436 .help = "",
437 .user_print = monitor_user_noop,
438 .mhandler.cmd_new = do_inject_nmi,
439 },
440
441 SQMP
442 inject-nmi
443 ----------
444
445 Inject an NMI on guest's CPUs.
446
447 Arguments: None.
448
449 Example:
450
451 -> { "execute": "inject-nmi" }
452 <- { "return": {} }
453
454 Note: inject-nmi is only supported for x86 guest currently, it will
455 returns "Unsupported" error for non-x86 guest.
456
457 EQMP
458
459 {
460 .name = "migrate",
461 .args_type = "detach:-d,blk:-b,inc:-i,uri:s",
462 .params = "[-d] [-b] [-i] uri",
463 .help = "migrate to URI (using -d to not wait for completion)"
464 "\n\t\t\t -b for migration without shared storage with"
465 " full copy of disk\n\t\t\t -i for migration without "
466 "shared storage with incremental copy of disk "
467 "(base image shared between src and destination)",
468 .user_print = monitor_user_noop,
469 .mhandler.cmd_new = do_migrate,
470 },
471
472 SQMP
473 migrate
474 -------
475
476 Migrate to URI.
477
478 Arguments:
479
480 - "blk": block migration, full disk copy (json-bool, optional)
481 - "inc": incremental disk copy (json-bool, optional)
482 - "uri": Destination URI (json-string)
483
484 Example:
485
486 -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } }
487 <- { "return": {} }
488
489 Notes:
490
491 (1) The 'query-migrate' command should be used to check migration's progress
492 and final result (this information is provided by the 'status' member)
493 (2) All boolean arguments default to false
494 (3) The user Monitor's "detach" argument is invalid in QMP and should not
495 be used
496
497 EQMP
498
499 {
500 .name = "migrate_cancel",
501 .args_type = "",
502 .params = "",
503 .help = "cancel the current VM migration",
504 .user_print = monitor_user_noop,
505 .mhandler.cmd_new = do_migrate_cancel,
506 },
507
508 SQMP
509 migrate_cancel
510 --------------
511
512 Cancel the current migration.
513
514 Arguments: None.
515
516 Example:
517
518 -> { "execute": "migrate_cancel" }
519 <- { "return": {} }
520
521 EQMP
522
523 {
524 .name = "migrate_set_speed",
525 .args_type = "value:o",
526 .params = "value",
527 .help = "set maximum speed (in bytes) for migrations",
528 .user_print = monitor_user_noop,
529 .mhandler.cmd_new = do_migrate_set_speed,
530 },
531
532 SQMP
533 migrate_set_speed
534 -----------------
535
536 Set maximum speed for migrations.
537
538 Arguments:
539
540 - "value": maximum speed, in bytes per second (json-int)
541
542 Example:
543
544 -> { "execute": "migrate_set_speed", "arguments": { "value": 1024 } }
545 <- { "return": {} }
546
547 EQMP
548
549 {
550 .name = "migrate_set_downtime",
551 .args_type = "value:T",
552 .params = "value",
553 .help = "set maximum tolerated downtime (in seconds) for migrations",
554 .user_print = monitor_user_noop,
555 .mhandler.cmd_new = do_migrate_set_downtime,
556 },
557
558 SQMP
559 migrate_set_downtime
560 --------------------
561
562 Set maximum tolerated downtime (in seconds) for migrations.
563
564 Arguments:
565
566 - "value": maximum downtime (json-number)
567
568 Example:
569
570 -> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } }
571 <- { "return": {} }
572
573 EQMP
574
575 {
576 .name = "client_migrate_info",
577 .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?",
578 .params = "protocol hostname port tls-port cert-subject",
579 .help = "send migration info to spice/vnc client",
580 .user_print = monitor_user_noop,
581 .mhandler.cmd_new = client_migrate_info,
582 },
583
584 SQMP
585 client_migrate_info
586 ------------------
587
588 Set the spice/vnc connection info for the migration target. The spice/vnc
589 server will ask the spice/vnc client to automatically reconnect using the
590 new parameters (if specified) once the vm migration finished successfully.
591
592 Arguments:
593
594 - "protocol": protocol: "spice" or "vnc" (json-string)
595 - "hostname": migration target hostname (json-string)
596 - "port": spice/vnc tcp port for plaintext channels (json-int, optional)
597 - "tls-port": spice tcp port for tls-secured channels (json-int, optional)
598 - "cert-subject": server certificate subject (json-string, optional)
599
600 Example:
601
602 -> { "execute": "client_migrate_info",
603 "arguments": { "protocol": "spice",
604 "hostname": "virt42.lab.kraxel.org",
605 "port": 1234 } }
606 <- { "return": {} }
607
608 EQMP
609
610 {
611 .name = "netdev_add",
612 .args_type = "netdev:O",
613 .params = "[user|tap|socket],id=str[,prop=value][,...]",
614 .help = "add host network device",
615 .user_print = monitor_user_noop,
616 .mhandler.cmd_new = do_netdev_add,
617 },
618
619 SQMP
620 netdev_add
621 ----------
622
623 Add host network device.
624
625 Arguments:
626
627 - "type": the device type, "tap", "user", ... (json-string)
628 - "id": the device's ID, must be unique (json-string)
629 - device options
630
631 Example:
632
633 -> { "execute": "netdev_add", "arguments": { "type": "user", "id": "netdev1" } }
634 <- { "return": {} }
635
636 Note: The supported device options are the same ones supported by the '-net'
637 command-line argument, which are listed in the '-help' output or QEMU's
638 manual
639
640 EQMP
641
642 {
643 .name = "netdev_del",
644 .args_type = "id:s",
645 .params = "id",
646 .help = "remove host network device",
647 .user_print = monitor_user_noop,
648 .mhandler.cmd_new = do_netdev_del,
649 },
650
651 SQMP
652 netdev_del
653 ----------
654
655 Remove host network device.
656
657 Arguments:
658
659 - "id": the device's ID, must be unique (json-string)
660
661 Example:
662
663 -> { "execute": "netdev_del", "arguments": { "id": "netdev1" } }
664 <- { "return": {} }
665
666
667 EQMP
668
669 {
670 .name = "block_resize",
671 .args_type = "device:B,size:o",
672 .params = "device size",
673 .help = "resize a block image",
674 .user_print = monitor_user_noop,
675 .mhandler.cmd_new = do_block_resize,
676 },
677
678 SQMP
679 block_resize
680 ------------
681
682 Resize a block image while a guest is running.
683
684 Arguments:
685
686 - "device": the device's ID, must be unique (json-string)
687 - "size": new size
688
689 Example:
690
691 -> { "execute": "block_resize", "arguments": { "device": "scratch", "size": 1073741824 } }
692 <- { "return": {} }
693
694 EQMP
695
696 {
697 .name = "blockdev-snapshot-sync",
698 .args_type = "device:B,snapshot-file:s?,format:s?",
699 .params = "device [new-image-file] [format]",
700 .user_print = monitor_user_noop,
701 .mhandler.cmd_new = do_snapshot_blkdev,
702 },
703
704 SQMP
705 blockdev-snapshot-sync
706 ----------------------
707
708 Synchronous snapshot of a block device. snapshot-file specifies the
709 target of the new image. If the file exists, or if it is a device, the
710 snapshot will be created in the existing file/device. If does not
711 exist, a new file will be created. format specifies the format of the
712 snapshot image, default is qcow2.
713
714 Arguments:
715
716 - "device": device name to snapshot (json-string)
717 - "snapshot-file": name of new image file (json-string)
718 - "format": format of new image (json-string, optional)
719
720 Example:
721
722 -> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0",
723 "snapshot-file":
724 "/some/place/my-image",
725 "format": "qcow2" } }
726 <- { "return": {} }
727
728 EQMP
729
730 {
731 .name = "balloon",
732 .args_type = "value:M",
733 .params = "target",
734 .help = "request VM to change its memory allocation (in MB)",
735 .user_print = monitor_user_noop,
736 .mhandler.cmd_async = do_balloon,
737 .flags = MONITOR_CMD_ASYNC,
738 },
739
740 SQMP
741 balloon
742 -------
743
744 Request VM to change its memory allocation (in bytes).
745
746 Arguments:
747
748 - "value": New memory allocation (json-int)
749
750 Example:
751
752 -> { "execute": "balloon", "arguments": { "value": 536870912 } }
753 <- { "return": {} }
754
755 EQMP
756
757 {
758 .name = "set_link",
759 .args_type = "name:s,up:b",
760 .params = "name on|off",
761 .help = "change the link status of a network adapter",
762 .user_print = monitor_user_noop,
763 .mhandler.cmd_new = do_set_link,
764 },
765
766 SQMP
767 set_link
768 --------
769
770 Change the link status of a network adapter.
771
772 Arguments:
773
774 - "name": network device name (json-string)
775 - "up": status is up (json-bool)
776
777 Example:
778
779 -> { "execute": "set_link", "arguments": { "name": "e1000.0", "up": false } }
780 <- { "return": {} }
781
782 EQMP
783
784 {
785 .name = "getfd",
786 .args_type = "fdname:s",
787 .params = "getfd name",
788 .help = "receive a file descriptor via SCM rights and assign it a name",
789 .user_print = monitor_user_noop,
790 .mhandler.cmd_new = do_getfd,
791 },
792
793 SQMP
794 getfd
795 -----
796
797 Receive a file descriptor via SCM rights and assign it a name.
798
799 Arguments:
800
801 - "fdname": file descriptor name (json-string)
802
803 Example:
804
805 -> { "execute": "getfd", "arguments": { "fdname": "fd1" } }
806 <- { "return": {} }
807
808 EQMP
809
810 {
811 .name = "closefd",
812 .args_type = "fdname:s",
813 .params = "closefd name",
814 .help = "close a file descriptor previously passed via SCM rights",
815 .user_print = monitor_user_noop,
816 .mhandler.cmd_new = do_closefd,
817 },
818
819 SQMP
820 closefd
821 -------
822
823 Close a file descriptor previously passed via SCM rights.
824
825 Arguments:
826
827 - "fdname": file descriptor name (json-string)
828
829 Example:
830
831 -> { "execute": "closefd", "arguments": { "fdname": "fd1" } }
832 <- { "return": {} }
833
834 EQMP
835
836 {
837 .name = "block_passwd",
838 .args_type = "device:B,password:s",
839 .params = "block_passwd device password",
840 .help = "set the password of encrypted block devices",
841 .user_print = monitor_user_noop,
842 .mhandler.cmd_new = do_block_set_passwd,
843 },
844
845 SQMP
846 block_passwd
847 ------------
848
849 Set the password of encrypted block devices.
850
851 Arguments:
852
853 - "device": device name (json-string)
854 - "password": password (json-string)
855
856 Example:
857
858 -> { "execute": "block_passwd", "arguments": { "device": "ide0-hd0",
859 "password": "12345" } }
860 <- { "return": {} }
861
862 EQMP
863
864 {
865 .name = "set_password",
866 .args_type = "protocol:s,password:s,connected:s?",
867 .params = "protocol password action-if-connected",
868 .help = "set spice/vnc password",
869 .user_print = monitor_user_noop,
870 .mhandler.cmd_new = set_password,
871 },
872
873 SQMP
874 set_password
875 ------------
876
877 Set the password for vnc/spice protocols.
878
879 Arguments:
880
881 - "protocol": protocol name (json-string)
882 - "password": password (json-string)
883 - "connected": [ keep | disconnect | fail ] (josn-string, optional)
884
885 Example:
886
887 -> { "execute": "set_password", "arguments": { "protocol": "vnc",
888 "password": "secret" } }
889 <- { "return": {} }
890
891 EQMP
892
893 {
894 .name = "expire_password",
895 .args_type = "protocol:s,time:s",
896 .params = "protocol time",
897 .help = "set spice/vnc password expire-time",
898 .user_print = monitor_user_noop,
899 .mhandler.cmd_new = expire_password,
900 },
901
902 SQMP
903 expire_password
904 ---------------
905
906 Set the password expire time for vnc/spice protocols.
907
908 Arguments:
909
910 - "protocol": protocol name (json-string)
911 - "time": [ now | never | +secs | secs ] (json-string)
912
913 Example:
914
915 -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
916 "time": "+60" } }
917 <- { "return": {} }
918
919 EQMP
920
921 {
922 .name = "qmp_capabilities",
923 .args_type = "",
924 .params = "",
925 .help = "enable QMP capabilities",
926 .user_print = monitor_user_noop,
927 .mhandler.cmd_new = do_qmp_capabilities,
928 },
929
930 SQMP
931 qmp_capabilities
932 ----------------
933
934 Enable QMP capabilities.
935
936 Arguments: None.
937
938 Example:
939
940 -> { "execute": "qmp_capabilities" }
941 <- { "return": {} }
942
943 Note: This command must be issued before issuing any other command.
944
945 EQMP
946
947 {
948 .name = "human-monitor-command",
949 .args_type = "command-line:s,cpu-index:i?",
950 .params = "",
951 .help = "",
952 .user_print = monitor_user_noop,
953 .mhandler.cmd_new = do_hmp_passthrough,
954 },
955
956 SQMP
957 human-monitor-command
958 ---------------------
959
960 Execute a Human Monitor command.
961
962 Arguments:
963
964 - command-line: the command name and its arguments, just like the
965 Human Monitor's shell (json-string)
966 - cpu-index: select the CPU number to be used by commands which access CPU
967 data, like 'info registers'. The Monitor selects CPU 0 if this
968 argument is not provided (json-int, optional)
969
970 Example:
971
972 -> { "execute": "human-monitor-command", "arguments": { "command-line": "info kvm" } }
973 <- { "return": "kvm support: enabled\r\n" }
974
975 Notes:
976
977 (1) The Human Monitor is NOT an stable interface, this means that command
978 names, arguments and responses can change or be removed at ANY time.
979 Applications that rely on long term stability guarantees should NOT
980 use this command
981
982 (2) Limitations:
983
984 o This command is stateless, this means that commands that depend
985 on state information (such as getfd) might not work
986
987 o Commands that prompt the user for data (eg. 'cont' when the block
988 device is encrypted) don't currently work
989
990 3. Query Commands
991 =================
992
993 HXCOMM Each query command below is inside a SQMP/EQMP section, do NOT change
994 HXCOMM this! We will possibly move query commands definitions inside those
995 HXCOMM sections, just like regular commands.
996
997 EQMP
998
999 SQMP
1000 query-version
1001 -------------
1002
1003 Show QEMU version.
1004
1005 Return a json-object with the following information:
1006
1007 - "qemu": A json-object containing three integer values:
1008 - "major": QEMU's major version (json-int)
1009 - "minor": QEMU's minor version (json-int)
1010 - "micro": QEMU's micro version (json-int)
1011 - "package": package's version (json-string)
1012
1013 Example:
1014
1015 -> { "execute": "query-version" }
1016 <- {
1017 "return":{
1018 "qemu":{
1019 "major":0,
1020 "minor":11,
1021 "micro":5
1022 },
1023 "package":""
1024 }
1025 }
1026
1027 EQMP
1028
1029 SQMP
1030 query-commands
1031 --------------
1032
1033 List QMP available commands.
1034
1035 Each command is represented by a json-object, the returned value is a json-array
1036 of all commands.
1037
1038 Each json-object contain:
1039
1040 - "name": command's name (json-string)
1041
1042 Example:
1043
1044 -> { "execute": "query-commands" }
1045 <- {
1046 "return":[
1047 {
1048 "name":"query-balloon"
1049 },
1050 {
1051 "name":"system_powerdown"
1052 }
1053 ]
1054 }
1055
1056 Note: This example has been shortened as the real response is too long.
1057
1058 EQMP
1059
1060 SQMP
1061 query-chardev
1062 -------------
1063
1064 Each device is represented by a json-object. The returned value is a json-array
1065 of all devices.
1066
1067 Each json-object contain the following:
1068
1069 - "label": device's label (json-string)
1070 - "filename": device's file (json-string)
1071
1072 Example:
1073
1074 -> { "execute": "query-chardev" }
1075 <- {
1076 "return":[
1077 {
1078 "label":"monitor",
1079 "filename":"stdio"
1080 },
1081 {
1082 "label":"serial0",
1083 "filename":"vc"
1084 }
1085 ]
1086 }
1087
1088 EQMP
1089
1090 SQMP
1091 query-block
1092 -----------
1093
1094 Show the block devices.
1095
1096 Each block device information is stored in a json-object and the returned value
1097 is a json-array of all devices.
1098
1099 Each json-object contain the following:
1100
1101 - "device": device name (json-string)
1102 - "type": device type (json-string)
1103 - deprecated, retained for backward compatibility
1104 - Possible values: "unknown"
1105 - "removable": true if the device is removable, false otherwise (json-bool)
1106 - "locked": true if the device is locked, false otherwise (json-bool)
1107 - "inserted": only present if the device is inserted, it is a json-object
1108 containing the following:
1109 - "file": device file name (json-string)
1110 - "ro": true if read-only, false otherwise (json-bool)
1111 - "drv": driver format name (json-string)
1112 - Possible values: "blkdebug", "bochs", "cloop", "cow", "dmg",
1113 "file", "file", "ftp", "ftps", "host_cdrom",
1114 "host_device", "host_floppy", "http", "https",
1115 "nbd", "parallels", "qcow", "qcow2", "raw",
1116 "tftp", "vdi", "vmdk", "vpc", "vvfat"
1117 - "backing_file": backing file name (json-string, optional)
1118 - "encrypted": true if encrypted, false otherwise (json-bool)
1119
1120 Example:
1121
1122 -> { "execute": "query-block" }
1123 <- {
1124 "return":[
1125 {
1126 "device":"ide0-hd0",
1127 "locked":false,
1128 "removable":false,
1129 "inserted":{
1130 "ro":false,
1131 "drv":"qcow2",
1132 "encrypted":false,
1133 "file":"disks/test.img"
1134 },
1135 "type":"unknown"
1136 },
1137 {
1138 "device":"ide1-cd0",
1139 "locked":false,
1140 "removable":true,
1141 "type":"unknown"
1142 },
1143 {
1144 "device":"floppy0",
1145 "locked":false,
1146 "removable":true,
1147 "type":"unknown"
1148 },
1149 {
1150 "device":"sd0",
1151 "locked":false,
1152 "removable":true,
1153 "type":"unknown"
1154 }
1155 ]
1156 }
1157
1158 EQMP
1159
1160 SQMP
1161 query-blockstats
1162 ----------------
1163
1164 Show block device statistics.
1165
1166 Each device statistic information is stored in a json-object and the returned
1167 value is a json-array of all devices.
1168
1169 Each json-object contain the following:
1170
1171 - "device": device name (json-string)
1172 - "stats": A json-object with the statistics information, it contains:
1173 - "rd_bytes": bytes read (json-int)
1174 - "wr_bytes": bytes written (json-int)
1175 - "rd_operations": read operations (json-int)
1176 - "wr_operations": write operations (json-int)
1177 - "wr_highest_offset": Highest offset of a sector written since the
1178 BlockDriverState has been opened (json-int)
1179 - "parent": Contains recursively the statistics of the underlying
1180 protocol (e.g. the host file for a qcow2 image). If there is
1181 no underlying protocol, this field is omitted
1182 (json-object, optional)
1183
1184 Example:
1185
1186 -> { "execute": "query-blockstats" }
1187 <- {
1188 "return":[
1189 {
1190 "device":"ide0-hd0",
1191 "parent":{
1192 "stats":{
1193 "wr_highest_offset":3686448128,
1194 "wr_bytes":9786368,
1195 "wr_operations":751,
1196 "rd_bytes":122567168,
1197 "rd_operations":36772
1198 }
1199 },
1200 "stats":{
1201 "wr_highest_offset":2821110784,
1202 "wr_bytes":9786368,
1203 "wr_operations":692,
1204 "rd_bytes":122739200,
1205 "rd_operations":36604
1206 }
1207 },
1208 {
1209 "device":"ide1-cd0",
1210 "stats":{
1211 "wr_highest_offset":0,
1212 "wr_bytes":0,
1213 "wr_operations":0,
1214 "rd_bytes":0,
1215 "rd_operations":0
1216 }
1217 },
1218 {
1219 "device":"floppy0",
1220 "stats":{
1221 "wr_highest_offset":0,
1222 "wr_bytes":0,
1223 "wr_operations":0,
1224 "rd_bytes":0,
1225 "rd_operations":0
1226 }
1227 },
1228 {
1229 "device":"sd0",
1230 "stats":{
1231 "wr_highest_offset":0,
1232 "wr_bytes":0,
1233 "wr_operations":0,
1234 "rd_bytes":0,
1235 "rd_operations":0
1236 }
1237 }
1238 ]
1239 }
1240
1241 EQMP
1242
1243 SQMP
1244 query-cpus
1245 ----------
1246
1247 Show CPU information.
1248
1249 Return a json-array. Each CPU is represented by a json-object, which contains:
1250
1251 - "CPU": CPU index (json-int)
1252 - "current": true if this is the current CPU, false otherwise (json-bool)
1253 - "halted": true if the cpu is halted, false otherwise (json-bool)
1254 - Current program counter. The key's name depends on the architecture:
1255 "pc": i386/x86_64 (json-int)
1256 "nip": PPC (json-int)
1257 "pc" and "npc": sparc (json-int)
1258 "PC": mips (json-int)
1259 - "thread_id": ID of the underlying host thread (json-int)
1260
1261 Example:
1262
1263 -> { "execute": "query-cpus" }
1264 <- {
1265 "return":[
1266 {
1267 "CPU":0,
1268 "current":true,
1269 "halted":false,
1270 "pc":3227107138
1271 "thread_id":3134
1272 },
1273 {
1274 "CPU":1,
1275 "current":false,
1276 "halted":true,
1277 "pc":7108165
1278 "thread_id":3135
1279 }
1280 ]
1281 }
1282
1283 EQMP
1284
1285 SQMP
1286 query-pci
1287 ---------
1288
1289 PCI buses and devices information.
1290
1291 The returned value is a json-array of all buses. Each bus is represented by
1292 a json-object, which has a key with a json-array of all PCI devices attached
1293 to it. Each device is represented by a json-object.
1294
1295 The bus json-object contains the following:
1296
1297 - "bus": bus number (json-int)
1298 - "devices": a json-array of json-objects, each json-object represents a
1299 PCI device
1300
1301 The PCI device json-object contains the following:
1302
1303 - "bus": identical to the parent's bus number (json-int)
1304 - "slot": slot number (json-int)
1305 - "function": function number (json-int)
1306 - "class_info": a json-object containing:
1307 - "desc": device class description (json-string, optional)
1308 - "class": device class number (json-int)
1309 - "id": a json-object containing:
1310 - "device": device ID (json-int)
1311 - "vendor": vendor ID (json-int)
1312 - "irq": device's IRQ if assigned (json-int, optional)
1313 - "qdev_id": qdev id string (json-string)
1314 - "pci_bridge": It's a json-object, only present if this device is a
1315 PCI bridge, contains:
1316 - "bus": bus number (json-int)
1317 - "secondary": secondary bus number (json-int)
1318 - "subordinate": subordinate bus number (json-int)
1319 - "io_range": I/O memory range information, a json-object with the
1320 following members:
1321 - "base": base address, in bytes (json-int)
1322 - "limit": limit address, in bytes (json-int)
1323 - "memory_range": memory range information, a json-object with the
1324 following members:
1325 - "base": base address, in bytes (json-int)
1326 - "limit": limit address, in bytes (json-int)
1327 - "prefetchable_range": Prefetchable memory range information, a
1328 json-object with the following members:
1329 - "base": base address, in bytes (json-int)
1330 - "limit": limit address, in bytes (json-int)
1331 - "devices": a json-array of PCI devices if there's any attached, each
1332 each element is represented by a json-object, which contains
1333 the same members of the 'PCI device json-object' described
1334 above (optional)
1335 - "regions": a json-array of json-objects, each json-object represents a
1336 memory region of this device
1337
1338 The memory range json-object contains the following:
1339
1340 - "base": base memory address (json-int)
1341 - "limit": limit value (json-int)
1342
1343 The region json-object can be an I/O region or a memory region, an I/O region
1344 json-object contains the following:
1345
1346 - "type": "io" (json-string, fixed)
1347 - "bar": BAR number (json-int)
1348 - "address": memory address (json-int)
1349 - "size": memory size (json-int)
1350
1351 A memory region json-object contains the following:
1352
1353 - "type": "memory" (json-string, fixed)
1354 - "bar": BAR number (json-int)
1355 - "address": memory address (json-int)
1356 - "size": memory size (json-int)
1357 - "mem_type_64": true or false (json-bool)
1358 - "prefetch": true or false (json-bool)
1359
1360 Example:
1361
1362 -> { "execute": "query-pci" }
1363 <- {
1364 "return":[
1365 {
1366 "bus":0,
1367 "devices":[
1368 {
1369 "bus":0,
1370 "qdev_id":"",
1371 "slot":0,
1372 "class_info":{
1373 "class":1536,
1374 "desc":"Host bridge"
1375 },
1376 "id":{
1377 "device":32902,
1378 "vendor":4663
1379 },
1380 "function":0,
1381 "regions":[
1382
1383 ]
1384 },
1385 {
1386 "bus":0,
1387 "qdev_id":"",
1388 "slot":1,
1389 "class_info":{
1390 "class":1537,
1391 "desc":"ISA bridge"
1392 },
1393 "id":{
1394 "device":32902,
1395 "vendor":28672
1396 },
1397 "function":0,
1398 "regions":[
1399
1400 ]
1401 },
1402 {
1403 "bus":0,
1404 "qdev_id":"",
1405 "slot":1,
1406 "class_info":{
1407 "class":257,
1408 "desc":"IDE controller"
1409 },
1410 "id":{
1411 "device":32902,
1412 "vendor":28688
1413 },
1414 "function":1,
1415 "regions":[
1416 {
1417 "bar":4,
1418 "size":16,
1419 "address":49152,
1420 "type":"io"
1421 }
1422 ]
1423 },
1424 {
1425 "bus":0,
1426 "qdev_id":"",
1427 "slot":2,
1428 "class_info":{
1429 "class":768,
1430 "desc":"VGA controller"
1431 },
1432 "id":{
1433 "device":4115,
1434 "vendor":184
1435 },
1436 "function":0,
1437 "regions":[
1438 {
1439 "prefetch":true,
1440 "mem_type_64":false,
1441 "bar":0,
1442 "size":33554432,
1443 "address":4026531840,
1444 "type":"memory"
1445 },
1446 {
1447 "prefetch":false,
1448 "mem_type_64":false,
1449 "bar":1,
1450 "size":4096,
1451 "address":4060086272,
1452 "type":"memory"
1453 },
1454 {
1455 "prefetch":false,
1456 "mem_type_64":false,
1457 "bar":6,
1458 "size":65536,
1459 "address":-1,
1460 "type":"memory"
1461 }
1462 ]
1463 },
1464 {
1465 "bus":0,
1466 "qdev_id":"",
1467 "irq":11,
1468 "slot":4,
1469 "class_info":{
1470 "class":1280,
1471 "desc":"RAM controller"
1472 },
1473 "id":{
1474 "device":6900,
1475 "vendor":4098
1476 },
1477 "function":0,
1478 "regions":[
1479 {
1480 "bar":0,
1481 "size":32,
1482 "address":49280,
1483 "type":"io"
1484 }
1485 ]
1486 }
1487 ]
1488 }
1489 ]
1490 }
1491
1492 Note: This example has been shortened as the real response is too long.
1493
1494 EQMP
1495
1496 SQMP
1497 query-kvm
1498 ---------
1499
1500 Show KVM information.
1501
1502 Return a json-object with the following information:
1503
1504 - "enabled": true if KVM support is enabled, false otherwise (json-bool)
1505 - "present": true if QEMU has KVM support, false otherwise (json-bool)
1506
1507 Example:
1508
1509 -> { "execute": "query-kvm" }
1510 <- { "return": { "enabled": true, "present": true } }
1511
1512 EQMP
1513
1514 SQMP
1515 query-status
1516 ------------
1517
1518 Return a json-object with the following information:
1519
1520 - "running": true if the VM is running, or false if it is paused (json-bool)
1521 - "singlestep": true if the VM is in single step mode,
1522 false otherwise (json-bool)
1523
1524 Example:
1525
1526 -> { "execute": "query-status" }
1527 <- { "return": { "running": true, "singlestep": false } }
1528
1529 EQMP
1530
1531 SQMP
1532 query-mice
1533 ----------
1534
1535 Show VM mice information.
1536
1537 Each mouse is represented by a json-object, the returned value is a json-array
1538 of all mice.
1539
1540 The mouse json-object contains the following:
1541
1542 - "name": mouse's name (json-string)
1543 - "index": mouse's index (json-int)
1544 - "current": true if this mouse is receiving events, false otherwise (json-bool)
1545 - "absolute": true if the mouse generates absolute input events (json-bool)
1546
1547 Example:
1548
1549 -> { "execute": "query-mice" }
1550 <- {
1551 "return":[
1552 {
1553 "name":"QEMU Microsoft Mouse",
1554 "index":0,
1555 "current":false,
1556 "absolute":false
1557 },
1558 {
1559 "name":"QEMU PS/2 Mouse",
1560 "index":1,
1561 "current":true,
1562 "absolute":true
1563 }
1564 ]
1565 }
1566
1567 EQMP
1568
1569 SQMP
1570 query-vnc
1571 ---------
1572
1573 Show VNC server information.
1574
1575 Return a json-object with server information. Connected clients are returned
1576 as a json-array of json-objects.
1577
1578 The main json-object contains the following:
1579
1580 - "enabled": true or false (json-bool)
1581 - "host": server's IP address (json-string)
1582 - "family": address family (json-string)
1583 - Possible values: "ipv4", "ipv6", "unix", "unknown"
1584 - "service": server's port number (json-string)
1585 - "auth": authentication method (json-string)
1586 - Possible values: "invalid", "none", "ra2", "ra2ne", "sasl", "tight",
1587 "tls", "ultra", "unknown", "vencrypt", "vencrypt",
1588 "vencrypt+plain", "vencrypt+tls+none",
1589 "vencrypt+tls+plain", "vencrypt+tls+sasl",
1590 "vencrypt+tls+vnc", "vencrypt+x509+none",
1591 "vencrypt+x509+plain", "vencrypt+x509+sasl",
1592 "vencrypt+x509+vnc", "vnc"
1593 - "clients": a json-array of all connected clients
1594
1595 Clients are described by a json-object, each one contain the following:
1596
1597 - "host": client's IP address (json-string)
1598 - "family": address family (json-string)
1599 - Possible values: "ipv4", "ipv6", "unix", "unknown"
1600 - "service": client's port number (json-string)
1601 - "x509_dname": TLS dname (json-string, optional)
1602 - "sasl_username": SASL username (json-string, optional)
1603
1604 Example:
1605
1606 -> { "execute": "query-vnc" }
1607 <- {
1608 "return":{
1609 "enabled":true,
1610 "host":"0.0.0.0",
1611 "service":"50402",
1612 "auth":"vnc",
1613 "family":"ipv4",
1614 "clients":[
1615 {
1616 "host":"127.0.0.1",
1617 "service":"50401",
1618 "family":"ipv4"
1619 }
1620 ]
1621 }
1622 }
1623
1624 EQMP
1625
1626 SQMP
1627 query-spice
1628 -----------
1629
1630 Show SPICE server information.
1631
1632 Return a json-object with server information. Connected clients are returned
1633 as a json-array of json-objects.
1634
1635 The main json-object contains the following:
1636
1637 - "enabled": true or false (json-bool)
1638 - "host": server's IP address (json-string)
1639 - "port": server's port number (json-int, optional)
1640 - "tls-port": server's port number (json-int, optional)
1641 - "auth": authentication method (json-string)
1642 - Possible values: "none", "spice"
1643 - "channels": a json-array of all active channels clients
1644
1645 Channels are described by a json-object, each one contain the following:
1646
1647 - "host": client's IP address (json-string)
1648 - "family": address family (json-string)
1649 - Possible values: "ipv4", "ipv6", "unix", "unknown"
1650 - "port": client's port number (json-string)
1651 - "connection-id": spice connection id. All channels with the same id
1652 belong to the same spice session (json-int)
1653 - "channel-type": channel type. "1" is the main control channel, filter for
1654 this one if you want track spice sessions only (json-int)
1655 - "channel-id": channel id. Usually "0", might be different needed when
1656 multiple channels of the same type exist, such as multiple
1657 display channels in a multihead setup (json-int)
1658 - "tls": whevener the channel is encrypted (json-bool)
1659
1660 Example:
1661
1662 -> { "execute": "query-spice" }
1663 <- {
1664 "return": {
1665 "enabled": true,
1666 "auth": "spice",
1667 "port": 5920,
1668 "tls-port": 5921,
1669 "host": "0.0.0.0",
1670 "channels": [
1671 {
1672 "port": "54924",
1673 "family": "ipv4",
1674 "channel-type": 1,
1675 "connection-id": 1804289383,
1676 "host": "127.0.0.1",
1677 "channel-id": 0,
1678 "tls": true
1679 },
1680 {
1681 "port": "36710",
1682 "family": "ipv4",
1683 "channel-type": 4,
1684 "connection-id": 1804289383,
1685 "host": "127.0.0.1",
1686 "channel-id": 0,
1687 "tls": false
1688 },
1689 [ ... more channels follow ... ]
1690 ]
1691 }
1692 }
1693
1694 EQMP
1695
1696 SQMP
1697 query-name
1698 ----------
1699
1700 Show VM name.
1701
1702 Return a json-object with the following information:
1703
1704 - "name": VM's name (json-string, optional)
1705
1706 Example:
1707
1708 -> { "execute": "query-name" }
1709 <- { "return": { "name": "qemu-name" } }
1710
1711 EQMP
1712
1713 SQMP
1714 query-uuid
1715 ----------
1716
1717 Show VM UUID.
1718
1719 Return a json-object with the following information:
1720
1721 - "UUID": Universally Unique Identifier (json-string)
1722
1723 Example:
1724
1725 -> { "execute": "query-uuid" }
1726 <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } }
1727
1728 EQMP
1729
1730 SQMP
1731 query-migrate
1732 -------------
1733
1734 Migration status.
1735
1736 Return a json-object. If migration is active there will be another json-object
1737 with RAM migration status and if block migration is active another one with
1738 block migration status.
1739
1740 The main json-object contains the following:
1741
1742 - "status": migration status (json-string)
1743 - Possible values: "active", "completed", "failed", "cancelled"
1744 - "ram": only present if "status" is "active", it is a json-object with the
1745 following RAM information (in bytes):
1746 - "transferred": amount transferred (json-int)
1747 - "remaining": amount remaining (json-int)
1748 - "total": total (json-int)
1749 - "disk": only present if "status" is "active" and it is a block migration,
1750 it is a json-object with the following disk information (in bytes):
1751 - "transferred": amount transferred (json-int)
1752 - "remaining": amount remaining (json-int)
1753 - "total": total (json-int)
1754
1755 Examples:
1756
1757 1. Before the first migration
1758
1759 -> { "execute": "query-migrate" }
1760 <- { "return": {} }
1761
1762 2. Migration is done and has succeeded
1763
1764 -> { "execute": "query-migrate" }
1765 <- { "return": { "status": "completed" } }
1766
1767 3. Migration is done and has failed
1768
1769 -> { "execute": "query-migrate" }
1770 <- { "return": { "status": "failed" } }
1771
1772 4. Migration is being performed and is not a block migration:
1773
1774 -> { "execute": "query-migrate" }
1775 <- {
1776 "return":{
1777 "status":"active",
1778 "ram":{
1779 "transferred":123,
1780 "remaining":123,
1781 "total":246
1782 }
1783 }
1784 }
1785
1786 5. Migration is being performed and is a block migration:
1787
1788 -> { "execute": "query-migrate" }
1789 <- {
1790 "return":{
1791 "status":"active",
1792 "ram":{
1793 "total":1057024,
1794 "remaining":1053304,
1795 "transferred":3720
1796 },
1797 "disk":{
1798 "total":20971520,
1799 "remaining":20880384,
1800 "transferred":91136
1801 }
1802 }
1803 }
1804
1805 EQMP
1806
1807 SQMP
1808 query-balloon
1809 -------------
1810
1811 Show balloon information.
1812
1813 Make an asynchronous request for balloon info. When the request completes a
1814 json-object will be returned containing the following data:
1815
1816 - "actual": current balloon value in bytes (json-int)
1817 - "mem_swapped_in": Amount of memory swapped in bytes (json-int, optional)
1818 - "mem_swapped_out": Amount of memory swapped out in bytes (json-int, optional)
1819 - "major_page_faults": Number of major faults (json-int, optional)
1820 - "minor_page_faults": Number of minor faults (json-int, optional)
1821 - "free_mem": Total amount of free and unused memory in
1822 bytes (json-int, optional)
1823 - "total_mem": Total amount of available memory in bytes (json-int, optional)
1824
1825 Example:
1826
1827 -> { "execute": "query-balloon" }
1828 <- {
1829 "return":{
1830 "actual":1073741824,
1831 "mem_swapped_in":0,
1832 "mem_swapped_out":0,
1833 "major_page_faults":142,
1834 "minor_page_faults":239245,
1835 "free_mem":1014185984,
1836 "total_mem":1044668416
1837 }
1838 }
1839
1840 EQMP
1841