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 "qapi/error.h"
29 #include "qapi/clone-visitor.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-control.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-rocker.h"
39 #include "qapi/qapi-commands-run-state.h"
40 #include "qapi/qapi-commands-tpm.h"
41 #include "qapi/qapi-commands-ui.h"
42 #include "qapi/qapi-visit-net.h"
43 #include "qapi/qmp/qdict.h"
44 #include "qapi/qmp/qerror.h"
45 #include "qapi/string-input-visitor.h"
46 #include "qapi/string-output-visitor.h"
47 #include "qom/object_interfaces.h"
48 #include "ui/console.h"
49 #include "block/nbd.h"
50 #include "block/qapi.h"
52 #include "qemu/cutils.h"
53 #include "qemu/error-report.h"
54 #include "exec/ramlist.h"
55 #include "hw/intc/intc.h"
56 #include "hw/rdma/rdma.h"
57 #include "migration/snapshot.h"
58 #include "migration/misc.h"
61 #include <spice/enums.h>
64 void hmp_handle_error(Monitor
*mon
, Error
*err
)
67 error_reportf_err(err
, "Error: ");
72 * Produce a strList from a comma separated list.
73 * A NULL or empty input string return NULL.
75 static strList
*strList_from_comma_list(const char *in
)
78 strList
**hook
= &res
;
81 char *comma
= strchr(in
, ',');
82 *hook
= g_new0(strList
, 1);
85 (*hook
)->value
= g_strndup(in
, comma
- in
);
86 in
= comma
+ 1; /* skip the , */
88 (*hook
)->value
= g_strdup(in
);
91 hook
= &(*hook
)->next
;
97 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
101 info
= qmp_query_name(NULL
);
102 if (info
->has_name
) {
103 monitor_printf(mon
, "%s\n", info
->name
);
105 qapi_free_NameInfo(info
);
108 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
112 info
= qmp_query_version(NULL
);
114 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
115 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
118 qapi_free_VersionInfo(info
);
121 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
125 info
= qmp_query_kvm(NULL
);
126 monitor_printf(mon
, "kvm support: ");
128 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
130 monitor_printf(mon
, "not compiled\n");
133 qapi_free_KvmInfo(info
);
136 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
140 info
= qmp_query_status(NULL
);
142 monitor_printf(mon
, "VM status: %s%s",
143 info
->running
? "running" : "paused",
144 info
->singlestep
? " (single step mode)" : "");
146 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
147 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
150 monitor_printf(mon
, "\n");
152 qapi_free_StatusInfo(info
);
155 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
159 info
= qmp_query_uuid(NULL
);
160 monitor_printf(mon
, "%s\n", info
->UUID
);
161 qapi_free_UuidInfo(info
);
164 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
166 ChardevInfoList
*char_info
, *info
;
168 char_info
= qmp_query_chardev(NULL
);
169 for (info
= char_info
; info
; info
= info
->next
) {
170 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
171 info
->value
->filename
);
174 qapi_free_ChardevInfoList(char_info
);
177 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
179 MouseInfoList
*mice_list
, *mouse
;
181 mice_list
= qmp_query_mice(NULL
);
183 monitor_printf(mon
, "No mouse devices connected\n");
187 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
188 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
189 mouse
->value
->current
? '*' : ' ',
190 mouse
->value
->index
, mouse
->value
->name
,
191 mouse
->value
->absolute
? " (absolute)" : "");
194 qapi_free_MouseInfoList(mice_list
);
197 static char *SocketAddress_to_str(SocketAddress
*addr
)
199 switch (addr
->type
) {
200 case SOCKET_ADDRESS_TYPE_INET
:
201 return g_strdup_printf("tcp:%s:%s",
204 case SOCKET_ADDRESS_TYPE_UNIX
:
205 return g_strdup_printf("unix:%s",
206 addr
->u
.q_unix
.path
);
207 case SOCKET_ADDRESS_TYPE_FD
:
208 return g_strdup_printf("fd:%s", addr
->u
.fd
.str
);
209 case SOCKET_ADDRESS_TYPE_VSOCK
:
210 return g_strdup_printf("tcp:%s:%s",
214 return g_strdup("unknown address type");
218 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
222 info
= qmp_query_migrate(NULL
);
224 migration_global_dump(mon
);
226 if (info
->has_status
) {
227 monitor_printf(mon
, "Migration status: %s",
228 MigrationStatus_str(info
->status
));
229 if (info
->status
== MIGRATION_STATUS_FAILED
&&
230 info
->has_error_desc
) {
231 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
233 monitor_printf(mon
, "\n");
236 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
238 if (info
->has_expected_downtime
) {
239 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
240 info
->expected_downtime
);
242 if (info
->has_downtime
) {
243 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
246 if (info
->has_setup_time
) {
247 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
253 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
254 info
->ram
->transferred
>> 10);
255 monitor_printf(mon
, "throughput: %0.2f mbps\n",
257 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
258 info
->ram
->remaining
>> 10);
259 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
260 info
->ram
->total
>> 10);
261 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
262 info
->ram
->duplicate
);
263 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
265 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
267 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
268 info
->ram
->normal_bytes
>> 10);
269 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
270 info
->ram
->dirty_sync_count
);
271 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
272 info
->ram
->page_size
>> 10);
273 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
274 info
->ram
->multifd_bytes
>> 10);
275 monitor_printf(mon
, "pages-per-second: %" PRIu64
"\n",
276 info
->ram
->pages_per_second
);
278 if (info
->ram
->dirty_pages_rate
) {
279 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
280 info
->ram
->dirty_pages_rate
);
282 if (info
->ram
->postcopy_requests
) {
283 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
284 info
->ram
->postcopy_requests
);
288 if (info
->has_disk
) {
289 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
290 info
->disk
->transferred
>> 10);
291 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
292 info
->disk
->remaining
>> 10);
293 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
294 info
->disk
->total
>> 10);
297 if (info
->has_xbzrle_cache
) {
298 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
299 info
->xbzrle_cache
->cache_size
);
300 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
301 info
->xbzrle_cache
->bytes
>> 10);
302 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
303 info
->xbzrle_cache
->pages
);
304 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
305 info
->xbzrle_cache
->cache_miss
);
306 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
307 info
->xbzrle_cache
->cache_miss_rate
);
308 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
309 info
->xbzrle_cache
->overflow
);
312 if (info
->has_compression
) {
313 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
314 info
->compression
->pages
);
315 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
316 info
->compression
->busy
);
317 monitor_printf(mon
, "compression busy rate: %0.2f\n",
318 info
->compression
->busy_rate
);
319 monitor_printf(mon
, "compressed size: %" PRIu64
"\n",
320 info
->compression
->compressed_size
);
321 monitor_printf(mon
, "compression rate: %0.2f\n",
322 info
->compression
->compression_rate
);
325 if (info
->has_cpu_throttle_percentage
) {
326 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
327 info
->cpu_throttle_percentage
);
330 if (info
->has_postcopy_blocktime
) {
331 monitor_printf(mon
, "postcopy blocktime: %u\n",
332 info
->postcopy_blocktime
);
335 if (info
->has_postcopy_vcpu_blocktime
) {
338 v
= string_output_visitor_new(false, &str
);
339 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
, NULL
);
340 visit_complete(v
, &str
);
341 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
345 if (info
->has_socket_address
) {
346 SocketAddressList
*addr
;
348 monitor_printf(mon
, "socket address: [\n");
350 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
351 char *s
= SocketAddress_to_str(addr
->value
);
352 monitor_printf(mon
, "\t%s\n", s
);
355 monitor_printf(mon
, "]\n");
357 qapi_free_MigrationInfo(info
);
360 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
362 MigrationCapabilityStatusList
*caps
, *cap
;
364 caps
= qmp_query_migrate_capabilities(NULL
);
367 for (cap
= caps
; cap
; cap
= cap
->next
) {
368 monitor_printf(mon
, "%s: %s\n",
369 MigrationCapability_str(cap
->value
->capability
),
370 cap
->value
->state
? "on" : "off");
374 qapi_free_MigrationCapabilityStatusList(caps
);
377 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
379 MigrationParameters
*params
;
381 params
= qmp_query_migrate_parameters(NULL
);
384 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
385 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
386 params
->announce_initial
);
387 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
388 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
389 params
->announce_max
);
390 monitor_printf(mon
, "%s: %" PRIu64
"\n",
391 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
392 params
->announce_rounds
);
393 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
394 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
395 params
->announce_step
);
396 assert(params
->has_compress_level
);
397 monitor_printf(mon
, "%s: %u\n",
398 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
399 params
->compress_level
);
400 assert(params
->has_compress_threads
);
401 monitor_printf(mon
, "%s: %u\n",
402 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
403 params
->compress_threads
);
404 assert(params
->has_compress_wait_thread
);
405 monitor_printf(mon
, "%s: %s\n",
406 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
407 params
->compress_wait_thread
? "on" : "off");
408 assert(params
->has_decompress_threads
);
409 monitor_printf(mon
, "%s: %u\n",
410 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
411 params
->decompress_threads
);
412 assert(params
->has_cpu_throttle_initial
);
413 monitor_printf(mon
, "%s: %u\n",
414 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
415 params
->cpu_throttle_initial
);
416 assert(params
->has_cpu_throttle_increment
);
417 monitor_printf(mon
, "%s: %u\n",
418 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
419 params
->cpu_throttle_increment
);
420 assert(params
->has_max_cpu_throttle
);
421 monitor_printf(mon
, "%s: %u\n",
422 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
423 params
->max_cpu_throttle
);
424 assert(params
->has_tls_creds
);
425 monitor_printf(mon
, "%s: '%s'\n",
426 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
428 assert(params
->has_tls_hostname
);
429 monitor_printf(mon
, "%s: '%s'\n",
430 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
431 params
->tls_hostname
);
432 assert(params
->has_max_bandwidth
);
433 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
434 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
435 params
->max_bandwidth
);
436 assert(params
->has_downtime_limit
);
437 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
438 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
439 params
->downtime_limit
);
440 assert(params
->has_x_checkpoint_delay
);
441 monitor_printf(mon
, "%s: %u\n",
442 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
443 params
->x_checkpoint_delay
);
444 assert(params
->has_block_incremental
);
445 monitor_printf(mon
, "%s: %s\n",
446 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
447 params
->block_incremental
? "on" : "off");
448 monitor_printf(mon
, "%s: %u\n",
449 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS
),
450 params
->multifd_channels
);
451 monitor_printf(mon
, "%s: %" PRIu64
"\n",
452 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
453 params
->xbzrle_cache_size
);
454 monitor_printf(mon
, "%s: %" PRIu64
"\n",
455 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
456 params
->max_postcopy_bandwidth
);
457 monitor_printf(mon
, " %s: '%s'\n",
458 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
459 params
->has_tls_authz
? params
->tls_authz
: "");
462 qapi_free_MigrationParameters(params
);
465 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
467 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
468 qmp_query_migrate_cache_size(NULL
) >> 10);
471 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
472 BlockDeviceInfo
*inserted
, bool verbose
)
474 ImageInfo
*image_info
;
476 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
478 if (info
&& *info
->device
) {
479 monitor_printf(mon
, "%s", info
->device
);
480 if (inserted
&& inserted
->has_node_name
) {
481 monitor_printf(mon
, " (%s)", inserted
->node_name
);
484 assert(info
|| inserted
);
485 monitor_printf(mon
, "%s",
486 inserted
&& inserted
->has_node_name
? inserted
->node_name
487 : info
&& info
->has_qdev
? info
->qdev
492 monitor_printf(mon
, ": %s (%s%s%s)\n",
495 inserted
->ro
? ", read-only" : "",
496 inserted
->encrypted
? ", encrypted" : "");
498 monitor_printf(mon
, ": [not inserted]\n");
502 if (info
->has_qdev
) {
503 monitor_printf(mon
, " Attached to: %s\n", info
->qdev
);
505 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
506 monitor_printf(mon
, " I/O status: %s\n",
507 BlockDeviceIoStatus_str(info
->io_status
));
510 if (info
->removable
) {
511 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
512 info
->locked
? "" : "not ",
513 info
->tray_open
? "open" : "closed");
522 monitor_printf(mon
, " Cache mode: %s%s%s\n",
523 inserted
->cache
->writeback
? "writeback" : "writethrough",
524 inserted
->cache
->direct
? ", direct" : "",
525 inserted
->cache
->no_flush
? ", ignore flushes" : "");
527 if (inserted
->has_backing_file
) {
530 "(chain depth: %" PRId64
")\n",
531 inserted
->backing_file
,
532 inserted
->backing_file_depth
);
535 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
536 monitor_printf(mon
, " Detect zeroes: %s\n",
537 BlockdevDetectZeroesOptions_str(inserted
->detect_zeroes
));
540 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
541 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
543 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
544 " bps_rd=%" PRId64
" bps_wr=%" PRId64
546 " bps_rd_max=%" PRId64
547 " bps_wr_max=%" PRId64
548 " iops=%" PRId64
" iops_rd=%" PRId64
551 " iops_rd_max=%" PRId64
552 " iops_wr_max=%" PRId64
553 " iops_size=%" PRId64
559 inserted
->bps_rd_max
,
560 inserted
->bps_wr_max
,
565 inserted
->iops_rd_max
,
566 inserted
->iops_wr_max
,
572 monitor_printf(mon
, "\nImages:\n");
573 image_info
= inserted
->image
;
575 bdrv_image_info_dump(image_info
);
576 if (image_info
->has_backing_image
) {
577 image_info
= image_info
->backing_image
;
585 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
587 BlockInfoList
*block_list
, *info
;
588 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
589 const char *device
= qdict_get_try_str(qdict
, "device");
590 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
591 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
592 bool printed
= false;
594 /* Print BlockBackend information */
596 block_list
= qmp_query_block(NULL
);
601 for (info
= block_list
; info
; info
= info
->next
) {
602 if (device
&& strcmp(device
, info
->value
->device
)) {
606 if (info
!= block_list
) {
607 monitor_printf(mon
, "\n");
610 print_block_info(mon
, info
->value
, info
->value
->has_inserted
611 ? info
->value
->inserted
: NULL
,
616 qapi_free_BlockInfoList(block_list
);
618 if ((!device
&& !nodes
) || printed
) {
622 /* Print node information */
623 blockdev_list
= qmp_query_named_block_nodes(NULL
);
624 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
625 assert(blockdev
->value
->has_node_name
);
626 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
630 if (blockdev
!= blockdev_list
) {
631 monitor_printf(mon
, "\n");
634 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
636 qapi_free_BlockDeviceInfoList(blockdev_list
);
639 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
641 BlockStatsList
*stats_list
, *stats
;
643 stats_list
= qmp_query_blockstats(false, false, NULL
);
645 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
646 if (!stats
->value
->has_device
) {
650 monitor_printf(mon
, "%s:", stats
->value
->device
);
651 monitor_printf(mon
, " rd_bytes=%" PRId64
653 " rd_operations=%" PRId64
654 " wr_operations=%" PRId64
655 " flush_operations=%" PRId64
656 " wr_total_time_ns=%" PRId64
657 " rd_total_time_ns=%" PRId64
658 " flush_total_time_ns=%" PRId64
659 " rd_merged=%" PRId64
660 " wr_merged=%" PRId64
661 " idle_time_ns=%" PRId64
663 stats
->value
->stats
->rd_bytes
,
664 stats
->value
->stats
->wr_bytes
,
665 stats
->value
->stats
->rd_operations
,
666 stats
->value
->stats
->wr_operations
,
667 stats
->value
->stats
->flush_operations
,
668 stats
->value
->stats
->wr_total_time_ns
,
669 stats
->value
->stats
->rd_total_time_ns
,
670 stats
->value
->stats
->flush_total_time_ns
,
671 stats
->value
->stats
->rd_merged
,
672 stats
->value
->stats
->wr_merged
,
673 stats
->value
->stats
->idle_time_ns
);
676 qapi_free_BlockStatsList(stats_list
);
680 /* Helper for hmp_info_vnc_clients, _servers */
681 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
684 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
688 NetworkAddressFamily_str(info
->family
),
689 info
->websocket
? " (Websocket)" : "");
692 /* Helper displaying and auth and crypt info */
693 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
695 VncVencryptSubAuth
*vencrypt
)
697 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
698 VncPrimaryAuth_str(auth
),
699 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
702 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
705 VncClientInfo
*cinfo
= client
->value
;
707 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
708 monitor_printf(mon
, " x509_dname: %s\n",
709 cinfo
->has_x509_dname
?
710 cinfo
->x509_dname
: "none");
711 monitor_printf(mon
, " sasl_username: %s\n",
712 cinfo
->has_sasl_username
?
713 cinfo
->sasl_username
: "none");
715 client
= client
->next
;
719 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
722 VncServerInfo2
*sinfo
= server
->value
;
723 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
724 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
725 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
726 server
= server
->next
;
730 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
732 VncInfo2List
*info2l
;
735 info2l
= qmp_query_vnc_servers(&err
);
737 hmp_handle_error(mon
, err
);
741 monitor_printf(mon
, "None\n");
746 VncInfo2
*info
= info2l
->value
;
747 monitor_printf(mon
, "%s:\n", info
->id
);
748 hmp_info_vnc_servers(mon
, info
->server
);
749 hmp_info_vnc_clients(mon
, info
->clients
);
751 /* The server entry displays its auth, we only
752 * need to display in the case of 'reverse' connections
753 * where there's no server.
755 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
756 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
758 if (info
->has_display
) {
759 monitor_printf(mon
, " Display: %s\n", info
->display
);
761 info2l
= info2l
->next
;
764 qapi_free_VncInfo2List(info2l
);
770 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
772 SpiceChannelList
*chan
;
774 const char *channel_name
;
775 const char * const channel_names
[] = {
776 [SPICE_CHANNEL_MAIN
] = "main",
777 [SPICE_CHANNEL_DISPLAY
] = "display",
778 [SPICE_CHANNEL_INPUTS
] = "inputs",
779 [SPICE_CHANNEL_CURSOR
] = "cursor",
780 [SPICE_CHANNEL_PLAYBACK
] = "playback",
781 [SPICE_CHANNEL_RECORD
] = "record",
782 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
783 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
784 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
785 [SPICE_CHANNEL_PORT
] = "port",
787 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
788 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
789 * as quick fix for build failures with older versions. */
790 [SPICE_CHANNEL_WEBDAV
] = "webdav",
794 info
= qmp_query_spice(NULL
);
796 if (!info
->enabled
) {
797 monitor_printf(mon
, "Server: disabled\n");
801 monitor_printf(mon
, "Server:\n");
802 if (info
->has_port
) {
803 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
804 info
->host
, info
->port
);
806 if (info
->has_tls_port
) {
807 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
808 info
->host
, info
->tls_port
);
810 monitor_printf(mon
, " migrated: %s\n",
811 info
->migrated
? "true" : "false");
812 monitor_printf(mon
, " auth: %s\n", info
->auth
);
813 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
814 monitor_printf(mon
, " mouse-mode: %s\n",
815 SpiceQueryMouseMode_str(info
->mouse_mode
));
817 if (!info
->has_channels
|| info
->channels
== NULL
) {
818 monitor_printf(mon
, "Channels: none\n");
820 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
821 monitor_printf(mon
, "Channel:\n");
822 monitor_printf(mon
, " address: %s:%s%s\n",
823 chan
->value
->host
, chan
->value
->port
,
824 chan
->value
->tls
? " [tls]" : "");
825 monitor_printf(mon
, " session: %" PRId64
"\n",
826 chan
->value
->connection_id
);
827 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
828 chan
->value
->channel_type
, chan
->value
->channel_id
);
830 channel_name
= "unknown";
831 if (chan
->value
->channel_type
> 0 &&
832 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
833 channel_names
[chan
->value
->channel_type
]) {
834 channel_name
= channel_names
[chan
->value
->channel_type
];
837 monitor_printf(mon
, " channel name: %s\n", channel_name
);
842 qapi_free_SpiceInfo(info
);
846 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
851 info
= qmp_query_balloon(&err
);
853 hmp_handle_error(mon
, err
);
857 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
859 qapi_free_BalloonInfo(info
);
862 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
864 PciMemoryRegionList
*region
;
866 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
867 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
868 dev
->slot
, dev
->function
);
869 monitor_printf(mon
, " ");
871 if (dev
->class_info
->has_desc
) {
872 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
874 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
877 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
878 dev
->id
->vendor
, dev
->id
->device
);
879 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
880 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
881 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
885 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
888 if (dev
->has_pci_bridge
) {
889 monitor_printf(mon
, " BUS %" PRId64
".\n",
890 dev
->pci_bridge
->bus
->number
);
891 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
892 dev
->pci_bridge
->bus
->secondary
);
893 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
894 dev
->pci_bridge
->bus
->subordinate
);
896 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
897 dev
->pci_bridge
->bus
->io_range
->base
,
898 dev
->pci_bridge
->bus
->io_range
->limit
);
901 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
902 dev
->pci_bridge
->bus
->memory_range
->base
,
903 dev
->pci_bridge
->bus
->memory_range
->limit
);
905 monitor_printf(mon
, " prefetchable memory range "
906 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
907 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
908 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
911 for (region
= dev
->regions
; region
; region
= region
->next
) {
914 addr
= region
->value
->address
;
915 size
= region
->value
->size
;
917 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
919 if (!strcmp(region
->value
->type
, "io")) {
920 monitor_printf(mon
, "I/O at 0x%04" PRIx64
921 " [0x%04" PRIx64
"].\n",
922 addr
, addr
+ size
- 1);
924 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
925 " [0x%08" PRIx64
"].\n",
926 region
->value
->mem_type_64
? 64 : 32,
927 region
->value
->prefetch
? " prefetchable" : "",
928 addr
, addr
+ size
- 1);
932 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
934 if (dev
->has_pci_bridge
) {
935 if (dev
->pci_bridge
->has_devices
) {
936 PciDeviceInfoList
*cdev
;
937 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
938 hmp_info_pci_device(mon
, cdev
->value
);
944 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
946 InterruptStatsProvider
*intc
;
947 InterruptStatsProviderClass
*k
;
948 Monitor
*mon
= opaque
;
950 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
951 intc
= INTERRUPT_STATS_PROVIDER(obj
);
952 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
953 uint64_t *irq_counts
;
954 unsigned int nb_irqs
, i
;
955 if (k
->get_statistics
&&
956 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
958 monitor_printf(mon
, "IRQ statistics for %s:\n",
959 object_get_typename(obj
));
960 for (i
= 0; i
< nb_irqs
; i
++) {
961 if (irq_counts
[i
] > 0) {
962 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
968 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
969 object_get_typename(obj
));
976 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
978 object_child_foreach_recursive(object_get_root(),
979 hmp_info_irq_foreach
, mon
);
982 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
984 InterruptStatsProvider
*intc
;
985 InterruptStatsProviderClass
*k
;
986 Monitor
*mon
= opaque
;
988 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
989 intc
= INTERRUPT_STATS_PROVIDER(obj
);
990 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
992 k
->print_info(intc
, mon
);
994 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
995 object_get_typename(obj
));
1002 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
1004 object_child_foreach_recursive(object_get_root(),
1005 hmp_info_pic_foreach
, mon
);
1008 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
1011 RdmaProviderClass
*k
;
1012 Monitor
*mon
= opaque
;
1014 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
1015 rdma
= RDMA_PROVIDER(obj
);
1016 k
= RDMA_PROVIDER_GET_CLASS(obj
);
1017 if (k
->print_statistics
) {
1018 k
->print_statistics(mon
, rdma
);
1020 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
1021 object_get_typename(obj
));
1028 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
1030 object_child_foreach_recursive(object_get_root(),
1031 hmp_info_rdma_foreach
, mon
);
1034 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
1036 PciInfoList
*info_list
, *info
;
1039 info_list
= qmp_query_pci(&err
);
1041 monitor_printf(mon
, "PCI devices not supported\n");
1046 for (info
= info_list
; info
; info
= info
->next
) {
1047 PciDeviceInfoList
*dev
;
1049 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
1050 hmp_info_pci_device(mon
, dev
->value
);
1054 qapi_free_PciInfoList(info_list
);
1057 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
1059 BlockJobInfoList
*list
;
1062 list
= qmp_query_block_jobs(&err
);
1066 monitor_printf(mon
, "No active jobs\n");
1071 if (strcmp(list
->value
->type
, "stream") == 0) {
1072 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
1073 " of %" PRId64
" bytes, speed limit %" PRId64
1075 list
->value
->device
,
1076 list
->value
->offset
,
1078 list
->value
->speed
);
1080 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
1081 " of %" PRId64
" bytes, speed limit %" PRId64
1084 list
->value
->device
,
1085 list
->value
->offset
,
1087 list
->value
->speed
);
1092 qapi_free_BlockJobInfoList(list
);
1095 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
1097 TPMInfoList
*info_list
, *info
;
1100 TPMPassthroughOptions
*tpo
;
1101 TPMEmulatorOptions
*teo
;
1103 info_list
= qmp_query_tpm(&err
);
1105 monitor_printf(mon
, "TPM device not supported\n");
1111 monitor_printf(mon
, "TPM device:\n");
1114 for (info
= info_list
; info
; info
= info
->next
) {
1115 TPMInfo
*ti
= info
->value
;
1116 monitor_printf(mon
, " tpm%d: model=%s\n",
1117 c
, TpmModel_str(ti
->model
));
1119 monitor_printf(mon
, " \\ %s: type=%s",
1120 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
1122 switch (ti
->options
->type
) {
1123 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
1124 tpo
= ti
->options
->u
.passthrough
.data
;
1125 monitor_printf(mon
, "%s%s%s%s",
1126 tpo
->has_path
? ",path=" : "",
1127 tpo
->has_path
? tpo
->path
: "",
1128 tpo
->has_cancel_path
? ",cancel-path=" : "",
1129 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
1131 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
1132 teo
= ti
->options
->u
.emulator
.data
;
1133 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
1135 case TPM_TYPE_OPTIONS_KIND__MAX
:
1138 monitor_printf(mon
, "\n");
1141 qapi_free_TPMInfoList(info_list
);
1144 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
1146 monitor_suspend(mon
);
1150 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
1155 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
1157 const char *op
= qdict_get_try_str(qdict
, "op");
1160 bool on
= qsp_is_enabled();
1162 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
1165 if (!strcmp(op
, "on")) {
1167 } else if (!strcmp(op
, "off")) {
1169 } else if (!strcmp(op
, "reset")) {
1174 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
1175 hmp_handle_error(mon
, err
);
1179 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
1181 qmp_system_reset(NULL
);
1184 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
1186 qmp_system_powerdown(NULL
);
1189 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
1193 qmp_x_exit_preconfig(&err
);
1194 hmp_handle_error(mon
, err
);
1197 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1201 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1202 use it are converted to the QAPI */
1203 cpu_index
= qdict_get_int(qdict
, "index");
1204 if (monitor_set_cpu(cpu_index
) < 0) {
1205 monitor_printf(mon
, "invalid CPU index\n");
1209 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1211 uint32_t size
= qdict_get_int(qdict
, "size");
1212 const char *filename
= qdict_get_str(qdict
, "filename");
1213 uint64_t addr
= qdict_get_int(qdict
, "val");
1215 int cpu_index
= monitor_get_cpu_index();
1217 if (cpu_index
< 0) {
1218 monitor_printf(mon
, "No CPU available\n");
1222 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1223 hmp_handle_error(mon
, err
);
1226 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1228 uint32_t size
= qdict_get_int(qdict
, "size");
1229 const char *filename
= qdict_get_str(qdict
, "filename");
1230 uint64_t addr
= qdict_get_int(qdict
, "val");
1233 qmp_pmemsave(addr
, size
, filename
, &err
);
1234 hmp_handle_error(mon
, err
);
1237 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1239 const char *chardev
= qdict_get_str(qdict
, "device");
1240 const char *data
= qdict_get_str(qdict
, "data");
1243 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1245 hmp_handle_error(mon
, err
);
1248 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1250 uint32_t size
= qdict_get_int(qdict
, "size");
1251 const char *chardev
= qdict_get_str(qdict
, "device");
1256 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1258 hmp_handle_error(mon
, err
);
1262 for (i
= 0; data
[i
]; i
++) {
1263 unsigned char ch
= data
[i
];
1266 monitor_printf(mon
, "\\\\");
1267 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1268 monitor_printf(mon
, "\\u%04X", ch
);
1270 monitor_printf(mon
, "%c", ch
);
1274 monitor_printf(mon
, "\n");
1278 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1283 hmp_handle_error(mon
, err
);
1286 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1290 qmp_system_wakeup(&err
);
1291 hmp_handle_error(mon
, err
);
1294 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1298 qmp_inject_nmi(&err
);
1299 hmp_handle_error(mon
, err
);
1302 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1304 const char *name
= qdict_get_str(qdict
, "name");
1305 bool up
= qdict_get_bool(qdict
, "up");
1308 qmp_set_link(name
, up
, &err
);
1309 hmp_handle_error(mon
, err
);
1312 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1314 const char *device
= qdict_get_str(qdict
, "device");
1315 const char *password
= qdict_get_str(qdict
, "password");
1318 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1319 hmp_handle_error(mon
, err
);
1322 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1324 int64_t value
= qdict_get_int(qdict
, "value");
1327 qmp_balloon(value
, &err
);
1328 hmp_handle_error(mon
, err
);
1331 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1333 const char *device
= qdict_get_str(qdict
, "device");
1334 int64_t size
= qdict_get_int(qdict
, "size");
1337 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1338 hmp_handle_error(mon
, err
);
1341 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1343 const char *filename
= qdict_get_str(qdict
, "target");
1344 const char *format
= qdict_get_try_str(qdict
, "format");
1345 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1346 bool full
= qdict_get_try_bool(qdict
, "full", false);
1348 DriveMirror mirror
= {
1349 .device
= (char *)qdict_get_str(qdict
, "device"),
1350 .target
= (char *)filename
,
1351 .has_format
= !!format
,
1352 .format
= (char *)format
,
1353 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1355 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1360 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1361 hmp_handle_error(mon
, err
);
1364 qmp_drive_mirror(&mirror
, &err
);
1365 hmp_handle_error(mon
, err
);
1368 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1370 const char *device
= qdict_get_str(qdict
, "device");
1371 const char *filename
= qdict_get_str(qdict
, "target");
1372 const char *format
= qdict_get_try_str(qdict
, "format");
1373 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1374 bool full
= qdict_get_try_bool(qdict
, "full", false);
1375 bool compress
= qdict_get_try_bool(qdict
, "compress", false);
1377 DriveBackup backup
= {
1378 .device
= (char *)device
,
1379 .target
= (char *)filename
,
1380 .has_format
= !!format
,
1381 .format
= (char *)format
,
1382 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1384 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1385 .has_compress
= !!compress
,
1386 .compress
= compress
,
1390 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1391 hmp_handle_error(mon
, err
);
1395 qmp_drive_backup(&backup
, &err
);
1396 hmp_handle_error(mon
, err
);
1399 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1401 const char *device
= qdict_get_str(qdict
, "device");
1402 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1403 const char *format
= qdict_get_try_str(qdict
, "format");
1404 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1405 enum NewImageMode mode
;
1409 /* In the future, if 'snapshot-file' is not specified, the snapshot
1410 will be taken internally. Today it's actually required. */
1411 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1412 hmp_handle_error(mon
, err
);
1416 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1417 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1418 filename
, false, NULL
,
1421 hmp_handle_error(mon
, err
);
1424 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1426 const char *device
= qdict_get_str(qdict
, "device");
1427 const char *name
= qdict_get_str(qdict
, "name");
1430 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1431 hmp_handle_error(mon
, err
);
1434 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1436 const char *device
= qdict_get_str(qdict
, "device");
1437 const char *name
= qdict_get_str(qdict
, "name");
1438 const char *id
= qdict_get_try_str(qdict
, "id");
1441 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1443 hmp_handle_error(mon
, err
);
1446 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1448 int saved_vm_running
= runstate_is_running();
1449 const char *name
= qdict_get_str(qdict
, "name");
1452 vm_stop(RUN_STATE_RESTORE_VM
);
1454 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1457 hmp_handle_error(mon
, err
);
1460 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1464 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1465 hmp_handle_error(mon
, err
);
1468 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1470 BlockDriverState
*bs
;
1472 const char *name
= qdict_get_str(qdict
, "name");
1474 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1476 "deleting snapshot on device '%s': ",
1477 bdrv_get_device_name(bs
));
1479 hmp_handle_error(mon
, err
);
1482 void hmp_info_snapshots(Monitor
*mon
, const QDict
*qdict
)
1484 BlockDriverState
*bs
, *bs1
;
1485 BdrvNextIterator it1
;
1486 QEMUSnapshotInfo
*sn_tab
, *sn
;
1487 bool no_snapshot
= true;
1490 int *global_snapshots
;
1491 AioContext
*aio_context
;
1493 typedef struct SnapshotEntry
{
1494 QEMUSnapshotInfo sn
;
1495 QTAILQ_ENTRY(SnapshotEntry
) next
;
1498 typedef struct ImageEntry
{
1499 const char *imagename
;
1500 QTAILQ_ENTRY(ImageEntry
) next
;
1501 QTAILQ_HEAD(, SnapshotEntry
) snapshots
;
1504 QTAILQ_HEAD(, ImageEntry
) image_list
=
1505 QTAILQ_HEAD_INITIALIZER(image_list
);
1507 ImageEntry
*image_entry
, *next_ie
;
1508 SnapshotEntry
*snapshot_entry
;
1510 bs
= bdrv_all_find_vmstate_bs();
1512 monitor_printf(mon
, "No available block device supports snapshots\n");
1515 aio_context
= bdrv_get_aio_context(bs
);
1517 aio_context_acquire(aio_context
);
1518 nb_sns
= bdrv_snapshot_list(bs
, &sn_tab
);
1519 aio_context_release(aio_context
);
1522 monitor_printf(mon
, "bdrv_snapshot_list: error %d\n", nb_sns
);
1526 for (bs1
= bdrv_first(&it1
); bs1
; bs1
= bdrv_next(&it1
)) {
1530 AioContext
*ctx
= bdrv_get_aio_context(bs1
);
1532 aio_context_acquire(ctx
);
1533 if (bdrv_can_snapshot(bs1
)) {
1535 bs1_nb_sns
= bdrv_snapshot_list(bs1
, &sn
);
1536 if (bs1_nb_sns
> 0) {
1537 no_snapshot
= false;
1538 ie
= g_new0(ImageEntry
, 1);
1539 ie
->imagename
= bdrv_get_device_name(bs1
);
1540 QTAILQ_INIT(&ie
->snapshots
);
1541 QTAILQ_INSERT_TAIL(&image_list
, ie
, next
);
1542 for (i
= 0; i
< bs1_nb_sns
; i
++) {
1543 se
= g_new0(SnapshotEntry
, 1);
1545 QTAILQ_INSERT_TAIL(&ie
->snapshots
, se
, next
);
1550 aio_context_release(ctx
);
1554 monitor_printf(mon
, "There is no snapshot available.\n");
1558 global_snapshots
= g_new0(int, nb_sns
);
1560 for (i
= 0; i
< nb_sns
; i
++) {
1561 SnapshotEntry
*next_sn
;
1562 if (bdrv_all_find_snapshot(sn_tab
[i
].name
, &bs1
) == 0) {
1563 global_snapshots
[total
] = i
;
1565 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1566 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
,
1568 if (!strcmp(sn_tab
[i
].name
, snapshot_entry
->sn
.name
)) {
1569 QTAILQ_REMOVE(&image_entry
->snapshots
, snapshot_entry
,
1571 g_free(snapshot_entry
);
1578 monitor_printf(mon
, "List of snapshots present on all disks:\n");
1581 bdrv_snapshot_dump(NULL
);
1582 monitor_printf(mon
, "\n");
1583 for (i
= 0; i
< total
; i
++) {
1584 sn
= &sn_tab
[global_snapshots
[i
]];
1585 /* The ID is not guaranteed to be the same on all images, so
1588 pstrcpy(sn
->id_str
, sizeof(sn
->id_str
), "--");
1589 bdrv_snapshot_dump(sn
);
1590 monitor_printf(mon
, "\n");
1593 monitor_printf(mon
, "None\n");
1596 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1597 if (QTAILQ_EMPTY(&image_entry
->snapshots
)) {
1601 "\nList of partial (non-loadable) snapshots on '%s':\n",
1602 image_entry
->imagename
);
1603 bdrv_snapshot_dump(NULL
);
1604 monitor_printf(mon
, "\n");
1605 QTAILQ_FOREACH(snapshot_entry
, &image_entry
->snapshots
, next
) {
1606 bdrv_snapshot_dump(&snapshot_entry
->sn
);
1607 monitor_printf(mon
, "\n");
1611 QTAILQ_FOREACH_SAFE(image_entry
, &image_list
, next
, next_ie
) {
1612 SnapshotEntry
*next_sn
;
1613 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
, next
,
1615 g_free(snapshot_entry
);
1617 g_free(image_entry
);
1620 g_free(global_snapshots
);
1624 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1626 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1627 const char *id
= qdict_get_try_str(qdict
, "id");
1628 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1629 migrate_announce_params());
1631 qapi_free_strList(params
->interfaces
);
1632 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1633 params
->has_interfaces
= params
->interfaces
!= NULL
;
1634 params
->id
= g_strdup(id
);
1635 params
->has_id
= !!params
->id
;
1636 qmp_announce_self(params
, NULL
);
1637 qapi_free_AnnounceParameters(params
);
1640 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1642 qmp_migrate_cancel(NULL
);
1645 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1648 const char *state
= qdict_get_str(qdict
, "state");
1649 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1652 qmp_migrate_continue(val
, &err
);
1655 hmp_handle_error(mon
, err
);
1658 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1661 const char *uri
= qdict_get_str(qdict
, "uri");
1663 qmp_migrate_incoming(uri
, &err
);
1665 hmp_handle_error(mon
, err
);
1668 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1671 const char *uri
= qdict_get_str(qdict
, "uri");
1673 qmp_migrate_recover(uri
, &err
);
1675 hmp_handle_error(mon
, err
);
1678 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1682 qmp_migrate_pause(&err
);
1684 hmp_handle_error(mon
, err
);
1687 /* Kept for backwards compatibility */
1688 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1690 double value
= qdict_get_double(qdict
, "value");
1691 qmp_migrate_set_downtime(value
, NULL
);
1694 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1696 int64_t value
= qdict_get_int(qdict
, "value");
1699 qmp_migrate_set_cache_size(value
, &err
);
1700 hmp_handle_error(mon
, err
);
1703 /* Kept for backwards compatibility */
1704 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1706 int64_t value
= qdict_get_int(qdict
, "value");
1707 qmp_migrate_set_speed(value
, NULL
);
1710 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1712 const char *cap
= qdict_get_str(qdict
, "capability");
1713 bool state
= qdict_get_bool(qdict
, "state");
1715 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1718 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1723 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1724 caps
->value
->capability
= val
;
1725 caps
->value
->state
= state
;
1727 qmp_migrate_set_capabilities(caps
, &err
);
1730 qapi_free_MigrationCapabilityStatusList(caps
);
1731 hmp_handle_error(mon
, err
);
1734 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1736 const char *param
= qdict_get_str(qdict
, "parameter");
1737 const char *valuestr
= qdict_get_str(qdict
, "value");
1738 Visitor
*v
= string_input_visitor_new(valuestr
);
1739 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1740 uint64_t valuebw
= 0;
1741 uint64_t cache_size
;
1745 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1751 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1752 p
->has_compress_level
= true;
1753 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1755 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1756 p
->has_compress_threads
= true;
1757 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1759 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1760 p
->has_compress_wait_thread
= true;
1761 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1763 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1764 p
->has_decompress_threads
= true;
1765 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1767 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1768 p
->has_cpu_throttle_initial
= true;
1769 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1771 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1772 p
->has_cpu_throttle_increment
= true;
1773 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1775 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1776 p
->has_max_cpu_throttle
= true;
1777 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1779 case MIGRATION_PARAMETER_TLS_CREDS
:
1780 p
->has_tls_creds
= true;
1781 p
->tls_creds
= g_new0(StrOrNull
, 1);
1782 p
->tls_creds
->type
= QTYPE_QSTRING
;
1783 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1785 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1786 p
->has_tls_hostname
= true;
1787 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1788 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1789 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1791 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1792 p
->has_tls_authz
= true;
1793 p
->tls_authz
= g_new0(StrOrNull
, 1);
1794 p
->tls_authz
->type
= QTYPE_QSTRING
;
1795 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1797 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1798 p
->has_max_bandwidth
= true;
1800 * Can't use visit_type_size() here, because it
1801 * defaults to Bytes rather than Mebibytes.
1803 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1804 if (ret
< 0 || valuebw
> INT64_MAX
1805 || (size_t)valuebw
!= valuebw
) {
1806 error_setg(&err
, "Invalid size %s", valuestr
);
1809 p
->max_bandwidth
= valuebw
;
1811 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1812 p
->has_downtime_limit
= true;
1813 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1815 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1816 p
->has_x_checkpoint_delay
= true;
1817 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1819 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1820 p
->has_block_incremental
= true;
1821 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1823 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1824 p
->has_multifd_channels
= true;
1825 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1827 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1828 p
->has_xbzrle_cache_size
= true;
1829 visit_type_size(v
, param
, &cache_size
, &err
);
1833 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1834 error_setg(&err
, "Invalid size %s", valuestr
);
1837 p
->xbzrle_cache_size
= cache_size
;
1839 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1840 p
->has_max_postcopy_bandwidth
= true;
1841 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1843 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1844 p
->has_announce_initial
= true;
1845 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1847 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1848 p
->has_announce_max
= true;
1849 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1851 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1852 p
->has_announce_rounds
= true;
1853 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1855 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1856 p
->has_announce_step
= true;
1857 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1867 qmp_migrate_set_parameters(p
, &err
);
1870 qapi_free_MigrateSetParameters(p
);
1872 hmp_handle_error(mon
, err
);
1875 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1878 const char *protocol
= qdict_get_str(qdict
, "protocol");
1879 const char *hostname
= qdict_get_str(qdict
, "hostname");
1880 bool has_port
= qdict_haskey(qdict
, "port");
1881 int port
= qdict_get_try_int(qdict
, "port", -1);
1882 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1883 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1884 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1886 qmp_client_migrate_info(protocol
, hostname
,
1887 has_port
, port
, has_tls_port
, tls_port
,
1888 !!cert_subject
, cert_subject
, &err
);
1889 hmp_handle_error(mon
, err
);
1892 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1895 qmp_migrate_start_postcopy(&err
);
1896 hmp_handle_error(mon
, err
);
1899 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1903 qmp_x_colo_lost_heartbeat(&err
);
1904 hmp_handle_error(mon
, err
);
1907 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1909 const char *protocol
= qdict_get_str(qdict
, "protocol");
1910 const char *password
= qdict_get_str(qdict
, "password");
1911 const char *connected
= qdict_get_try_str(qdict
, "connected");
1914 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1915 hmp_handle_error(mon
, err
);
1918 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1920 const char *protocol
= qdict_get_str(qdict
, "protocol");
1921 const char *whenstr
= qdict_get_str(qdict
, "time");
1924 qmp_expire_password(protocol
, whenstr
, &err
);
1925 hmp_handle_error(mon
, err
);
1928 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1930 bool force
= qdict_get_try_bool(qdict
, "force", false);
1931 const char *device
= qdict_get_str(qdict
, "device");
1934 qmp_eject(true, device
, false, NULL
, true, force
, &err
);
1935 hmp_handle_error(mon
, err
);
1939 static void hmp_change_read_arg(void *opaque
, const char *password
,
1940 void *readline_opaque
)
1942 qmp_change_vnc_password(password
, NULL
);
1943 monitor_read_command(opaque
, 1);
1947 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1949 const char *device
= qdict_get_str(qdict
, "device");
1950 const char *target
= qdict_get_str(qdict
, "target");
1951 const char *arg
= qdict_get_try_str(qdict
, "arg");
1952 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1953 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1957 if (strcmp(device
, "vnc") == 0) {
1960 "Parameter 'read-only-mode' is invalid for VNC\n");
1963 if (strcmp(target
, "passwd") == 0 ||
1964 strcmp(target
, "password") == 0) {
1966 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1967 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1971 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1977 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1979 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1981 hmp_handle_error(mon
, err
);
1986 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1987 !!arg
, arg
, !!read_only
, read_only_mode
,
1991 hmp_handle_error(mon
, err
);
1994 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1997 char *device
= (char *) qdict_get_str(qdict
, "device");
1998 BlockIOThrottle throttle
= {
1999 .bps
= qdict_get_int(qdict
, "bps"),
2000 .bps_rd
= qdict_get_int(qdict
, "bps_rd"),
2001 .bps_wr
= qdict_get_int(qdict
, "bps_wr"),
2002 .iops
= qdict_get_int(qdict
, "iops"),
2003 .iops_rd
= qdict_get_int(qdict
, "iops_rd"),
2004 .iops_wr
= qdict_get_int(qdict
, "iops_wr"),
2007 /* qmp_block_set_io_throttle has separate parameters for the
2008 * (deprecated) block device name and the qdev ID but the HMP
2009 * version has only one, so we must decide which one to pass. */
2010 if (blk_by_name(device
)) {
2011 throttle
.has_device
= true;
2012 throttle
.device
= device
;
2014 throttle
.has_id
= true;
2015 throttle
.id
= device
;
2018 qmp_block_set_io_throttle(&throttle
, &err
);
2019 hmp_handle_error(mon
, err
);
2022 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
2024 Error
*error
= NULL
;
2025 const char *device
= qdict_get_str(qdict
, "device");
2026 const char *base
= qdict_get_try_str(qdict
, "base");
2027 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
2029 qmp_block_stream(true, device
, device
, base
!= NULL
, base
, false, NULL
,
2030 false, NULL
, qdict_haskey(qdict
, "speed"), speed
, true,
2031 BLOCKDEV_ON_ERROR_REPORT
, false, false, false, false,
2034 hmp_handle_error(mon
, error
);
2037 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
2039 Error
*error
= NULL
;
2040 const char *device
= qdict_get_str(qdict
, "device");
2041 int64_t value
= qdict_get_int(qdict
, "speed");
2043 qmp_block_job_set_speed(device
, value
, &error
);
2045 hmp_handle_error(mon
, error
);
2048 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
2050 Error
*error
= NULL
;
2051 const char *device
= qdict_get_str(qdict
, "device");
2052 bool force
= qdict_get_try_bool(qdict
, "force", false);
2054 qmp_block_job_cancel(device
, true, force
, &error
);
2056 hmp_handle_error(mon
, error
);
2059 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
2061 Error
*error
= NULL
;
2062 const char *device
= qdict_get_str(qdict
, "device");
2064 qmp_block_job_pause(device
, &error
);
2066 hmp_handle_error(mon
, error
);
2069 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
2071 Error
*error
= NULL
;
2072 const char *device
= qdict_get_str(qdict
, "device");
2074 qmp_block_job_resume(device
, &error
);
2076 hmp_handle_error(mon
, error
);
2079 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
2081 Error
*error
= NULL
;
2082 const char *device
= qdict_get_str(qdict
, "device");
2084 qmp_block_job_complete(device
, &error
);
2086 hmp_handle_error(mon
, error
);
2089 typedef struct HMPMigrationStatus
2093 bool is_block_migration
;
2094 } HMPMigrationStatus
;
2096 static void hmp_migrate_status_cb(void *opaque
)
2098 HMPMigrationStatus
*status
= opaque
;
2099 MigrationInfo
*info
;
2101 info
= qmp_query_migrate(NULL
);
2102 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
2103 info
->status
== MIGRATION_STATUS_SETUP
) {
2104 if (info
->has_disk
) {
2107 if (info
->disk
->remaining
) {
2108 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
2113 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
2114 monitor_flush(status
->mon
);
2117 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
2119 if (status
->is_block_migration
) {
2120 monitor_printf(status
->mon
, "\n");
2122 if (info
->has_error_desc
) {
2123 error_report("%s", info
->error_desc
);
2125 monitor_resume(status
->mon
);
2126 timer_del(status
->timer
);
2127 timer_free(status
->timer
);
2131 qapi_free_MigrationInfo(info
);
2134 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
2136 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
2137 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
2138 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
2139 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
2140 const char *uri
= qdict_get_str(qdict
, "uri");
2143 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
2144 false, false, true, resume
, &err
);
2146 hmp_handle_error(mon
, err
);
2151 HMPMigrationStatus
*status
;
2153 if (monitor_suspend(mon
) < 0) {
2154 monitor_printf(mon
, "terminal does not allow synchronous "
2155 "migration, continuing detached\n");
2159 status
= g_malloc0(sizeof(*status
));
2161 status
->is_block_migration
= blk
|| inc
;
2162 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
2164 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
2168 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
2173 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
2178 netdev_add(opts
, &err
);
2180 qemu_opts_del(opts
);
2184 hmp_handle_error(mon
, err
);
2187 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
2189 const char *id
= qdict_get_str(qdict
, "id");
2192 qmp_netdev_del(id
, &err
);
2193 hmp_handle_error(mon
, err
);
2196 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
2202 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
2204 hmp_handle_error(mon
, err
);
2208 obj
= user_creatable_add_opts(opts
, &err
);
2209 qemu_opts_del(opts
);
2212 hmp_handle_error(mon
, err
);
2219 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
2221 const char *fdname
= qdict_get_str(qdict
, "fdname");
2224 qmp_getfd(fdname
, &err
);
2225 hmp_handle_error(mon
, err
);
2228 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
2230 const char *fdname
= qdict_get_str(qdict
, "fdname");
2233 qmp_closefd(fdname
, &err
);
2234 hmp_handle_error(mon
, err
);
2237 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
2239 const char *keys
= qdict_get_str(qdict
, "keys");
2240 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
2241 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
2242 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
2244 const char *separator
;
2248 separator
= qemu_strchrnul(keys
, '-');
2249 keyname_len
= separator
- keys
;
2251 /* Be compatible with old interface, convert user inputted "<" */
2252 if (keys
[0] == '<' && keyname_len
== 1) {
2257 keylist
= g_malloc0(sizeof(*keylist
));
2258 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
2264 tmp
->next
= keylist
;
2268 if (strstart(keys
, "0x", NULL
)) {
2270 int value
= strtoul(keys
, &endp
, 0);
2271 assert(endp
<= keys
+ keyname_len
);
2272 if (endp
!= keys
+ keyname_len
) {
2275 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
2276 keylist
->value
->u
.number
.data
= value
;
2278 int idx
= index_from_key(keys
, keyname_len
);
2279 if (idx
== Q_KEY_CODE__MAX
) {
2282 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
2283 keylist
->value
->u
.qcode
.data
= idx
;
2289 keys
= separator
+ 1;
2292 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
2293 hmp_handle_error(mon
, err
);
2296 qapi_free_KeyValueList(head
);
2300 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
2304 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
2306 const char *filename
= qdict_get_str(qdict
, "filename");
2307 const char *id
= qdict_get_try_str(qdict
, "device");
2308 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
2311 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
2312 hmp_handle_error(mon
, err
);
2315 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
2317 const char *uri
= qdict_get_str(qdict
, "uri");
2318 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2319 bool all
= qdict_get_try_bool(qdict
, "all", false);
2320 Error
*local_err
= NULL
;
2321 BlockInfoList
*block_list
, *info
;
2322 SocketAddress
*addr
;
2324 if (writable
&& !all
) {
2325 error_setg(&local_err
, "-w only valid together with -a");
2329 /* First check if the address is valid and start the server. */
2330 addr
= socket_parse(uri
, &local_err
);
2331 if (local_err
!= NULL
) {
2335 nbd_server_start(addr
, NULL
, NULL
, &local_err
);
2336 qapi_free_SocketAddress(addr
);
2337 if (local_err
!= NULL
) {
2345 /* Then try adding all block devices. If one fails, close all and
2348 block_list
= qmp_query_block(NULL
);
2350 for (info
= block_list
; info
; info
= info
->next
) {
2351 if (!info
->value
->has_inserted
) {
2355 qmp_nbd_server_add(info
->value
->device
, false, NULL
, false, NULL
,
2356 true, writable
, false, NULL
, &local_err
);
2358 if (local_err
!= NULL
) {
2359 qmp_nbd_server_stop(NULL
);
2364 qapi_free_BlockInfoList(block_list
);
2367 hmp_handle_error(mon
, local_err
);
2370 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
2372 const char *device
= qdict_get_str(qdict
, "device");
2373 const char *name
= qdict_get_try_str(qdict
, "name");
2374 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2375 Error
*local_err
= NULL
;
2377 qmp_nbd_server_add(device
, !!name
, name
, false, NULL
, true, writable
,
2378 false, NULL
, &local_err
);
2379 hmp_handle_error(mon
, local_err
);
2382 void hmp_nbd_server_remove(Monitor
*mon
, const QDict
*qdict
)
2384 const char *name
= qdict_get_str(qdict
, "name");
2385 bool force
= qdict_get_try_bool(qdict
, "force", false);
2388 /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
2389 qmp_nbd_server_remove(name
, force
, NBD_SERVER_REMOVE_MODE_HARD
, &err
);
2390 hmp_handle_error(mon
, err
);
2393 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
2397 qmp_nbd_server_stop(&err
);
2398 hmp_handle_error(mon
, err
);
2401 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
2403 const char *args
= qdict_get_str(qdict
, "args");
2407 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
2409 error_setg(&err
, "Parsing chardev args failed");
2411 qemu_chr_new_from_opts(opts
, NULL
, &err
);
2412 qemu_opts_del(opts
);
2414 hmp_handle_error(mon
, err
);
2417 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
2419 const char *args
= qdict_get_str(qdict
, "args");
2422 ChardevBackend
*backend
= NULL
;
2423 ChardevReturn
*ret
= NULL
;
2424 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
2427 error_setg(&err
, "Parsing chardev args failed");
2431 id
= qdict_get_str(qdict
, "id");
2432 if (qemu_opts_id(opts
)) {
2433 error_setg(&err
, "Unexpected 'id' parameter");
2437 backend
= qemu_chr_parse_opts(opts
, &err
);
2442 ret
= qmp_chardev_change(id
, backend
, &err
);
2445 qapi_free_ChardevReturn(ret
);
2446 qapi_free_ChardevBackend(backend
);
2447 qemu_opts_del(opts
);
2448 hmp_handle_error(mon
, err
);
2451 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
2453 Error
*local_err
= NULL
;
2455 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
2456 hmp_handle_error(mon
, local_err
);
2459 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
2461 Error
*local_err
= NULL
;
2463 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
2464 hmp_handle_error(mon
, local_err
);
2467 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
2470 BlockBackend
*local_blk
= NULL
;
2471 bool qdev
= qdict_get_try_bool(qdict
, "qdev", false);
2472 const char* device
= qdict_get_str(qdict
, "device");
2473 const char* command
= qdict_get_str(qdict
, "command");
2478 blk
= blk_by_qdev_id(device
, &err
);
2483 blk
= blk_by_name(device
);
2485 BlockDriverState
*bs
= bdrv_lookup_bs(NULL
, device
, &err
);
2487 blk
= local_blk
= blk_new(bdrv_get_aio_context(bs
),
2489 ret
= blk_insert_bs(blk
, bs
, &err
);
2500 * Notably absent: Proper permission management. This is sad, but it seems
2501 * almost impossible to achieve without changing the semantics and thereby
2502 * limiting the use cases of the qemu-io HMP command.
2504 * In an ideal world we would unconditionally create a new BlockBackend for
2505 * qemuio_command(), but we have commands like 'reopen' and want them to
2506 * take effect on the exact BlockBackend whose name the user passed instead
2507 * of just on a temporary copy of it.
2509 * Another problem is that deleting the temporary BlockBackend involves
2510 * draining all requests on it first, but some qemu-iotests cases want to
2511 * issue multiple aio_read/write requests and expect them to complete in
2512 * the background while the monitor has already returned.
2514 * This is also what prevents us from saving the original permissions and
2515 * restoring them later: We can't revoke permissions until all requests
2516 * have completed, and we don't know when that is nor can we really let
2517 * anything else run before we have revoken them to avoid race conditions.
2519 * What happens now is that command() in qemu-io-cmds.c can extend the
2520 * permissions if necessary for the qemu-io command. And they simply stay
2521 * extended, possibly resulting in a read-only guest device keeping write
2522 * permissions. Ugly, but it appears to be the lesser evil.
2524 qemuio_command(blk
, command
);
2527 blk_unref(local_blk
);
2528 hmp_handle_error(mon
, err
);
2531 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
2533 const char *id
= qdict_get_str(qdict
, "id");
2536 user_creatable_del(id
, &err
);
2537 hmp_handle_error(mon
, err
);
2540 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2543 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2544 MemoryDeviceInfoList
*info
;
2545 VirtioPMEMDeviceInfo
*vpi
;
2546 MemoryDeviceInfo
*value
;
2547 PCDIMMDeviceInfo
*di
;
2549 for (info
= info_list
; info
; info
= info
->next
) {
2550 value
= info
->value
;
2553 switch (value
->type
) {
2554 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2555 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
2556 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
2557 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
2558 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2559 MemoryDeviceInfoKind_str(value
->type
),
2560 di
->id
? di
->id
: "");
2561 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2562 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2563 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2564 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2565 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2566 monitor_printf(mon
, " hotplugged: %s\n",
2567 di
->hotplugged
? "true" : "false");
2568 monitor_printf(mon
, " hotpluggable: %s\n",
2569 di
->hotpluggable
? "true" : "false");
2571 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
2572 vpi
= value
->u
.virtio_pmem
.data
;
2573 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2574 MemoryDeviceInfoKind_str(value
->type
),
2575 vpi
->id
? vpi
->id
: "");
2576 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
2577 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
2578 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
2581 g_assert_not_reached();
2586 qapi_free_MemoryDeviceInfoList(info_list
);
2587 hmp_handle_error(mon
, err
);
2590 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2592 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2593 IOThreadInfoList
*info
;
2594 IOThreadInfo
*value
;
2596 for (info
= info_list
; info
; info
= info
->next
) {
2597 value
= info
->value
;
2598 monitor_printf(mon
, "%s:\n", value
->id
);
2599 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
2600 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
2601 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
2602 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
2605 qapi_free_IOThreadInfoList(info_list
);
2608 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2610 const char *name
= qdict_get_str(qdict
, "name");
2611 RockerSwitch
*rocker
;
2614 rocker
= qmp_query_rocker(name
, &err
);
2616 hmp_handle_error(mon
, err
);
2620 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2621 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2622 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2624 qapi_free_RockerSwitch(rocker
);
2627 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2629 RockerPortList
*list
, *port
;
2630 const char *name
= qdict_get_str(qdict
, "name");
2633 list
= qmp_query_rocker_ports(name
, &err
);
2635 hmp_handle_error(mon
, err
);
2639 monitor_printf(mon
, " ena/ speed/ auto\n");
2640 monitor_printf(mon
, " port link duplex neg?\n");
2642 for (port
= list
; port
; port
= port
->next
) {
2643 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2645 port
->value
->enabled
? port
->value
->link_up
?
2646 "up" : "down" : "!ena",
2647 port
->value
->speed
== 10000 ? "10G" : "??",
2648 port
->value
->duplex
? "FD" : "HD",
2649 port
->value
->autoneg
? "Yes" : "No");
2652 qapi_free_RockerPortList(list
);
2655 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2657 RockerOfDpaFlowList
*list
, *info
;
2658 const char *name
= qdict_get_str(qdict
, "name");
2659 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2662 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2664 hmp_handle_error(mon
, err
);
2668 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2670 for (info
= list
; info
; info
= info
->next
) {
2671 RockerOfDpaFlow
*flow
= info
->value
;
2672 RockerOfDpaFlowKey
*key
= flow
->key
;
2673 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2674 RockerOfDpaFlowAction
*action
= flow
->action
;
2677 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2678 key
->priority
, key
->tbl_id
, flow
->hits
);
2680 monitor_printf(mon
, "%-4d %-3d ",
2681 key
->priority
, key
->tbl_id
);
2684 if (key
->has_in_pport
) {
2685 monitor_printf(mon
, " pport %d", key
->in_pport
);
2686 if (mask
->has_in_pport
) {
2687 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2691 if (key
->has_vlan_id
) {
2692 monitor_printf(mon
, " vlan %d",
2693 key
->vlan_id
& VLAN_VID_MASK
);
2694 if (mask
->has_vlan_id
) {
2695 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2699 if (key
->has_tunnel_id
) {
2700 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2701 if (mask
->has_tunnel_id
) {
2702 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2706 if (key
->has_eth_type
) {
2707 switch (key
->eth_type
) {
2709 monitor_printf(mon
, " ARP");
2712 monitor_printf(mon
, " IP");
2715 monitor_printf(mon
, " IPv6");
2718 monitor_printf(mon
, " LACP");
2721 monitor_printf(mon
, " LLDP");
2724 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2729 if (key
->has_eth_src
) {
2730 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2731 (mask
->has_eth_src
) &&
2732 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2733 monitor_printf(mon
, " src <any mcast/bcast>");
2734 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2735 (mask
->has_eth_src
) &&
2736 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2737 monitor_printf(mon
, " src <any ucast>");
2739 monitor_printf(mon
, " src %s", key
->eth_src
);
2740 if (mask
->has_eth_src
) {
2741 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2746 if (key
->has_eth_dst
) {
2747 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2748 (mask
->has_eth_dst
) &&
2749 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2750 monitor_printf(mon
, " dst <any mcast/bcast>");
2751 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2752 (mask
->has_eth_dst
) &&
2753 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2754 monitor_printf(mon
, " dst <any ucast>");
2756 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2757 if (mask
->has_eth_dst
) {
2758 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2763 if (key
->has_ip_proto
) {
2764 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2765 if (mask
->has_ip_proto
) {
2766 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2770 if (key
->has_ip_tos
) {
2771 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2772 if (mask
->has_ip_tos
) {
2773 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2777 if (key
->has_ip_dst
) {
2778 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2781 if (action
->has_goto_tbl
|| action
->has_group_id
||
2782 action
->has_new_vlan_id
) {
2783 monitor_printf(mon
, " -->");
2786 if (action
->has_new_vlan_id
) {
2787 monitor_printf(mon
, " apply new vlan %d",
2788 ntohs(action
->new_vlan_id
));
2791 if (action
->has_group_id
) {
2792 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2795 if (action
->has_goto_tbl
) {
2796 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2799 monitor_printf(mon
, "\n");
2802 qapi_free_RockerOfDpaFlowList(list
);
2805 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2807 RockerOfDpaGroupList
*list
, *g
;
2808 const char *name
= qdict_get_str(qdict
, "name");
2809 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2813 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2815 hmp_handle_error(mon
, err
);
2819 monitor_printf(mon
, "id (decode) --> buckets\n");
2821 for (g
= list
; g
; g
= g
->next
) {
2822 RockerOfDpaGroup
*group
= g
->value
;
2824 monitor_printf(mon
, "0x%08x", group
->id
);
2826 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2827 group
->type
== 1 ? "L2 rewrite" :
2828 group
->type
== 2 ? "L3 unicast" :
2829 group
->type
== 3 ? "L2 multicast" :
2830 group
->type
== 4 ? "L2 flood" :
2831 group
->type
== 5 ? "L3 interface" :
2832 group
->type
== 6 ? "L3 multicast" :
2833 group
->type
== 7 ? "L3 ECMP" :
2834 group
->type
== 8 ? "L2 overlay" :
2837 if (group
->has_vlan_id
) {
2838 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2841 if (group
->has_pport
) {
2842 monitor_printf(mon
, " pport %d", group
->pport
);
2845 if (group
->has_index
) {
2846 monitor_printf(mon
, " index %d", group
->index
);
2849 monitor_printf(mon
, ") -->");
2851 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2853 monitor_printf(mon
, " set vlan %d",
2854 group
->set_vlan_id
& VLAN_VID_MASK
);
2857 if (group
->has_set_eth_src
) {
2860 monitor_printf(mon
, " set");
2862 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2865 if (group
->has_set_eth_dst
) {
2868 monitor_printf(mon
, " set");
2870 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2875 if (group
->has_ttl_check
&& group
->ttl_check
) {
2876 monitor_printf(mon
, " check TTL");
2879 if (group
->has_group_id
&& group
->group_id
) {
2880 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2883 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2884 monitor_printf(mon
, " pop vlan");
2887 if (group
->has_out_pport
) {
2888 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2891 if (group
->has_group_ids
) {
2892 struct uint32List
*id
;
2894 monitor_printf(mon
, " groups [");
2895 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2896 monitor_printf(mon
, "0x%08x", id
->value
);
2898 monitor_printf(mon
, ",");
2901 monitor_printf(mon
, "]");
2904 monitor_printf(mon
, "\n");
2907 qapi_free_RockerOfDpaGroupList(list
);
2910 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2912 ram_block_dump(mon
);
2915 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2918 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2920 monitor_printf(mon
, "%s\n", info
->guid
);
2922 hmp_handle_error(mon
, err
);
2923 qapi_free_GuidInfo(info
);
2926 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2929 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2931 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2934 if (info
->has_plugged_memory
) {
2935 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2936 info
->plugged_memory
);
2939 qapi_free_MemoryInfo(info
);
2941 hmp_handle_error(mon
, err
);