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_compress_wait_thread
);
331 monitor_printf(mon
, "%s: %s\n",
332 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
333 params
->compress_wait_thread
? "on" : "off");
334 assert(params
->has_decompress_threads
);
335 monitor_printf(mon
, "%s: %u\n",
336 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
337 params
->decompress_threads
);
338 assert(params
->has_cpu_throttle_initial
);
339 monitor_printf(mon
, "%s: %u\n",
340 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
341 params
->cpu_throttle_initial
);
342 assert(params
->has_cpu_throttle_increment
);
343 monitor_printf(mon
, "%s: %u\n",
344 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
345 params
->cpu_throttle_increment
);
346 assert(params
->has_max_cpu_throttle
);
347 monitor_printf(mon
, "%s: %u\n",
348 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
349 params
->max_cpu_throttle
);
350 assert(params
->has_tls_creds
);
351 monitor_printf(mon
, "%s: '%s'\n",
352 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
354 assert(params
->has_tls_hostname
);
355 monitor_printf(mon
, "%s: '%s'\n",
356 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
357 params
->tls_hostname
);
358 assert(params
->has_max_bandwidth
);
359 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
360 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
361 params
->max_bandwidth
);
362 assert(params
->has_downtime_limit
);
363 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
364 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
365 params
->downtime_limit
);
366 assert(params
->has_x_checkpoint_delay
);
367 monitor_printf(mon
, "%s: %u\n",
368 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
369 params
->x_checkpoint_delay
);
370 assert(params
->has_block_incremental
);
371 monitor_printf(mon
, "%s: %s\n",
372 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
373 params
->block_incremental
? "on" : "off");
374 monitor_printf(mon
, "%s: %u\n",
375 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
),
376 params
->x_multifd_channels
);
377 monitor_printf(mon
, "%s: %u\n",
378 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
),
379 params
->x_multifd_page_count
);
380 monitor_printf(mon
, "%s: %" PRIu64
"\n",
381 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
382 params
->xbzrle_cache_size
);
383 monitor_printf(mon
, "%s: %" PRIu64
"\n",
384 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
385 params
->max_postcopy_bandwidth
);
388 qapi_free_MigrationParameters(params
);
391 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
393 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
394 qmp_query_migrate_cache_size(NULL
) >> 10);
397 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
399 CpuInfoFastList
*cpu_list
, *cpu
;
401 cpu_list
= qmp_query_cpus_fast(NULL
);
403 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
406 if (cpu
->value
->cpu_index
== monitor_get_cpu_index()) {
410 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
,
411 cpu
->value
->cpu_index
);
412 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
415 qapi_free_CpuInfoFastList(cpu_list
);
418 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
419 BlockDeviceInfo
*inserted
, bool verbose
)
421 ImageInfo
*image_info
;
423 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
425 if (info
&& *info
->device
) {
426 monitor_printf(mon
, "%s", info
->device
);
427 if (inserted
&& inserted
->has_node_name
) {
428 monitor_printf(mon
, " (%s)", inserted
->node_name
);
431 assert(info
|| inserted
);
432 monitor_printf(mon
, "%s",
433 inserted
&& inserted
->has_node_name
? inserted
->node_name
434 : info
&& info
->has_qdev
? info
->qdev
439 monitor_printf(mon
, ": %s (%s%s%s)\n",
442 inserted
->ro
? ", read-only" : "",
443 inserted
->encrypted
? ", encrypted" : "");
445 monitor_printf(mon
, ": [not inserted]\n");
449 if (info
->has_qdev
) {
450 monitor_printf(mon
, " Attached to: %s\n", info
->qdev
);
452 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
453 monitor_printf(mon
, " I/O status: %s\n",
454 BlockDeviceIoStatus_str(info
->io_status
));
457 if (info
->removable
) {
458 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
459 info
->locked
? "" : "not ",
460 info
->tray_open
? "open" : "closed");
469 monitor_printf(mon
, " Cache mode: %s%s%s\n",
470 inserted
->cache
->writeback
? "writeback" : "writethrough",
471 inserted
->cache
->direct
? ", direct" : "",
472 inserted
->cache
->no_flush
? ", ignore flushes" : "");
474 if (inserted
->has_backing_file
) {
477 "(chain depth: %" PRId64
")\n",
478 inserted
->backing_file
,
479 inserted
->backing_file_depth
);
482 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
483 monitor_printf(mon
, " Detect zeroes: %s\n",
484 BlockdevDetectZeroesOptions_str(inserted
->detect_zeroes
));
487 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
488 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
490 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
491 " bps_rd=%" PRId64
" bps_wr=%" PRId64
493 " bps_rd_max=%" PRId64
494 " bps_wr_max=%" PRId64
495 " iops=%" PRId64
" iops_rd=%" PRId64
498 " iops_rd_max=%" PRId64
499 " iops_wr_max=%" PRId64
500 " iops_size=%" PRId64
506 inserted
->bps_rd_max
,
507 inserted
->bps_wr_max
,
512 inserted
->iops_rd_max
,
513 inserted
->iops_wr_max
,
519 monitor_printf(mon
, "\nImages:\n");
520 image_info
= inserted
->image
;
522 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
524 if (image_info
->has_backing_image
) {
525 image_info
= image_info
->backing_image
;
533 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
535 BlockInfoList
*block_list
, *info
;
536 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
537 const char *device
= qdict_get_try_str(qdict
, "device");
538 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
539 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
540 bool printed
= false;
542 /* Print BlockBackend information */
544 block_list
= qmp_query_block(NULL
);
549 for (info
= block_list
; info
; info
= info
->next
) {
550 if (device
&& strcmp(device
, info
->value
->device
)) {
554 if (info
!= block_list
) {
555 monitor_printf(mon
, "\n");
558 print_block_info(mon
, info
->value
, info
->value
->has_inserted
559 ? info
->value
->inserted
: NULL
,
564 qapi_free_BlockInfoList(block_list
);
566 if ((!device
&& !nodes
) || printed
) {
570 /* Print node information */
571 blockdev_list
= qmp_query_named_block_nodes(NULL
);
572 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
573 assert(blockdev
->value
->has_node_name
);
574 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
578 if (blockdev
!= blockdev_list
) {
579 monitor_printf(mon
, "\n");
582 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
584 qapi_free_BlockDeviceInfoList(blockdev_list
);
587 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
589 BlockStatsList
*stats_list
, *stats
;
591 stats_list
= qmp_query_blockstats(false, false, NULL
);
593 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
594 if (!stats
->value
->has_device
) {
598 monitor_printf(mon
, "%s:", stats
->value
->device
);
599 monitor_printf(mon
, " rd_bytes=%" PRId64
601 " rd_operations=%" PRId64
602 " wr_operations=%" PRId64
603 " flush_operations=%" PRId64
604 " wr_total_time_ns=%" PRId64
605 " rd_total_time_ns=%" PRId64
606 " flush_total_time_ns=%" PRId64
607 " rd_merged=%" PRId64
608 " wr_merged=%" PRId64
609 " idle_time_ns=%" PRId64
611 stats
->value
->stats
->rd_bytes
,
612 stats
->value
->stats
->wr_bytes
,
613 stats
->value
->stats
->rd_operations
,
614 stats
->value
->stats
->wr_operations
,
615 stats
->value
->stats
->flush_operations
,
616 stats
->value
->stats
->wr_total_time_ns
,
617 stats
->value
->stats
->rd_total_time_ns
,
618 stats
->value
->stats
->flush_total_time_ns
,
619 stats
->value
->stats
->rd_merged
,
620 stats
->value
->stats
->wr_merged
,
621 stats
->value
->stats
->idle_time_ns
);
624 qapi_free_BlockStatsList(stats_list
);
628 /* Helper for hmp_info_vnc_clients, _servers */
629 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
632 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
636 NetworkAddressFamily_str(info
->family
),
637 info
->websocket
? " (Websocket)" : "");
640 /* Helper displaying and auth and crypt info */
641 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
643 VncVencryptSubAuth
*vencrypt
)
645 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
646 VncPrimaryAuth_str(auth
),
647 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
650 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
653 VncClientInfo
*cinfo
= client
->value
;
655 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
656 monitor_printf(mon
, " x509_dname: %s\n",
657 cinfo
->has_x509_dname
?
658 cinfo
->x509_dname
: "none");
659 monitor_printf(mon
, " sasl_username: %s\n",
660 cinfo
->has_sasl_username
?
661 cinfo
->sasl_username
: "none");
663 client
= client
->next
;
667 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
670 VncServerInfo2
*sinfo
= server
->value
;
671 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
672 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
673 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
674 server
= server
->next
;
678 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
680 VncInfo2List
*info2l
;
683 info2l
= qmp_query_vnc_servers(&err
);
685 hmp_handle_error(mon
, &err
);
689 monitor_printf(mon
, "None\n");
694 VncInfo2
*info
= info2l
->value
;
695 monitor_printf(mon
, "%s:\n", info
->id
);
696 hmp_info_vnc_servers(mon
, info
->server
);
697 hmp_info_vnc_clients(mon
, info
->clients
);
699 /* The server entry displays its auth, we only
700 * need to display in the case of 'reverse' connections
701 * where there's no server.
703 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
704 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
706 if (info
->has_display
) {
707 monitor_printf(mon
, " Display: %s\n", info
->display
);
709 info2l
= info2l
->next
;
712 qapi_free_VncInfo2List(info2l
);
718 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
720 SpiceChannelList
*chan
;
722 const char *channel_name
;
723 const char * const channel_names
[] = {
724 [SPICE_CHANNEL_MAIN
] = "main",
725 [SPICE_CHANNEL_DISPLAY
] = "display",
726 [SPICE_CHANNEL_INPUTS
] = "inputs",
727 [SPICE_CHANNEL_CURSOR
] = "cursor",
728 [SPICE_CHANNEL_PLAYBACK
] = "playback",
729 [SPICE_CHANNEL_RECORD
] = "record",
730 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
731 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
732 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
733 [SPICE_CHANNEL_PORT
] = "port",
735 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
736 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
737 * as quick fix for build failures with older versions. */
738 [SPICE_CHANNEL_WEBDAV
] = "webdav",
742 info
= qmp_query_spice(NULL
);
744 if (!info
->enabled
) {
745 monitor_printf(mon
, "Server: disabled\n");
749 monitor_printf(mon
, "Server:\n");
750 if (info
->has_port
) {
751 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
752 info
->host
, info
->port
);
754 if (info
->has_tls_port
) {
755 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
756 info
->host
, info
->tls_port
);
758 monitor_printf(mon
, " migrated: %s\n",
759 info
->migrated
? "true" : "false");
760 monitor_printf(mon
, " auth: %s\n", info
->auth
);
761 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
762 monitor_printf(mon
, " mouse-mode: %s\n",
763 SpiceQueryMouseMode_str(info
->mouse_mode
));
765 if (!info
->has_channels
|| info
->channels
== NULL
) {
766 monitor_printf(mon
, "Channels: none\n");
768 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
769 monitor_printf(mon
, "Channel:\n");
770 monitor_printf(mon
, " address: %s:%s%s\n",
771 chan
->value
->host
, chan
->value
->port
,
772 chan
->value
->tls
? " [tls]" : "");
773 monitor_printf(mon
, " session: %" PRId64
"\n",
774 chan
->value
->connection_id
);
775 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
776 chan
->value
->channel_type
, chan
->value
->channel_id
);
778 channel_name
= "unknown";
779 if (chan
->value
->channel_type
> 0 &&
780 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
781 channel_names
[chan
->value
->channel_type
]) {
782 channel_name
= channel_names
[chan
->value
->channel_type
];
785 monitor_printf(mon
, " channel name: %s\n", channel_name
);
790 qapi_free_SpiceInfo(info
);
794 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
799 info
= qmp_query_balloon(&err
);
801 hmp_handle_error(mon
, &err
);
805 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
807 qapi_free_BalloonInfo(info
);
810 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
812 PciMemoryRegionList
*region
;
814 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
815 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
816 dev
->slot
, dev
->function
);
817 monitor_printf(mon
, " ");
819 if (dev
->class_info
->has_desc
) {
820 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
822 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
825 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
826 dev
->id
->vendor
, dev
->id
->device
);
829 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
832 if (dev
->has_pci_bridge
) {
833 monitor_printf(mon
, " BUS %" PRId64
".\n",
834 dev
->pci_bridge
->bus
->number
);
835 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
836 dev
->pci_bridge
->bus
->secondary
);
837 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
838 dev
->pci_bridge
->bus
->subordinate
);
840 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
841 dev
->pci_bridge
->bus
->io_range
->base
,
842 dev
->pci_bridge
->bus
->io_range
->limit
);
845 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
846 dev
->pci_bridge
->bus
->memory_range
->base
,
847 dev
->pci_bridge
->bus
->memory_range
->limit
);
849 monitor_printf(mon
, " prefetchable memory range "
850 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
851 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
852 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
855 for (region
= dev
->regions
; region
; region
= region
->next
) {
858 addr
= region
->value
->address
;
859 size
= region
->value
->size
;
861 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
863 if (!strcmp(region
->value
->type
, "io")) {
864 monitor_printf(mon
, "I/O at 0x%04" PRIx64
865 " [0x%04" PRIx64
"].\n",
866 addr
, addr
+ size
- 1);
868 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
869 " [0x%08" PRIx64
"].\n",
870 region
->value
->mem_type_64
? 64 : 32,
871 region
->value
->prefetch
? " prefetchable" : "",
872 addr
, addr
+ size
- 1);
876 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
878 if (dev
->has_pci_bridge
) {
879 if (dev
->pci_bridge
->has_devices
) {
880 PciDeviceInfoList
*cdev
;
881 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
882 hmp_info_pci_device(mon
, cdev
->value
);
888 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
890 InterruptStatsProvider
*intc
;
891 InterruptStatsProviderClass
*k
;
892 Monitor
*mon
= opaque
;
894 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
895 intc
= INTERRUPT_STATS_PROVIDER(obj
);
896 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
897 uint64_t *irq_counts
;
898 unsigned int nb_irqs
, i
;
899 if (k
->get_statistics
&&
900 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
902 monitor_printf(mon
, "IRQ statistics for %s:\n",
903 object_get_typename(obj
));
904 for (i
= 0; i
< nb_irqs
; i
++) {
905 if (irq_counts
[i
] > 0) {
906 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
912 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
913 object_get_typename(obj
));
920 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
922 object_child_foreach_recursive(object_get_root(),
923 hmp_info_irq_foreach
, mon
);
926 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
928 InterruptStatsProvider
*intc
;
929 InterruptStatsProviderClass
*k
;
930 Monitor
*mon
= opaque
;
932 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
933 intc
= INTERRUPT_STATS_PROVIDER(obj
);
934 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
936 k
->print_info(intc
, mon
);
938 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
939 object_get_typename(obj
));
946 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
948 object_child_foreach_recursive(object_get_root(),
949 hmp_info_pic_foreach
, mon
);
952 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
954 PciInfoList
*info_list
, *info
;
957 info_list
= qmp_query_pci(&err
);
959 monitor_printf(mon
, "PCI devices not supported\n");
964 for (info
= info_list
; info
; info
= info
->next
) {
965 PciDeviceInfoList
*dev
;
967 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
968 hmp_info_pci_device(mon
, dev
->value
);
972 qapi_free_PciInfoList(info_list
);
975 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
977 BlockJobInfoList
*list
;
980 list
= qmp_query_block_jobs(&err
);
984 monitor_printf(mon
, "No active jobs\n");
989 if (strcmp(list
->value
->type
, "stream") == 0) {
990 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
991 " of %" PRId64
" bytes, speed limit %" PRId64
998 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
999 " of %" PRId64
" bytes, speed limit %" PRId64
1002 list
->value
->device
,
1003 list
->value
->offset
,
1005 list
->value
->speed
);
1010 qapi_free_BlockJobInfoList(list
);
1013 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
1015 TPMInfoList
*info_list
, *info
;
1018 TPMPassthroughOptions
*tpo
;
1019 TPMEmulatorOptions
*teo
;
1021 info_list
= qmp_query_tpm(&err
);
1023 monitor_printf(mon
, "TPM device not supported\n");
1029 monitor_printf(mon
, "TPM device:\n");
1032 for (info
= info_list
; info
; info
= info
->next
) {
1033 TPMInfo
*ti
= info
->value
;
1034 monitor_printf(mon
, " tpm%d: model=%s\n",
1035 c
, TpmModel_str(ti
->model
));
1037 monitor_printf(mon
, " \\ %s: type=%s",
1038 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
1040 switch (ti
->options
->type
) {
1041 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
1042 tpo
= ti
->options
->u
.passthrough
.data
;
1043 monitor_printf(mon
, "%s%s%s%s",
1044 tpo
->has_path
? ",path=" : "",
1045 tpo
->has_path
? tpo
->path
: "",
1046 tpo
->has_cancel_path
? ",cancel-path=" : "",
1047 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
1049 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
1050 teo
= ti
->options
->u
.emulator
.data
;
1051 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
1053 case TPM_TYPE_OPTIONS_KIND__MAX
:
1056 monitor_printf(mon
, "\n");
1059 qapi_free_TPMInfoList(info_list
);
1062 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
1064 monitor_suspend(mon
);
1068 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
1073 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
1075 qmp_system_reset(NULL
);
1078 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
1080 qmp_system_powerdown(NULL
);
1083 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
1087 qmp_x_exit_preconfig(&err
);
1088 hmp_handle_error(mon
, &err
);
1091 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1095 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1096 use it are converted to the QAPI */
1097 cpu_index
= qdict_get_int(qdict
, "index");
1098 if (monitor_set_cpu(cpu_index
) < 0) {
1099 monitor_printf(mon
, "invalid CPU index\n");
1103 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1105 uint32_t size
= qdict_get_int(qdict
, "size");
1106 const char *filename
= qdict_get_str(qdict
, "filename");
1107 uint64_t addr
= qdict_get_int(qdict
, "val");
1109 int cpu_index
= monitor_get_cpu_index();
1111 if (cpu_index
< 0) {
1112 monitor_printf(mon
, "No CPU available\n");
1116 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1117 hmp_handle_error(mon
, &err
);
1120 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1122 uint32_t size
= qdict_get_int(qdict
, "size");
1123 const char *filename
= qdict_get_str(qdict
, "filename");
1124 uint64_t addr
= qdict_get_int(qdict
, "val");
1127 qmp_pmemsave(addr
, size
, filename
, &err
);
1128 hmp_handle_error(mon
, &err
);
1131 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1133 const char *chardev
= qdict_get_str(qdict
, "device");
1134 const char *data
= qdict_get_str(qdict
, "data");
1137 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1139 hmp_handle_error(mon
, &err
);
1142 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1144 uint32_t size
= qdict_get_int(qdict
, "size");
1145 const char *chardev
= qdict_get_str(qdict
, "device");
1150 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1152 hmp_handle_error(mon
, &err
);
1156 for (i
= 0; data
[i
]; i
++) {
1157 unsigned char ch
= data
[i
];
1160 monitor_printf(mon
, "\\\\");
1161 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1162 monitor_printf(mon
, "\\u%04X", ch
);
1164 monitor_printf(mon
, "%c", ch
);
1168 monitor_printf(mon
, "\n");
1172 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1177 hmp_handle_error(mon
, &err
);
1180 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1182 qmp_system_wakeup(NULL
);
1185 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1189 qmp_inject_nmi(&err
);
1190 hmp_handle_error(mon
, &err
);
1193 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1195 const char *name
= qdict_get_str(qdict
, "name");
1196 bool up
= qdict_get_bool(qdict
, "up");
1199 qmp_set_link(name
, up
, &err
);
1200 hmp_handle_error(mon
, &err
);
1203 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1205 const char *device
= qdict_get_str(qdict
, "device");
1206 const char *password
= qdict_get_str(qdict
, "password");
1209 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1210 hmp_handle_error(mon
, &err
);
1213 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1215 int64_t value
= qdict_get_int(qdict
, "value");
1218 qmp_balloon(value
, &err
);
1219 hmp_handle_error(mon
, &err
);
1222 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1224 const char *device
= qdict_get_str(qdict
, "device");
1225 int64_t size
= qdict_get_int(qdict
, "size");
1228 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1229 hmp_handle_error(mon
, &err
);
1232 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1234 const char *filename
= qdict_get_str(qdict
, "target");
1235 const char *format
= qdict_get_try_str(qdict
, "format");
1236 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1237 bool full
= qdict_get_try_bool(qdict
, "full", false);
1239 DriveMirror mirror
= {
1240 .device
= (char *)qdict_get_str(qdict
, "device"),
1241 .target
= (char *)filename
,
1242 .has_format
= !!format
,
1243 .format
= (char *)format
,
1244 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1246 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1251 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1252 hmp_handle_error(mon
, &err
);
1255 qmp_drive_mirror(&mirror
, &err
);
1256 hmp_handle_error(mon
, &err
);
1259 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1261 const char *device
= qdict_get_str(qdict
, "device");
1262 const char *filename
= qdict_get_str(qdict
, "target");
1263 const char *format
= qdict_get_try_str(qdict
, "format");
1264 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1265 bool full
= qdict_get_try_bool(qdict
, "full", false);
1266 bool compress
= qdict_get_try_bool(qdict
, "compress", false);
1268 DriveBackup backup
= {
1269 .device
= (char *)device
,
1270 .target
= (char *)filename
,
1271 .has_format
= !!format
,
1272 .format
= (char *)format
,
1273 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1275 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1276 .has_compress
= !!compress
,
1277 .compress
= compress
,
1281 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1282 hmp_handle_error(mon
, &err
);
1286 qmp_drive_backup(&backup
, &err
);
1287 hmp_handle_error(mon
, &err
);
1290 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1292 const char *device
= qdict_get_str(qdict
, "device");
1293 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1294 const char *format
= qdict_get_try_str(qdict
, "format");
1295 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1296 enum NewImageMode mode
;
1300 /* In the future, if 'snapshot-file' is not specified, the snapshot
1301 will be taken internally. Today it's actually required. */
1302 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1303 hmp_handle_error(mon
, &err
);
1307 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1308 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1309 filename
, false, NULL
,
1312 hmp_handle_error(mon
, &err
);
1315 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1317 const char *device
= qdict_get_str(qdict
, "device");
1318 const char *name
= qdict_get_str(qdict
, "name");
1321 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1322 hmp_handle_error(mon
, &err
);
1325 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1327 const char *device
= qdict_get_str(qdict
, "device");
1328 const char *name
= qdict_get_str(qdict
, "name");
1329 const char *id
= qdict_get_try_str(qdict
, "id");
1332 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1334 hmp_handle_error(mon
, &err
);
1337 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1339 int saved_vm_running
= runstate_is_running();
1340 const char *name
= qdict_get_str(qdict
, "name");
1343 vm_stop(RUN_STATE_RESTORE_VM
);
1345 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1348 hmp_handle_error(mon
, &err
);
1351 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1355 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1356 hmp_handle_error(mon
, &err
);
1359 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1361 BlockDriverState
*bs
;
1363 const char *name
= qdict_get_str(qdict
, "name");
1365 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1366 error_reportf_err(err
,
1367 "Error while deleting snapshot on device '%s': ",
1368 bdrv_get_device_name(bs
));
1372 void hmp_info_snapshots(Monitor
*mon
, const QDict
*qdict
)
1374 BlockDriverState
*bs
, *bs1
;
1375 BdrvNextIterator it1
;
1376 QEMUSnapshotInfo
*sn_tab
, *sn
;
1377 bool no_snapshot
= true;
1380 int *global_snapshots
;
1381 AioContext
*aio_context
;
1383 typedef struct SnapshotEntry
{
1384 QEMUSnapshotInfo sn
;
1385 QTAILQ_ENTRY(SnapshotEntry
) next
;
1388 typedef struct ImageEntry
{
1389 const char *imagename
;
1390 QTAILQ_ENTRY(ImageEntry
) next
;
1391 QTAILQ_HEAD(, SnapshotEntry
) snapshots
;
1394 QTAILQ_HEAD(, ImageEntry
) image_list
=
1395 QTAILQ_HEAD_INITIALIZER(image_list
);
1397 ImageEntry
*image_entry
, *next_ie
;
1398 SnapshotEntry
*snapshot_entry
;
1400 bs
= bdrv_all_find_vmstate_bs();
1402 monitor_printf(mon
, "No available block device supports snapshots\n");
1405 aio_context
= bdrv_get_aio_context(bs
);
1407 aio_context_acquire(aio_context
);
1408 nb_sns
= bdrv_snapshot_list(bs
, &sn_tab
);
1409 aio_context_release(aio_context
);
1412 monitor_printf(mon
, "bdrv_snapshot_list: error %d\n", nb_sns
);
1416 for (bs1
= bdrv_first(&it1
); bs1
; bs1
= bdrv_next(&it1
)) {
1420 AioContext
*ctx
= bdrv_get_aio_context(bs1
);
1422 aio_context_acquire(ctx
);
1423 if (bdrv_can_snapshot(bs1
)) {
1425 bs1_nb_sns
= bdrv_snapshot_list(bs1
, &sn
);
1426 if (bs1_nb_sns
> 0) {
1427 no_snapshot
= false;
1428 ie
= g_new0(ImageEntry
, 1);
1429 ie
->imagename
= bdrv_get_device_name(bs1
);
1430 QTAILQ_INIT(&ie
->snapshots
);
1431 QTAILQ_INSERT_TAIL(&image_list
, ie
, next
);
1432 for (i
= 0; i
< bs1_nb_sns
; i
++) {
1433 se
= g_new0(SnapshotEntry
, 1);
1435 QTAILQ_INSERT_TAIL(&ie
->snapshots
, se
, next
);
1440 aio_context_release(ctx
);
1444 monitor_printf(mon
, "There is no snapshot available.\n");
1448 global_snapshots
= g_new0(int, nb_sns
);
1450 for (i
= 0; i
< nb_sns
; i
++) {
1451 SnapshotEntry
*next_sn
;
1452 if (bdrv_all_find_snapshot(sn_tab
[i
].name
, &bs1
) == 0) {
1453 global_snapshots
[total
] = i
;
1455 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1456 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
,
1458 if (!strcmp(sn_tab
[i
].name
, snapshot_entry
->sn
.name
)) {
1459 QTAILQ_REMOVE(&image_entry
->snapshots
, snapshot_entry
,
1461 g_free(snapshot_entry
);
1468 monitor_printf(mon
, "List of snapshots present on all disks:\n");
1471 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1472 monitor_printf(mon
, "\n");
1473 for (i
= 0; i
< total
; i
++) {
1474 sn
= &sn_tab
[global_snapshots
[i
]];
1475 /* The ID is not guaranteed to be the same on all images, so
1478 pstrcpy(sn
->id_str
, sizeof(sn
->id_str
), "--");
1479 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, sn
);
1480 monitor_printf(mon
, "\n");
1483 monitor_printf(mon
, "None\n");
1486 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1487 if (QTAILQ_EMPTY(&image_entry
->snapshots
)) {
1491 "\nList of partial (non-loadable) snapshots on '%s':\n",
1492 image_entry
->imagename
);
1493 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1494 monitor_printf(mon
, "\n");
1495 QTAILQ_FOREACH(snapshot_entry
, &image_entry
->snapshots
, next
) {
1496 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
,
1497 &snapshot_entry
->sn
);
1498 monitor_printf(mon
, "\n");
1502 QTAILQ_FOREACH_SAFE(image_entry
, &image_list
, next
, next_ie
) {
1503 SnapshotEntry
*next_sn
;
1504 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
, next
,
1506 g_free(snapshot_entry
);
1508 g_free(image_entry
);
1511 g_free(global_snapshots
);
1515 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1517 qmp_migrate_cancel(NULL
);
1520 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1523 const char *state
= qdict_get_str(qdict
, "state");
1524 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1527 qmp_migrate_continue(val
, &err
);
1530 hmp_handle_error(mon
, &err
);
1533 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1536 const char *uri
= qdict_get_str(qdict
, "uri");
1538 qmp_migrate_incoming(uri
, &err
);
1540 hmp_handle_error(mon
, &err
);
1543 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1546 const char *uri
= qdict_get_str(qdict
, "uri");
1548 qmp_migrate_recover(uri
, &err
);
1550 hmp_handle_error(mon
, &err
);
1553 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1557 qmp_migrate_pause(&err
);
1559 hmp_handle_error(mon
, &err
);
1562 /* Kept for backwards compatibility */
1563 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1565 double value
= qdict_get_double(qdict
, "value");
1566 qmp_migrate_set_downtime(value
, NULL
);
1569 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1571 int64_t value
= qdict_get_int(qdict
, "value");
1574 qmp_migrate_set_cache_size(value
, &err
);
1575 hmp_handle_error(mon
, &err
);
1578 /* Kept for backwards compatibility */
1579 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1581 int64_t value
= qdict_get_int(qdict
, "value");
1582 qmp_migrate_set_speed(value
, NULL
);
1585 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1587 const char *cap
= qdict_get_str(qdict
, "capability");
1588 bool state
= qdict_get_bool(qdict
, "state");
1590 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1593 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1598 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1599 caps
->value
->capability
= val
;
1600 caps
->value
->state
= state
;
1602 qmp_migrate_set_capabilities(caps
, &err
);
1605 qapi_free_MigrationCapabilityStatusList(caps
);
1606 hmp_handle_error(mon
, &err
);
1609 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1611 const char *param
= qdict_get_str(qdict
, "parameter");
1612 const char *valuestr
= qdict_get_str(qdict
, "value");
1613 Visitor
*v
= string_input_visitor_new(valuestr
);
1614 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1615 uint64_t valuebw
= 0;
1616 uint64_t cache_size
;
1620 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1626 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1627 p
->has_compress_level
= true;
1628 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1630 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1631 p
->has_compress_threads
= true;
1632 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1634 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1635 p
->has_compress_wait_thread
= true;
1636 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1638 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1639 p
->has_decompress_threads
= true;
1640 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1642 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1643 p
->has_cpu_throttle_initial
= true;
1644 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1646 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1647 p
->has_cpu_throttle_increment
= true;
1648 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1650 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1651 p
->has_max_cpu_throttle
= true;
1652 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1654 case MIGRATION_PARAMETER_TLS_CREDS
:
1655 p
->has_tls_creds
= true;
1656 p
->tls_creds
= g_new0(StrOrNull
, 1);
1657 p
->tls_creds
->type
= QTYPE_QSTRING
;
1658 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1660 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1661 p
->has_tls_hostname
= true;
1662 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1663 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1664 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1666 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1667 p
->has_max_bandwidth
= true;
1669 * Can't use visit_type_size() here, because it
1670 * defaults to Bytes rather than Mebibytes.
1672 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1673 if (ret
< 0 || valuebw
> INT64_MAX
1674 || (size_t)valuebw
!= valuebw
) {
1675 error_setg(&err
, "Invalid size %s", valuestr
);
1678 p
->max_bandwidth
= valuebw
;
1680 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1681 p
->has_downtime_limit
= true;
1682 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1684 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1685 p
->has_x_checkpoint_delay
= true;
1686 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1688 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1689 p
->has_block_incremental
= true;
1690 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1692 case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
:
1693 p
->has_x_multifd_channels
= true;
1694 visit_type_int(v
, param
, &p
->x_multifd_channels
, &err
);
1696 case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
:
1697 p
->has_x_multifd_page_count
= true;
1698 visit_type_int(v
, param
, &p
->x_multifd_page_count
, &err
);
1700 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1701 p
->has_xbzrle_cache_size
= true;
1702 visit_type_size(v
, param
, &cache_size
, &err
);
1703 if (err
|| cache_size
> INT64_MAX
1704 || (size_t)cache_size
!= cache_size
) {
1705 error_setg(&err
, "Invalid size %s", valuestr
);
1708 p
->xbzrle_cache_size
= cache_size
;
1710 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1711 p
->has_max_postcopy_bandwidth
= true;
1712 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1722 qmp_migrate_set_parameters(p
, &err
);
1725 qapi_free_MigrateSetParameters(p
);
1727 hmp_handle_error(mon
, &err
);
1730 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1733 const char *protocol
= qdict_get_str(qdict
, "protocol");
1734 const char *hostname
= qdict_get_str(qdict
, "hostname");
1735 bool has_port
= qdict_haskey(qdict
, "port");
1736 int port
= qdict_get_try_int(qdict
, "port", -1);
1737 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1738 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1739 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1741 qmp_client_migrate_info(protocol
, hostname
,
1742 has_port
, port
, has_tls_port
, tls_port
,
1743 !!cert_subject
, cert_subject
, &err
);
1744 hmp_handle_error(mon
, &err
);
1747 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1750 qmp_migrate_start_postcopy(&err
);
1751 hmp_handle_error(mon
, &err
);
1754 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1758 qmp_x_colo_lost_heartbeat(&err
);
1759 hmp_handle_error(mon
, &err
);
1762 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1764 const char *protocol
= qdict_get_str(qdict
, "protocol");
1765 const char *password
= qdict_get_str(qdict
, "password");
1766 const char *connected
= qdict_get_try_str(qdict
, "connected");
1769 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1770 hmp_handle_error(mon
, &err
);
1773 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1775 const char *protocol
= qdict_get_str(qdict
, "protocol");
1776 const char *whenstr
= qdict_get_str(qdict
, "time");
1779 qmp_expire_password(protocol
, whenstr
, &err
);
1780 hmp_handle_error(mon
, &err
);
1783 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1785 bool force
= qdict_get_try_bool(qdict
, "force", false);
1786 const char *device
= qdict_get_str(qdict
, "device");
1789 qmp_eject(true, device
, false, NULL
, true, force
, &err
);
1790 hmp_handle_error(mon
, &err
);
1794 static void hmp_change_read_arg(void *opaque
, const char *password
,
1795 void *readline_opaque
)
1797 qmp_change_vnc_password(password
, NULL
);
1798 monitor_read_command(opaque
, 1);
1802 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1804 const char *device
= qdict_get_str(qdict
, "device");
1805 const char *target
= qdict_get_str(qdict
, "target");
1806 const char *arg
= qdict_get_try_str(qdict
, "arg");
1807 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1808 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1812 if (strcmp(device
, "vnc") == 0) {
1815 "Parameter 'read-only-mode' is invalid for VNC\n");
1818 if (strcmp(target
, "passwd") == 0 ||
1819 strcmp(target
, "password") == 0) {
1821 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1825 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1831 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1833 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1835 hmp_handle_error(mon
, &err
);
1840 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1841 !!arg
, arg
, !!read_only
, read_only_mode
,
1845 hmp_handle_error(mon
, &err
);
1848 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1851 char *device
= (char *) qdict_get_str(qdict
, "device");
1852 BlockIOThrottle throttle
= {
1853 .bps
= qdict_get_int(qdict
, "bps"),
1854 .bps_rd
= qdict_get_int(qdict
, "bps_rd"),
1855 .bps_wr
= qdict_get_int(qdict
, "bps_wr"),
1856 .iops
= qdict_get_int(qdict
, "iops"),
1857 .iops_rd
= qdict_get_int(qdict
, "iops_rd"),
1858 .iops_wr
= qdict_get_int(qdict
, "iops_wr"),
1861 /* qmp_block_set_io_throttle has separate parameters for the
1862 * (deprecated) block device name and the qdev ID but the HMP
1863 * version has only one, so we must decide which one to pass. */
1864 if (blk_by_name(device
)) {
1865 throttle
.has_device
= true;
1866 throttle
.device
= device
;
1868 throttle
.has_id
= true;
1869 throttle
.id
= device
;
1872 qmp_block_set_io_throttle(&throttle
, &err
);
1873 hmp_handle_error(mon
, &err
);
1876 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1878 Error
*error
= NULL
;
1879 const char *device
= qdict_get_str(qdict
, "device");
1880 const char *base
= qdict_get_try_str(qdict
, "base");
1881 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1883 qmp_block_stream(true, device
, device
, base
!= NULL
, base
, false, NULL
,
1884 false, NULL
, qdict_haskey(qdict
, "speed"), speed
,
1885 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1887 hmp_handle_error(mon
, &error
);
1890 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1892 Error
*error
= NULL
;
1893 const char *device
= qdict_get_str(qdict
, "device");
1894 int64_t value
= qdict_get_int(qdict
, "speed");
1896 qmp_block_job_set_speed(device
, value
, &error
);
1898 hmp_handle_error(mon
, &error
);
1901 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1903 Error
*error
= NULL
;
1904 const char *device
= qdict_get_str(qdict
, "device");
1905 bool force
= qdict_get_try_bool(qdict
, "force", false);
1907 qmp_block_job_cancel(device
, true, force
, &error
);
1909 hmp_handle_error(mon
, &error
);
1912 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1914 Error
*error
= NULL
;
1915 const char *device
= qdict_get_str(qdict
, "device");
1917 qmp_block_job_pause(device
, &error
);
1919 hmp_handle_error(mon
, &error
);
1922 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1924 Error
*error
= NULL
;
1925 const char *device
= qdict_get_str(qdict
, "device");
1927 qmp_block_job_resume(device
, &error
);
1929 hmp_handle_error(mon
, &error
);
1932 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1934 Error
*error
= NULL
;
1935 const char *device
= qdict_get_str(qdict
, "device");
1937 qmp_block_job_complete(device
, &error
);
1939 hmp_handle_error(mon
, &error
);
1942 typedef struct HMPMigrationStatus
1946 bool is_block_migration
;
1947 } HMPMigrationStatus
;
1949 static void hmp_migrate_status_cb(void *opaque
)
1951 HMPMigrationStatus
*status
= opaque
;
1952 MigrationInfo
*info
;
1954 info
= qmp_query_migrate(NULL
);
1955 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1956 info
->status
== MIGRATION_STATUS_SETUP
) {
1957 if (info
->has_disk
) {
1960 if (info
->disk
->remaining
) {
1961 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1966 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1967 monitor_flush(status
->mon
);
1970 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1972 if (status
->is_block_migration
) {
1973 monitor_printf(status
->mon
, "\n");
1975 if (info
->has_error_desc
) {
1976 error_report("%s", info
->error_desc
);
1978 monitor_resume(status
->mon
);
1979 timer_del(status
->timer
);
1983 qapi_free_MigrationInfo(info
);
1986 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1988 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1989 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1990 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1991 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1992 const char *uri
= qdict_get_str(qdict
, "uri");
1995 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1996 false, false, true, resume
, &err
);
1998 hmp_handle_error(mon
, &err
);
2003 HMPMigrationStatus
*status
;
2005 if (monitor_suspend(mon
) < 0) {
2006 monitor_printf(mon
, "terminal does not allow synchronous "
2007 "migration, continuing detached\n");
2011 status
= g_malloc0(sizeof(*status
));
2013 status
->is_block_migration
= blk
|| inc
;
2014 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
2016 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
2020 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
2024 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
2025 hmp_handle_error(mon
, &err
);
2028 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
2030 const char *id
= qdict_get_str(qdict
, "id");
2033 qmp_device_del(id
, &err
);
2034 hmp_handle_error(mon
, &err
);
2037 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
2040 bool win_dmp
= qdict_get_try_bool(qdict
, "windmp", false);
2041 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
2042 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
2043 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
2044 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
2045 const char *file
= qdict_get_str(qdict
, "filename");
2046 bool has_begin
= qdict_haskey(qdict
, "begin");
2047 bool has_length
= qdict_haskey(qdict
, "length");
2048 bool has_detach
= qdict_haskey(qdict
, "detach");
2051 bool detach
= false;
2052 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
2055 if (zlib
+ lzo
+ snappy
+ win_dmp
> 1) {
2056 error_setg(&err
, "only one of '-z|-l|-s|-w' can be set");
2057 hmp_handle_error(mon
, &err
);
2062 dump_format
= DUMP_GUEST_MEMORY_FORMAT_WIN_DMP
;
2066 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
2070 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
2074 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
2078 begin
= qdict_get_int(qdict
, "begin");
2081 length
= qdict_get_int(qdict
, "length");
2084 detach
= qdict_get_bool(qdict
, "detach");
2087 prot
= g_strconcat("file:", file
, NULL
);
2089 qmp_dump_guest_memory(paging
, prot
, true, detach
, has_begin
, begin
,
2090 has_length
, length
, true, dump_format
, &err
);
2091 hmp_handle_error(mon
, &err
);
2095 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
2100 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
2105 netdev_add(opts
, &err
);
2107 qemu_opts_del(opts
);
2111 hmp_handle_error(mon
, &err
);
2114 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
2116 const char *id
= qdict_get_str(qdict
, "id");
2119 qmp_netdev_del(id
, &err
);
2120 hmp_handle_error(mon
, &err
);
2123 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
2129 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
2131 hmp_handle_error(mon
, &err
);
2135 obj
= user_creatable_add_opts(opts
, &err
);
2136 qemu_opts_del(opts
);
2139 hmp_handle_error(mon
, &err
);
2146 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
2148 const char *fdname
= qdict_get_str(qdict
, "fdname");
2151 qmp_getfd(fdname
, &err
);
2152 hmp_handle_error(mon
, &err
);
2155 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
2157 const char *fdname
= qdict_get_str(qdict
, "fdname");
2160 qmp_closefd(fdname
, &err
);
2161 hmp_handle_error(mon
, &err
);
2164 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
2166 const char *keys
= qdict_get_str(qdict
, "keys");
2167 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
2168 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
2169 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
2171 const char *separator
;
2175 separator
= qemu_strchrnul(keys
, '-');
2176 keyname_len
= separator
- keys
;
2178 /* Be compatible with old interface, convert user inputted "<" */
2179 if (keys
[0] == '<' && keyname_len
== 1) {
2184 keylist
= g_malloc0(sizeof(*keylist
));
2185 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
2191 tmp
->next
= keylist
;
2195 if (strstart(keys
, "0x", NULL
)) {
2197 int value
= strtoul(keys
, &endp
, 0);
2198 assert(endp
<= keys
+ keyname_len
);
2199 if (endp
!= keys
+ keyname_len
) {
2202 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
2203 keylist
->value
->u
.number
.data
= value
;
2205 int idx
= index_from_key(keys
, keyname_len
);
2206 if (idx
== Q_KEY_CODE__MAX
) {
2209 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
2210 keylist
->value
->u
.qcode
.data
= idx
;
2216 keys
= separator
+ 1;
2219 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
2220 hmp_handle_error(mon
, &err
);
2223 qapi_free_KeyValueList(head
);
2227 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
2231 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
2233 const char *filename
= qdict_get_str(qdict
, "filename");
2234 const char *id
= qdict_get_try_str(qdict
, "device");
2235 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
2238 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
2239 hmp_handle_error(mon
, &err
);
2242 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
2244 const char *uri
= qdict_get_str(qdict
, "uri");
2245 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2246 bool all
= qdict_get_try_bool(qdict
, "all", false);
2247 Error
*local_err
= NULL
;
2248 BlockInfoList
*block_list
, *info
;
2249 SocketAddress
*addr
;
2251 if (writable
&& !all
) {
2252 error_setg(&local_err
, "-w only valid together with -a");
2256 /* First check if the address is valid and start the server. */
2257 addr
= socket_parse(uri
, &local_err
);
2258 if (local_err
!= NULL
) {
2262 nbd_server_start(addr
, NULL
, &local_err
);
2263 qapi_free_SocketAddress(addr
);
2264 if (local_err
!= NULL
) {
2272 /* Then try adding all block devices. If one fails, close all and
2275 block_list
= qmp_query_block(NULL
);
2277 for (info
= block_list
; info
; info
= info
->next
) {
2278 if (!info
->value
->has_inserted
) {
2282 qmp_nbd_server_add(info
->value
->device
, false, NULL
,
2283 true, writable
, &local_err
);
2285 if (local_err
!= NULL
) {
2286 qmp_nbd_server_stop(NULL
);
2291 qapi_free_BlockInfoList(block_list
);
2294 hmp_handle_error(mon
, &local_err
);
2297 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
2299 const char *device
= qdict_get_str(qdict
, "device");
2300 const char *name
= qdict_get_try_str(qdict
, "name");
2301 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2302 Error
*local_err
= NULL
;
2304 qmp_nbd_server_add(device
, !!name
, name
, true, writable
, &local_err
);
2305 hmp_handle_error(mon
, &local_err
);
2308 void hmp_nbd_server_remove(Monitor
*mon
, const QDict
*qdict
)
2310 const char *name
= qdict_get_str(qdict
, "name");
2311 bool force
= qdict_get_try_bool(qdict
, "force", false);
2314 /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
2315 qmp_nbd_server_remove(name
, force
, NBD_SERVER_REMOVE_MODE_HARD
, &err
);
2316 hmp_handle_error(mon
, &err
);
2319 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
2323 qmp_nbd_server_stop(&err
);
2324 hmp_handle_error(mon
, &err
);
2327 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
2332 cpuid
= qdict_get_int(qdict
, "id");
2333 qmp_cpu_add(cpuid
, &err
);
2334 hmp_handle_error(mon
, &err
);
2337 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
2339 const char *args
= qdict_get_str(qdict
, "args");
2343 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
2345 error_setg(&err
, "Parsing chardev args failed");
2347 qemu_chr_new_from_opts(opts
, &err
);
2348 qemu_opts_del(opts
);
2350 hmp_handle_error(mon
, &err
);
2353 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
2355 const char *args
= qdict_get_str(qdict
, "args");
2358 ChardevBackend
*backend
= NULL
;
2359 ChardevReturn
*ret
= NULL
;
2360 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
2363 error_setg(&err
, "Parsing chardev args failed");
2367 id
= qdict_get_str(qdict
, "id");
2368 if (qemu_opts_id(opts
)) {
2369 error_setg(&err
, "Unexpected 'id' parameter");
2373 backend
= qemu_chr_parse_opts(opts
, &err
);
2378 ret
= qmp_chardev_change(id
, backend
, &err
);
2381 qapi_free_ChardevReturn(ret
);
2382 qapi_free_ChardevBackend(backend
);
2383 qemu_opts_del(opts
);
2384 hmp_handle_error(mon
, &err
);
2387 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
2389 Error
*local_err
= NULL
;
2391 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
2392 hmp_handle_error(mon
, &local_err
);
2395 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
2397 Error
*local_err
= NULL
;
2399 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
2400 hmp_handle_error(mon
, &local_err
);
2403 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
2406 BlockBackend
*local_blk
= NULL
;
2407 const char* device
= qdict_get_str(qdict
, "device");
2408 const char* command
= qdict_get_str(qdict
, "command");
2412 blk
= blk_by_name(device
);
2414 BlockDriverState
*bs
= bdrv_lookup_bs(NULL
, device
, &err
);
2416 blk
= local_blk
= blk_new(0, BLK_PERM_ALL
);
2417 ret
= blk_insert_bs(blk
, bs
, &err
);
2427 * Notably absent: Proper permission management. This is sad, but it seems
2428 * almost impossible to achieve without changing the semantics and thereby
2429 * limiting the use cases of the qemu-io HMP command.
2431 * In an ideal world we would unconditionally create a new BlockBackend for
2432 * qemuio_command(), but we have commands like 'reopen' and want them to
2433 * take effect on the exact BlockBackend whose name the user passed instead
2434 * of just on a temporary copy of it.
2436 * Another problem is that deleting the temporary BlockBackend involves
2437 * draining all requests on it first, but some qemu-iotests cases want to
2438 * issue multiple aio_read/write requests and expect them to complete in
2439 * the background while the monitor has already returned.
2441 * This is also what prevents us from saving the original permissions and
2442 * restoring them later: We can't revoke permissions until all requests
2443 * have completed, and we don't know when that is nor can we really let
2444 * anything else run before we have revoken them to avoid race conditions.
2446 * What happens now is that command() in qemu-io-cmds.c can extend the
2447 * permissions if necessary for the qemu-io command. And they simply stay
2448 * extended, possibly resulting in a read-only guest device keeping write
2449 * permissions. Ugly, but it appears to be the lesser evil.
2451 qemuio_command(blk
, command
);
2454 blk_unref(local_blk
);
2455 hmp_handle_error(mon
, &err
);
2458 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
2460 const char *id
= qdict_get_str(qdict
, "id");
2463 user_creatable_del(id
, &err
);
2464 hmp_handle_error(mon
, &err
);
2467 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
2470 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
2471 MemdevList
*m
= memdev_list
;
2476 v
= string_output_visitor_new(false, &str
);
2477 visit_type_uint16List(v
, NULL
, &m
->value
->host_nodes
, NULL
);
2478 monitor_printf(mon
, "memory backend: %s\n", m
->value
->id
);
2479 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
2480 monitor_printf(mon
, " merge: %s\n",
2481 m
->value
->merge
? "true" : "false");
2482 monitor_printf(mon
, " dump: %s\n",
2483 m
->value
->dump
? "true" : "false");
2484 monitor_printf(mon
, " prealloc: %s\n",
2485 m
->value
->prealloc
? "true" : "false");
2486 monitor_printf(mon
, " policy: %s\n",
2487 HostMemPolicy_str(m
->value
->policy
));
2488 visit_complete(v
, &str
);
2489 monitor_printf(mon
, " host nodes: %s\n", str
);
2496 monitor_printf(mon
, "\n");
2498 qapi_free_MemdevList(memdev_list
);
2499 hmp_handle_error(mon
, &err
);
2502 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2505 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2506 MemoryDeviceInfoList
*info
;
2507 MemoryDeviceInfo
*value
;
2508 PCDIMMDeviceInfo
*di
;
2510 for (info
= info_list
; info
; info
= info
->next
) {
2511 value
= info
->value
;
2514 switch (value
->type
) {
2515 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2516 di
= value
->u
.dimm
.data
;
2519 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
2520 di
= value
->u
.nvdimm
.data
;
2529 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2530 MemoryDeviceInfoKind_str(value
->type
),
2531 di
->id
? di
->id
: "");
2532 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2533 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2534 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2535 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2536 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2537 monitor_printf(mon
, " hotplugged: %s\n",
2538 di
->hotplugged
? "true" : "false");
2539 monitor_printf(mon
, " hotpluggable: %s\n",
2540 di
->hotpluggable
? "true" : "false");
2545 qapi_free_MemoryDeviceInfoList(info_list
);
2546 hmp_handle_error(mon
, &err
);
2549 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2551 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2552 IOThreadInfoList
*info
;
2553 IOThreadInfo
*value
;
2555 for (info
= info_list
; info
; info
= info
->next
) {
2556 value
= info
->value
;
2557 monitor_printf(mon
, "%s:\n", value
->id
);
2558 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
2559 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
2560 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
2561 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
2564 qapi_free_IOThreadInfoList(info_list
);
2567 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2569 const char *path
= qdict_get_try_str(qdict
, "path");
2570 ObjectPropertyInfoList
*list
;
2574 monitor_printf(mon
, "/\n");
2578 list
= qmp_qom_list(path
, &err
);
2580 ObjectPropertyInfoList
*start
= list
;
2581 while (list
!= NULL
) {
2582 ObjectPropertyInfo
*value
= list
->value
;
2584 monitor_printf(mon
, "%s (%s)\n",
2585 value
->name
, value
->type
);
2588 qapi_free_ObjectPropertyInfoList(start
);
2590 hmp_handle_error(mon
, &err
);
2593 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2595 const char *path
= qdict_get_str(qdict
, "path");
2596 const char *property
= qdict_get_str(qdict
, "property");
2597 const char *value
= qdict_get_str(qdict
, "value");
2599 bool ambiguous
= false;
2602 obj
= object_resolve_path(path
, &ambiguous
);
2604 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2605 "Device '%s' not found", path
);
2608 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2610 object_property_parse(obj
, value
, property
, &err
);
2612 hmp_handle_error(mon
, &err
);
2615 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2617 const char *name
= qdict_get_str(qdict
, "name");
2618 RockerSwitch
*rocker
;
2621 rocker
= qmp_query_rocker(name
, &err
);
2623 hmp_handle_error(mon
, &err
);
2627 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2628 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2629 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2631 qapi_free_RockerSwitch(rocker
);
2634 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2636 RockerPortList
*list
, *port
;
2637 const char *name
= qdict_get_str(qdict
, "name");
2640 list
= qmp_query_rocker_ports(name
, &err
);
2642 hmp_handle_error(mon
, &err
);
2646 monitor_printf(mon
, " ena/ speed/ auto\n");
2647 monitor_printf(mon
, " port link duplex neg?\n");
2649 for (port
= list
; port
; port
= port
->next
) {
2650 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2652 port
->value
->enabled
? port
->value
->link_up
?
2653 "up" : "down" : "!ena",
2654 port
->value
->speed
== 10000 ? "10G" : "??",
2655 port
->value
->duplex
? "FD" : "HD",
2656 port
->value
->autoneg
? "Yes" : "No");
2659 qapi_free_RockerPortList(list
);
2662 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2664 RockerOfDpaFlowList
*list
, *info
;
2665 const char *name
= qdict_get_str(qdict
, "name");
2666 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2669 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2671 hmp_handle_error(mon
, &err
);
2675 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2677 for (info
= list
; info
; info
= info
->next
) {
2678 RockerOfDpaFlow
*flow
= info
->value
;
2679 RockerOfDpaFlowKey
*key
= flow
->key
;
2680 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2681 RockerOfDpaFlowAction
*action
= flow
->action
;
2684 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2685 key
->priority
, key
->tbl_id
, flow
->hits
);
2687 monitor_printf(mon
, "%-4d %-3d ",
2688 key
->priority
, key
->tbl_id
);
2691 if (key
->has_in_pport
) {
2692 monitor_printf(mon
, " pport %d", key
->in_pport
);
2693 if (mask
->has_in_pport
) {
2694 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2698 if (key
->has_vlan_id
) {
2699 monitor_printf(mon
, " vlan %d",
2700 key
->vlan_id
& VLAN_VID_MASK
);
2701 if (mask
->has_vlan_id
) {
2702 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2706 if (key
->has_tunnel_id
) {
2707 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2708 if (mask
->has_tunnel_id
) {
2709 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2713 if (key
->has_eth_type
) {
2714 switch (key
->eth_type
) {
2716 monitor_printf(mon
, " ARP");
2719 monitor_printf(mon
, " IP");
2722 monitor_printf(mon
, " IPv6");
2725 monitor_printf(mon
, " LACP");
2728 monitor_printf(mon
, " LLDP");
2731 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2736 if (key
->has_eth_src
) {
2737 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2738 (mask
->has_eth_src
) &&
2739 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2740 monitor_printf(mon
, " src <any mcast/bcast>");
2741 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2742 (mask
->has_eth_src
) &&
2743 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2744 monitor_printf(mon
, " src <any ucast>");
2746 monitor_printf(mon
, " src %s", key
->eth_src
);
2747 if (mask
->has_eth_src
) {
2748 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2753 if (key
->has_eth_dst
) {
2754 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2755 (mask
->has_eth_dst
) &&
2756 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2757 monitor_printf(mon
, " dst <any mcast/bcast>");
2758 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2759 (mask
->has_eth_dst
) &&
2760 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2761 monitor_printf(mon
, " dst <any ucast>");
2763 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2764 if (mask
->has_eth_dst
) {
2765 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2770 if (key
->has_ip_proto
) {
2771 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2772 if (mask
->has_ip_proto
) {
2773 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2777 if (key
->has_ip_tos
) {
2778 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2779 if (mask
->has_ip_tos
) {
2780 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2784 if (key
->has_ip_dst
) {
2785 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2788 if (action
->has_goto_tbl
|| action
->has_group_id
||
2789 action
->has_new_vlan_id
) {
2790 monitor_printf(mon
, " -->");
2793 if (action
->has_new_vlan_id
) {
2794 monitor_printf(mon
, " apply new vlan %d",
2795 ntohs(action
->new_vlan_id
));
2798 if (action
->has_group_id
) {
2799 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2802 if (action
->has_goto_tbl
) {
2803 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2806 monitor_printf(mon
, "\n");
2809 qapi_free_RockerOfDpaFlowList(list
);
2812 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2814 RockerOfDpaGroupList
*list
, *g
;
2815 const char *name
= qdict_get_str(qdict
, "name");
2816 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2820 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2822 hmp_handle_error(mon
, &err
);
2826 monitor_printf(mon
, "id (decode) --> buckets\n");
2828 for (g
= list
; g
; g
= g
->next
) {
2829 RockerOfDpaGroup
*group
= g
->value
;
2831 monitor_printf(mon
, "0x%08x", group
->id
);
2833 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2834 group
->type
== 1 ? "L2 rewrite" :
2835 group
->type
== 2 ? "L3 unicast" :
2836 group
->type
== 3 ? "L2 multicast" :
2837 group
->type
== 4 ? "L2 flood" :
2838 group
->type
== 5 ? "L3 interface" :
2839 group
->type
== 6 ? "L3 multicast" :
2840 group
->type
== 7 ? "L3 ECMP" :
2841 group
->type
== 8 ? "L2 overlay" :
2844 if (group
->has_vlan_id
) {
2845 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2848 if (group
->has_pport
) {
2849 monitor_printf(mon
, " pport %d", group
->pport
);
2852 if (group
->has_index
) {
2853 monitor_printf(mon
, " index %d", group
->index
);
2856 monitor_printf(mon
, ") -->");
2858 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2860 monitor_printf(mon
, " set vlan %d",
2861 group
->set_vlan_id
& VLAN_VID_MASK
);
2864 if (group
->has_set_eth_src
) {
2867 monitor_printf(mon
, " set");
2869 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2872 if (group
->has_set_eth_dst
) {
2875 monitor_printf(mon
, " set");
2877 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2882 if (group
->has_ttl_check
&& group
->ttl_check
) {
2883 monitor_printf(mon
, " check TTL");
2886 if (group
->has_group_id
&& group
->group_id
) {
2887 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2890 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2891 monitor_printf(mon
, " pop vlan");
2894 if (group
->has_out_pport
) {
2895 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2898 if (group
->has_group_ids
) {
2899 struct uint32List
*id
;
2901 monitor_printf(mon
, " groups [");
2902 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2903 monitor_printf(mon
, "0x%08x", id
->value
);
2905 monitor_printf(mon
, ",");
2908 monitor_printf(mon
, "]");
2911 monitor_printf(mon
, "\n");
2914 qapi_free_RockerOfDpaGroupList(list
);
2917 void hmp_info_dump(Monitor
*mon
, const QDict
*qdict
)
2919 DumpQueryResult
*result
= qmp_query_dump(NULL
);
2921 assert(result
&& result
->status
< DUMP_STATUS__MAX
);
2922 monitor_printf(mon
, "Status: %s\n", DumpStatus_str(result
->status
));
2924 if (result
->status
== DUMP_STATUS_ACTIVE
) {
2926 assert(result
->total
!= 0);
2927 percent
= 100.0 * result
->completed
/ result
->total
;
2928 monitor_printf(mon
, "Finished: %.2f %%\n", percent
);
2931 qapi_free_DumpQueryResult(result
);
2934 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2936 ram_block_dump(mon
);
2939 void hmp_hotpluggable_cpus(Monitor
*mon
, const QDict
*qdict
)
2942 HotpluggableCPUList
*l
= qmp_query_hotpluggable_cpus(&err
);
2943 HotpluggableCPUList
*saved
= l
;
2944 CpuInstanceProperties
*c
;
2947 hmp_handle_error(mon
, &err
);
2951 monitor_printf(mon
, "Hotpluggable CPUs:\n");
2953 monitor_printf(mon
, " type: \"%s\"\n", l
->value
->type
);
2954 monitor_printf(mon
, " vcpus_count: \"%" PRIu64
"\"\n",
2955 l
->value
->vcpus_count
);
2956 if (l
->value
->has_qom_path
) {
2957 monitor_printf(mon
, " qom_path: \"%s\"\n", l
->value
->qom_path
);
2960 c
= l
->value
->props
;
2961 monitor_printf(mon
, " CPUInstance Properties:\n");
2962 if (c
->has_node_id
) {
2963 monitor_printf(mon
, " node-id: \"%" PRIu64
"\"\n", c
->node_id
);
2965 if (c
->has_socket_id
) {
2966 monitor_printf(mon
, " socket-id: \"%" PRIu64
"\"\n", c
->socket_id
);
2968 if (c
->has_core_id
) {
2969 monitor_printf(mon
, " core-id: \"%" PRIu64
"\"\n", c
->core_id
);
2971 if (c
->has_thread_id
) {
2972 monitor_printf(mon
, " thread-id: \"%" PRIu64
"\"\n", c
->thread_id
);
2978 qapi_free_HotpluggableCPUList(saved
);
2981 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2984 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2986 monitor_printf(mon
, "%s\n", info
->guid
);
2988 hmp_handle_error(mon
, &err
);
2989 qapi_free_GuidInfo(info
);
2992 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2995 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2997 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
3000 if (info
->has_plugged_memory
) {
3001 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
3002 info
->plugged_memory
);
3005 qapi_free_MemoryInfo(info
);
3007 hmp_handle_error(mon
, &err
);