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/qapi-visit-migration.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 "qemu/cutils.h"
51 #include "qemu/error-report.h"
52 #include "exec/ramlist.h"
53 #include "hw/intc/intc.h"
54 #include "hw/rdma/rdma.h"
55 #include "migration/snapshot.h"
56 #include "migration/misc.h"
59 #include <spice/enums.h>
62 void hmp_handle_error(Monitor
*mon
, Error
*err
)
65 error_reportf_err(err
, "Error: ");
70 * Produce a strList from a comma separated list.
71 * A NULL or empty input string return NULL.
73 static strList
*strList_from_comma_list(const char *in
)
76 strList
**hook
= &res
;
79 char *comma
= strchr(in
, ',');
80 *hook
= g_new0(strList
, 1);
83 (*hook
)->value
= g_strndup(in
, comma
- in
);
84 in
= comma
+ 1; /* skip the , */
86 (*hook
)->value
= g_strdup(in
);
89 hook
= &(*hook
)->next
;
95 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
99 info
= qmp_query_name(NULL
);
100 if (info
->has_name
) {
101 monitor_printf(mon
, "%s\n", info
->name
);
103 qapi_free_NameInfo(info
);
106 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
110 info
= qmp_query_version(NULL
);
112 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
113 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
116 qapi_free_VersionInfo(info
);
119 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
123 info
= qmp_query_kvm(NULL
);
124 monitor_printf(mon
, "kvm support: ");
126 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
128 monitor_printf(mon
, "not compiled\n");
131 qapi_free_KvmInfo(info
);
134 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
138 info
= qmp_query_status(NULL
);
140 monitor_printf(mon
, "VM status: %s%s",
141 info
->running
? "running" : "paused",
142 info
->singlestep
? " (single step mode)" : "");
144 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
145 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
148 monitor_printf(mon
, "\n");
150 qapi_free_StatusInfo(info
);
153 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
157 info
= qmp_query_uuid(NULL
);
158 monitor_printf(mon
, "%s\n", info
->UUID
);
159 qapi_free_UuidInfo(info
);
162 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
164 ChardevInfoList
*char_info
, *info
;
166 char_info
= qmp_query_chardev(NULL
);
167 for (info
= char_info
; info
; info
= info
->next
) {
168 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
169 info
->value
->filename
);
172 qapi_free_ChardevInfoList(char_info
);
175 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
177 MouseInfoList
*mice_list
, *mouse
;
179 mice_list
= qmp_query_mice(NULL
);
181 monitor_printf(mon
, "No mouse devices connected\n");
185 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
186 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
187 mouse
->value
->current
? '*' : ' ',
188 mouse
->value
->index
, mouse
->value
->name
,
189 mouse
->value
->absolute
? " (absolute)" : "");
192 qapi_free_MouseInfoList(mice_list
);
195 static char *SocketAddress_to_str(SocketAddress
*addr
)
197 switch (addr
->type
) {
198 case SOCKET_ADDRESS_TYPE_INET
:
199 return g_strdup_printf("tcp:%s:%s",
202 case SOCKET_ADDRESS_TYPE_UNIX
:
203 return g_strdup_printf("unix:%s",
204 addr
->u
.q_unix
.path
);
205 case SOCKET_ADDRESS_TYPE_FD
:
206 return g_strdup_printf("fd:%s", addr
->u
.fd
.str
);
207 case SOCKET_ADDRESS_TYPE_VSOCK
:
208 return g_strdup_printf("tcp:%s:%s",
212 return g_strdup("unknown address type");
216 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
220 info
= qmp_query_migrate(NULL
);
222 migration_global_dump(mon
);
224 if (info
->has_status
) {
225 monitor_printf(mon
, "Migration status: %s",
226 MigrationStatus_str(info
->status
));
227 if (info
->status
== MIGRATION_STATUS_FAILED
&&
228 info
->has_error_desc
) {
229 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
231 monitor_printf(mon
, "\n");
234 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
236 if (info
->has_expected_downtime
) {
237 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
238 info
->expected_downtime
);
240 if (info
->has_downtime
) {
241 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
244 if (info
->has_setup_time
) {
245 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
251 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
252 info
->ram
->transferred
>> 10);
253 monitor_printf(mon
, "throughput: %0.2f mbps\n",
255 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
256 info
->ram
->remaining
>> 10);
257 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
258 info
->ram
->total
>> 10);
259 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
260 info
->ram
->duplicate
);
261 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
263 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
265 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
266 info
->ram
->normal_bytes
>> 10);
267 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
268 info
->ram
->dirty_sync_count
);
269 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
270 info
->ram
->page_size
>> 10);
271 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
272 info
->ram
->multifd_bytes
>> 10);
273 monitor_printf(mon
, "pages-per-second: %" PRIu64
"\n",
274 info
->ram
->pages_per_second
);
276 if (info
->ram
->dirty_pages_rate
) {
277 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
278 info
->ram
->dirty_pages_rate
);
280 if (info
->ram
->postcopy_requests
) {
281 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
282 info
->ram
->postcopy_requests
);
286 if (info
->has_disk
) {
287 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
288 info
->disk
->transferred
>> 10);
289 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
290 info
->disk
->remaining
>> 10);
291 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
292 info
->disk
->total
>> 10);
295 if (info
->has_xbzrle_cache
) {
296 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
297 info
->xbzrle_cache
->cache_size
);
298 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
299 info
->xbzrle_cache
->bytes
>> 10);
300 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
301 info
->xbzrle_cache
->pages
);
302 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
303 info
->xbzrle_cache
->cache_miss
);
304 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
305 info
->xbzrle_cache
->cache_miss_rate
);
306 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
307 info
->xbzrle_cache
->overflow
);
310 if (info
->has_compression
) {
311 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
312 info
->compression
->pages
);
313 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
314 info
->compression
->busy
);
315 monitor_printf(mon
, "compression busy rate: %0.2f\n",
316 info
->compression
->busy_rate
);
317 monitor_printf(mon
, "compressed size: %" PRIu64
"\n",
318 info
->compression
->compressed_size
);
319 monitor_printf(mon
, "compression rate: %0.2f\n",
320 info
->compression
->compression_rate
);
323 if (info
->has_cpu_throttle_percentage
) {
324 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
325 info
->cpu_throttle_percentage
);
328 if (info
->has_postcopy_blocktime
) {
329 monitor_printf(mon
, "postcopy blocktime: %u\n",
330 info
->postcopy_blocktime
);
333 if (info
->has_postcopy_vcpu_blocktime
) {
336 v
= string_output_visitor_new(false, &str
);
337 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
, NULL
);
338 visit_complete(v
, &str
);
339 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
343 if (info
->has_socket_address
) {
344 SocketAddressList
*addr
;
346 monitor_printf(mon
, "socket address: [\n");
348 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
349 char *s
= SocketAddress_to_str(addr
->value
);
350 monitor_printf(mon
, "\t%s\n", s
);
353 monitor_printf(mon
, "]\n");
355 qapi_free_MigrationInfo(info
);
358 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
360 MigrationCapabilityStatusList
*caps
, *cap
;
362 caps
= qmp_query_migrate_capabilities(NULL
);
365 for (cap
= caps
; cap
; cap
= cap
->next
) {
366 monitor_printf(mon
, "%s: %s\n",
367 MigrationCapability_str(cap
->value
->capability
),
368 cap
->value
->state
? "on" : "off");
372 qapi_free_MigrationCapabilityStatusList(caps
);
375 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
377 MigrationParameters
*params
;
379 params
= qmp_query_migrate_parameters(NULL
);
382 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
383 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
384 params
->announce_initial
);
385 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
386 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
387 params
->announce_max
);
388 monitor_printf(mon
, "%s: %" PRIu64
"\n",
389 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
390 params
->announce_rounds
);
391 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
392 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
393 params
->announce_step
);
394 assert(params
->has_compress_level
);
395 monitor_printf(mon
, "%s: %u\n",
396 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
397 params
->compress_level
);
398 assert(params
->has_compress_threads
);
399 monitor_printf(mon
, "%s: %u\n",
400 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
401 params
->compress_threads
);
402 assert(params
->has_compress_wait_thread
);
403 monitor_printf(mon
, "%s: %s\n",
404 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
405 params
->compress_wait_thread
? "on" : "off");
406 assert(params
->has_decompress_threads
);
407 monitor_printf(mon
, "%s: %u\n",
408 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
409 params
->decompress_threads
);
410 assert(params
->has_throttle_trigger_threshold
);
411 monitor_printf(mon
, "%s: %u\n",
412 MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
),
413 params
->throttle_trigger_threshold
);
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: %s\n",
454 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION
),
455 MultiFDCompression_str(params
->multifd_compression
));
456 monitor_printf(mon
, "%s: %" PRIu64
"\n",
457 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
458 params
->xbzrle_cache_size
);
459 monitor_printf(mon
, "%s: %" PRIu64
"\n",
460 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
461 params
->max_postcopy_bandwidth
);
462 monitor_printf(mon
, " %s: '%s'\n",
463 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
464 params
->has_tls_authz
? params
->tls_authz
: "");
467 qapi_free_MigrationParameters(params
);
470 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
472 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
473 qmp_query_migrate_cache_size(NULL
) >> 10);
478 /* Helper for hmp_info_vnc_clients, _servers */
479 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
482 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
486 NetworkAddressFamily_str(info
->family
),
487 info
->websocket
? " (Websocket)" : "");
490 /* Helper displaying and auth and crypt info */
491 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
493 VncVencryptSubAuth
*vencrypt
)
495 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
496 VncPrimaryAuth_str(auth
),
497 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
500 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
503 VncClientInfo
*cinfo
= client
->value
;
505 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
506 monitor_printf(mon
, " x509_dname: %s\n",
507 cinfo
->has_x509_dname
?
508 cinfo
->x509_dname
: "none");
509 monitor_printf(mon
, " sasl_username: %s\n",
510 cinfo
->has_sasl_username
?
511 cinfo
->sasl_username
: "none");
513 client
= client
->next
;
517 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
520 VncServerInfo2
*sinfo
= server
->value
;
521 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
522 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
523 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
524 server
= server
->next
;
528 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
530 VncInfo2List
*info2l
;
533 info2l
= qmp_query_vnc_servers(&err
);
535 hmp_handle_error(mon
, err
);
539 monitor_printf(mon
, "None\n");
544 VncInfo2
*info
= info2l
->value
;
545 monitor_printf(mon
, "%s:\n", info
->id
);
546 hmp_info_vnc_servers(mon
, info
->server
);
547 hmp_info_vnc_clients(mon
, info
->clients
);
549 /* The server entry displays its auth, we only
550 * need to display in the case of 'reverse' connections
551 * where there's no server.
553 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
554 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
556 if (info
->has_display
) {
557 monitor_printf(mon
, " Display: %s\n", info
->display
);
559 info2l
= info2l
->next
;
562 qapi_free_VncInfo2List(info2l
);
568 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
570 SpiceChannelList
*chan
;
572 const char *channel_name
;
573 const char * const channel_names
[] = {
574 [SPICE_CHANNEL_MAIN
] = "main",
575 [SPICE_CHANNEL_DISPLAY
] = "display",
576 [SPICE_CHANNEL_INPUTS
] = "inputs",
577 [SPICE_CHANNEL_CURSOR
] = "cursor",
578 [SPICE_CHANNEL_PLAYBACK
] = "playback",
579 [SPICE_CHANNEL_RECORD
] = "record",
580 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
581 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
582 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
583 [SPICE_CHANNEL_PORT
] = "port",
585 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
586 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
587 * as quick fix for build failures with older versions. */
588 [SPICE_CHANNEL_WEBDAV
] = "webdav",
592 info
= qmp_query_spice(NULL
);
594 if (!info
->enabled
) {
595 monitor_printf(mon
, "Server: disabled\n");
599 monitor_printf(mon
, "Server:\n");
600 if (info
->has_port
) {
601 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
602 info
->host
, info
->port
);
604 if (info
->has_tls_port
) {
605 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
606 info
->host
, info
->tls_port
);
608 monitor_printf(mon
, " migrated: %s\n",
609 info
->migrated
? "true" : "false");
610 monitor_printf(mon
, " auth: %s\n", info
->auth
);
611 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
612 monitor_printf(mon
, " mouse-mode: %s\n",
613 SpiceQueryMouseMode_str(info
->mouse_mode
));
615 if (!info
->has_channels
|| info
->channels
== NULL
) {
616 monitor_printf(mon
, "Channels: none\n");
618 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
619 monitor_printf(mon
, "Channel:\n");
620 monitor_printf(mon
, " address: %s:%s%s\n",
621 chan
->value
->host
, chan
->value
->port
,
622 chan
->value
->tls
? " [tls]" : "");
623 monitor_printf(mon
, " session: %" PRId64
"\n",
624 chan
->value
->connection_id
);
625 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
626 chan
->value
->channel_type
, chan
->value
->channel_id
);
628 channel_name
= "unknown";
629 if (chan
->value
->channel_type
> 0 &&
630 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
631 channel_names
[chan
->value
->channel_type
]) {
632 channel_name
= channel_names
[chan
->value
->channel_type
];
635 monitor_printf(mon
, " channel name: %s\n", channel_name
);
640 qapi_free_SpiceInfo(info
);
644 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
649 info
= qmp_query_balloon(&err
);
651 hmp_handle_error(mon
, err
);
655 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
657 qapi_free_BalloonInfo(info
);
660 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
662 PciMemoryRegionList
*region
;
664 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
665 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
666 dev
->slot
, dev
->function
);
667 monitor_printf(mon
, " ");
669 if (dev
->class_info
->has_desc
) {
670 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
672 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
675 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
676 dev
->id
->vendor
, dev
->id
->device
);
677 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
678 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
679 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
683 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
686 if (dev
->has_pci_bridge
) {
687 monitor_printf(mon
, " BUS %" PRId64
".\n",
688 dev
->pci_bridge
->bus
->number
);
689 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
690 dev
->pci_bridge
->bus
->secondary
);
691 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
692 dev
->pci_bridge
->bus
->subordinate
);
694 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
695 dev
->pci_bridge
->bus
->io_range
->base
,
696 dev
->pci_bridge
->bus
->io_range
->limit
);
699 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
700 dev
->pci_bridge
->bus
->memory_range
->base
,
701 dev
->pci_bridge
->bus
->memory_range
->limit
);
703 monitor_printf(mon
, " prefetchable memory range "
704 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
705 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
706 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
709 for (region
= dev
->regions
; region
; region
= region
->next
) {
712 addr
= region
->value
->address
;
713 size
= region
->value
->size
;
715 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
717 if (!strcmp(region
->value
->type
, "io")) {
718 monitor_printf(mon
, "I/O at 0x%04" PRIx64
719 " [0x%04" PRIx64
"].\n",
720 addr
, addr
+ size
- 1);
722 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
723 " [0x%08" PRIx64
"].\n",
724 region
->value
->mem_type_64
? 64 : 32,
725 region
->value
->prefetch
? " prefetchable" : "",
726 addr
, addr
+ size
- 1);
730 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
732 if (dev
->has_pci_bridge
) {
733 if (dev
->pci_bridge
->has_devices
) {
734 PciDeviceInfoList
*cdev
;
735 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
736 hmp_info_pci_device(mon
, cdev
->value
);
742 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
744 InterruptStatsProvider
*intc
;
745 InterruptStatsProviderClass
*k
;
746 Monitor
*mon
= opaque
;
748 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
749 intc
= INTERRUPT_STATS_PROVIDER(obj
);
750 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
751 uint64_t *irq_counts
;
752 unsigned int nb_irqs
, i
;
753 if (k
->get_statistics
&&
754 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
756 monitor_printf(mon
, "IRQ statistics for %s:\n",
757 object_get_typename(obj
));
758 for (i
= 0; i
< nb_irqs
; i
++) {
759 if (irq_counts
[i
] > 0) {
760 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
766 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
767 object_get_typename(obj
));
774 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
776 object_child_foreach_recursive(object_get_root(),
777 hmp_info_irq_foreach
, mon
);
780 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
782 InterruptStatsProvider
*intc
;
783 InterruptStatsProviderClass
*k
;
784 Monitor
*mon
= opaque
;
786 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
787 intc
= INTERRUPT_STATS_PROVIDER(obj
);
788 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
790 k
->print_info(intc
, mon
);
792 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
793 object_get_typename(obj
));
800 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
802 object_child_foreach_recursive(object_get_root(),
803 hmp_info_pic_foreach
, mon
);
806 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
809 RdmaProviderClass
*k
;
810 Monitor
*mon
= opaque
;
812 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
813 rdma
= RDMA_PROVIDER(obj
);
814 k
= RDMA_PROVIDER_GET_CLASS(obj
);
815 if (k
->print_statistics
) {
816 k
->print_statistics(mon
, rdma
);
818 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
819 object_get_typename(obj
));
826 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
828 object_child_foreach_recursive(object_get_root(),
829 hmp_info_rdma_foreach
, mon
);
832 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
834 PciInfoList
*info_list
, *info
;
837 info_list
= qmp_query_pci(&err
);
839 monitor_printf(mon
, "PCI devices not supported\n");
844 for (info
= info_list
; info
; info
= info
->next
) {
845 PciDeviceInfoList
*dev
;
847 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
848 hmp_info_pci_device(mon
, dev
->value
);
852 qapi_free_PciInfoList(info_list
);
855 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
857 TPMInfoList
*info_list
, *info
;
860 TPMPassthroughOptions
*tpo
;
861 TPMEmulatorOptions
*teo
;
863 info_list
= qmp_query_tpm(&err
);
865 monitor_printf(mon
, "TPM device not supported\n");
871 monitor_printf(mon
, "TPM device:\n");
874 for (info
= info_list
; info
; info
= info
->next
) {
875 TPMInfo
*ti
= info
->value
;
876 monitor_printf(mon
, " tpm%d: model=%s\n",
877 c
, TpmModel_str(ti
->model
));
879 monitor_printf(mon
, " \\ %s: type=%s",
880 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
882 switch (ti
->options
->type
) {
883 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
884 tpo
= ti
->options
->u
.passthrough
.data
;
885 monitor_printf(mon
, "%s%s%s%s",
886 tpo
->has_path
? ",path=" : "",
887 tpo
->has_path
? tpo
->path
: "",
888 tpo
->has_cancel_path
? ",cancel-path=" : "",
889 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
891 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
892 teo
= ti
->options
->u
.emulator
.data
;
893 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
895 case TPM_TYPE_OPTIONS_KIND__MAX
:
898 monitor_printf(mon
, "\n");
901 qapi_free_TPMInfoList(info_list
);
904 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
906 monitor_suspend(mon
);
910 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
915 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
917 const char *op
= qdict_get_try_str(qdict
, "op");
920 bool on
= qsp_is_enabled();
922 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
925 if (!strcmp(op
, "on")) {
927 } else if (!strcmp(op
, "off")) {
929 } else if (!strcmp(op
, "reset")) {
934 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
935 hmp_handle_error(mon
, err
);
939 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
941 qmp_system_reset(NULL
);
944 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
946 qmp_system_powerdown(NULL
);
949 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
953 qmp_x_exit_preconfig(&err
);
954 hmp_handle_error(mon
, err
);
957 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
961 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
962 use it are converted to the QAPI */
963 cpu_index
= qdict_get_int(qdict
, "index");
964 if (monitor_set_cpu(cpu_index
) < 0) {
965 monitor_printf(mon
, "invalid CPU index\n");
969 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
971 uint32_t size
= qdict_get_int(qdict
, "size");
972 const char *filename
= qdict_get_str(qdict
, "filename");
973 uint64_t addr
= qdict_get_int(qdict
, "val");
975 int cpu_index
= monitor_get_cpu_index();
978 monitor_printf(mon
, "No CPU available\n");
982 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
983 hmp_handle_error(mon
, err
);
986 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
988 uint32_t size
= qdict_get_int(qdict
, "size");
989 const char *filename
= qdict_get_str(qdict
, "filename");
990 uint64_t addr
= qdict_get_int(qdict
, "val");
993 qmp_pmemsave(addr
, size
, filename
, &err
);
994 hmp_handle_error(mon
, err
);
997 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
999 const char *chardev
= qdict_get_str(qdict
, "device");
1000 const char *data
= qdict_get_str(qdict
, "data");
1003 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1005 hmp_handle_error(mon
, err
);
1008 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1010 uint32_t size
= qdict_get_int(qdict
, "size");
1011 const char *chardev
= qdict_get_str(qdict
, "device");
1016 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1018 hmp_handle_error(mon
, err
);
1022 for (i
= 0; data
[i
]; i
++) {
1023 unsigned char ch
= data
[i
];
1026 monitor_printf(mon
, "\\\\");
1027 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1028 monitor_printf(mon
, "\\u%04X", ch
);
1030 monitor_printf(mon
, "%c", ch
);
1034 monitor_printf(mon
, "\n");
1038 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1043 hmp_handle_error(mon
, err
);
1046 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1050 qmp_system_wakeup(&err
);
1051 hmp_handle_error(mon
, err
);
1054 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1058 qmp_inject_nmi(&err
);
1059 hmp_handle_error(mon
, err
);
1062 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1064 const char *name
= qdict_get_str(qdict
, "name");
1065 bool up
= qdict_get_bool(qdict
, "up");
1068 qmp_set_link(name
, up
, &err
);
1069 hmp_handle_error(mon
, err
);
1072 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1074 int64_t value
= qdict_get_int(qdict
, "value");
1077 qmp_balloon(value
, &err
);
1078 hmp_handle_error(mon
, err
);
1081 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1083 int saved_vm_running
= runstate_is_running();
1084 const char *name
= qdict_get_str(qdict
, "name");
1087 vm_stop(RUN_STATE_RESTORE_VM
);
1089 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1092 hmp_handle_error(mon
, err
);
1095 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1099 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1100 hmp_handle_error(mon
, err
);
1103 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1105 BlockDriverState
*bs
;
1107 const char *name
= qdict_get_str(qdict
, "name");
1109 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1111 "deleting snapshot on device '%s': ",
1112 bdrv_get_device_name(bs
));
1114 hmp_handle_error(mon
, err
);
1117 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1119 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1120 const char *id
= qdict_get_try_str(qdict
, "id");
1121 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1122 migrate_announce_params());
1124 qapi_free_strList(params
->interfaces
);
1125 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1126 params
->has_interfaces
= params
->interfaces
!= NULL
;
1127 params
->id
= g_strdup(id
);
1128 params
->has_id
= !!params
->id
;
1129 qmp_announce_self(params
, NULL
);
1130 qapi_free_AnnounceParameters(params
);
1133 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1135 qmp_migrate_cancel(NULL
);
1138 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1141 const char *state
= qdict_get_str(qdict
, "state");
1142 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1145 qmp_migrate_continue(val
, &err
);
1148 hmp_handle_error(mon
, err
);
1151 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1154 const char *uri
= qdict_get_str(qdict
, "uri");
1156 qmp_migrate_incoming(uri
, &err
);
1158 hmp_handle_error(mon
, err
);
1161 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1164 const char *uri
= qdict_get_str(qdict
, "uri");
1166 qmp_migrate_recover(uri
, &err
);
1168 hmp_handle_error(mon
, err
);
1171 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1175 qmp_migrate_pause(&err
);
1177 hmp_handle_error(mon
, err
);
1180 /* Kept for backwards compatibility */
1181 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1183 double value
= qdict_get_double(qdict
, "value");
1184 qmp_migrate_set_downtime(value
, NULL
);
1187 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1189 int64_t value
= qdict_get_int(qdict
, "value");
1192 qmp_migrate_set_cache_size(value
, &err
);
1193 hmp_handle_error(mon
, err
);
1196 /* Kept for backwards compatibility */
1197 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1199 int64_t value
= qdict_get_int(qdict
, "value");
1200 qmp_migrate_set_speed(value
, NULL
);
1203 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1205 const char *cap
= qdict_get_str(qdict
, "capability");
1206 bool state
= qdict_get_bool(qdict
, "state");
1208 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1211 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1216 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1217 caps
->value
->capability
= val
;
1218 caps
->value
->state
= state
;
1220 qmp_migrate_set_capabilities(caps
, &err
);
1223 qapi_free_MigrationCapabilityStatusList(caps
);
1224 hmp_handle_error(mon
, err
);
1227 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1229 const char *param
= qdict_get_str(qdict
, "parameter");
1230 const char *valuestr
= qdict_get_str(qdict
, "value");
1231 Visitor
*v
= string_input_visitor_new(valuestr
);
1232 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1233 uint64_t valuebw
= 0;
1234 uint64_t cache_size
;
1235 MultiFDCompression compress_type
;
1239 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1245 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1246 p
->has_compress_level
= true;
1247 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1249 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1250 p
->has_compress_threads
= true;
1251 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1253 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1254 p
->has_compress_wait_thread
= true;
1255 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1257 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1258 p
->has_decompress_threads
= true;
1259 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1261 case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
:
1262 p
->has_throttle_trigger_threshold
= true;
1263 visit_type_int(v
, param
, &p
->throttle_trigger_threshold
, &err
);
1264 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1265 p
->has_cpu_throttle_initial
= true;
1266 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1268 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1269 p
->has_cpu_throttle_increment
= true;
1270 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1272 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1273 p
->has_max_cpu_throttle
= true;
1274 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1276 case MIGRATION_PARAMETER_TLS_CREDS
:
1277 p
->has_tls_creds
= true;
1278 p
->tls_creds
= g_new0(StrOrNull
, 1);
1279 p
->tls_creds
->type
= QTYPE_QSTRING
;
1280 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1282 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1283 p
->has_tls_hostname
= true;
1284 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1285 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1286 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1288 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1289 p
->has_tls_authz
= true;
1290 p
->tls_authz
= g_new0(StrOrNull
, 1);
1291 p
->tls_authz
->type
= QTYPE_QSTRING
;
1292 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1294 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1295 p
->has_max_bandwidth
= true;
1297 * Can't use visit_type_size() here, because it
1298 * defaults to Bytes rather than Mebibytes.
1300 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1301 if (ret
< 0 || valuebw
> INT64_MAX
1302 || (size_t)valuebw
!= valuebw
) {
1303 error_setg(&err
, "Invalid size %s", valuestr
);
1306 p
->max_bandwidth
= valuebw
;
1308 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1309 p
->has_downtime_limit
= true;
1310 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1312 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1313 p
->has_x_checkpoint_delay
= true;
1314 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1316 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1317 p
->has_block_incremental
= true;
1318 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1320 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1321 p
->has_multifd_channels
= true;
1322 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1324 case MIGRATION_PARAMETER_MULTIFD_COMPRESSION
:
1325 p
->has_multifd_compression
= true;
1326 visit_type_MultiFDCompression(v
, param
, &compress_type
, &err
);
1330 p
->multifd_compression
= compress_type
;
1332 case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL
:
1333 p
->has_multifd_zlib_level
= true;
1334 visit_type_int(v
, param
, &p
->multifd_zlib_level
, &err
);
1336 case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL
:
1337 p
->has_multifd_zstd_level
= true;
1338 visit_type_int(v
, param
, &p
->multifd_zstd_level
, &err
);
1340 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1341 p
->has_xbzrle_cache_size
= true;
1342 visit_type_size(v
, param
, &cache_size
, &err
);
1346 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1347 error_setg(&err
, "Invalid size %s", valuestr
);
1350 p
->xbzrle_cache_size
= cache_size
;
1352 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1353 p
->has_max_postcopy_bandwidth
= true;
1354 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1356 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1357 p
->has_announce_initial
= true;
1358 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1360 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1361 p
->has_announce_max
= true;
1362 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1364 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1365 p
->has_announce_rounds
= true;
1366 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1368 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1369 p
->has_announce_step
= true;
1370 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1380 qmp_migrate_set_parameters(p
, &err
);
1383 qapi_free_MigrateSetParameters(p
);
1385 hmp_handle_error(mon
, err
);
1388 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1391 const char *protocol
= qdict_get_str(qdict
, "protocol");
1392 const char *hostname
= qdict_get_str(qdict
, "hostname");
1393 bool has_port
= qdict_haskey(qdict
, "port");
1394 int port
= qdict_get_try_int(qdict
, "port", -1);
1395 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1396 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1397 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1399 qmp_client_migrate_info(protocol
, hostname
,
1400 has_port
, port
, has_tls_port
, tls_port
,
1401 !!cert_subject
, cert_subject
, &err
);
1402 hmp_handle_error(mon
, err
);
1405 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1408 qmp_migrate_start_postcopy(&err
);
1409 hmp_handle_error(mon
, err
);
1412 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1416 qmp_x_colo_lost_heartbeat(&err
);
1417 hmp_handle_error(mon
, err
);
1420 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1422 const char *protocol
= qdict_get_str(qdict
, "protocol");
1423 const char *password
= qdict_get_str(qdict
, "password");
1424 const char *connected
= qdict_get_try_str(qdict
, "connected");
1427 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1428 hmp_handle_error(mon
, err
);
1431 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1433 const char *protocol
= qdict_get_str(qdict
, "protocol");
1434 const char *whenstr
= qdict_get_str(qdict
, "time");
1437 qmp_expire_password(protocol
, whenstr
, &err
);
1438 hmp_handle_error(mon
, err
);
1443 static void hmp_change_read_arg(void *opaque
, const char *password
,
1444 void *readline_opaque
)
1446 qmp_change_vnc_password(password
, NULL
);
1447 monitor_read_command(opaque
, 1);
1451 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1453 const char *device
= qdict_get_str(qdict
, "device");
1454 const char *target
= qdict_get_str(qdict
, "target");
1455 const char *arg
= qdict_get_try_str(qdict
, "arg");
1456 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1457 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1461 if (strcmp(device
, "vnc") == 0) {
1464 "Parameter 'read-only-mode' is invalid for VNC\n");
1467 if (strcmp(target
, "passwd") == 0 ||
1468 strcmp(target
, "password") == 0) {
1470 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1471 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1475 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1481 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1483 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1485 hmp_handle_error(mon
, err
);
1490 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1491 !!arg
, arg
, !!read_only
, read_only_mode
,
1495 hmp_handle_error(mon
, err
);
1498 typedef struct HMPMigrationStatus
1502 bool is_block_migration
;
1503 } HMPMigrationStatus
;
1505 static void hmp_migrate_status_cb(void *opaque
)
1507 HMPMigrationStatus
*status
= opaque
;
1508 MigrationInfo
*info
;
1510 info
= qmp_query_migrate(NULL
);
1511 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1512 info
->status
== MIGRATION_STATUS_SETUP
) {
1513 if (info
->has_disk
) {
1516 if (info
->disk
->remaining
) {
1517 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1522 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1523 monitor_flush(status
->mon
);
1526 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1528 if (status
->is_block_migration
) {
1529 monitor_printf(status
->mon
, "\n");
1531 if (info
->has_error_desc
) {
1532 error_report("%s", info
->error_desc
);
1534 monitor_resume(status
->mon
);
1535 timer_del(status
->timer
);
1536 timer_free(status
->timer
);
1540 qapi_free_MigrationInfo(info
);
1543 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1545 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1546 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1547 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1548 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1549 const char *uri
= qdict_get_str(qdict
, "uri");
1552 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1553 false, false, true, resume
, &err
);
1555 hmp_handle_error(mon
, err
);
1560 HMPMigrationStatus
*status
;
1562 if (monitor_suspend(mon
) < 0) {
1563 monitor_printf(mon
, "terminal does not allow synchronous "
1564 "migration, continuing detached\n");
1568 status
= g_malloc0(sizeof(*status
));
1570 status
->is_block_migration
= blk
|| inc
;
1571 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1573 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1577 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1582 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1587 netdev_add(opts
, &err
);
1589 qemu_opts_del(opts
);
1593 hmp_handle_error(mon
, err
);
1596 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1598 const char *id
= qdict_get_str(qdict
, "id");
1601 qmp_netdev_del(id
, &err
);
1602 hmp_handle_error(mon
, err
);
1605 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1611 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1613 hmp_handle_error(mon
, err
);
1617 obj
= user_creatable_add_opts(opts
, &err
);
1618 qemu_opts_del(opts
);
1621 hmp_handle_error(mon
, err
);
1628 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1630 const char *fdname
= qdict_get_str(qdict
, "fdname");
1633 qmp_getfd(fdname
, &err
);
1634 hmp_handle_error(mon
, err
);
1637 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1639 const char *fdname
= qdict_get_str(qdict
, "fdname");
1642 qmp_closefd(fdname
, &err
);
1643 hmp_handle_error(mon
, err
);
1646 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1648 const char *keys
= qdict_get_str(qdict
, "keys");
1649 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1650 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1651 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1653 const char *separator
;
1657 separator
= qemu_strchrnul(keys
, '-');
1658 keyname_len
= separator
- keys
;
1660 /* Be compatible with old interface, convert user inputted "<" */
1661 if (keys
[0] == '<' && keyname_len
== 1) {
1666 keylist
= g_malloc0(sizeof(*keylist
));
1667 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1673 tmp
->next
= keylist
;
1677 if (strstart(keys
, "0x", NULL
)) {
1679 int value
= strtoul(keys
, &endp
, 0);
1680 assert(endp
<= keys
+ keyname_len
);
1681 if (endp
!= keys
+ keyname_len
) {
1684 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1685 keylist
->value
->u
.number
.data
= value
;
1687 int idx
= index_from_key(keys
, keyname_len
);
1688 if (idx
== Q_KEY_CODE__MAX
) {
1691 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1692 keylist
->value
->u
.qcode
.data
= idx
;
1698 keys
= separator
+ 1;
1701 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1702 hmp_handle_error(mon
, err
);
1705 qapi_free_KeyValueList(head
);
1709 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1713 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1715 const char *filename
= qdict_get_str(qdict
, "filename");
1716 const char *id
= qdict_get_try_str(qdict
, "device");
1717 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
1720 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
1721 hmp_handle_error(mon
, err
);
1724 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1726 const char *args
= qdict_get_str(qdict
, "args");
1730 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1732 error_setg(&err
, "Parsing chardev args failed");
1734 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1735 qemu_opts_del(opts
);
1737 hmp_handle_error(mon
, err
);
1740 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
1742 const char *args
= qdict_get_str(qdict
, "args");
1745 ChardevBackend
*backend
= NULL
;
1746 ChardevReturn
*ret
= NULL
;
1747 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
1750 error_setg(&err
, "Parsing chardev args failed");
1754 id
= qdict_get_str(qdict
, "id");
1755 if (qemu_opts_id(opts
)) {
1756 error_setg(&err
, "Unexpected 'id' parameter");
1760 backend
= qemu_chr_parse_opts(opts
, &err
);
1765 ret
= qmp_chardev_change(id
, backend
, &err
);
1768 qapi_free_ChardevReturn(ret
);
1769 qapi_free_ChardevBackend(backend
);
1770 qemu_opts_del(opts
);
1771 hmp_handle_error(mon
, err
);
1774 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1776 Error
*local_err
= NULL
;
1778 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1779 hmp_handle_error(mon
, local_err
);
1782 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
1784 Error
*local_err
= NULL
;
1786 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
1787 hmp_handle_error(mon
, local_err
);
1790 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1792 const char *id
= qdict_get_str(qdict
, "id");
1795 user_creatable_del(id
, &err
);
1796 hmp_handle_error(mon
, err
);
1799 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1802 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1803 MemoryDeviceInfoList
*info
;
1804 VirtioPMEMDeviceInfo
*vpi
;
1805 MemoryDeviceInfo
*value
;
1806 PCDIMMDeviceInfo
*di
;
1808 for (info
= info_list
; info
; info
= info
->next
) {
1809 value
= info
->value
;
1812 switch (value
->type
) {
1813 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1814 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
1815 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
1816 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
1817 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1818 MemoryDeviceInfoKind_str(value
->type
),
1819 di
->id
? di
->id
: "");
1820 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1821 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1822 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1823 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1824 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1825 monitor_printf(mon
, " hotplugged: %s\n",
1826 di
->hotplugged
? "true" : "false");
1827 monitor_printf(mon
, " hotpluggable: %s\n",
1828 di
->hotpluggable
? "true" : "false");
1830 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
1831 vpi
= value
->u
.virtio_pmem
.data
;
1832 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1833 MemoryDeviceInfoKind_str(value
->type
),
1834 vpi
->id
? vpi
->id
: "");
1835 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
1836 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
1837 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
1840 g_assert_not_reached();
1845 qapi_free_MemoryDeviceInfoList(info_list
);
1846 hmp_handle_error(mon
, err
);
1849 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
1851 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
1852 IOThreadInfoList
*info
;
1853 IOThreadInfo
*value
;
1855 for (info
= info_list
; info
; info
= info
->next
) {
1856 value
= info
->value
;
1857 monitor_printf(mon
, "%s:\n", value
->id
);
1858 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
1859 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
1860 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
1861 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
1864 qapi_free_IOThreadInfoList(info_list
);
1867 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
1869 const char *name
= qdict_get_str(qdict
, "name");
1870 RockerSwitch
*rocker
;
1873 rocker
= qmp_query_rocker(name
, &err
);
1875 hmp_handle_error(mon
, err
);
1879 monitor_printf(mon
, "name: %s\n", rocker
->name
);
1880 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
1881 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
1883 qapi_free_RockerSwitch(rocker
);
1886 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
1888 RockerPortList
*list
, *port
;
1889 const char *name
= qdict_get_str(qdict
, "name");
1892 list
= qmp_query_rocker_ports(name
, &err
);
1894 hmp_handle_error(mon
, err
);
1898 monitor_printf(mon
, " ena/ speed/ auto\n");
1899 monitor_printf(mon
, " port link duplex neg?\n");
1901 for (port
= list
; port
; port
= port
->next
) {
1902 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
1904 port
->value
->enabled
? port
->value
->link_up
?
1905 "up" : "down" : "!ena",
1906 port
->value
->speed
== 10000 ? "10G" : "??",
1907 port
->value
->duplex
? "FD" : "HD",
1908 port
->value
->autoneg
? "Yes" : "No");
1911 qapi_free_RockerPortList(list
);
1914 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
1916 RockerOfDpaFlowList
*list
, *info
;
1917 const char *name
= qdict_get_str(qdict
, "name");
1918 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
1921 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
1923 hmp_handle_error(mon
, err
);
1927 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
1929 for (info
= list
; info
; info
= info
->next
) {
1930 RockerOfDpaFlow
*flow
= info
->value
;
1931 RockerOfDpaFlowKey
*key
= flow
->key
;
1932 RockerOfDpaFlowMask
*mask
= flow
->mask
;
1933 RockerOfDpaFlowAction
*action
= flow
->action
;
1936 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
1937 key
->priority
, key
->tbl_id
, flow
->hits
);
1939 monitor_printf(mon
, "%-4d %-3d ",
1940 key
->priority
, key
->tbl_id
);
1943 if (key
->has_in_pport
) {
1944 monitor_printf(mon
, " pport %d", key
->in_pport
);
1945 if (mask
->has_in_pport
) {
1946 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
1950 if (key
->has_vlan_id
) {
1951 monitor_printf(mon
, " vlan %d",
1952 key
->vlan_id
& VLAN_VID_MASK
);
1953 if (mask
->has_vlan_id
) {
1954 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
1958 if (key
->has_tunnel_id
) {
1959 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
1960 if (mask
->has_tunnel_id
) {
1961 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
1965 if (key
->has_eth_type
) {
1966 switch (key
->eth_type
) {
1968 monitor_printf(mon
, " ARP");
1971 monitor_printf(mon
, " IP");
1974 monitor_printf(mon
, " IPv6");
1977 monitor_printf(mon
, " LACP");
1980 monitor_printf(mon
, " LLDP");
1983 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
1988 if (key
->has_eth_src
) {
1989 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
1990 (mask
->has_eth_src
) &&
1991 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
1992 monitor_printf(mon
, " src <any mcast/bcast>");
1993 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
1994 (mask
->has_eth_src
) &&
1995 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
1996 monitor_printf(mon
, " src <any ucast>");
1998 monitor_printf(mon
, " src %s", key
->eth_src
);
1999 if (mask
->has_eth_src
) {
2000 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2005 if (key
->has_eth_dst
) {
2006 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2007 (mask
->has_eth_dst
) &&
2008 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2009 monitor_printf(mon
, " dst <any mcast/bcast>");
2010 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2011 (mask
->has_eth_dst
) &&
2012 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2013 monitor_printf(mon
, " dst <any ucast>");
2015 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2016 if (mask
->has_eth_dst
) {
2017 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2022 if (key
->has_ip_proto
) {
2023 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2024 if (mask
->has_ip_proto
) {
2025 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2029 if (key
->has_ip_tos
) {
2030 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2031 if (mask
->has_ip_tos
) {
2032 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2036 if (key
->has_ip_dst
) {
2037 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2040 if (action
->has_goto_tbl
|| action
->has_group_id
||
2041 action
->has_new_vlan_id
) {
2042 monitor_printf(mon
, " -->");
2045 if (action
->has_new_vlan_id
) {
2046 monitor_printf(mon
, " apply new vlan %d",
2047 ntohs(action
->new_vlan_id
));
2050 if (action
->has_group_id
) {
2051 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2054 if (action
->has_goto_tbl
) {
2055 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2058 monitor_printf(mon
, "\n");
2061 qapi_free_RockerOfDpaFlowList(list
);
2064 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2066 RockerOfDpaGroupList
*list
, *g
;
2067 const char *name
= qdict_get_str(qdict
, "name");
2068 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2071 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2073 hmp_handle_error(mon
, err
);
2077 monitor_printf(mon
, "id (decode) --> buckets\n");
2079 for (g
= list
; g
; g
= g
->next
) {
2080 RockerOfDpaGroup
*group
= g
->value
;
2083 monitor_printf(mon
, "0x%08x", group
->id
);
2085 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2086 group
->type
== 1 ? "L2 rewrite" :
2087 group
->type
== 2 ? "L3 unicast" :
2088 group
->type
== 3 ? "L2 multicast" :
2089 group
->type
== 4 ? "L2 flood" :
2090 group
->type
== 5 ? "L3 interface" :
2091 group
->type
== 6 ? "L3 multicast" :
2092 group
->type
== 7 ? "L3 ECMP" :
2093 group
->type
== 8 ? "L2 overlay" :
2096 if (group
->has_vlan_id
) {
2097 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2100 if (group
->has_pport
) {
2101 monitor_printf(mon
, " pport %d", group
->pport
);
2104 if (group
->has_index
) {
2105 monitor_printf(mon
, " index %d", group
->index
);
2108 monitor_printf(mon
, ") -->");
2110 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2112 monitor_printf(mon
, " set vlan %d",
2113 group
->set_vlan_id
& VLAN_VID_MASK
);
2116 if (group
->has_set_eth_src
) {
2119 monitor_printf(mon
, " set");
2121 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2124 if (group
->has_set_eth_dst
) {
2126 monitor_printf(mon
, " set");
2128 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2131 if (group
->has_ttl_check
&& group
->ttl_check
) {
2132 monitor_printf(mon
, " check TTL");
2135 if (group
->has_group_id
&& group
->group_id
) {
2136 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2139 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2140 monitor_printf(mon
, " pop vlan");
2143 if (group
->has_out_pport
) {
2144 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2147 if (group
->has_group_ids
) {
2148 struct uint32List
*id
;
2150 monitor_printf(mon
, " groups [");
2151 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2152 monitor_printf(mon
, "0x%08x", id
->value
);
2154 monitor_printf(mon
, ",");
2157 monitor_printf(mon
, "]");
2160 monitor_printf(mon
, "\n");
2163 qapi_free_RockerOfDpaGroupList(list
);
2166 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2168 ram_block_dump(mon
);
2171 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2174 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2176 monitor_printf(mon
, "%s\n", info
->guid
);
2178 hmp_handle_error(mon
, err
);
2179 qapi_free_GuidInfo(info
);
2182 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2185 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2187 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2190 if (info
->has_plugged_memory
) {
2191 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2192 info
->plugged_memory
);
2195 qapi_free_MemoryInfo(info
);
2197 hmp_handle_error(mon
, err
);