2 * Human Monitor Interface
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
16 #include "qemu/osdep.h"
20 #include "chardev/char.h"
21 #include "sysemu/block-backend.h"
22 #include "sysemu/sysemu.h"
23 #include "qemu/config-file.h"
24 #include "qemu/option.h"
25 #include "qemu/timer.h"
26 #include "qemu/sockets.h"
27 #include "monitor/monitor.h"
28 #include "monitor/qdev.h"
29 #include "qapi/error.h"
30 #include "qapi/opts-visitor.h"
31 #include "qapi/qapi-builtin-visit.h"
32 #include "qapi/qapi-commands-block.h"
33 #include "qapi/qapi-commands-char.h"
34 #include "qapi/qapi-commands-migration.h"
35 #include "qapi/qapi-commands-misc.h"
36 #include "qapi/qapi-commands-net.h"
37 #include "qapi/qapi-commands-rocker.h"
38 #include "qapi/qapi-commands-run-state.h"
39 #include "qapi/qapi-commands-tpm.h"
40 #include "qapi/qapi-commands-ui.h"
41 #include "qapi/qmp/qdict.h"
42 #include "qapi/qmp/qerror.h"
43 #include "qapi/string-input-visitor.h"
44 #include "qapi/string-output-visitor.h"
45 #include "qom/object_interfaces.h"
46 #include "ui/console.h"
47 #include "block/nbd.h"
48 #include "block/qapi.h"
50 #include "qemu/cutils.h"
51 #include "qemu/error-report.h"
52 #include "exec/ramlist.h"
53 #include "hw/intc/intc.h"
54 #include "migration/snapshot.h"
55 #include "migration/misc.h"
58 #include <spice/enums.h>
61 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
65 error_report_err(*errp
);
69 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
73 info
= qmp_query_name(NULL
);
75 monitor_printf(mon
, "%s\n", info
->name
);
77 qapi_free_NameInfo(info
);
80 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
84 info
= qmp_query_version(NULL
);
86 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
87 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
90 qapi_free_VersionInfo(info
);
93 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
97 info
= qmp_query_kvm(NULL
);
98 monitor_printf(mon
, "kvm support: ");
100 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
102 monitor_printf(mon
, "not compiled\n");
105 qapi_free_KvmInfo(info
);
108 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
112 info
= qmp_query_status(NULL
);
114 monitor_printf(mon
, "VM status: %s%s",
115 info
->running
? "running" : "paused",
116 info
->singlestep
? " (single step mode)" : "");
118 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
119 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
122 monitor_printf(mon
, "\n");
124 qapi_free_StatusInfo(info
);
127 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
131 info
= qmp_query_uuid(NULL
);
132 monitor_printf(mon
, "%s\n", info
->UUID
);
133 qapi_free_UuidInfo(info
);
136 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
138 ChardevInfoList
*char_info
, *info
;
140 char_info
= qmp_query_chardev(NULL
);
141 for (info
= char_info
; info
; info
= info
->next
) {
142 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
143 info
->value
->filename
);
146 qapi_free_ChardevInfoList(char_info
);
149 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
151 MouseInfoList
*mice_list
, *mouse
;
153 mice_list
= qmp_query_mice(NULL
);
155 monitor_printf(mon
, "No mouse devices connected\n");
159 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
160 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
161 mouse
->value
->current
? '*' : ' ',
162 mouse
->value
->index
, mouse
->value
->name
,
163 mouse
->value
->absolute
? " (absolute)" : "");
166 qapi_free_MouseInfoList(mice_list
);
169 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
172 MigrationCapabilityStatusList
*caps
, *cap
;
174 info
= qmp_query_migrate(NULL
);
175 caps
= qmp_query_migrate_capabilities(NULL
);
177 migration_global_dump(mon
);
179 /* do not display parameters during setup */
180 if (info
->has_status
&& caps
) {
181 monitor_printf(mon
, "capabilities: ");
182 for (cap
= caps
; cap
; cap
= cap
->next
) {
183 monitor_printf(mon
, "%s: %s ",
184 MigrationCapability_str(cap
->value
->capability
),
185 cap
->value
->state
? "on" : "off");
187 monitor_printf(mon
, "\n");
190 if (info
->has_status
) {
191 monitor_printf(mon
, "Migration status: %s",
192 MigrationStatus_str(info
->status
));
193 if (info
->status
== MIGRATION_STATUS_FAILED
&&
194 info
->has_error_desc
) {
195 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
197 monitor_printf(mon
, "\n");
200 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
202 if (info
->has_expected_downtime
) {
203 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
204 info
->expected_downtime
);
206 if (info
->has_downtime
) {
207 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
210 if (info
->has_setup_time
) {
211 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
217 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
218 info
->ram
->transferred
>> 10);
219 monitor_printf(mon
, "throughput: %0.2f mbps\n",
221 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
222 info
->ram
->remaining
>> 10);
223 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
224 info
->ram
->total
>> 10);
225 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
226 info
->ram
->duplicate
);
227 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
229 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
231 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
232 info
->ram
->normal_bytes
>> 10);
233 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
234 info
->ram
->dirty_sync_count
);
235 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
236 info
->ram
->page_size
>> 10);
237 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
238 info
->ram
->multifd_bytes
>> 10);
240 if (info
->ram
->dirty_pages_rate
) {
241 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
242 info
->ram
->dirty_pages_rate
);
244 if (info
->ram
->postcopy_requests
) {
245 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
246 info
->ram
->postcopy_requests
);
250 if (info
->has_disk
) {
251 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
252 info
->disk
->transferred
>> 10);
253 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
254 info
->disk
->remaining
>> 10);
255 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
256 info
->disk
->total
>> 10);
259 if (info
->has_xbzrle_cache
) {
260 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
261 info
->xbzrle_cache
->cache_size
);
262 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
263 info
->xbzrle_cache
->bytes
>> 10);
264 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
265 info
->xbzrle_cache
->pages
);
266 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
267 info
->xbzrle_cache
->cache_miss
);
268 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
269 info
->xbzrle_cache
->cache_miss_rate
);
270 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
271 info
->xbzrle_cache
->overflow
);
274 if (info
->has_cpu_throttle_percentage
) {
275 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
276 info
->cpu_throttle_percentage
);
279 if (info
->has_postcopy_blocktime
) {
280 monitor_printf(mon
, "postcopy blocktime: %u\n",
281 info
->postcopy_blocktime
);
284 if (info
->has_postcopy_vcpu_blocktime
) {
287 v
= string_output_visitor_new(false, &str
);
288 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
, NULL
);
289 visit_complete(v
, &str
);
290 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
294 qapi_free_MigrationInfo(info
);
295 qapi_free_MigrationCapabilityStatusList(caps
);
298 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
300 MigrationCapabilityStatusList
*caps
, *cap
;
302 caps
= qmp_query_migrate_capabilities(NULL
);
305 for (cap
= caps
; cap
; cap
= cap
->next
) {
306 monitor_printf(mon
, "%s: %s\n",
307 MigrationCapability_str(cap
->value
->capability
),
308 cap
->value
->state
? "on" : "off");
312 qapi_free_MigrationCapabilityStatusList(caps
);
315 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
317 MigrationParameters
*params
;
319 params
= qmp_query_migrate_parameters(NULL
);
322 assert(params
->has_compress_level
);
323 monitor_printf(mon
, "%s: %u\n",
324 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
325 params
->compress_level
);
326 assert(params
->has_compress_threads
);
327 monitor_printf(mon
, "%s: %u\n",
328 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
329 params
->compress_threads
);
330 assert(params
->has_decompress_threads
);
331 monitor_printf(mon
, "%s: %u\n",
332 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
333 params
->decompress_threads
);
334 assert(params
->has_cpu_throttle_initial
);
335 monitor_printf(mon
, "%s: %u\n",
336 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
337 params
->cpu_throttle_initial
);
338 assert(params
->has_cpu_throttle_increment
);
339 monitor_printf(mon
, "%s: %u\n",
340 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
341 params
->cpu_throttle_increment
);
342 assert(params
->has_max_cpu_throttle
);
343 monitor_printf(mon
, "%s: %u\n",
344 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
345 params
->max_cpu_throttle
);
346 assert(params
->has_tls_creds
);
347 monitor_printf(mon
, "%s: '%s'\n",
348 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
350 assert(params
->has_tls_hostname
);
351 monitor_printf(mon
, "%s: '%s'\n",
352 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
353 params
->tls_hostname
);
354 assert(params
->has_max_bandwidth
);
355 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
356 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
357 params
->max_bandwidth
);
358 assert(params
->has_downtime_limit
);
359 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
360 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
361 params
->downtime_limit
);
362 assert(params
->has_x_checkpoint_delay
);
363 monitor_printf(mon
, "%s: %u\n",
364 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
365 params
->x_checkpoint_delay
);
366 assert(params
->has_block_incremental
);
367 monitor_printf(mon
, "%s: %s\n",
368 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
369 params
->block_incremental
? "on" : "off");
370 monitor_printf(mon
, "%s: %u\n",
371 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
),
372 params
->x_multifd_channels
);
373 monitor_printf(mon
, "%s: %u\n",
374 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
),
375 params
->x_multifd_page_count
);
376 monitor_printf(mon
, "%s: %" PRIu64
"\n",
377 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
378 params
->xbzrle_cache_size
);
379 monitor_printf(mon
, "%s: %" PRIu64
"\n",
380 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
381 params
->max_postcopy_bandwidth
);
384 qapi_free_MigrationParameters(params
);
387 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
389 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
390 qmp_query_migrate_cache_size(NULL
) >> 10);
393 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
395 CpuInfoFastList
*cpu_list
, *cpu
;
397 cpu_list
= qmp_query_cpus_fast(NULL
);
399 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
402 if (cpu
->value
->cpu_index
== monitor_get_cpu_index()) {
406 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
,
407 cpu
->value
->cpu_index
);
408 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
411 qapi_free_CpuInfoFastList(cpu_list
);
414 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
415 BlockDeviceInfo
*inserted
, bool verbose
)
417 ImageInfo
*image_info
;
419 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
421 if (info
&& *info
->device
) {
422 monitor_printf(mon
, "%s", info
->device
);
423 if (inserted
&& inserted
->has_node_name
) {
424 monitor_printf(mon
, " (%s)", inserted
->node_name
);
427 assert(info
|| inserted
);
428 monitor_printf(mon
, "%s",
429 inserted
&& inserted
->has_node_name
? inserted
->node_name
430 : info
&& info
->has_qdev
? info
->qdev
435 monitor_printf(mon
, ": %s (%s%s%s)\n",
438 inserted
->ro
? ", read-only" : "",
439 inserted
->encrypted
? ", encrypted" : "");
441 monitor_printf(mon
, ": [not inserted]\n");
445 if (info
->has_qdev
) {
446 monitor_printf(mon
, " Attached to: %s\n", info
->qdev
);
448 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
449 monitor_printf(mon
, " I/O status: %s\n",
450 BlockDeviceIoStatus_str(info
->io_status
));
453 if (info
->removable
) {
454 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
455 info
->locked
? "" : "not ",
456 info
->tray_open
? "open" : "closed");
465 monitor_printf(mon
, " Cache mode: %s%s%s\n",
466 inserted
->cache
->writeback
? "writeback" : "writethrough",
467 inserted
->cache
->direct
? ", direct" : "",
468 inserted
->cache
->no_flush
? ", ignore flushes" : "");
470 if (inserted
->has_backing_file
) {
473 "(chain depth: %" PRId64
")\n",
474 inserted
->backing_file
,
475 inserted
->backing_file_depth
);
478 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
479 monitor_printf(mon
, " Detect zeroes: %s\n",
480 BlockdevDetectZeroesOptions_str(inserted
->detect_zeroes
));
483 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
484 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
486 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
487 " bps_rd=%" PRId64
" bps_wr=%" PRId64
489 " bps_rd_max=%" PRId64
490 " bps_wr_max=%" PRId64
491 " iops=%" PRId64
" iops_rd=%" PRId64
494 " iops_rd_max=%" PRId64
495 " iops_wr_max=%" PRId64
496 " iops_size=%" PRId64
502 inserted
->bps_rd_max
,
503 inserted
->bps_wr_max
,
508 inserted
->iops_rd_max
,
509 inserted
->iops_wr_max
,
515 monitor_printf(mon
, "\nImages:\n");
516 image_info
= inserted
->image
;
518 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
520 if (image_info
->has_backing_image
) {
521 image_info
= image_info
->backing_image
;
529 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
531 BlockInfoList
*block_list
, *info
;
532 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
533 const char *device
= qdict_get_try_str(qdict
, "device");
534 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
535 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
536 bool printed
= false;
538 /* Print BlockBackend information */
540 block_list
= qmp_query_block(NULL
);
545 for (info
= block_list
; info
; info
= info
->next
) {
546 if (device
&& strcmp(device
, info
->value
->device
)) {
550 if (info
!= block_list
) {
551 monitor_printf(mon
, "\n");
554 print_block_info(mon
, info
->value
, info
->value
->has_inserted
555 ? info
->value
->inserted
: NULL
,
560 qapi_free_BlockInfoList(block_list
);
562 if ((!device
&& !nodes
) || printed
) {
566 /* Print node information */
567 blockdev_list
= qmp_query_named_block_nodes(NULL
);
568 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
569 assert(blockdev
->value
->has_node_name
);
570 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
574 if (blockdev
!= blockdev_list
) {
575 monitor_printf(mon
, "\n");
578 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
580 qapi_free_BlockDeviceInfoList(blockdev_list
);
583 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
585 BlockStatsList
*stats_list
, *stats
;
587 stats_list
= qmp_query_blockstats(false, false, NULL
);
589 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
590 if (!stats
->value
->has_device
) {
594 monitor_printf(mon
, "%s:", stats
->value
->device
);
595 monitor_printf(mon
, " rd_bytes=%" PRId64
597 " rd_operations=%" PRId64
598 " wr_operations=%" PRId64
599 " flush_operations=%" PRId64
600 " wr_total_time_ns=%" PRId64
601 " rd_total_time_ns=%" PRId64
602 " flush_total_time_ns=%" PRId64
603 " rd_merged=%" PRId64
604 " wr_merged=%" PRId64
605 " idle_time_ns=%" PRId64
607 stats
->value
->stats
->rd_bytes
,
608 stats
->value
->stats
->wr_bytes
,
609 stats
->value
->stats
->rd_operations
,
610 stats
->value
->stats
->wr_operations
,
611 stats
->value
->stats
->flush_operations
,
612 stats
->value
->stats
->wr_total_time_ns
,
613 stats
->value
->stats
->rd_total_time_ns
,
614 stats
->value
->stats
->flush_total_time_ns
,
615 stats
->value
->stats
->rd_merged
,
616 stats
->value
->stats
->wr_merged
,
617 stats
->value
->stats
->idle_time_ns
);
620 qapi_free_BlockStatsList(stats_list
);
624 /* Helper for hmp_info_vnc_clients, _servers */
625 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
628 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
632 NetworkAddressFamily_str(info
->family
),
633 info
->websocket
? " (Websocket)" : "");
636 /* Helper displaying and auth and crypt info */
637 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
639 VncVencryptSubAuth
*vencrypt
)
641 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
642 VncPrimaryAuth_str(auth
),
643 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
646 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
649 VncClientInfo
*cinfo
= client
->value
;
651 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
652 monitor_printf(mon
, " x509_dname: %s\n",
653 cinfo
->has_x509_dname
?
654 cinfo
->x509_dname
: "none");
655 monitor_printf(mon
, " sasl_username: %s\n",
656 cinfo
->has_sasl_username
?
657 cinfo
->sasl_username
: "none");
659 client
= client
->next
;
663 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
666 VncServerInfo2
*sinfo
= server
->value
;
667 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
668 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
669 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
670 server
= server
->next
;
674 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
676 VncInfo2List
*info2l
;
679 info2l
= qmp_query_vnc_servers(&err
);
681 hmp_handle_error(mon
, &err
);
685 monitor_printf(mon
, "None\n");
690 VncInfo2
*info
= info2l
->value
;
691 monitor_printf(mon
, "%s:\n", info
->id
);
692 hmp_info_vnc_servers(mon
, info
->server
);
693 hmp_info_vnc_clients(mon
, info
->clients
);
695 /* The server entry displays its auth, we only
696 * need to display in the case of 'reverse' connections
697 * where there's no server.
699 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
700 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
702 if (info
->has_display
) {
703 monitor_printf(mon
, " Display: %s\n", info
->display
);
705 info2l
= info2l
->next
;
708 qapi_free_VncInfo2List(info2l
);
714 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
716 SpiceChannelList
*chan
;
718 const char *channel_name
;
719 const char * const channel_names
[] = {
720 [SPICE_CHANNEL_MAIN
] = "main",
721 [SPICE_CHANNEL_DISPLAY
] = "display",
722 [SPICE_CHANNEL_INPUTS
] = "inputs",
723 [SPICE_CHANNEL_CURSOR
] = "cursor",
724 [SPICE_CHANNEL_PLAYBACK
] = "playback",
725 [SPICE_CHANNEL_RECORD
] = "record",
726 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
727 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
728 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
729 [SPICE_CHANNEL_PORT
] = "port",
731 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
732 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
733 * as quick fix for build failures with older versions. */
734 [SPICE_CHANNEL_WEBDAV
] = "webdav",
738 info
= qmp_query_spice(NULL
);
740 if (!info
->enabled
) {
741 monitor_printf(mon
, "Server: disabled\n");
745 monitor_printf(mon
, "Server:\n");
746 if (info
->has_port
) {
747 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
748 info
->host
, info
->port
);
750 if (info
->has_tls_port
) {
751 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
752 info
->host
, info
->tls_port
);
754 monitor_printf(mon
, " migrated: %s\n",
755 info
->migrated
? "true" : "false");
756 monitor_printf(mon
, " auth: %s\n", info
->auth
);
757 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
758 monitor_printf(mon
, " mouse-mode: %s\n",
759 SpiceQueryMouseMode_str(info
->mouse_mode
));
761 if (!info
->has_channels
|| info
->channels
== NULL
) {
762 monitor_printf(mon
, "Channels: none\n");
764 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
765 monitor_printf(mon
, "Channel:\n");
766 monitor_printf(mon
, " address: %s:%s%s\n",
767 chan
->value
->host
, chan
->value
->port
,
768 chan
->value
->tls
? " [tls]" : "");
769 monitor_printf(mon
, " session: %" PRId64
"\n",
770 chan
->value
->connection_id
);
771 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
772 chan
->value
->channel_type
, chan
->value
->channel_id
);
774 channel_name
= "unknown";
775 if (chan
->value
->channel_type
> 0 &&
776 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
777 channel_names
[chan
->value
->channel_type
]) {
778 channel_name
= channel_names
[chan
->value
->channel_type
];
781 monitor_printf(mon
, " channel name: %s\n", channel_name
);
786 qapi_free_SpiceInfo(info
);
790 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
795 info
= qmp_query_balloon(&err
);
797 hmp_handle_error(mon
, &err
);
801 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
803 qapi_free_BalloonInfo(info
);
806 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
808 PciMemoryRegionList
*region
;
810 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
811 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
812 dev
->slot
, dev
->function
);
813 monitor_printf(mon
, " ");
815 if (dev
->class_info
->has_desc
) {
816 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
818 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
821 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
822 dev
->id
->vendor
, dev
->id
->device
);
825 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
828 if (dev
->has_pci_bridge
) {
829 monitor_printf(mon
, " BUS %" PRId64
".\n",
830 dev
->pci_bridge
->bus
->number
);
831 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
832 dev
->pci_bridge
->bus
->secondary
);
833 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
834 dev
->pci_bridge
->bus
->subordinate
);
836 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
837 dev
->pci_bridge
->bus
->io_range
->base
,
838 dev
->pci_bridge
->bus
->io_range
->limit
);
841 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
842 dev
->pci_bridge
->bus
->memory_range
->base
,
843 dev
->pci_bridge
->bus
->memory_range
->limit
);
845 monitor_printf(mon
, " prefetchable memory range "
846 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
847 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
848 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
851 for (region
= dev
->regions
; region
; region
= region
->next
) {
854 addr
= region
->value
->address
;
855 size
= region
->value
->size
;
857 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
859 if (!strcmp(region
->value
->type
, "io")) {
860 monitor_printf(mon
, "I/O at 0x%04" PRIx64
861 " [0x%04" PRIx64
"].\n",
862 addr
, addr
+ size
- 1);
864 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
865 " [0x%08" PRIx64
"].\n",
866 region
->value
->mem_type_64
? 64 : 32,
867 region
->value
->prefetch
? " prefetchable" : "",
868 addr
, addr
+ size
- 1);
872 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
874 if (dev
->has_pci_bridge
) {
875 if (dev
->pci_bridge
->has_devices
) {
876 PciDeviceInfoList
*cdev
;
877 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
878 hmp_info_pci_device(mon
, cdev
->value
);
884 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
886 InterruptStatsProvider
*intc
;
887 InterruptStatsProviderClass
*k
;
888 Monitor
*mon
= opaque
;
890 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
891 intc
= INTERRUPT_STATS_PROVIDER(obj
);
892 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
893 uint64_t *irq_counts
;
894 unsigned int nb_irqs
, i
;
895 if (k
->get_statistics
&&
896 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
898 monitor_printf(mon
, "IRQ statistics for %s:\n",
899 object_get_typename(obj
));
900 for (i
= 0; i
< nb_irqs
; i
++) {
901 if (irq_counts
[i
] > 0) {
902 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
908 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
909 object_get_typename(obj
));
916 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
918 object_child_foreach_recursive(object_get_root(),
919 hmp_info_irq_foreach
, mon
);
922 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
924 InterruptStatsProvider
*intc
;
925 InterruptStatsProviderClass
*k
;
926 Monitor
*mon
= opaque
;
928 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
929 intc
= INTERRUPT_STATS_PROVIDER(obj
);
930 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
932 k
->print_info(intc
, mon
);
934 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
935 object_get_typename(obj
));
942 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
944 object_child_foreach_recursive(object_get_root(),
945 hmp_info_pic_foreach
, mon
);
948 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
950 PciInfoList
*info_list
, *info
;
953 info_list
= qmp_query_pci(&err
);
955 monitor_printf(mon
, "PCI devices not supported\n");
960 for (info
= info_list
; info
; info
= info
->next
) {
961 PciDeviceInfoList
*dev
;
963 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
964 hmp_info_pci_device(mon
, dev
->value
);
968 qapi_free_PciInfoList(info_list
);
971 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
973 BlockJobInfoList
*list
;
976 list
= qmp_query_block_jobs(&err
);
980 monitor_printf(mon
, "No active jobs\n");
985 if (strcmp(list
->value
->type
, "stream") == 0) {
986 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
987 " of %" PRId64
" bytes, speed limit %" PRId64
994 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
995 " of %" PRId64
" bytes, speed limit %" PRId64
1001 list
->value
->speed
);
1006 qapi_free_BlockJobInfoList(list
);
1009 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
1011 TPMInfoList
*info_list
, *info
;
1014 TPMPassthroughOptions
*tpo
;
1015 TPMEmulatorOptions
*teo
;
1017 info_list
= qmp_query_tpm(&err
);
1019 monitor_printf(mon
, "TPM device not supported\n");
1025 monitor_printf(mon
, "TPM device:\n");
1028 for (info
= info_list
; info
; info
= info
->next
) {
1029 TPMInfo
*ti
= info
->value
;
1030 monitor_printf(mon
, " tpm%d: model=%s\n",
1031 c
, TpmModel_str(ti
->model
));
1033 monitor_printf(mon
, " \\ %s: type=%s",
1034 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
1036 switch (ti
->options
->type
) {
1037 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
1038 tpo
= ti
->options
->u
.passthrough
.data
;
1039 monitor_printf(mon
, "%s%s%s%s",
1040 tpo
->has_path
? ",path=" : "",
1041 tpo
->has_path
? tpo
->path
: "",
1042 tpo
->has_cancel_path
? ",cancel-path=" : "",
1043 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
1045 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
1046 teo
= ti
->options
->u
.emulator
.data
;
1047 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
1049 case TPM_TYPE_OPTIONS_KIND__MAX
:
1052 monitor_printf(mon
, "\n");
1055 qapi_free_TPMInfoList(info_list
);
1058 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
1060 monitor_suspend(mon
);
1064 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
1069 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
1071 qmp_system_reset(NULL
);
1074 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
1076 qmp_system_powerdown(NULL
);
1079 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
1083 qmp_x_exit_preconfig(&err
);
1084 hmp_handle_error(mon
, &err
);
1087 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1091 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1092 use it are converted to the QAPI */
1093 cpu_index
= qdict_get_int(qdict
, "index");
1094 if (monitor_set_cpu(cpu_index
) < 0) {
1095 monitor_printf(mon
, "invalid CPU index\n");
1099 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1101 uint32_t size
= qdict_get_int(qdict
, "size");
1102 const char *filename
= qdict_get_str(qdict
, "filename");
1103 uint64_t addr
= qdict_get_int(qdict
, "val");
1105 int cpu_index
= monitor_get_cpu_index();
1107 if (cpu_index
< 0) {
1108 monitor_printf(mon
, "No CPU available\n");
1112 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1113 hmp_handle_error(mon
, &err
);
1116 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1118 uint32_t size
= qdict_get_int(qdict
, "size");
1119 const char *filename
= qdict_get_str(qdict
, "filename");
1120 uint64_t addr
= qdict_get_int(qdict
, "val");
1123 qmp_pmemsave(addr
, size
, filename
, &err
);
1124 hmp_handle_error(mon
, &err
);
1127 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1129 const char *chardev
= qdict_get_str(qdict
, "device");
1130 const char *data
= qdict_get_str(qdict
, "data");
1133 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1135 hmp_handle_error(mon
, &err
);
1138 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1140 uint32_t size
= qdict_get_int(qdict
, "size");
1141 const char *chardev
= qdict_get_str(qdict
, "device");
1146 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1148 hmp_handle_error(mon
, &err
);
1152 for (i
= 0; data
[i
]; i
++) {
1153 unsigned char ch
= data
[i
];
1156 monitor_printf(mon
, "\\\\");
1157 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1158 monitor_printf(mon
, "\\u%04X", ch
);
1160 monitor_printf(mon
, "%c", ch
);
1164 monitor_printf(mon
, "\n");
1168 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1173 hmp_handle_error(mon
, &err
);
1176 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1178 qmp_system_wakeup(NULL
);
1181 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1185 qmp_inject_nmi(&err
);
1186 hmp_handle_error(mon
, &err
);
1189 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1191 const char *name
= qdict_get_str(qdict
, "name");
1192 bool up
= qdict_get_bool(qdict
, "up");
1195 qmp_set_link(name
, up
, &err
);
1196 hmp_handle_error(mon
, &err
);
1199 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1201 const char *device
= qdict_get_str(qdict
, "device");
1202 const char *password
= qdict_get_str(qdict
, "password");
1205 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1206 hmp_handle_error(mon
, &err
);
1209 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1211 int64_t value
= qdict_get_int(qdict
, "value");
1214 qmp_balloon(value
, &err
);
1215 hmp_handle_error(mon
, &err
);
1218 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1220 const char *device
= qdict_get_str(qdict
, "device");
1221 int64_t size
= qdict_get_int(qdict
, "size");
1224 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1225 hmp_handle_error(mon
, &err
);
1228 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1230 const char *filename
= qdict_get_str(qdict
, "target");
1231 const char *format
= qdict_get_try_str(qdict
, "format");
1232 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1233 bool full
= qdict_get_try_bool(qdict
, "full", false);
1235 DriveMirror mirror
= {
1236 .device
= (char *)qdict_get_str(qdict
, "device"),
1237 .target
= (char *)filename
,
1238 .has_format
= !!format
,
1239 .format
= (char *)format
,
1240 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1242 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1247 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1248 hmp_handle_error(mon
, &err
);
1251 qmp_drive_mirror(&mirror
, &err
);
1252 hmp_handle_error(mon
, &err
);
1255 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1257 const char *device
= qdict_get_str(qdict
, "device");
1258 const char *filename
= qdict_get_str(qdict
, "target");
1259 const char *format
= qdict_get_try_str(qdict
, "format");
1260 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1261 bool full
= qdict_get_try_bool(qdict
, "full", false);
1262 bool compress
= qdict_get_try_bool(qdict
, "compress", false);
1264 DriveBackup backup
= {
1265 .device
= (char *)device
,
1266 .target
= (char *)filename
,
1267 .has_format
= !!format
,
1268 .format
= (char *)format
,
1269 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1271 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1272 .has_compress
= !!compress
,
1273 .compress
= compress
,
1277 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1278 hmp_handle_error(mon
, &err
);
1282 qmp_drive_backup(&backup
, &err
);
1283 hmp_handle_error(mon
, &err
);
1286 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1288 const char *device
= qdict_get_str(qdict
, "device");
1289 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1290 const char *format
= qdict_get_try_str(qdict
, "format");
1291 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1292 enum NewImageMode mode
;
1296 /* In the future, if 'snapshot-file' is not specified, the snapshot
1297 will be taken internally. Today it's actually required. */
1298 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1299 hmp_handle_error(mon
, &err
);
1303 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1304 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1305 filename
, false, NULL
,
1308 hmp_handle_error(mon
, &err
);
1311 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1313 const char *device
= qdict_get_str(qdict
, "device");
1314 const char *name
= qdict_get_str(qdict
, "name");
1317 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1318 hmp_handle_error(mon
, &err
);
1321 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1323 const char *device
= qdict_get_str(qdict
, "device");
1324 const char *name
= qdict_get_str(qdict
, "name");
1325 const char *id
= qdict_get_try_str(qdict
, "id");
1328 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1330 hmp_handle_error(mon
, &err
);
1333 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1335 int saved_vm_running
= runstate_is_running();
1336 const char *name
= qdict_get_str(qdict
, "name");
1339 vm_stop(RUN_STATE_RESTORE_VM
);
1341 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1344 hmp_handle_error(mon
, &err
);
1347 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1351 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1352 hmp_handle_error(mon
, &err
);
1355 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1357 BlockDriverState
*bs
;
1359 const char *name
= qdict_get_str(qdict
, "name");
1361 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1362 error_reportf_err(err
,
1363 "Error while deleting snapshot on device '%s': ",
1364 bdrv_get_device_name(bs
));
1368 void hmp_info_snapshots(Monitor
*mon
, const QDict
*qdict
)
1370 BlockDriverState
*bs
, *bs1
;
1371 BdrvNextIterator it1
;
1372 QEMUSnapshotInfo
*sn_tab
, *sn
;
1373 bool no_snapshot
= true;
1376 int *global_snapshots
;
1377 AioContext
*aio_context
;
1379 typedef struct SnapshotEntry
{
1380 QEMUSnapshotInfo sn
;
1381 QTAILQ_ENTRY(SnapshotEntry
) next
;
1384 typedef struct ImageEntry
{
1385 const char *imagename
;
1386 QTAILQ_ENTRY(ImageEntry
) next
;
1387 QTAILQ_HEAD(, SnapshotEntry
) snapshots
;
1390 QTAILQ_HEAD(, ImageEntry
) image_list
=
1391 QTAILQ_HEAD_INITIALIZER(image_list
);
1393 ImageEntry
*image_entry
, *next_ie
;
1394 SnapshotEntry
*snapshot_entry
;
1396 bs
= bdrv_all_find_vmstate_bs();
1398 monitor_printf(mon
, "No available block device supports snapshots\n");
1401 aio_context
= bdrv_get_aio_context(bs
);
1403 aio_context_acquire(aio_context
);
1404 nb_sns
= bdrv_snapshot_list(bs
, &sn_tab
);
1405 aio_context_release(aio_context
);
1408 monitor_printf(mon
, "bdrv_snapshot_list: error %d\n", nb_sns
);
1412 for (bs1
= bdrv_first(&it1
); bs1
; bs1
= bdrv_next(&it1
)) {
1416 AioContext
*ctx
= bdrv_get_aio_context(bs1
);
1418 aio_context_acquire(ctx
);
1419 if (bdrv_can_snapshot(bs1
)) {
1421 bs1_nb_sns
= bdrv_snapshot_list(bs1
, &sn
);
1422 if (bs1_nb_sns
> 0) {
1423 no_snapshot
= false;
1424 ie
= g_new0(ImageEntry
, 1);
1425 ie
->imagename
= bdrv_get_device_name(bs1
);
1426 QTAILQ_INIT(&ie
->snapshots
);
1427 QTAILQ_INSERT_TAIL(&image_list
, ie
, next
);
1428 for (i
= 0; i
< bs1_nb_sns
; i
++) {
1429 se
= g_new0(SnapshotEntry
, 1);
1431 QTAILQ_INSERT_TAIL(&ie
->snapshots
, se
, next
);
1436 aio_context_release(ctx
);
1440 monitor_printf(mon
, "There is no snapshot available.\n");
1444 global_snapshots
= g_new0(int, nb_sns
);
1446 for (i
= 0; i
< nb_sns
; i
++) {
1447 SnapshotEntry
*next_sn
;
1448 if (bdrv_all_find_snapshot(sn_tab
[i
].name
, &bs1
) == 0) {
1449 global_snapshots
[total
] = i
;
1451 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1452 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
,
1454 if (!strcmp(sn_tab
[i
].name
, snapshot_entry
->sn
.name
)) {
1455 QTAILQ_REMOVE(&image_entry
->snapshots
, snapshot_entry
,
1457 g_free(snapshot_entry
);
1464 monitor_printf(mon
, "List of snapshots present on all disks:\n");
1467 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1468 monitor_printf(mon
, "\n");
1469 for (i
= 0; i
< total
; i
++) {
1470 sn
= &sn_tab
[global_snapshots
[i
]];
1471 /* The ID is not guaranteed to be the same on all images, so
1474 pstrcpy(sn
->id_str
, sizeof(sn
->id_str
), "--");
1475 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, sn
);
1476 monitor_printf(mon
, "\n");
1479 monitor_printf(mon
, "None\n");
1482 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1483 if (QTAILQ_EMPTY(&image_entry
->snapshots
)) {
1487 "\nList of partial (non-loadable) snapshots on '%s':\n",
1488 image_entry
->imagename
);
1489 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1490 monitor_printf(mon
, "\n");
1491 QTAILQ_FOREACH(snapshot_entry
, &image_entry
->snapshots
, next
) {
1492 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
,
1493 &snapshot_entry
->sn
);
1494 monitor_printf(mon
, "\n");
1498 QTAILQ_FOREACH_SAFE(image_entry
, &image_list
, next
, next_ie
) {
1499 SnapshotEntry
*next_sn
;
1500 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
, next
,
1502 g_free(snapshot_entry
);
1504 g_free(image_entry
);
1507 g_free(global_snapshots
);
1511 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1513 qmp_migrate_cancel(NULL
);
1516 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1519 const char *state
= qdict_get_str(qdict
, "state");
1520 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1523 qmp_migrate_continue(val
, &err
);
1526 hmp_handle_error(mon
, &err
);
1529 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1532 const char *uri
= qdict_get_str(qdict
, "uri");
1534 qmp_migrate_incoming(uri
, &err
);
1536 hmp_handle_error(mon
, &err
);
1539 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1542 const char *uri
= qdict_get_str(qdict
, "uri");
1544 qmp_migrate_recover(uri
, &err
);
1546 hmp_handle_error(mon
, &err
);
1549 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1553 qmp_migrate_pause(&err
);
1555 hmp_handle_error(mon
, &err
);
1558 /* Kept for backwards compatibility */
1559 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1561 double value
= qdict_get_double(qdict
, "value");
1562 qmp_migrate_set_downtime(value
, NULL
);
1565 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1567 int64_t value
= qdict_get_int(qdict
, "value");
1570 qmp_migrate_set_cache_size(value
, &err
);
1571 hmp_handle_error(mon
, &err
);
1574 /* Kept for backwards compatibility */
1575 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1577 int64_t value
= qdict_get_int(qdict
, "value");
1578 qmp_migrate_set_speed(value
, NULL
);
1581 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1583 const char *cap
= qdict_get_str(qdict
, "capability");
1584 bool state
= qdict_get_bool(qdict
, "state");
1586 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1589 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1594 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1595 caps
->value
->capability
= val
;
1596 caps
->value
->state
= state
;
1598 qmp_migrate_set_capabilities(caps
, &err
);
1601 qapi_free_MigrationCapabilityStatusList(caps
);
1602 hmp_handle_error(mon
, &err
);
1605 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1607 const char *param
= qdict_get_str(qdict
, "parameter");
1608 const char *valuestr
= qdict_get_str(qdict
, "value");
1609 Visitor
*v
= string_input_visitor_new(valuestr
);
1610 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1611 uint64_t valuebw
= 0;
1612 uint64_t cache_size
;
1616 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1622 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1623 p
->has_compress_level
= true;
1624 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1626 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1627 p
->has_compress_threads
= true;
1628 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1630 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1631 p
->has_decompress_threads
= true;
1632 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1634 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1635 p
->has_cpu_throttle_initial
= true;
1636 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1638 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1639 p
->has_cpu_throttle_increment
= true;
1640 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1642 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1643 p
->has_max_cpu_throttle
= true;
1644 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1646 case MIGRATION_PARAMETER_TLS_CREDS
:
1647 p
->has_tls_creds
= true;
1648 p
->tls_creds
= g_new0(StrOrNull
, 1);
1649 p
->tls_creds
->type
= QTYPE_QSTRING
;
1650 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1652 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1653 p
->has_tls_hostname
= true;
1654 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1655 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1656 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1658 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1659 p
->has_max_bandwidth
= true;
1661 * Can't use visit_type_size() here, because it
1662 * defaults to Bytes rather than Mebibytes.
1664 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1665 if (ret
< 0 || valuebw
> INT64_MAX
1666 || (size_t)valuebw
!= valuebw
) {
1667 error_setg(&err
, "Invalid size %s", valuestr
);
1670 p
->max_bandwidth
= valuebw
;
1672 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1673 p
->has_downtime_limit
= true;
1674 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1676 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1677 p
->has_x_checkpoint_delay
= true;
1678 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1680 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1681 p
->has_block_incremental
= true;
1682 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1684 case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
:
1685 p
->has_x_multifd_channels
= true;
1686 visit_type_int(v
, param
, &p
->x_multifd_channels
, &err
);
1688 case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
:
1689 p
->has_x_multifd_page_count
= true;
1690 visit_type_int(v
, param
, &p
->x_multifd_page_count
, &err
);
1692 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1693 p
->has_xbzrle_cache_size
= true;
1694 visit_type_size(v
, param
, &cache_size
, &err
);
1695 if (err
|| cache_size
> INT64_MAX
1696 || (size_t)cache_size
!= cache_size
) {
1697 error_setg(&err
, "Invalid size %s", valuestr
);
1700 p
->xbzrle_cache_size
= cache_size
;
1702 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1703 p
->has_max_postcopy_bandwidth
= true;
1704 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1714 qmp_migrate_set_parameters(p
, &err
);
1717 qapi_free_MigrateSetParameters(p
);
1719 hmp_handle_error(mon
, &err
);
1722 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1725 const char *protocol
= qdict_get_str(qdict
, "protocol");
1726 const char *hostname
= qdict_get_str(qdict
, "hostname");
1727 bool has_port
= qdict_haskey(qdict
, "port");
1728 int port
= qdict_get_try_int(qdict
, "port", -1);
1729 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1730 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1731 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1733 qmp_client_migrate_info(protocol
, hostname
,
1734 has_port
, port
, has_tls_port
, tls_port
,
1735 !!cert_subject
, cert_subject
, &err
);
1736 hmp_handle_error(mon
, &err
);
1739 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1742 qmp_migrate_start_postcopy(&err
);
1743 hmp_handle_error(mon
, &err
);
1746 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1750 qmp_x_colo_lost_heartbeat(&err
);
1751 hmp_handle_error(mon
, &err
);
1754 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1756 const char *protocol
= qdict_get_str(qdict
, "protocol");
1757 const char *password
= qdict_get_str(qdict
, "password");
1758 const char *connected
= qdict_get_try_str(qdict
, "connected");
1761 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1762 hmp_handle_error(mon
, &err
);
1765 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1767 const char *protocol
= qdict_get_str(qdict
, "protocol");
1768 const char *whenstr
= qdict_get_str(qdict
, "time");
1771 qmp_expire_password(protocol
, whenstr
, &err
);
1772 hmp_handle_error(mon
, &err
);
1775 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1777 bool force
= qdict_get_try_bool(qdict
, "force", false);
1778 const char *device
= qdict_get_str(qdict
, "device");
1781 qmp_eject(true, device
, false, NULL
, true, force
, &err
);
1782 hmp_handle_error(mon
, &err
);
1786 static void hmp_change_read_arg(void *opaque
, const char *password
,
1787 void *readline_opaque
)
1789 qmp_change_vnc_password(password
, NULL
);
1790 monitor_read_command(opaque
, 1);
1794 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1796 const char *device
= qdict_get_str(qdict
, "device");
1797 const char *target
= qdict_get_str(qdict
, "target");
1798 const char *arg
= qdict_get_try_str(qdict
, "arg");
1799 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1800 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1804 if (strcmp(device
, "vnc") == 0) {
1807 "Parameter 'read-only-mode' is invalid for VNC\n");
1810 if (strcmp(target
, "passwd") == 0 ||
1811 strcmp(target
, "password") == 0) {
1813 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1817 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1823 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1825 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1827 hmp_handle_error(mon
, &err
);
1832 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1833 !!arg
, arg
, !!read_only
, read_only_mode
,
1837 hmp_handle_error(mon
, &err
);
1840 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1843 char *device
= (char *) qdict_get_str(qdict
, "device");
1844 BlockIOThrottle throttle
= {
1845 .bps
= qdict_get_int(qdict
, "bps"),
1846 .bps_rd
= qdict_get_int(qdict
, "bps_rd"),
1847 .bps_wr
= qdict_get_int(qdict
, "bps_wr"),
1848 .iops
= qdict_get_int(qdict
, "iops"),
1849 .iops_rd
= qdict_get_int(qdict
, "iops_rd"),
1850 .iops_wr
= qdict_get_int(qdict
, "iops_wr"),
1853 /* qmp_block_set_io_throttle has separate parameters for the
1854 * (deprecated) block device name and the qdev ID but the HMP
1855 * version has only one, so we must decide which one to pass. */
1856 if (blk_by_name(device
)) {
1857 throttle
.has_device
= true;
1858 throttle
.device
= device
;
1860 throttle
.has_id
= true;
1861 throttle
.id
= device
;
1864 qmp_block_set_io_throttle(&throttle
, &err
);
1865 hmp_handle_error(mon
, &err
);
1868 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1870 Error
*error
= NULL
;
1871 const char *device
= qdict_get_str(qdict
, "device");
1872 const char *base
= qdict_get_try_str(qdict
, "base");
1873 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1875 qmp_block_stream(true, device
, device
, base
!= NULL
, base
, false, NULL
,
1876 false, NULL
, qdict_haskey(qdict
, "speed"), speed
,
1877 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1879 hmp_handle_error(mon
, &error
);
1882 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1884 Error
*error
= NULL
;
1885 const char *device
= qdict_get_str(qdict
, "device");
1886 int64_t value
= qdict_get_int(qdict
, "speed");
1888 qmp_block_job_set_speed(device
, value
, &error
);
1890 hmp_handle_error(mon
, &error
);
1893 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1895 Error
*error
= NULL
;
1896 const char *device
= qdict_get_str(qdict
, "device");
1897 bool force
= qdict_get_try_bool(qdict
, "force", false);
1899 qmp_block_job_cancel(device
, true, force
, &error
);
1901 hmp_handle_error(mon
, &error
);
1904 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1906 Error
*error
= NULL
;
1907 const char *device
= qdict_get_str(qdict
, "device");
1909 qmp_block_job_pause(device
, &error
);
1911 hmp_handle_error(mon
, &error
);
1914 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1916 Error
*error
= NULL
;
1917 const char *device
= qdict_get_str(qdict
, "device");
1919 qmp_block_job_resume(device
, &error
);
1921 hmp_handle_error(mon
, &error
);
1924 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1926 Error
*error
= NULL
;
1927 const char *device
= qdict_get_str(qdict
, "device");
1929 qmp_block_job_complete(device
, &error
);
1931 hmp_handle_error(mon
, &error
);
1934 typedef struct HMPMigrationStatus
1938 bool is_block_migration
;
1939 } HMPMigrationStatus
;
1941 static void hmp_migrate_status_cb(void *opaque
)
1943 HMPMigrationStatus
*status
= opaque
;
1944 MigrationInfo
*info
;
1946 info
= qmp_query_migrate(NULL
);
1947 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1948 info
->status
== MIGRATION_STATUS_SETUP
) {
1949 if (info
->has_disk
) {
1952 if (info
->disk
->remaining
) {
1953 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1958 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1959 monitor_flush(status
->mon
);
1962 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1964 if (status
->is_block_migration
) {
1965 monitor_printf(status
->mon
, "\n");
1967 if (info
->has_error_desc
) {
1968 error_report("%s", info
->error_desc
);
1970 monitor_resume(status
->mon
);
1971 timer_del(status
->timer
);
1975 qapi_free_MigrationInfo(info
);
1978 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1980 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1981 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1982 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1983 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1984 const char *uri
= qdict_get_str(qdict
, "uri");
1987 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1988 false, false, true, resume
, &err
);
1990 hmp_handle_error(mon
, &err
);
1995 HMPMigrationStatus
*status
;
1997 if (monitor_suspend(mon
) < 0) {
1998 monitor_printf(mon
, "terminal does not allow synchronous "
1999 "migration, continuing detached\n");
2003 status
= g_malloc0(sizeof(*status
));
2005 status
->is_block_migration
= blk
|| inc
;
2006 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
2008 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
2012 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
2016 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
2017 hmp_handle_error(mon
, &err
);
2020 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
2022 const char *id
= qdict_get_str(qdict
, "id");
2025 qmp_device_del(id
, &err
);
2026 hmp_handle_error(mon
, &err
);
2029 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
2032 bool win_dmp
= qdict_get_try_bool(qdict
, "windmp", false);
2033 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
2034 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
2035 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
2036 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
2037 const char *file
= qdict_get_str(qdict
, "filename");
2038 bool has_begin
= qdict_haskey(qdict
, "begin");
2039 bool has_length
= qdict_haskey(qdict
, "length");
2040 bool has_detach
= qdict_haskey(qdict
, "detach");
2043 bool detach
= false;
2044 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
2047 if (zlib
+ lzo
+ snappy
+ win_dmp
> 1) {
2048 error_setg(&err
, "only one of '-z|-l|-s|-w' can be set");
2049 hmp_handle_error(mon
, &err
);
2054 dump_format
= DUMP_GUEST_MEMORY_FORMAT_WIN_DMP
;
2058 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
2062 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
2066 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
2070 begin
= qdict_get_int(qdict
, "begin");
2073 length
= qdict_get_int(qdict
, "length");
2076 detach
= qdict_get_bool(qdict
, "detach");
2079 prot
= g_strconcat("file:", file
, NULL
);
2081 qmp_dump_guest_memory(paging
, prot
, true, detach
, has_begin
, begin
,
2082 has_length
, length
, true, dump_format
, &err
);
2083 hmp_handle_error(mon
, &err
);
2087 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
2092 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
2097 netdev_add(opts
, &err
);
2099 qemu_opts_del(opts
);
2103 hmp_handle_error(mon
, &err
);
2106 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
2108 const char *id
= qdict_get_str(qdict
, "id");
2111 qmp_netdev_del(id
, &err
);
2112 hmp_handle_error(mon
, &err
);
2115 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
2121 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
2123 hmp_handle_error(mon
, &err
);
2127 obj
= user_creatable_add_opts(opts
, &err
);
2128 qemu_opts_del(opts
);
2131 hmp_handle_error(mon
, &err
);
2138 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
2140 const char *fdname
= qdict_get_str(qdict
, "fdname");
2143 qmp_getfd(fdname
, &err
);
2144 hmp_handle_error(mon
, &err
);
2147 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
2149 const char *fdname
= qdict_get_str(qdict
, "fdname");
2152 qmp_closefd(fdname
, &err
);
2153 hmp_handle_error(mon
, &err
);
2156 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
2158 const char *keys
= qdict_get_str(qdict
, "keys");
2159 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
2160 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
2161 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
2163 const char *separator
;
2167 separator
= qemu_strchrnul(keys
, '-');
2168 keyname_len
= separator
- keys
;
2170 /* Be compatible with old interface, convert user inputted "<" */
2171 if (keys
[0] == '<' && keyname_len
== 1) {
2176 keylist
= g_malloc0(sizeof(*keylist
));
2177 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
2183 tmp
->next
= keylist
;
2187 if (strstart(keys
, "0x", NULL
)) {
2189 int value
= strtoul(keys
, &endp
, 0);
2190 assert(endp
<= keys
+ keyname_len
);
2191 if (endp
!= keys
+ keyname_len
) {
2194 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
2195 keylist
->value
->u
.number
.data
= value
;
2197 int idx
= index_from_key(keys
, keyname_len
);
2198 if (idx
== Q_KEY_CODE__MAX
) {
2201 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
2202 keylist
->value
->u
.qcode
.data
= idx
;
2208 keys
= separator
+ 1;
2211 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
2212 hmp_handle_error(mon
, &err
);
2215 qapi_free_KeyValueList(head
);
2219 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
2223 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
2225 const char *filename
= qdict_get_str(qdict
, "filename");
2226 const char *id
= qdict_get_try_str(qdict
, "device");
2227 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
2230 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
2231 hmp_handle_error(mon
, &err
);
2234 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
2236 const char *uri
= qdict_get_str(qdict
, "uri");
2237 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2238 bool all
= qdict_get_try_bool(qdict
, "all", false);
2239 Error
*local_err
= NULL
;
2240 BlockInfoList
*block_list
, *info
;
2241 SocketAddress
*addr
;
2243 if (writable
&& !all
) {
2244 error_setg(&local_err
, "-w only valid together with -a");
2248 /* First check if the address is valid and start the server. */
2249 addr
= socket_parse(uri
, &local_err
);
2250 if (local_err
!= NULL
) {
2254 nbd_server_start(addr
, NULL
, &local_err
);
2255 qapi_free_SocketAddress(addr
);
2256 if (local_err
!= NULL
) {
2264 /* Then try adding all block devices. If one fails, close all and
2267 block_list
= qmp_query_block(NULL
);
2269 for (info
= block_list
; info
; info
= info
->next
) {
2270 if (!info
->value
->has_inserted
) {
2274 qmp_nbd_server_add(info
->value
->device
, false, NULL
,
2275 true, writable
, &local_err
);
2277 if (local_err
!= NULL
) {
2278 qmp_nbd_server_stop(NULL
);
2283 qapi_free_BlockInfoList(block_list
);
2286 hmp_handle_error(mon
, &local_err
);
2289 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
2291 const char *device
= qdict_get_str(qdict
, "device");
2292 const char *name
= qdict_get_try_str(qdict
, "name");
2293 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2294 Error
*local_err
= NULL
;
2296 qmp_nbd_server_add(device
, !!name
, name
, true, writable
, &local_err
);
2297 hmp_handle_error(mon
, &local_err
);
2300 void hmp_nbd_server_remove(Monitor
*mon
, const QDict
*qdict
)
2302 const char *name
= qdict_get_str(qdict
, "name");
2303 bool force
= qdict_get_try_bool(qdict
, "force", false);
2306 /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
2307 qmp_nbd_server_remove(name
, force
, NBD_SERVER_REMOVE_MODE_HARD
, &err
);
2308 hmp_handle_error(mon
, &err
);
2311 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
2315 qmp_nbd_server_stop(&err
);
2316 hmp_handle_error(mon
, &err
);
2319 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
2324 cpuid
= qdict_get_int(qdict
, "id");
2325 qmp_cpu_add(cpuid
, &err
);
2326 hmp_handle_error(mon
, &err
);
2329 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
2331 const char *args
= qdict_get_str(qdict
, "args");
2335 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
2337 error_setg(&err
, "Parsing chardev args failed");
2339 qemu_chr_new_from_opts(opts
, &err
);
2340 qemu_opts_del(opts
);
2342 hmp_handle_error(mon
, &err
);
2345 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
2347 const char *args
= qdict_get_str(qdict
, "args");
2350 ChardevBackend
*backend
= NULL
;
2351 ChardevReturn
*ret
= NULL
;
2352 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
2355 error_setg(&err
, "Parsing chardev args failed");
2359 id
= qdict_get_str(qdict
, "id");
2360 if (qemu_opts_id(opts
)) {
2361 error_setg(&err
, "Unexpected 'id' parameter");
2365 backend
= qemu_chr_parse_opts(opts
, &err
);
2370 ret
= qmp_chardev_change(id
, backend
, &err
);
2373 qapi_free_ChardevReturn(ret
);
2374 qapi_free_ChardevBackend(backend
);
2375 qemu_opts_del(opts
);
2376 hmp_handle_error(mon
, &err
);
2379 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
2381 Error
*local_err
= NULL
;
2383 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
2384 hmp_handle_error(mon
, &local_err
);
2387 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
2389 Error
*local_err
= NULL
;
2391 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
2392 hmp_handle_error(mon
, &local_err
);
2395 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
2398 BlockBackend
*local_blk
= NULL
;
2399 const char* device
= qdict_get_str(qdict
, "device");
2400 const char* command
= qdict_get_str(qdict
, "command");
2404 blk
= blk_by_name(device
);
2406 BlockDriverState
*bs
= bdrv_lookup_bs(NULL
, device
, &err
);
2408 blk
= local_blk
= blk_new(0, BLK_PERM_ALL
);
2409 ret
= blk_insert_bs(blk
, bs
, &err
);
2419 * Notably absent: Proper permission management. This is sad, but it seems
2420 * almost impossible to achieve without changing the semantics and thereby
2421 * limiting the use cases of the qemu-io HMP command.
2423 * In an ideal world we would unconditionally create a new BlockBackend for
2424 * qemuio_command(), but we have commands like 'reopen' and want them to
2425 * take effect on the exact BlockBackend whose name the user passed instead
2426 * of just on a temporary copy of it.
2428 * Another problem is that deleting the temporary BlockBackend involves
2429 * draining all requests on it first, but some qemu-iotests cases want to
2430 * issue multiple aio_read/write requests and expect them to complete in
2431 * the background while the monitor has already returned.
2433 * This is also what prevents us from saving the original permissions and
2434 * restoring them later: We can't revoke permissions until all requests
2435 * have completed, and we don't know when that is nor can we really let
2436 * anything else run before we have revoken them to avoid race conditions.
2438 * What happens now is that command() in qemu-io-cmds.c can extend the
2439 * permissions if necessary for the qemu-io command. And they simply stay
2440 * extended, possibly resulting in a read-only guest device keeping write
2441 * permissions. Ugly, but it appears to be the lesser evil.
2443 qemuio_command(blk
, command
);
2446 blk_unref(local_blk
);
2447 hmp_handle_error(mon
, &err
);
2450 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
2452 const char *id
= qdict_get_str(qdict
, "id");
2455 user_creatable_del(id
, &err
);
2456 hmp_handle_error(mon
, &err
);
2459 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
2462 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
2463 MemdevList
*m
= memdev_list
;
2468 v
= string_output_visitor_new(false, &str
);
2469 visit_type_uint16List(v
, NULL
, &m
->value
->host_nodes
, NULL
);
2470 monitor_printf(mon
, "memory backend: %s\n", m
->value
->id
);
2471 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
2472 monitor_printf(mon
, " merge: %s\n",
2473 m
->value
->merge
? "true" : "false");
2474 monitor_printf(mon
, " dump: %s\n",
2475 m
->value
->dump
? "true" : "false");
2476 monitor_printf(mon
, " prealloc: %s\n",
2477 m
->value
->prealloc
? "true" : "false");
2478 monitor_printf(mon
, " policy: %s\n",
2479 HostMemPolicy_str(m
->value
->policy
));
2480 visit_complete(v
, &str
);
2481 monitor_printf(mon
, " host nodes: %s\n", str
);
2488 monitor_printf(mon
, "\n");
2490 qapi_free_MemdevList(memdev_list
);
2491 hmp_handle_error(mon
, &err
);
2494 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2497 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2498 MemoryDeviceInfoList
*info
;
2499 MemoryDeviceInfo
*value
;
2500 PCDIMMDeviceInfo
*di
;
2502 for (info
= info_list
; info
; info
= info
->next
) {
2503 value
= info
->value
;
2506 switch (value
->type
) {
2507 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2508 di
= value
->u
.dimm
.data
;
2511 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
2512 di
= value
->u
.nvdimm
.data
;
2521 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2522 MemoryDeviceInfoKind_str(value
->type
),
2523 di
->id
? di
->id
: "");
2524 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2525 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2526 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2527 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2528 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2529 monitor_printf(mon
, " hotplugged: %s\n",
2530 di
->hotplugged
? "true" : "false");
2531 monitor_printf(mon
, " hotpluggable: %s\n",
2532 di
->hotpluggable
? "true" : "false");
2537 qapi_free_MemoryDeviceInfoList(info_list
);
2538 hmp_handle_error(mon
, &err
);
2541 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2543 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2544 IOThreadInfoList
*info
;
2545 IOThreadInfo
*value
;
2547 for (info
= info_list
; info
; info
= info
->next
) {
2548 value
= info
->value
;
2549 monitor_printf(mon
, "%s:\n", value
->id
);
2550 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
2551 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
2552 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
2553 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
2556 qapi_free_IOThreadInfoList(info_list
);
2559 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2561 const char *path
= qdict_get_try_str(qdict
, "path");
2562 ObjectPropertyInfoList
*list
;
2566 monitor_printf(mon
, "/\n");
2570 list
= qmp_qom_list(path
, &err
);
2572 ObjectPropertyInfoList
*start
= list
;
2573 while (list
!= NULL
) {
2574 ObjectPropertyInfo
*value
= list
->value
;
2576 monitor_printf(mon
, "%s (%s)\n",
2577 value
->name
, value
->type
);
2580 qapi_free_ObjectPropertyInfoList(start
);
2582 hmp_handle_error(mon
, &err
);
2585 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2587 const char *path
= qdict_get_str(qdict
, "path");
2588 const char *property
= qdict_get_str(qdict
, "property");
2589 const char *value
= qdict_get_str(qdict
, "value");
2591 bool ambiguous
= false;
2594 obj
= object_resolve_path(path
, &ambiguous
);
2596 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2597 "Device '%s' not found", path
);
2600 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2602 object_property_parse(obj
, value
, property
, &err
);
2604 hmp_handle_error(mon
, &err
);
2607 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2609 const char *name
= qdict_get_str(qdict
, "name");
2610 RockerSwitch
*rocker
;
2613 rocker
= qmp_query_rocker(name
, &err
);
2615 hmp_handle_error(mon
, &err
);
2619 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2620 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2621 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2623 qapi_free_RockerSwitch(rocker
);
2626 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2628 RockerPortList
*list
, *port
;
2629 const char *name
= qdict_get_str(qdict
, "name");
2632 list
= qmp_query_rocker_ports(name
, &err
);
2634 hmp_handle_error(mon
, &err
);
2638 monitor_printf(mon
, " ena/ speed/ auto\n");
2639 monitor_printf(mon
, " port link duplex neg?\n");
2641 for (port
= list
; port
; port
= port
->next
) {
2642 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2644 port
->value
->enabled
? port
->value
->link_up
?
2645 "up" : "down" : "!ena",
2646 port
->value
->speed
== 10000 ? "10G" : "??",
2647 port
->value
->duplex
? "FD" : "HD",
2648 port
->value
->autoneg
? "Yes" : "No");
2651 qapi_free_RockerPortList(list
);
2654 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2656 RockerOfDpaFlowList
*list
, *info
;
2657 const char *name
= qdict_get_str(qdict
, "name");
2658 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2661 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2663 hmp_handle_error(mon
, &err
);
2667 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2669 for (info
= list
; info
; info
= info
->next
) {
2670 RockerOfDpaFlow
*flow
= info
->value
;
2671 RockerOfDpaFlowKey
*key
= flow
->key
;
2672 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2673 RockerOfDpaFlowAction
*action
= flow
->action
;
2676 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2677 key
->priority
, key
->tbl_id
, flow
->hits
);
2679 monitor_printf(mon
, "%-4d %-3d ",
2680 key
->priority
, key
->tbl_id
);
2683 if (key
->has_in_pport
) {
2684 monitor_printf(mon
, " pport %d", key
->in_pport
);
2685 if (mask
->has_in_pport
) {
2686 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2690 if (key
->has_vlan_id
) {
2691 monitor_printf(mon
, " vlan %d",
2692 key
->vlan_id
& VLAN_VID_MASK
);
2693 if (mask
->has_vlan_id
) {
2694 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2698 if (key
->has_tunnel_id
) {
2699 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2700 if (mask
->has_tunnel_id
) {
2701 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2705 if (key
->has_eth_type
) {
2706 switch (key
->eth_type
) {
2708 monitor_printf(mon
, " ARP");
2711 monitor_printf(mon
, " IP");
2714 monitor_printf(mon
, " IPv6");
2717 monitor_printf(mon
, " LACP");
2720 monitor_printf(mon
, " LLDP");
2723 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2728 if (key
->has_eth_src
) {
2729 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2730 (mask
->has_eth_src
) &&
2731 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2732 monitor_printf(mon
, " src <any mcast/bcast>");
2733 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2734 (mask
->has_eth_src
) &&
2735 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2736 monitor_printf(mon
, " src <any ucast>");
2738 monitor_printf(mon
, " src %s", key
->eth_src
);
2739 if (mask
->has_eth_src
) {
2740 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2745 if (key
->has_eth_dst
) {
2746 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2747 (mask
->has_eth_dst
) &&
2748 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2749 monitor_printf(mon
, " dst <any mcast/bcast>");
2750 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2751 (mask
->has_eth_dst
) &&
2752 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2753 monitor_printf(mon
, " dst <any ucast>");
2755 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2756 if (mask
->has_eth_dst
) {
2757 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2762 if (key
->has_ip_proto
) {
2763 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2764 if (mask
->has_ip_proto
) {
2765 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2769 if (key
->has_ip_tos
) {
2770 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2771 if (mask
->has_ip_tos
) {
2772 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2776 if (key
->has_ip_dst
) {
2777 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2780 if (action
->has_goto_tbl
|| action
->has_group_id
||
2781 action
->has_new_vlan_id
) {
2782 monitor_printf(mon
, " -->");
2785 if (action
->has_new_vlan_id
) {
2786 monitor_printf(mon
, " apply new vlan %d",
2787 ntohs(action
->new_vlan_id
));
2790 if (action
->has_group_id
) {
2791 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2794 if (action
->has_goto_tbl
) {
2795 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2798 monitor_printf(mon
, "\n");
2801 qapi_free_RockerOfDpaFlowList(list
);
2804 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2806 RockerOfDpaGroupList
*list
, *g
;
2807 const char *name
= qdict_get_str(qdict
, "name");
2808 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2812 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2814 hmp_handle_error(mon
, &err
);
2818 monitor_printf(mon
, "id (decode) --> buckets\n");
2820 for (g
= list
; g
; g
= g
->next
) {
2821 RockerOfDpaGroup
*group
= g
->value
;
2823 monitor_printf(mon
, "0x%08x", group
->id
);
2825 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2826 group
->type
== 1 ? "L2 rewrite" :
2827 group
->type
== 2 ? "L3 unicast" :
2828 group
->type
== 3 ? "L2 multicast" :
2829 group
->type
== 4 ? "L2 flood" :
2830 group
->type
== 5 ? "L3 interface" :
2831 group
->type
== 6 ? "L3 multicast" :
2832 group
->type
== 7 ? "L3 ECMP" :
2833 group
->type
== 8 ? "L2 overlay" :
2836 if (group
->has_vlan_id
) {
2837 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2840 if (group
->has_pport
) {
2841 monitor_printf(mon
, " pport %d", group
->pport
);
2844 if (group
->has_index
) {
2845 monitor_printf(mon
, " index %d", group
->index
);
2848 monitor_printf(mon
, ") -->");
2850 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2852 monitor_printf(mon
, " set vlan %d",
2853 group
->set_vlan_id
& VLAN_VID_MASK
);
2856 if (group
->has_set_eth_src
) {
2859 monitor_printf(mon
, " set");
2861 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2864 if (group
->has_set_eth_dst
) {
2867 monitor_printf(mon
, " set");
2869 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2874 if (group
->has_ttl_check
&& group
->ttl_check
) {
2875 monitor_printf(mon
, " check TTL");
2878 if (group
->has_group_id
&& group
->group_id
) {
2879 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2882 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2883 monitor_printf(mon
, " pop vlan");
2886 if (group
->has_out_pport
) {
2887 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2890 if (group
->has_group_ids
) {
2891 struct uint32List
*id
;
2893 monitor_printf(mon
, " groups [");
2894 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2895 monitor_printf(mon
, "0x%08x", id
->value
);
2897 monitor_printf(mon
, ",");
2900 monitor_printf(mon
, "]");
2903 monitor_printf(mon
, "\n");
2906 qapi_free_RockerOfDpaGroupList(list
);
2909 void hmp_info_dump(Monitor
*mon
, const QDict
*qdict
)
2911 DumpQueryResult
*result
= qmp_query_dump(NULL
);
2913 assert(result
&& result
->status
< DUMP_STATUS__MAX
);
2914 monitor_printf(mon
, "Status: %s\n", DumpStatus_str(result
->status
));
2916 if (result
->status
== DUMP_STATUS_ACTIVE
) {
2918 assert(result
->total
!= 0);
2919 percent
= 100.0 * result
->completed
/ result
->total
;
2920 monitor_printf(mon
, "Finished: %.2f %%\n", percent
);
2923 qapi_free_DumpQueryResult(result
);
2926 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2928 ram_block_dump(mon
);
2931 void hmp_hotpluggable_cpus(Monitor
*mon
, const QDict
*qdict
)
2934 HotpluggableCPUList
*l
= qmp_query_hotpluggable_cpus(&err
);
2935 HotpluggableCPUList
*saved
= l
;
2936 CpuInstanceProperties
*c
;
2939 hmp_handle_error(mon
, &err
);
2943 monitor_printf(mon
, "Hotpluggable CPUs:\n");
2945 monitor_printf(mon
, " type: \"%s\"\n", l
->value
->type
);
2946 monitor_printf(mon
, " vcpus_count: \"%" PRIu64
"\"\n",
2947 l
->value
->vcpus_count
);
2948 if (l
->value
->has_qom_path
) {
2949 monitor_printf(mon
, " qom_path: \"%s\"\n", l
->value
->qom_path
);
2952 c
= l
->value
->props
;
2953 monitor_printf(mon
, " CPUInstance Properties:\n");
2954 if (c
->has_node_id
) {
2955 monitor_printf(mon
, " node-id: \"%" PRIu64
"\"\n", c
->node_id
);
2957 if (c
->has_socket_id
) {
2958 monitor_printf(mon
, " socket-id: \"%" PRIu64
"\"\n", c
->socket_id
);
2960 if (c
->has_core_id
) {
2961 monitor_printf(mon
, " core-id: \"%" PRIu64
"\"\n", c
->core_id
);
2963 if (c
->has_thread_id
) {
2964 monitor_printf(mon
, " thread-id: \"%" PRIu64
"\"\n", c
->thread_id
);
2970 qapi_free_HotpluggableCPUList(saved
);
2973 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2976 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2978 monitor_printf(mon
, "%s\n", info
->guid
);
2980 hmp_handle_error(mon
, &err
);
2981 qapi_free_GuidInfo(info
);
2984 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2987 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2989 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2992 if (info
->has_plugged_memory
) {
2993 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2994 info
->plugged_memory
);
2997 qapi_free_MemoryInfo(info
);
2999 hmp_handle_error(mon
, &err
);