2 * Human Monitor Interface commands
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"
17 #include "monitor/hmp.h"
20 #include "chardev/char.h"
21 #include "sysemu/block-backend.h"
22 #include "sysemu/runstate.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-internal.h"
28 #include "monitor/qdev.h"
29 #include "qapi/error.h"
30 #include "qapi/clone-visitor.h"
31 #include "qapi/opts-visitor.h"
32 #include "qapi/qapi-builtin-visit.h"
33 #include "qapi/qapi-commands-block.h"
34 #include "qapi/qapi-commands-char.h"
35 #include "qapi/qapi-commands-migration.h"
36 #include "qapi/qapi-commands-misc.h"
37 #include "qapi/qapi-commands-net.h"
38 #include "qapi/qapi-commands-qdev.h"
39 #include "qapi/qapi-commands-rocker.h"
40 #include "qapi/qapi-commands-run-state.h"
41 #include "qapi/qapi-commands-tpm.h"
42 #include "qapi/qapi-commands-ui.h"
43 #include "qapi/qapi-visit-net.h"
44 #include "qapi/qmp/qdict.h"
45 #include "qapi/qmp/qerror.h"
46 #include "qapi/string-input-visitor.h"
47 #include "qapi/string-output-visitor.h"
48 #include "qom/object_interfaces.h"
49 #include "ui/console.h"
50 #include "block/nbd.h"
51 #include "block/qapi.h"
53 #include "qemu/cutils.h"
54 #include "qemu/error-report.h"
55 #include "exec/ramlist.h"
56 #include "hw/intc/intc.h"
57 #include "hw/rdma/rdma.h"
58 #include "migration/snapshot.h"
59 #include "migration/misc.h"
62 #include <spice/enums.h>
65 void hmp_handle_error(Monitor
*mon
, Error
**errp
)
69 error_reportf_err(*errp
, "Error: ");
74 * Produce a strList from a comma separated list.
75 * A NULL or empty input string return NULL.
77 static strList
*strList_from_comma_list(const char *in
)
80 strList
**hook
= &res
;
83 char *comma
= strchr(in
, ',');
84 *hook
= g_new0(strList
, 1);
87 (*hook
)->value
= g_strndup(in
, comma
- in
);
88 in
= comma
+ 1; /* skip the , */
90 (*hook
)->value
= g_strdup(in
);
93 hook
= &(*hook
)->next
;
99 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
103 info
= qmp_query_name(NULL
);
104 if (info
->has_name
) {
105 monitor_printf(mon
, "%s\n", info
->name
);
107 qapi_free_NameInfo(info
);
110 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
114 info
= qmp_query_version(NULL
);
116 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
117 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
120 qapi_free_VersionInfo(info
);
123 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
127 info
= qmp_query_kvm(NULL
);
128 monitor_printf(mon
, "kvm support: ");
130 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
132 monitor_printf(mon
, "not compiled\n");
135 qapi_free_KvmInfo(info
);
138 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
142 info
= qmp_query_status(NULL
);
144 monitor_printf(mon
, "VM status: %s%s",
145 info
->running
? "running" : "paused",
146 info
->singlestep
? " (single step mode)" : "");
148 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
149 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
152 monitor_printf(mon
, "\n");
154 qapi_free_StatusInfo(info
);
157 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
161 info
= qmp_query_uuid(NULL
);
162 monitor_printf(mon
, "%s\n", info
->UUID
);
163 qapi_free_UuidInfo(info
);
166 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
168 ChardevInfoList
*char_info
, *info
;
170 char_info
= qmp_query_chardev(NULL
);
171 for (info
= char_info
; info
; info
= info
->next
) {
172 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
173 info
->value
->filename
);
176 qapi_free_ChardevInfoList(char_info
);
179 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
181 MouseInfoList
*mice_list
, *mouse
;
183 mice_list
= qmp_query_mice(NULL
);
185 monitor_printf(mon
, "No mouse devices connected\n");
189 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
190 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
191 mouse
->value
->current
? '*' : ' ',
192 mouse
->value
->index
, mouse
->value
->name
,
193 mouse
->value
->absolute
? " (absolute)" : "");
196 qapi_free_MouseInfoList(mice_list
);
199 static char *SocketAddress_to_str(SocketAddress
*addr
)
201 switch (addr
->type
) {
202 case SOCKET_ADDRESS_TYPE_INET
:
203 return g_strdup_printf("tcp:%s:%s",
206 case SOCKET_ADDRESS_TYPE_UNIX
:
207 return g_strdup_printf("unix:%s",
208 addr
->u
.q_unix
.path
);
209 case SOCKET_ADDRESS_TYPE_FD
:
210 return g_strdup_printf("fd:%s", addr
->u
.fd
.str
);
211 case SOCKET_ADDRESS_TYPE_VSOCK
:
212 return g_strdup_printf("tcp:%s:%s",
216 return g_strdup("unknown address type");
220 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
224 info
= qmp_query_migrate(NULL
);
226 migration_global_dump(mon
);
228 if (info
->has_status
) {
229 monitor_printf(mon
, "Migration status: %s",
230 MigrationStatus_str(info
->status
));
231 if (info
->status
== MIGRATION_STATUS_FAILED
&&
232 info
->has_error_desc
) {
233 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
235 monitor_printf(mon
, "\n");
238 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
240 if (info
->has_expected_downtime
) {
241 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
242 info
->expected_downtime
);
244 if (info
->has_downtime
) {
245 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
248 if (info
->has_setup_time
) {
249 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
255 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
256 info
->ram
->transferred
>> 10);
257 monitor_printf(mon
, "throughput: %0.2f mbps\n",
259 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
260 info
->ram
->remaining
>> 10);
261 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
262 info
->ram
->total
>> 10);
263 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
264 info
->ram
->duplicate
);
265 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
267 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
269 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
270 info
->ram
->normal_bytes
>> 10);
271 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
272 info
->ram
->dirty_sync_count
);
273 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
274 info
->ram
->page_size
>> 10);
275 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
276 info
->ram
->multifd_bytes
>> 10);
277 monitor_printf(mon
, "pages-per-second: %" PRIu64
"\n",
278 info
->ram
->pages_per_second
);
280 if (info
->ram
->dirty_pages_rate
) {
281 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
282 info
->ram
->dirty_pages_rate
);
284 if (info
->ram
->postcopy_requests
) {
285 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
286 info
->ram
->postcopy_requests
);
290 if (info
->has_disk
) {
291 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
292 info
->disk
->transferred
>> 10);
293 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
294 info
->disk
->remaining
>> 10);
295 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
296 info
->disk
->total
>> 10);
299 if (info
->has_xbzrle_cache
) {
300 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
301 info
->xbzrle_cache
->cache_size
);
302 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
303 info
->xbzrle_cache
->bytes
>> 10);
304 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
305 info
->xbzrle_cache
->pages
);
306 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
307 info
->xbzrle_cache
->cache_miss
);
308 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
309 info
->xbzrle_cache
->cache_miss_rate
);
310 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
311 info
->xbzrle_cache
->overflow
);
314 if (info
->has_compression
) {
315 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
316 info
->compression
->pages
);
317 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
318 info
->compression
->busy
);
319 monitor_printf(mon
, "compression busy rate: %0.2f\n",
320 info
->compression
->busy_rate
);
321 monitor_printf(mon
, "compressed size: %" PRIu64
"\n",
322 info
->compression
->compressed_size
);
323 monitor_printf(mon
, "compression rate: %0.2f\n",
324 info
->compression
->compression_rate
);
327 if (info
->has_cpu_throttle_percentage
) {
328 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
329 info
->cpu_throttle_percentage
);
332 if (info
->has_postcopy_blocktime
) {
333 monitor_printf(mon
, "postcopy blocktime: %u\n",
334 info
->postcopy_blocktime
);
337 if (info
->has_postcopy_vcpu_blocktime
) {
340 v
= string_output_visitor_new(false, &str
);
341 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
, NULL
);
342 visit_complete(v
, &str
);
343 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
347 if (info
->has_socket_address
) {
348 SocketAddressList
*addr
;
350 monitor_printf(mon
, "socket address: [\n");
352 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
353 char *s
= SocketAddress_to_str(addr
->value
);
354 monitor_printf(mon
, "\t%s\n", s
);
357 monitor_printf(mon
, "]\n");
359 qapi_free_MigrationInfo(info
);
362 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
364 MigrationCapabilityStatusList
*caps
, *cap
;
366 caps
= qmp_query_migrate_capabilities(NULL
);
369 for (cap
= caps
; cap
; cap
= cap
->next
) {
370 monitor_printf(mon
, "%s: %s\n",
371 MigrationCapability_str(cap
->value
->capability
),
372 cap
->value
->state
? "on" : "off");
376 qapi_free_MigrationCapabilityStatusList(caps
);
379 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
381 MigrationParameters
*params
;
383 params
= qmp_query_migrate_parameters(NULL
);
386 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
387 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
388 params
->announce_initial
);
389 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
390 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
391 params
->announce_max
);
392 monitor_printf(mon
, "%s: %" PRIu64
"\n",
393 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
394 params
->announce_rounds
);
395 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
396 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
397 params
->announce_step
);
398 assert(params
->has_compress_level
);
399 monitor_printf(mon
, "%s: %u\n",
400 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
401 params
->compress_level
);
402 assert(params
->has_compress_threads
);
403 monitor_printf(mon
, "%s: %u\n",
404 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
405 params
->compress_threads
);
406 assert(params
->has_compress_wait_thread
);
407 monitor_printf(mon
, "%s: %s\n",
408 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
409 params
->compress_wait_thread
? "on" : "off");
410 assert(params
->has_decompress_threads
);
411 monitor_printf(mon
, "%s: %u\n",
412 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
413 params
->decompress_threads
);
414 assert(params
->has_cpu_throttle_initial
);
415 monitor_printf(mon
, "%s: %u\n",
416 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
417 params
->cpu_throttle_initial
);
418 assert(params
->has_cpu_throttle_increment
);
419 monitor_printf(mon
, "%s: %u\n",
420 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
421 params
->cpu_throttle_increment
);
422 assert(params
->has_max_cpu_throttle
);
423 monitor_printf(mon
, "%s: %u\n",
424 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
425 params
->max_cpu_throttle
);
426 assert(params
->has_tls_creds
);
427 monitor_printf(mon
, "%s: '%s'\n",
428 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
430 assert(params
->has_tls_hostname
);
431 monitor_printf(mon
, "%s: '%s'\n",
432 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
433 params
->tls_hostname
);
434 assert(params
->has_max_bandwidth
);
435 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
436 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
437 params
->max_bandwidth
);
438 assert(params
->has_downtime_limit
);
439 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
440 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
441 params
->downtime_limit
);
442 assert(params
->has_x_checkpoint_delay
);
443 monitor_printf(mon
, "%s: %u\n",
444 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
445 params
->x_checkpoint_delay
);
446 assert(params
->has_block_incremental
);
447 monitor_printf(mon
, "%s: %s\n",
448 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
449 params
->block_incremental
? "on" : "off");
450 monitor_printf(mon
, "%s: %u\n",
451 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS
),
452 params
->multifd_channels
);
453 monitor_printf(mon
, "%s: %" PRIu64
"\n",
454 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
455 params
->xbzrle_cache_size
);
456 monitor_printf(mon
, "%s: %" PRIu64
"\n",
457 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
458 params
->max_postcopy_bandwidth
);
459 monitor_printf(mon
, " %s: '%s'\n",
460 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
461 params
->has_tls_authz
? params
->tls_authz
: "");
464 qapi_free_MigrationParameters(params
);
467 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
469 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
470 qmp_query_migrate_cache_size(NULL
) >> 10);
473 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
474 BlockDeviceInfo
*inserted
, bool verbose
)
476 ImageInfo
*image_info
;
478 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
480 if (info
&& *info
->device
) {
481 monitor_printf(mon
, "%s", info
->device
);
482 if (inserted
&& inserted
->has_node_name
) {
483 monitor_printf(mon
, " (%s)", inserted
->node_name
);
486 assert(info
|| inserted
);
487 monitor_printf(mon
, "%s",
488 inserted
&& inserted
->has_node_name
? inserted
->node_name
489 : info
&& info
->has_qdev
? info
->qdev
494 monitor_printf(mon
, ": %s (%s%s%s)\n",
497 inserted
->ro
? ", read-only" : "",
498 inserted
->encrypted
? ", encrypted" : "");
500 monitor_printf(mon
, ": [not inserted]\n");
504 if (info
->has_qdev
) {
505 monitor_printf(mon
, " Attached to: %s\n", info
->qdev
);
507 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
508 monitor_printf(mon
, " I/O status: %s\n",
509 BlockDeviceIoStatus_str(info
->io_status
));
512 if (info
->removable
) {
513 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
514 info
->locked
? "" : "not ",
515 info
->tray_open
? "open" : "closed");
524 monitor_printf(mon
, " Cache mode: %s%s%s\n",
525 inserted
->cache
->writeback
? "writeback" : "writethrough",
526 inserted
->cache
->direct
? ", direct" : "",
527 inserted
->cache
->no_flush
? ", ignore flushes" : "");
529 if (inserted
->has_backing_file
) {
532 "(chain depth: %" PRId64
")\n",
533 inserted
->backing_file
,
534 inserted
->backing_file_depth
);
537 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
538 monitor_printf(mon
, " Detect zeroes: %s\n",
539 BlockdevDetectZeroesOptions_str(inserted
->detect_zeroes
));
542 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
543 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
545 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
546 " bps_rd=%" PRId64
" bps_wr=%" PRId64
548 " bps_rd_max=%" PRId64
549 " bps_wr_max=%" PRId64
550 " iops=%" PRId64
" iops_rd=%" PRId64
553 " iops_rd_max=%" PRId64
554 " iops_wr_max=%" PRId64
555 " iops_size=%" PRId64
561 inserted
->bps_rd_max
,
562 inserted
->bps_wr_max
,
567 inserted
->iops_rd_max
,
568 inserted
->iops_wr_max
,
574 monitor_printf(mon
, "\nImages:\n");
575 image_info
= inserted
->image
;
577 bdrv_image_info_dump(image_info
);
578 if (image_info
->has_backing_image
) {
579 image_info
= image_info
->backing_image
;
587 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
589 BlockInfoList
*block_list
, *info
;
590 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
591 const char *device
= qdict_get_try_str(qdict
, "device");
592 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
593 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
594 bool printed
= false;
596 /* Print BlockBackend information */
598 block_list
= qmp_query_block(NULL
);
603 for (info
= block_list
; info
; info
= info
->next
) {
604 if (device
&& strcmp(device
, info
->value
->device
)) {
608 if (info
!= block_list
) {
609 monitor_printf(mon
, "\n");
612 print_block_info(mon
, info
->value
, info
->value
->has_inserted
613 ? info
->value
->inserted
: NULL
,
618 qapi_free_BlockInfoList(block_list
);
620 if ((!device
&& !nodes
) || printed
) {
624 /* Print node information */
625 blockdev_list
= qmp_query_named_block_nodes(NULL
);
626 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
627 assert(blockdev
->value
->has_node_name
);
628 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
632 if (blockdev
!= blockdev_list
) {
633 monitor_printf(mon
, "\n");
636 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
638 qapi_free_BlockDeviceInfoList(blockdev_list
);
641 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
643 BlockStatsList
*stats_list
, *stats
;
645 stats_list
= qmp_query_blockstats(false, false, NULL
);
647 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
648 if (!stats
->value
->has_device
) {
652 monitor_printf(mon
, "%s:", stats
->value
->device
);
653 monitor_printf(mon
, " rd_bytes=%" PRId64
655 " rd_operations=%" PRId64
656 " wr_operations=%" PRId64
657 " flush_operations=%" PRId64
658 " wr_total_time_ns=%" PRId64
659 " rd_total_time_ns=%" PRId64
660 " flush_total_time_ns=%" PRId64
661 " rd_merged=%" PRId64
662 " wr_merged=%" PRId64
663 " idle_time_ns=%" PRId64
665 stats
->value
->stats
->rd_bytes
,
666 stats
->value
->stats
->wr_bytes
,
667 stats
->value
->stats
->rd_operations
,
668 stats
->value
->stats
->wr_operations
,
669 stats
->value
->stats
->flush_operations
,
670 stats
->value
->stats
->wr_total_time_ns
,
671 stats
->value
->stats
->rd_total_time_ns
,
672 stats
->value
->stats
->flush_total_time_ns
,
673 stats
->value
->stats
->rd_merged
,
674 stats
->value
->stats
->wr_merged
,
675 stats
->value
->stats
->idle_time_ns
);
678 qapi_free_BlockStatsList(stats_list
);
682 /* Helper for hmp_info_vnc_clients, _servers */
683 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
686 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
690 NetworkAddressFamily_str(info
->family
),
691 info
->websocket
? " (Websocket)" : "");
694 /* Helper displaying and auth and crypt info */
695 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
697 VncVencryptSubAuth
*vencrypt
)
699 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
700 VncPrimaryAuth_str(auth
),
701 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
704 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
707 VncClientInfo
*cinfo
= client
->value
;
709 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
710 monitor_printf(mon
, " x509_dname: %s\n",
711 cinfo
->has_x509_dname
?
712 cinfo
->x509_dname
: "none");
713 monitor_printf(mon
, " sasl_username: %s\n",
714 cinfo
->has_sasl_username
?
715 cinfo
->sasl_username
: "none");
717 client
= client
->next
;
721 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
724 VncServerInfo2
*sinfo
= server
->value
;
725 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
726 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
727 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
728 server
= server
->next
;
732 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
734 VncInfo2List
*info2l
;
737 info2l
= qmp_query_vnc_servers(&err
);
739 hmp_handle_error(mon
, &err
);
743 monitor_printf(mon
, "None\n");
748 VncInfo2
*info
= info2l
->value
;
749 monitor_printf(mon
, "%s:\n", info
->id
);
750 hmp_info_vnc_servers(mon
, info
->server
);
751 hmp_info_vnc_clients(mon
, info
->clients
);
753 /* The server entry displays its auth, we only
754 * need to display in the case of 'reverse' connections
755 * where there's no server.
757 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
758 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
760 if (info
->has_display
) {
761 monitor_printf(mon
, " Display: %s\n", info
->display
);
763 info2l
= info2l
->next
;
766 qapi_free_VncInfo2List(info2l
);
772 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
774 SpiceChannelList
*chan
;
776 const char *channel_name
;
777 const char * const channel_names
[] = {
778 [SPICE_CHANNEL_MAIN
] = "main",
779 [SPICE_CHANNEL_DISPLAY
] = "display",
780 [SPICE_CHANNEL_INPUTS
] = "inputs",
781 [SPICE_CHANNEL_CURSOR
] = "cursor",
782 [SPICE_CHANNEL_PLAYBACK
] = "playback",
783 [SPICE_CHANNEL_RECORD
] = "record",
784 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
785 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
786 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
787 [SPICE_CHANNEL_PORT
] = "port",
789 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
790 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
791 * as quick fix for build failures with older versions. */
792 [SPICE_CHANNEL_WEBDAV
] = "webdav",
796 info
= qmp_query_spice(NULL
);
798 if (!info
->enabled
) {
799 monitor_printf(mon
, "Server: disabled\n");
803 monitor_printf(mon
, "Server:\n");
804 if (info
->has_port
) {
805 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
806 info
->host
, info
->port
);
808 if (info
->has_tls_port
) {
809 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
810 info
->host
, info
->tls_port
);
812 monitor_printf(mon
, " migrated: %s\n",
813 info
->migrated
? "true" : "false");
814 monitor_printf(mon
, " auth: %s\n", info
->auth
);
815 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
816 monitor_printf(mon
, " mouse-mode: %s\n",
817 SpiceQueryMouseMode_str(info
->mouse_mode
));
819 if (!info
->has_channels
|| info
->channels
== NULL
) {
820 monitor_printf(mon
, "Channels: none\n");
822 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
823 monitor_printf(mon
, "Channel:\n");
824 monitor_printf(mon
, " address: %s:%s%s\n",
825 chan
->value
->host
, chan
->value
->port
,
826 chan
->value
->tls
? " [tls]" : "");
827 monitor_printf(mon
, " session: %" PRId64
"\n",
828 chan
->value
->connection_id
);
829 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
830 chan
->value
->channel_type
, chan
->value
->channel_id
);
832 channel_name
= "unknown";
833 if (chan
->value
->channel_type
> 0 &&
834 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
835 channel_names
[chan
->value
->channel_type
]) {
836 channel_name
= channel_names
[chan
->value
->channel_type
];
839 monitor_printf(mon
, " channel name: %s\n", channel_name
);
844 qapi_free_SpiceInfo(info
);
848 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
853 info
= qmp_query_balloon(&err
);
855 hmp_handle_error(mon
, &err
);
859 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
861 qapi_free_BalloonInfo(info
);
864 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
866 PciMemoryRegionList
*region
;
868 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
869 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
870 dev
->slot
, dev
->function
);
871 monitor_printf(mon
, " ");
873 if (dev
->class_info
->has_desc
) {
874 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
876 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
879 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
880 dev
->id
->vendor
, dev
->id
->device
);
881 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
882 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
883 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
887 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
890 if (dev
->has_pci_bridge
) {
891 monitor_printf(mon
, " BUS %" PRId64
".\n",
892 dev
->pci_bridge
->bus
->number
);
893 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
894 dev
->pci_bridge
->bus
->secondary
);
895 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
896 dev
->pci_bridge
->bus
->subordinate
);
898 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
899 dev
->pci_bridge
->bus
->io_range
->base
,
900 dev
->pci_bridge
->bus
->io_range
->limit
);
903 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
904 dev
->pci_bridge
->bus
->memory_range
->base
,
905 dev
->pci_bridge
->bus
->memory_range
->limit
);
907 monitor_printf(mon
, " prefetchable memory range "
908 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
909 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
910 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
913 for (region
= dev
->regions
; region
; region
= region
->next
) {
916 addr
= region
->value
->address
;
917 size
= region
->value
->size
;
919 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
921 if (!strcmp(region
->value
->type
, "io")) {
922 monitor_printf(mon
, "I/O at 0x%04" PRIx64
923 " [0x%04" PRIx64
"].\n",
924 addr
, addr
+ size
- 1);
926 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
927 " [0x%08" PRIx64
"].\n",
928 region
->value
->mem_type_64
? 64 : 32,
929 region
->value
->prefetch
? " prefetchable" : "",
930 addr
, addr
+ size
- 1);
934 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
936 if (dev
->has_pci_bridge
) {
937 if (dev
->pci_bridge
->has_devices
) {
938 PciDeviceInfoList
*cdev
;
939 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
940 hmp_info_pci_device(mon
, cdev
->value
);
946 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
948 InterruptStatsProvider
*intc
;
949 InterruptStatsProviderClass
*k
;
950 Monitor
*mon
= opaque
;
952 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
953 intc
= INTERRUPT_STATS_PROVIDER(obj
);
954 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
955 uint64_t *irq_counts
;
956 unsigned int nb_irqs
, i
;
957 if (k
->get_statistics
&&
958 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
960 monitor_printf(mon
, "IRQ statistics for %s:\n",
961 object_get_typename(obj
));
962 for (i
= 0; i
< nb_irqs
; i
++) {
963 if (irq_counts
[i
] > 0) {
964 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
970 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
971 object_get_typename(obj
));
978 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
980 object_child_foreach_recursive(object_get_root(),
981 hmp_info_irq_foreach
, mon
);
984 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
986 InterruptStatsProvider
*intc
;
987 InterruptStatsProviderClass
*k
;
988 Monitor
*mon
= opaque
;
990 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
991 intc
= INTERRUPT_STATS_PROVIDER(obj
);
992 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
994 k
->print_info(intc
, mon
);
996 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
997 object_get_typename(obj
));
1004 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
1006 object_child_foreach_recursive(object_get_root(),
1007 hmp_info_pic_foreach
, mon
);
1010 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
1013 RdmaProviderClass
*k
;
1014 Monitor
*mon
= opaque
;
1016 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
1017 rdma
= RDMA_PROVIDER(obj
);
1018 k
= RDMA_PROVIDER_GET_CLASS(obj
);
1019 if (k
->print_statistics
) {
1020 k
->print_statistics(mon
, rdma
);
1022 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
1023 object_get_typename(obj
));
1030 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
1032 object_child_foreach_recursive(object_get_root(),
1033 hmp_info_rdma_foreach
, mon
);
1036 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
1038 PciInfoList
*info_list
, *info
;
1041 info_list
= qmp_query_pci(&err
);
1043 monitor_printf(mon
, "PCI devices not supported\n");
1048 for (info
= info_list
; info
; info
= info
->next
) {
1049 PciDeviceInfoList
*dev
;
1051 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
1052 hmp_info_pci_device(mon
, dev
->value
);
1056 qapi_free_PciInfoList(info_list
);
1059 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
1061 BlockJobInfoList
*list
;
1064 list
= qmp_query_block_jobs(&err
);
1068 monitor_printf(mon
, "No active jobs\n");
1073 if (strcmp(list
->value
->type
, "stream") == 0) {
1074 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
1075 " of %" PRId64
" bytes, speed limit %" PRId64
1077 list
->value
->device
,
1078 list
->value
->offset
,
1080 list
->value
->speed
);
1082 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
1083 " of %" PRId64
" bytes, speed limit %" PRId64
1086 list
->value
->device
,
1087 list
->value
->offset
,
1089 list
->value
->speed
);
1094 qapi_free_BlockJobInfoList(list
);
1097 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
1099 TPMInfoList
*info_list
, *info
;
1102 TPMPassthroughOptions
*tpo
;
1103 TPMEmulatorOptions
*teo
;
1105 info_list
= qmp_query_tpm(&err
);
1107 monitor_printf(mon
, "TPM device not supported\n");
1113 monitor_printf(mon
, "TPM device:\n");
1116 for (info
= info_list
; info
; info
= info
->next
) {
1117 TPMInfo
*ti
= info
->value
;
1118 monitor_printf(mon
, " tpm%d: model=%s\n",
1119 c
, TpmModel_str(ti
->model
));
1121 monitor_printf(mon
, " \\ %s: type=%s",
1122 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
1124 switch (ti
->options
->type
) {
1125 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
1126 tpo
= ti
->options
->u
.passthrough
.data
;
1127 monitor_printf(mon
, "%s%s%s%s",
1128 tpo
->has_path
? ",path=" : "",
1129 tpo
->has_path
? tpo
->path
: "",
1130 tpo
->has_cancel_path
? ",cancel-path=" : "",
1131 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
1133 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
1134 teo
= ti
->options
->u
.emulator
.data
;
1135 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
1137 case TPM_TYPE_OPTIONS_KIND__MAX
:
1140 monitor_printf(mon
, "\n");
1143 qapi_free_TPMInfoList(info_list
);
1146 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
1148 monitor_suspend(mon
);
1152 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
1157 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
1159 const char *op
= qdict_get_try_str(qdict
, "op");
1162 bool on
= qsp_is_enabled();
1164 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
1167 if (!strcmp(op
, "on")) {
1169 } else if (!strcmp(op
, "off")) {
1171 } else if (!strcmp(op
, "reset")) {
1176 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
1177 hmp_handle_error(mon
, &err
);
1181 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
1183 qmp_system_reset(NULL
);
1186 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
1188 qmp_system_powerdown(NULL
);
1191 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
1195 qmp_x_exit_preconfig(&err
);
1196 hmp_handle_error(mon
, &err
);
1199 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1203 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1204 use it are converted to the QAPI */
1205 cpu_index
= qdict_get_int(qdict
, "index");
1206 if (monitor_set_cpu(cpu_index
) < 0) {
1207 monitor_printf(mon
, "invalid CPU index\n");
1211 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1213 uint32_t size
= qdict_get_int(qdict
, "size");
1214 const char *filename
= qdict_get_str(qdict
, "filename");
1215 uint64_t addr
= qdict_get_int(qdict
, "val");
1217 int cpu_index
= monitor_get_cpu_index();
1219 if (cpu_index
< 0) {
1220 monitor_printf(mon
, "No CPU available\n");
1224 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1225 hmp_handle_error(mon
, &err
);
1228 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1230 uint32_t size
= qdict_get_int(qdict
, "size");
1231 const char *filename
= qdict_get_str(qdict
, "filename");
1232 uint64_t addr
= qdict_get_int(qdict
, "val");
1235 qmp_pmemsave(addr
, size
, filename
, &err
);
1236 hmp_handle_error(mon
, &err
);
1239 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1241 const char *chardev
= qdict_get_str(qdict
, "device");
1242 const char *data
= qdict_get_str(qdict
, "data");
1245 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1247 hmp_handle_error(mon
, &err
);
1250 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1252 uint32_t size
= qdict_get_int(qdict
, "size");
1253 const char *chardev
= qdict_get_str(qdict
, "device");
1258 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1260 hmp_handle_error(mon
, &err
);
1264 for (i
= 0; data
[i
]; i
++) {
1265 unsigned char ch
= data
[i
];
1268 monitor_printf(mon
, "\\\\");
1269 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1270 monitor_printf(mon
, "\\u%04X", ch
);
1272 monitor_printf(mon
, "%c", ch
);
1276 monitor_printf(mon
, "\n");
1280 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1285 hmp_handle_error(mon
, &err
);
1288 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1292 qmp_system_wakeup(&err
);
1293 hmp_handle_error(mon
, &err
);
1296 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1300 qmp_inject_nmi(&err
);
1301 hmp_handle_error(mon
, &err
);
1304 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1306 const char *name
= qdict_get_str(qdict
, "name");
1307 bool up
= qdict_get_bool(qdict
, "up");
1310 qmp_set_link(name
, up
, &err
);
1311 hmp_handle_error(mon
, &err
);
1314 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1316 const char *device
= qdict_get_str(qdict
, "device");
1317 const char *password
= qdict_get_str(qdict
, "password");
1320 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1321 hmp_handle_error(mon
, &err
);
1324 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1326 int64_t value
= qdict_get_int(qdict
, "value");
1329 qmp_balloon(value
, &err
);
1330 hmp_handle_error(mon
, &err
);
1333 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1335 const char *device
= qdict_get_str(qdict
, "device");
1336 int64_t size
= qdict_get_int(qdict
, "size");
1339 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1340 hmp_handle_error(mon
, &err
);
1343 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1345 const char *filename
= qdict_get_str(qdict
, "target");
1346 const char *format
= qdict_get_try_str(qdict
, "format");
1347 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1348 bool full
= qdict_get_try_bool(qdict
, "full", false);
1350 DriveMirror mirror
= {
1351 .device
= (char *)qdict_get_str(qdict
, "device"),
1352 .target
= (char *)filename
,
1353 .has_format
= !!format
,
1354 .format
= (char *)format
,
1355 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1357 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1362 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1363 hmp_handle_error(mon
, &err
);
1366 qmp_drive_mirror(&mirror
, &err
);
1367 hmp_handle_error(mon
, &err
);
1370 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1372 const char *device
= qdict_get_str(qdict
, "device");
1373 const char *filename
= qdict_get_str(qdict
, "target");
1374 const char *format
= qdict_get_try_str(qdict
, "format");
1375 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1376 bool full
= qdict_get_try_bool(qdict
, "full", false);
1377 bool compress
= qdict_get_try_bool(qdict
, "compress", false);
1379 DriveBackup backup
= {
1380 .device
= (char *)device
,
1381 .target
= (char *)filename
,
1382 .has_format
= !!format
,
1383 .format
= (char *)format
,
1384 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1386 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1387 .has_compress
= !!compress
,
1388 .compress
= compress
,
1392 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1393 hmp_handle_error(mon
, &err
);
1397 qmp_drive_backup(&backup
, &err
);
1398 hmp_handle_error(mon
, &err
);
1401 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1403 const char *device
= qdict_get_str(qdict
, "device");
1404 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1405 const char *format
= qdict_get_try_str(qdict
, "format");
1406 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1407 enum NewImageMode mode
;
1411 /* In the future, if 'snapshot-file' is not specified, the snapshot
1412 will be taken internally. Today it's actually required. */
1413 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1414 hmp_handle_error(mon
, &err
);
1418 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1419 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1420 filename
, false, NULL
,
1423 hmp_handle_error(mon
, &err
);
1426 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1428 const char *device
= qdict_get_str(qdict
, "device");
1429 const char *name
= qdict_get_str(qdict
, "name");
1432 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1433 hmp_handle_error(mon
, &err
);
1436 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1438 const char *device
= qdict_get_str(qdict
, "device");
1439 const char *name
= qdict_get_str(qdict
, "name");
1440 const char *id
= qdict_get_try_str(qdict
, "id");
1443 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1445 hmp_handle_error(mon
, &err
);
1448 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1450 int saved_vm_running
= runstate_is_running();
1451 const char *name
= qdict_get_str(qdict
, "name");
1454 vm_stop(RUN_STATE_RESTORE_VM
);
1456 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1459 hmp_handle_error(mon
, &err
);
1462 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1466 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1467 hmp_handle_error(mon
, &err
);
1470 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1472 BlockDriverState
*bs
;
1474 const char *name
= qdict_get_str(qdict
, "name");
1476 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1478 "deleting snapshot on device '%s': ",
1479 bdrv_get_device_name(bs
));
1481 hmp_handle_error(mon
, &err
);
1484 void hmp_info_snapshots(Monitor
*mon
, const QDict
*qdict
)
1486 BlockDriverState
*bs
, *bs1
;
1487 BdrvNextIterator it1
;
1488 QEMUSnapshotInfo
*sn_tab
, *sn
;
1489 bool no_snapshot
= true;
1492 int *global_snapshots
;
1493 AioContext
*aio_context
;
1495 typedef struct SnapshotEntry
{
1496 QEMUSnapshotInfo sn
;
1497 QTAILQ_ENTRY(SnapshotEntry
) next
;
1500 typedef struct ImageEntry
{
1501 const char *imagename
;
1502 QTAILQ_ENTRY(ImageEntry
) next
;
1503 QTAILQ_HEAD(, SnapshotEntry
) snapshots
;
1506 QTAILQ_HEAD(, ImageEntry
) image_list
=
1507 QTAILQ_HEAD_INITIALIZER(image_list
);
1509 ImageEntry
*image_entry
, *next_ie
;
1510 SnapshotEntry
*snapshot_entry
;
1512 bs
= bdrv_all_find_vmstate_bs();
1514 monitor_printf(mon
, "No available block device supports snapshots\n");
1517 aio_context
= bdrv_get_aio_context(bs
);
1519 aio_context_acquire(aio_context
);
1520 nb_sns
= bdrv_snapshot_list(bs
, &sn_tab
);
1521 aio_context_release(aio_context
);
1524 monitor_printf(mon
, "bdrv_snapshot_list: error %d\n", nb_sns
);
1528 for (bs1
= bdrv_first(&it1
); bs1
; bs1
= bdrv_next(&it1
)) {
1532 AioContext
*ctx
= bdrv_get_aio_context(bs1
);
1534 aio_context_acquire(ctx
);
1535 if (bdrv_can_snapshot(bs1
)) {
1537 bs1_nb_sns
= bdrv_snapshot_list(bs1
, &sn
);
1538 if (bs1_nb_sns
> 0) {
1539 no_snapshot
= false;
1540 ie
= g_new0(ImageEntry
, 1);
1541 ie
->imagename
= bdrv_get_device_name(bs1
);
1542 QTAILQ_INIT(&ie
->snapshots
);
1543 QTAILQ_INSERT_TAIL(&image_list
, ie
, next
);
1544 for (i
= 0; i
< bs1_nb_sns
; i
++) {
1545 se
= g_new0(SnapshotEntry
, 1);
1547 QTAILQ_INSERT_TAIL(&ie
->snapshots
, se
, next
);
1552 aio_context_release(ctx
);
1556 monitor_printf(mon
, "There is no snapshot available.\n");
1560 global_snapshots
= g_new0(int, nb_sns
);
1562 for (i
= 0; i
< nb_sns
; i
++) {
1563 SnapshotEntry
*next_sn
;
1564 if (bdrv_all_find_snapshot(sn_tab
[i
].name
, &bs1
) == 0) {
1565 global_snapshots
[total
] = i
;
1567 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1568 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
,
1570 if (!strcmp(sn_tab
[i
].name
, snapshot_entry
->sn
.name
)) {
1571 QTAILQ_REMOVE(&image_entry
->snapshots
, snapshot_entry
,
1573 g_free(snapshot_entry
);
1580 monitor_printf(mon
, "List of snapshots present on all disks:\n");
1583 bdrv_snapshot_dump(NULL
);
1584 monitor_printf(mon
, "\n");
1585 for (i
= 0; i
< total
; i
++) {
1586 sn
= &sn_tab
[global_snapshots
[i
]];
1587 /* The ID is not guaranteed to be the same on all images, so
1590 pstrcpy(sn
->id_str
, sizeof(sn
->id_str
), "--");
1591 bdrv_snapshot_dump(sn
);
1592 monitor_printf(mon
, "\n");
1595 monitor_printf(mon
, "None\n");
1598 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1599 if (QTAILQ_EMPTY(&image_entry
->snapshots
)) {
1603 "\nList of partial (non-loadable) snapshots on '%s':\n",
1604 image_entry
->imagename
);
1605 bdrv_snapshot_dump(NULL
);
1606 monitor_printf(mon
, "\n");
1607 QTAILQ_FOREACH(snapshot_entry
, &image_entry
->snapshots
, next
) {
1608 bdrv_snapshot_dump(&snapshot_entry
->sn
);
1609 monitor_printf(mon
, "\n");
1613 QTAILQ_FOREACH_SAFE(image_entry
, &image_list
, next
, next_ie
) {
1614 SnapshotEntry
*next_sn
;
1615 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
, next
,
1617 g_free(snapshot_entry
);
1619 g_free(image_entry
);
1622 g_free(global_snapshots
);
1626 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1628 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1629 const char *id
= qdict_get_try_str(qdict
, "id");
1630 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1631 migrate_announce_params());
1633 qapi_free_strList(params
->interfaces
);
1634 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1635 params
->has_interfaces
= params
->interfaces
!= NULL
;
1636 params
->id
= g_strdup(id
);
1637 params
->has_id
= !!params
->id
;
1638 qmp_announce_self(params
, NULL
);
1639 qapi_free_AnnounceParameters(params
);
1642 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1644 qmp_migrate_cancel(NULL
);
1647 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1650 const char *state
= qdict_get_str(qdict
, "state");
1651 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1654 qmp_migrate_continue(val
, &err
);
1657 hmp_handle_error(mon
, &err
);
1660 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1663 const char *uri
= qdict_get_str(qdict
, "uri");
1665 qmp_migrate_incoming(uri
, &err
);
1667 hmp_handle_error(mon
, &err
);
1670 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1673 const char *uri
= qdict_get_str(qdict
, "uri");
1675 qmp_migrate_recover(uri
, &err
);
1677 hmp_handle_error(mon
, &err
);
1680 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1684 qmp_migrate_pause(&err
);
1686 hmp_handle_error(mon
, &err
);
1689 /* Kept for backwards compatibility */
1690 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1692 double value
= qdict_get_double(qdict
, "value");
1693 qmp_migrate_set_downtime(value
, NULL
);
1696 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1698 int64_t value
= qdict_get_int(qdict
, "value");
1701 qmp_migrate_set_cache_size(value
, &err
);
1702 hmp_handle_error(mon
, &err
);
1705 /* Kept for backwards compatibility */
1706 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1708 int64_t value
= qdict_get_int(qdict
, "value");
1709 qmp_migrate_set_speed(value
, NULL
);
1712 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1714 const char *cap
= qdict_get_str(qdict
, "capability");
1715 bool state
= qdict_get_bool(qdict
, "state");
1717 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1720 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1725 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1726 caps
->value
->capability
= val
;
1727 caps
->value
->state
= state
;
1729 qmp_migrate_set_capabilities(caps
, &err
);
1732 qapi_free_MigrationCapabilityStatusList(caps
);
1733 hmp_handle_error(mon
, &err
);
1736 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1738 const char *param
= qdict_get_str(qdict
, "parameter");
1739 const char *valuestr
= qdict_get_str(qdict
, "value");
1740 Visitor
*v
= string_input_visitor_new(valuestr
);
1741 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1742 uint64_t valuebw
= 0;
1743 uint64_t cache_size
;
1747 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1753 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1754 p
->has_compress_level
= true;
1755 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1757 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1758 p
->has_compress_threads
= true;
1759 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1761 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1762 p
->has_compress_wait_thread
= true;
1763 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1765 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1766 p
->has_decompress_threads
= true;
1767 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1769 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1770 p
->has_cpu_throttle_initial
= true;
1771 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1773 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1774 p
->has_cpu_throttle_increment
= true;
1775 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1777 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1778 p
->has_max_cpu_throttle
= true;
1779 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1781 case MIGRATION_PARAMETER_TLS_CREDS
:
1782 p
->has_tls_creds
= true;
1783 p
->tls_creds
= g_new0(StrOrNull
, 1);
1784 p
->tls_creds
->type
= QTYPE_QSTRING
;
1785 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1787 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1788 p
->has_tls_hostname
= true;
1789 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1790 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1791 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1793 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1794 p
->has_tls_authz
= true;
1795 p
->tls_authz
= g_new0(StrOrNull
, 1);
1796 p
->tls_authz
->type
= QTYPE_QSTRING
;
1797 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1799 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1800 p
->has_max_bandwidth
= true;
1802 * Can't use visit_type_size() here, because it
1803 * defaults to Bytes rather than Mebibytes.
1805 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1806 if (ret
< 0 || valuebw
> INT64_MAX
1807 || (size_t)valuebw
!= valuebw
) {
1808 error_setg(&err
, "Invalid size %s", valuestr
);
1811 p
->max_bandwidth
= valuebw
;
1813 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1814 p
->has_downtime_limit
= true;
1815 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1817 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1818 p
->has_x_checkpoint_delay
= true;
1819 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1821 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1822 p
->has_block_incremental
= true;
1823 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1825 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1826 p
->has_multifd_channels
= true;
1827 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1829 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1830 p
->has_xbzrle_cache_size
= true;
1831 visit_type_size(v
, param
, &cache_size
, &err
);
1835 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1836 error_setg(&err
, "Invalid size %s", valuestr
);
1839 p
->xbzrle_cache_size
= cache_size
;
1841 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1842 p
->has_max_postcopy_bandwidth
= true;
1843 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1845 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1846 p
->has_announce_initial
= true;
1847 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1849 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1850 p
->has_announce_max
= true;
1851 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1853 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1854 p
->has_announce_rounds
= true;
1855 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1857 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1858 p
->has_announce_step
= true;
1859 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1869 qmp_migrate_set_parameters(p
, &err
);
1872 qapi_free_MigrateSetParameters(p
);
1874 hmp_handle_error(mon
, &err
);
1877 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1880 const char *protocol
= qdict_get_str(qdict
, "protocol");
1881 const char *hostname
= qdict_get_str(qdict
, "hostname");
1882 bool has_port
= qdict_haskey(qdict
, "port");
1883 int port
= qdict_get_try_int(qdict
, "port", -1);
1884 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1885 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1886 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1888 qmp_client_migrate_info(protocol
, hostname
,
1889 has_port
, port
, has_tls_port
, tls_port
,
1890 !!cert_subject
, cert_subject
, &err
);
1891 hmp_handle_error(mon
, &err
);
1894 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1897 qmp_migrate_start_postcopy(&err
);
1898 hmp_handle_error(mon
, &err
);
1901 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1905 qmp_x_colo_lost_heartbeat(&err
);
1906 hmp_handle_error(mon
, &err
);
1909 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1911 const char *protocol
= qdict_get_str(qdict
, "protocol");
1912 const char *password
= qdict_get_str(qdict
, "password");
1913 const char *connected
= qdict_get_try_str(qdict
, "connected");
1916 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1917 hmp_handle_error(mon
, &err
);
1920 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1922 const char *protocol
= qdict_get_str(qdict
, "protocol");
1923 const char *whenstr
= qdict_get_str(qdict
, "time");
1926 qmp_expire_password(protocol
, whenstr
, &err
);
1927 hmp_handle_error(mon
, &err
);
1930 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1932 bool force
= qdict_get_try_bool(qdict
, "force", false);
1933 const char *device
= qdict_get_str(qdict
, "device");
1936 qmp_eject(true, device
, false, NULL
, true, force
, &err
);
1937 hmp_handle_error(mon
, &err
);
1941 static void hmp_change_read_arg(void *opaque
, const char *password
,
1942 void *readline_opaque
)
1944 qmp_change_vnc_password(password
, NULL
);
1945 monitor_read_command(opaque
, 1);
1949 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1951 const char *device
= qdict_get_str(qdict
, "device");
1952 const char *target
= qdict_get_str(qdict
, "target");
1953 const char *arg
= qdict_get_try_str(qdict
, "arg");
1954 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1955 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1959 if (strcmp(device
, "vnc") == 0) {
1962 "Parameter 'read-only-mode' is invalid for VNC\n");
1965 if (strcmp(target
, "passwd") == 0 ||
1966 strcmp(target
, "password") == 0) {
1968 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1969 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1973 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1979 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1981 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1983 hmp_handle_error(mon
, &err
);
1988 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1989 !!arg
, arg
, !!read_only
, read_only_mode
,
1993 hmp_handle_error(mon
, &err
);
1996 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1999 char *device
= (char *) qdict_get_str(qdict
, "device");
2000 BlockIOThrottle throttle
= {
2001 .bps
= qdict_get_int(qdict
, "bps"),
2002 .bps_rd
= qdict_get_int(qdict
, "bps_rd"),
2003 .bps_wr
= qdict_get_int(qdict
, "bps_wr"),
2004 .iops
= qdict_get_int(qdict
, "iops"),
2005 .iops_rd
= qdict_get_int(qdict
, "iops_rd"),
2006 .iops_wr
= qdict_get_int(qdict
, "iops_wr"),
2009 /* qmp_block_set_io_throttle has separate parameters for the
2010 * (deprecated) block device name and the qdev ID but the HMP
2011 * version has only one, so we must decide which one to pass. */
2012 if (blk_by_name(device
)) {
2013 throttle
.has_device
= true;
2014 throttle
.device
= device
;
2016 throttle
.has_id
= true;
2017 throttle
.id
= device
;
2020 qmp_block_set_io_throttle(&throttle
, &err
);
2021 hmp_handle_error(mon
, &err
);
2024 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
2026 Error
*error
= NULL
;
2027 const char *device
= qdict_get_str(qdict
, "device");
2028 const char *base
= qdict_get_try_str(qdict
, "base");
2029 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
2031 qmp_block_stream(true, device
, device
, base
!= NULL
, base
, false, NULL
,
2032 false, NULL
, qdict_haskey(qdict
, "speed"), speed
, true,
2033 BLOCKDEV_ON_ERROR_REPORT
, false, false, false, false,
2036 hmp_handle_error(mon
, &error
);
2039 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
2041 Error
*error
= NULL
;
2042 const char *device
= qdict_get_str(qdict
, "device");
2043 int64_t value
= qdict_get_int(qdict
, "speed");
2045 qmp_block_job_set_speed(device
, value
, &error
);
2047 hmp_handle_error(mon
, &error
);
2050 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
2052 Error
*error
= NULL
;
2053 const char *device
= qdict_get_str(qdict
, "device");
2054 bool force
= qdict_get_try_bool(qdict
, "force", false);
2056 qmp_block_job_cancel(device
, true, force
, &error
);
2058 hmp_handle_error(mon
, &error
);
2061 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
2063 Error
*error
= NULL
;
2064 const char *device
= qdict_get_str(qdict
, "device");
2066 qmp_block_job_pause(device
, &error
);
2068 hmp_handle_error(mon
, &error
);
2071 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
2073 Error
*error
= NULL
;
2074 const char *device
= qdict_get_str(qdict
, "device");
2076 qmp_block_job_resume(device
, &error
);
2078 hmp_handle_error(mon
, &error
);
2081 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
2083 Error
*error
= NULL
;
2084 const char *device
= qdict_get_str(qdict
, "device");
2086 qmp_block_job_complete(device
, &error
);
2088 hmp_handle_error(mon
, &error
);
2091 typedef struct HMPMigrationStatus
2095 bool is_block_migration
;
2096 } HMPMigrationStatus
;
2098 static void hmp_migrate_status_cb(void *opaque
)
2100 HMPMigrationStatus
*status
= opaque
;
2101 MigrationInfo
*info
;
2103 info
= qmp_query_migrate(NULL
);
2104 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
2105 info
->status
== MIGRATION_STATUS_SETUP
) {
2106 if (info
->has_disk
) {
2109 if (info
->disk
->remaining
) {
2110 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
2115 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
2116 monitor_flush(status
->mon
);
2119 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
2121 if (status
->is_block_migration
) {
2122 monitor_printf(status
->mon
, "\n");
2124 if (info
->has_error_desc
) {
2125 error_report("%s", info
->error_desc
);
2127 monitor_resume(status
->mon
);
2128 timer_del(status
->timer
);
2129 timer_free(status
->timer
);
2133 qapi_free_MigrationInfo(info
);
2136 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
2138 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
2139 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
2140 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
2141 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
2142 const char *uri
= qdict_get_str(qdict
, "uri");
2145 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
2146 false, false, true, resume
, &err
);
2148 hmp_handle_error(mon
, &err
);
2153 HMPMigrationStatus
*status
;
2155 if (monitor_suspend(mon
) < 0) {
2156 monitor_printf(mon
, "terminal does not allow synchronous "
2157 "migration, continuing detached\n");
2161 status
= g_malloc0(sizeof(*status
));
2163 status
->is_block_migration
= blk
|| inc
;
2164 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
2166 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
2170 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
2174 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
2175 hmp_handle_error(mon
, &err
);
2178 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
2180 const char *id
= qdict_get_str(qdict
, "id");
2183 qmp_device_del(id
, &err
);
2184 hmp_handle_error(mon
, &err
);
2187 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
2192 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
2197 netdev_add(opts
, &err
);
2199 qemu_opts_del(opts
);
2203 hmp_handle_error(mon
, &err
);
2206 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
2208 const char *id
= qdict_get_str(qdict
, "id");
2211 qmp_netdev_del(id
, &err
);
2212 hmp_handle_error(mon
, &err
);
2215 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
2221 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
2223 hmp_handle_error(mon
, &err
);
2227 obj
= user_creatable_add_opts(opts
, &err
);
2228 qemu_opts_del(opts
);
2231 hmp_handle_error(mon
, &err
);
2238 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
2240 const char *fdname
= qdict_get_str(qdict
, "fdname");
2243 qmp_getfd(fdname
, &err
);
2244 hmp_handle_error(mon
, &err
);
2247 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
2249 const char *fdname
= qdict_get_str(qdict
, "fdname");
2252 qmp_closefd(fdname
, &err
);
2253 hmp_handle_error(mon
, &err
);
2256 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
2258 const char *keys
= qdict_get_str(qdict
, "keys");
2259 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
2260 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
2261 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
2263 const char *separator
;
2267 separator
= qemu_strchrnul(keys
, '-');
2268 keyname_len
= separator
- keys
;
2270 /* Be compatible with old interface, convert user inputted "<" */
2271 if (keys
[0] == '<' && keyname_len
== 1) {
2276 keylist
= g_malloc0(sizeof(*keylist
));
2277 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
2283 tmp
->next
= keylist
;
2287 if (strstart(keys
, "0x", NULL
)) {
2289 int value
= strtoul(keys
, &endp
, 0);
2290 assert(endp
<= keys
+ keyname_len
);
2291 if (endp
!= keys
+ keyname_len
) {
2294 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
2295 keylist
->value
->u
.number
.data
= value
;
2297 int idx
= index_from_key(keys
, keyname_len
);
2298 if (idx
== Q_KEY_CODE__MAX
) {
2301 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
2302 keylist
->value
->u
.qcode
.data
= idx
;
2308 keys
= separator
+ 1;
2311 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
2312 hmp_handle_error(mon
, &err
);
2315 qapi_free_KeyValueList(head
);
2319 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
2323 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
2325 const char *filename
= qdict_get_str(qdict
, "filename");
2326 const char *id
= qdict_get_try_str(qdict
, "device");
2327 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
2330 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
2331 hmp_handle_error(mon
, &err
);
2334 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
2336 const char *uri
= qdict_get_str(qdict
, "uri");
2337 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2338 bool all
= qdict_get_try_bool(qdict
, "all", false);
2339 Error
*local_err
= NULL
;
2340 BlockInfoList
*block_list
, *info
;
2341 SocketAddress
*addr
;
2343 if (writable
&& !all
) {
2344 error_setg(&local_err
, "-w only valid together with -a");
2348 /* First check if the address is valid and start the server. */
2349 addr
= socket_parse(uri
, &local_err
);
2350 if (local_err
!= NULL
) {
2354 nbd_server_start(addr
, NULL
, NULL
, &local_err
);
2355 qapi_free_SocketAddress(addr
);
2356 if (local_err
!= NULL
) {
2364 /* Then try adding all block devices. If one fails, close all and
2367 block_list
= qmp_query_block(NULL
);
2369 for (info
= block_list
; info
; info
= info
->next
) {
2370 if (!info
->value
->has_inserted
) {
2374 qmp_nbd_server_add(info
->value
->device
, false, NULL
,
2375 true, writable
, false, NULL
, &local_err
);
2377 if (local_err
!= NULL
) {
2378 qmp_nbd_server_stop(NULL
);
2383 qapi_free_BlockInfoList(block_list
);
2386 hmp_handle_error(mon
, &local_err
);
2389 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
2391 const char *device
= qdict_get_str(qdict
, "device");
2392 const char *name
= qdict_get_try_str(qdict
, "name");
2393 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2394 Error
*local_err
= NULL
;
2396 qmp_nbd_server_add(device
, !!name
, name
, true, writable
,
2397 false, NULL
, &local_err
);
2398 hmp_handle_error(mon
, &local_err
);
2401 void hmp_nbd_server_remove(Monitor
*mon
, const QDict
*qdict
)
2403 const char *name
= qdict_get_str(qdict
, "name");
2404 bool force
= qdict_get_try_bool(qdict
, "force", false);
2407 /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
2408 qmp_nbd_server_remove(name
, force
, NBD_SERVER_REMOVE_MODE_HARD
, &err
);
2409 hmp_handle_error(mon
, &err
);
2412 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
2416 qmp_nbd_server_stop(&err
);
2417 hmp_handle_error(mon
, &err
);
2420 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
2422 const char *args
= qdict_get_str(qdict
, "args");
2426 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
2428 error_setg(&err
, "Parsing chardev args failed");
2430 qemu_chr_new_from_opts(opts
, NULL
, &err
);
2431 qemu_opts_del(opts
);
2433 hmp_handle_error(mon
, &err
);
2436 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
2438 const char *args
= qdict_get_str(qdict
, "args");
2441 ChardevBackend
*backend
= NULL
;
2442 ChardevReturn
*ret
= NULL
;
2443 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
2446 error_setg(&err
, "Parsing chardev args failed");
2450 id
= qdict_get_str(qdict
, "id");
2451 if (qemu_opts_id(opts
)) {
2452 error_setg(&err
, "Unexpected 'id' parameter");
2456 backend
= qemu_chr_parse_opts(opts
, &err
);
2461 ret
= qmp_chardev_change(id
, backend
, &err
);
2464 qapi_free_ChardevReturn(ret
);
2465 qapi_free_ChardevBackend(backend
);
2466 qemu_opts_del(opts
);
2467 hmp_handle_error(mon
, &err
);
2470 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
2472 Error
*local_err
= NULL
;
2474 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
2475 hmp_handle_error(mon
, &local_err
);
2478 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
2480 Error
*local_err
= NULL
;
2482 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
2483 hmp_handle_error(mon
, &local_err
);
2486 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
2489 BlockBackend
*local_blk
= NULL
;
2490 const char* device
= qdict_get_str(qdict
, "device");
2491 const char* command
= qdict_get_str(qdict
, "command");
2495 blk
= blk_by_name(device
);
2497 BlockDriverState
*bs
= bdrv_lookup_bs(NULL
, device
, &err
);
2499 blk
= local_blk
= blk_new(bdrv_get_aio_context(bs
),
2501 ret
= blk_insert_bs(blk
, bs
, &err
);
2511 * Notably absent: Proper permission management. This is sad, but it seems
2512 * almost impossible to achieve without changing the semantics and thereby
2513 * limiting the use cases of the qemu-io HMP command.
2515 * In an ideal world we would unconditionally create a new BlockBackend for
2516 * qemuio_command(), but we have commands like 'reopen' and want them to
2517 * take effect on the exact BlockBackend whose name the user passed instead
2518 * of just on a temporary copy of it.
2520 * Another problem is that deleting the temporary BlockBackend involves
2521 * draining all requests on it first, but some qemu-iotests cases want to
2522 * issue multiple aio_read/write requests and expect them to complete in
2523 * the background while the monitor has already returned.
2525 * This is also what prevents us from saving the original permissions and
2526 * restoring them later: We can't revoke permissions until all requests
2527 * have completed, and we don't know when that is nor can we really let
2528 * anything else run before we have revoken them to avoid race conditions.
2530 * What happens now is that command() in qemu-io-cmds.c can extend the
2531 * permissions if necessary for the qemu-io command. And they simply stay
2532 * extended, possibly resulting in a read-only guest device keeping write
2533 * permissions. Ugly, but it appears to be the lesser evil.
2535 qemuio_command(blk
, command
);
2538 blk_unref(local_blk
);
2539 hmp_handle_error(mon
, &err
);
2542 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
2544 const char *id
= qdict_get_str(qdict
, "id");
2547 user_creatable_del(id
, &err
);
2548 hmp_handle_error(mon
, &err
);
2551 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2554 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2555 MemoryDeviceInfoList
*info
;
2556 VirtioPMEMDeviceInfo
*vpi
;
2557 MemoryDeviceInfo
*value
;
2558 PCDIMMDeviceInfo
*di
;
2560 for (info
= info_list
; info
; info
= info
->next
) {
2561 value
= info
->value
;
2564 switch (value
->type
) {
2565 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2566 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
2567 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
2568 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
2569 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2570 MemoryDeviceInfoKind_str(value
->type
),
2571 di
->id
? di
->id
: "");
2572 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2573 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2574 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2575 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2576 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2577 monitor_printf(mon
, " hotplugged: %s\n",
2578 di
->hotplugged
? "true" : "false");
2579 monitor_printf(mon
, " hotpluggable: %s\n",
2580 di
->hotpluggable
? "true" : "false");
2582 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
2583 vpi
= value
->u
.virtio_pmem
.data
;
2584 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2585 MemoryDeviceInfoKind_str(value
->type
),
2586 vpi
->id
? vpi
->id
: "");
2587 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
2588 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
2589 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
2592 g_assert_not_reached();
2597 qapi_free_MemoryDeviceInfoList(info_list
);
2598 hmp_handle_error(mon
, &err
);
2601 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2603 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2604 IOThreadInfoList
*info
;
2605 IOThreadInfo
*value
;
2607 for (info
= info_list
; info
; info
= info
->next
) {
2608 value
= info
->value
;
2609 monitor_printf(mon
, "%s:\n", value
->id
);
2610 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
2611 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
2612 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
2613 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
2616 qapi_free_IOThreadInfoList(info_list
);
2619 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2621 const char *name
= qdict_get_str(qdict
, "name");
2622 RockerSwitch
*rocker
;
2625 rocker
= qmp_query_rocker(name
, &err
);
2627 hmp_handle_error(mon
, &err
);
2631 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2632 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2633 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2635 qapi_free_RockerSwitch(rocker
);
2638 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2640 RockerPortList
*list
, *port
;
2641 const char *name
= qdict_get_str(qdict
, "name");
2644 list
= qmp_query_rocker_ports(name
, &err
);
2646 hmp_handle_error(mon
, &err
);
2650 monitor_printf(mon
, " ena/ speed/ auto\n");
2651 monitor_printf(mon
, " port link duplex neg?\n");
2653 for (port
= list
; port
; port
= port
->next
) {
2654 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2656 port
->value
->enabled
? port
->value
->link_up
?
2657 "up" : "down" : "!ena",
2658 port
->value
->speed
== 10000 ? "10G" : "??",
2659 port
->value
->duplex
? "FD" : "HD",
2660 port
->value
->autoneg
? "Yes" : "No");
2663 qapi_free_RockerPortList(list
);
2666 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2668 RockerOfDpaFlowList
*list
, *info
;
2669 const char *name
= qdict_get_str(qdict
, "name");
2670 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2673 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2675 hmp_handle_error(mon
, &err
);
2679 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2681 for (info
= list
; info
; info
= info
->next
) {
2682 RockerOfDpaFlow
*flow
= info
->value
;
2683 RockerOfDpaFlowKey
*key
= flow
->key
;
2684 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2685 RockerOfDpaFlowAction
*action
= flow
->action
;
2688 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2689 key
->priority
, key
->tbl_id
, flow
->hits
);
2691 monitor_printf(mon
, "%-4d %-3d ",
2692 key
->priority
, key
->tbl_id
);
2695 if (key
->has_in_pport
) {
2696 monitor_printf(mon
, " pport %d", key
->in_pport
);
2697 if (mask
->has_in_pport
) {
2698 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2702 if (key
->has_vlan_id
) {
2703 monitor_printf(mon
, " vlan %d",
2704 key
->vlan_id
& VLAN_VID_MASK
);
2705 if (mask
->has_vlan_id
) {
2706 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2710 if (key
->has_tunnel_id
) {
2711 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2712 if (mask
->has_tunnel_id
) {
2713 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2717 if (key
->has_eth_type
) {
2718 switch (key
->eth_type
) {
2720 monitor_printf(mon
, " ARP");
2723 monitor_printf(mon
, " IP");
2726 monitor_printf(mon
, " IPv6");
2729 monitor_printf(mon
, " LACP");
2732 monitor_printf(mon
, " LLDP");
2735 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2740 if (key
->has_eth_src
) {
2741 if ((strcmp(key
->eth_src
, "01: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 mcast/bcast>");
2745 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2746 (mask
->has_eth_src
) &&
2747 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2748 monitor_printf(mon
, " src <any ucast>");
2750 monitor_printf(mon
, " src %s", key
->eth_src
);
2751 if (mask
->has_eth_src
) {
2752 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2757 if (key
->has_eth_dst
) {
2758 if ((strcmp(key
->eth_dst
, "01: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 mcast/bcast>");
2762 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2763 (mask
->has_eth_dst
) &&
2764 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2765 monitor_printf(mon
, " dst <any ucast>");
2767 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2768 if (mask
->has_eth_dst
) {
2769 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2774 if (key
->has_ip_proto
) {
2775 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2776 if (mask
->has_ip_proto
) {
2777 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2781 if (key
->has_ip_tos
) {
2782 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2783 if (mask
->has_ip_tos
) {
2784 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2788 if (key
->has_ip_dst
) {
2789 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2792 if (action
->has_goto_tbl
|| action
->has_group_id
||
2793 action
->has_new_vlan_id
) {
2794 monitor_printf(mon
, " -->");
2797 if (action
->has_new_vlan_id
) {
2798 monitor_printf(mon
, " apply new vlan %d",
2799 ntohs(action
->new_vlan_id
));
2802 if (action
->has_group_id
) {
2803 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2806 if (action
->has_goto_tbl
) {
2807 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2810 monitor_printf(mon
, "\n");
2813 qapi_free_RockerOfDpaFlowList(list
);
2816 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2818 RockerOfDpaGroupList
*list
, *g
;
2819 const char *name
= qdict_get_str(qdict
, "name");
2820 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2824 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2826 hmp_handle_error(mon
, &err
);
2830 monitor_printf(mon
, "id (decode) --> buckets\n");
2832 for (g
= list
; g
; g
= g
->next
) {
2833 RockerOfDpaGroup
*group
= g
->value
;
2835 monitor_printf(mon
, "0x%08x", group
->id
);
2837 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2838 group
->type
== 1 ? "L2 rewrite" :
2839 group
->type
== 2 ? "L3 unicast" :
2840 group
->type
== 3 ? "L2 multicast" :
2841 group
->type
== 4 ? "L2 flood" :
2842 group
->type
== 5 ? "L3 interface" :
2843 group
->type
== 6 ? "L3 multicast" :
2844 group
->type
== 7 ? "L3 ECMP" :
2845 group
->type
== 8 ? "L2 overlay" :
2848 if (group
->has_vlan_id
) {
2849 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2852 if (group
->has_pport
) {
2853 monitor_printf(mon
, " pport %d", group
->pport
);
2856 if (group
->has_index
) {
2857 monitor_printf(mon
, " index %d", group
->index
);
2860 monitor_printf(mon
, ") -->");
2862 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2864 monitor_printf(mon
, " set vlan %d",
2865 group
->set_vlan_id
& VLAN_VID_MASK
);
2868 if (group
->has_set_eth_src
) {
2871 monitor_printf(mon
, " set");
2873 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2876 if (group
->has_set_eth_dst
) {
2879 monitor_printf(mon
, " set");
2881 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2886 if (group
->has_ttl_check
&& group
->ttl_check
) {
2887 monitor_printf(mon
, " check TTL");
2890 if (group
->has_group_id
&& group
->group_id
) {
2891 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2894 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2895 monitor_printf(mon
, " pop vlan");
2898 if (group
->has_out_pport
) {
2899 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2902 if (group
->has_group_ids
) {
2903 struct uint32List
*id
;
2905 monitor_printf(mon
, " groups [");
2906 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2907 monitor_printf(mon
, "0x%08x", id
->value
);
2909 monitor_printf(mon
, ",");
2912 monitor_printf(mon
, "]");
2915 monitor_printf(mon
, "\n");
2918 qapi_free_RockerOfDpaGroupList(list
);
2921 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2923 ram_block_dump(mon
);
2926 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2929 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2931 monitor_printf(mon
, "%s\n", info
->guid
);
2933 hmp_handle_error(mon
, &err
);
2934 qapi_free_GuidInfo(info
);
2937 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2940 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2942 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2945 if (info
->has_plugged_memory
) {
2946 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2947 info
->plugged_memory
);
2950 qapi_free_MemoryInfo(info
);
2952 hmp_handle_error(mon
, &err
);