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
,
339 visit_complete(v
, &str
);
340 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
344 if (info
->has_socket_address
) {
345 SocketAddressList
*addr
;
347 monitor_printf(mon
, "socket address: [\n");
349 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
350 char *s
= SocketAddress_to_str(addr
->value
);
351 monitor_printf(mon
, "\t%s\n", s
);
354 monitor_printf(mon
, "]\n");
356 qapi_free_MigrationInfo(info
);
359 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
361 MigrationCapabilityStatusList
*caps
, *cap
;
363 caps
= qmp_query_migrate_capabilities(NULL
);
366 for (cap
= caps
; cap
; cap
= cap
->next
) {
367 monitor_printf(mon
, "%s: %s\n",
368 MigrationCapability_str(cap
->value
->capability
),
369 cap
->value
->state
? "on" : "off");
373 qapi_free_MigrationCapabilityStatusList(caps
);
376 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
378 MigrationParameters
*params
;
380 params
= qmp_query_migrate_parameters(NULL
);
383 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
384 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
385 params
->announce_initial
);
386 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
387 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
388 params
->announce_max
);
389 monitor_printf(mon
, "%s: %" PRIu64
"\n",
390 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
391 params
->announce_rounds
);
392 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
393 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
394 params
->announce_step
);
395 assert(params
->has_compress_level
);
396 monitor_printf(mon
, "%s: %u\n",
397 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
398 params
->compress_level
);
399 assert(params
->has_compress_threads
);
400 monitor_printf(mon
, "%s: %u\n",
401 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
402 params
->compress_threads
);
403 assert(params
->has_compress_wait_thread
);
404 monitor_printf(mon
, "%s: %s\n",
405 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
406 params
->compress_wait_thread
? "on" : "off");
407 assert(params
->has_decompress_threads
);
408 monitor_printf(mon
, "%s: %u\n",
409 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
410 params
->decompress_threads
);
411 assert(params
->has_throttle_trigger_threshold
);
412 monitor_printf(mon
, "%s: %u\n",
413 MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
),
414 params
->throttle_trigger_threshold
);
415 assert(params
->has_cpu_throttle_initial
);
416 monitor_printf(mon
, "%s: %u\n",
417 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
418 params
->cpu_throttle_initial
);
419 assert(params
->has_cpu_throttle_increment
);
420 monitor_printf(mon
, "%s: %u\n",
421 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
422 params
->cpu_throttle_increment
);
423 assert(params
->has_max_cpu_throttle
);
424 monitor_printf(mon
, "%s: %u\n",
425 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
426 params
->max_cpu_throttle
);
427 assert(params
->has_tls_creds
);
428 monitor_printf(mon
, "%s: '%s'\n",
429 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
431 assert(params
->has_tls_hostname
);
432 monitor_printf(mon
, "%s: '%s'\n",
433 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
434 params
->tls_hostname
);
435 assert(params
->has_max_bandwidth
);
436 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
437 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
438 params
->max_bandwidth
);
439 assert(params
->has_downtime_limit
);
440 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
441 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
442 params
->downtime_limit
);
443 assert(params
->has_x_checkpoint_delay
);
444 monitor_printf(mon
, "%s: %u\n",
445 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
446 params
->x_checkpoint_delay
);
447 assert(params
->has_block_incremental
);
448 monitor_printf(mon
, "%s: %s\n",
449 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
450 params
->block_incremental
? "on" : "off");
451 monitor_printf(mon
, "%s: %u\n",
452 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS
),
453 params
->multifd_channels
);
454 monitor_printf(mon
, "%s: %s\n",
455 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION
),
456 MultiFDCompression_str(params
->multifd_compression
));
457 monitor_printf(mon
, "%s: %" PRIu64
"\n",
458 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
459 params
->xbzrle_cache_size
);
460 monitor_printf(mon
, "%s: %" PRIu64
"\n",
461 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
462 params
->max_postcopy_bandwidth
);
463 monitor_printf(mon
, "%s: '%s'\n",
464 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
468 qapi_free_MigrationParameters(params
);
471 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
473 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
474 qmp_query_migrate_cache_size(NULL
) >> 10);
479 /* Helper for hmp_info_vnc_clients, _servers */
480 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
483 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
487 NetworkAddressFamily_str(info
->family
),
488 info
->websocket
? " (Websocket)" : "");
491 /* Helper displaying and auth and crypt info */
492 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
494 VncVencryptSubAuth
*vencrypt
)
496 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
497 VncPrimaryAuth_str(auth
),
498 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
501 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
504 VncClientInfo
*cinfo
= client
->value
;
506 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
507 monitor_printf(mon
, " x509_dname: %s\n",
508 cinfo
->has_x509_dname
?
509 cinfo
->x509_dname
: "none");
510 monitor_printf(mon
, " sasl_username: %s\n",
511 cinfo
->has_sasl_username
?
512 cinfo
->sasl_username
: "none");
514 client
= client
->next
;
518 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
521 VncServerInfo2
*sinfo
= server
->value
;
522 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
523 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
524 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
525 server
= server
->next
;
529 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
531 VncInfo2List
*info2l
, *info2l_head
;
534 info2l
= qmp_query_vnc_servers(&err
);
535 info2l_head
= info2l
;
537 hmp_handle_error(mon
, err
);
541 monitor_printf(mon
, "None\n");
546 VncInfo2
*info
= info2l
->value
;
547 monitor_printf(mon
, "%s:\n", info
->id
);
548 hmp_info_vnc_servers(mon
, info
->server
);
549 hmp_info_vnc_clients(mon
, info
->clients
);
551 /* The server entry displays its auth, we only
552 * need to display in the case of 'reverse' connections
553 * where there's no server.
555 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
556 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
558 if (info
->has_display
) {
559 monitor_printf(mon
, " Display: %s\n", info
->display
);
561 info2l
= info2l
->next
;
564 qapi_free_VncInfo2List(info2l_head
);
570 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
572 SpiceChannelList
*chan
;
574 const char *channel_name
;
575 const char * const channel_names
[] = {
576 [SPICE_CHANNEL_MAIN
] = "main",
577 [SPICE_CHANNEL_DISPLAY
] = "display",
578 [SPICE_CHANNEL_INPUTS
] = "inputs",
579 [SPICE_CHANNEL_CURSOR
] = "cursor",
580 [SPICE_CHANNEL_PLAYBACK
] = "playback",
581 [SPICE_CHANNEL_RECORD
] = "record",
582 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
583 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
584 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
585 [SPICE_CHANNEL_PORT
] = "port",
587 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
588 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
589 * as quick fix for build failures with older versions. */
590 [SPICE_CHANNEL_WEBDAV
] = "webdav",
594 info
= qmp_query_spice(NULL
);
596 if (!info
->enabled
) {
597 monitor_printf(mon
, "Server: disabled\n");
601 monitor_printf(mon
, "Server:\n");
602 if (info
->has_port
) {
603 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
604 info
->host
, info
->port
);
606 if (info
->has_tls_port
) {
607 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
608 info
->host
, info
->tls_port
);
610 monitor_printf(mon
, " migrated: %s\n",
611 info
->migrated
? "true" : "false");
612 monitor_printf(mon
, " auth: %s\n", info
->auth
);
613 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
614 monitor_printf(mon
, " mouse-mode: %s\n",
615 SpiceQueryMouseMode_str(info
->mouse_mode
));
617 if (!info
->has_channels
|| info
->channels
== NULL
) {
618 monitor_printf(mon
, "Channels: none\n");
620 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
621 monitor_printf(mon
, "Channel:\n");
622 monitor_printf(mon
, " address: %s:%s%s\n",
623 chan
->value
->host
, chan
->value
->port
,
624 chan
->value
->tls
? " [tls]" : "");
625 monitor_printf(mon
, " session: %" PRId64
"\n",
626 chan
->value
->connection_id
);
627 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
628 chan
->value
->channel_type
, chan
->value
->channel_id
);
630 channel_name
= "unknown";
631 if (chan
->value
->channel_type
> 0 &&
632 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
633 channel_names
[chan
->value
->channel_type
]) {
634 channel_name
= channel_names
[chan
->value
->channel_type
];
637 monitor_printf(mon
, " channel name: %s\n", channel_name
);
642 qapi_free_SpiceInfo(info
);
646 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
651 info
= qmp_query_balloon(&err
);
653 hmp_handle_error(mon
, err
);
657 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
659 qapi_free_BalloonInfo(info
);
662 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
664 PciMemoryRegionList
*region
;
666 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
667 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
668 dev
->slot
, dev
->function
);
669 monitor_printf(mon
, " ");
671 if (dev
->class_info
->has_desc
) {
672 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
674 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
677 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
678 dev
->id
->vendor
, dev
->id
->device
);
679 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
680 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
681 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
685 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
688 if (dev
->has_pci_bridge
) {
689 monitor_printf(mon
, " BUS %" PRId64
".\n",
690 dev
->pci_bridge
->bus
->number
);
691 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
692 dev
->pci_bridge
->bus
->secondary
);
693 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
694 dev
->pci_bridge
->bus
->subordinate
);
696 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
697 dev
->pci_bridge
->bus
->io_range
->base
,
698 dev
->pci_bridge
->bus
->io_range
->limit
);
701 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
702 dev
->pci_bridge
->bus
->memory_range
->base
,
703 dev
->pci_bridge
->bus
->memory_range
->limit
);
705 monitor_printf(mon
, " prefetchable memory range "
706 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
707 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
708 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
711 for (region
= dev
->regions
; region
; region
= region
->next
) {
714 addr
= region
->value
->address
;
715 size
= region
->value
->size
;
717 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
719 if (!strcmp(region
->value
->type
, "io")) {
720 monitor_printf(mon
, "I/O at 0x%04" PRIx64
721 " [0x%04" PRIx64
"].\n",
722 addr
, addr
+ size
- 1);
724 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
725 " [0x%08" PRIx64
"].\n",
726 region
->value
->mem_type_64
? 64 : 32,
727 region
->value
->prefetch
? " prefetchable" : "",
728 addr
, addr
+ size
- 1);
732 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
734 if (dev
->has_pci_bridge
) {
735 if (dev
->pci_bridge
->has_devices
) {
736 PciDeviceInfoList
*cdev
;
737 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
738 hmp_info_pci_device(mon
, cdev
->value
);
744 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
746 InterruptStatsProvider
*intc
;
747 InterruptStatsProviderClass
*k
;
748 Monitor
*mon
= opaque
;
750 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
751 intc
= INTERRUPT_STATS_PROVIDER(obj
);
752 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
753 uint64_t *irq_counts
;
754 unsigned int nb_irqs
, i
;
755 if (k
->get_statistics
&&
756 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
758 monitor_printf(mon
, "IRQ statistics for %s:\n",
759 object_get_typename(obj
));
760 for (i
= 0; i
< nb_irqs
; i
++) {
761 if (irq_counts
[i
] > 0) {
762 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
768 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
769 object_get_typename(obj
));
776 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
778 object_child_foreach_recursive(object_get_root(),
779 hmp_info_irq_foreach
, mon
);
782 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
784 InterruptStatsProvider
*intc
;
785 InterruptStatsProviderClass
*k
;
786 Monitor
*mon
= opaque
;
788 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
789 intc
= INTERRUPT_STATS_PROVIDER(obj
);
790 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
792 k
->print_info(intc
, mon
);
794 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
795 object_get_typename(obj
));
802 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
804 object_child_foreach_recursive(object_get_root(),
805 hmp_info_pic_foreach
, mon
);
808 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
811 RdmaProviderClass
*k
;
812 Monitor
*mon
= opaque
;
814 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
815 rdma
= RDMA_PROVIDER(obj
);
816 k
= RDMA_PROVIDER_GET_CLASS(obj
);
817 if (k
->print_statistics
) {
818 k
->print_statistics(mon
, rdma
);
820 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
821 object_get_typename(obj
));
828 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
830 object_child_foreach_recursive(object_get_root(),
831 hmp_info_rdma_foreach
, mon
);
834 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
836 PciInfoList
*info_list
, *info
;
839 info_list
= qmp_query_pci(&err
);
841 monitor_printf(mon
, "PCI devices not supported\n");
846 for (info
= info_list
; info
; info
= info
->next
) {
847 PciDeviceInfoList
*dev
;
849 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
850 hmp_info_pci_device(mon
, dev
->value
);
854 qapi_free_PciInfoList(info_list
);
857 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
859 TPMInfoList
*info_list
, *info
;
862 TPMPassthroughOptions
*tpo
;
863 TPMEmulatorOptions
*teo
;
865 info_list
= qmp_query_tpm(&err
);
867 monitor_printf(mon
, "TPM device not supported\n");
873 monitor_printf(mon
, "TPM device:\n");
876 for (info
= info_list
; info
; info
= info
->next
) {
877 TPMInfo
*ti
= info
->value
;
878 monitor_printf(mon
, " tpm%d: model=%s\n",
879 c
, TpmModel_str(ti
->model
));
881 monitor_printf(mon
, " \\ %s: type=%s",
882 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
884 switch (ti
->options
->type
) {
885 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
886 tpo
= ti
->options
->u
.passthrough
.data
;
887 monitor_printf(mon
, "%s%s%s%s",
888 tpo
->has_path
? ",path=" : "",
889 tpo
->has_path
? tpo
->path
: "",
890 tpo
->has_cancel_path
? ",cancel-path=" : "",
891 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
893 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
894 teo
= ti
->options
->u
.emulator
.data
;
895 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
897 case TPM_TYPE_OPTIONS_KIND__MAX
:
900 monitor_printf(mon
, "\n");
903 qapi_free_TPMInfoList(info_list
);
906 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
908 monitor_suspend(mon
);
912 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
917 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
919 const char *op
= qdict_get_try_str(qdict
, "op");
922 bool on
= qsp_is_enabled();
924 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
927 if (!strcmp(op
, "on")) {
929 } else if (!strcmp(op
, "off")) {
931 } else if (!strcmp(op
, "reset")) {
936 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
937 hmp_handle_error(mon
, err
);
941 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
943 qmp_system_reset(NULL
);
946 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
948 qmp_system_powerdown(NULL
);
951 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
955 qmp_x_exit_preconfig(&err
);
956 hmp_handle_error(mon
, err
);
959 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
963 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
964 use it are converted to the QAPI */
965 cpu_index
= qdict_get_int(qdict
, "index");
966 if (monitor_set_cpu(cpu_index
) < 0) {
967 monitor_printf(mon
, "invalid CPU index\n");
971 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
973 uint32_t size
= qdict_get_int(qdict
, "size");
974 const char *filename
= qdict_get_str(qdict
, "filename");
975 uint64_t addr
= qdict_get_int(qdict
, "val");
977 int cpu_index
= monitor_get_cpu_index();
980 monitor_printf(mon
, "No CPU available\n");
984 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
985 hmp_handle_error(mon
, err
);
988 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
990 uint32_t size
= qdict_get_int(qdict
, "size");
991 const char *filename
= qdict_get_str(qdict
, "filename");
992 uint64_t addr
= qdict_get_int(qdict
, "val");
995 qmp_pmemsave(addr
, size
, filename
, &err
);
996 hmp_handle_error(mon
, err
);
999 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1001 const char *chardev
= qdict_get_str(qdict
, "device");
1002 const char *data
= qdict_get_str(qdict
, "data");
1005 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1007 hmp_handle_error(mon
, err
);
1010 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1012 uint32_t size
= qdict_get_int(qdict
, "size");
1013 const char *chardev
= qdict_get_str(qdict
, "device");
1018 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1020 hmp_handle_error(mon
, err
);
1024 for (i
= 0; data
[i
]; i
++) {
1025 unsigned char ch
= data
[i
];
1028 monitor_printf(mon
, "\\\\");
1029 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1030 monitor_printf(mon
, "\\u%04X", ch
);
1032 monitor_printf(mon
, "%c", ch
);
1036 monitor_printf(mon
, "\n");
1040 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1045 hmp_handle_error(mon
, err
);
1048 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1052 qmp_system_wakeup(&err
);
1053 hmp_handle_error(mon
, err
);
1056 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1060 qmp_inject_nmi(&err
);
1061 hmp_handle_error(mon
, err
);
1064 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1066 const char *name
= qdict_get_str(qdict
, "name");
1067 bool up
= qdict_get_bool(qdict
, "up");
1070 qmp_set_link(name
, up
, &err
);
1071 hmp_handle_error(mon
, err
);
1074 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1076 int64_t value
= qdict_get_int(qdict
, "value");
1079 qmp_balloon(value
, &err
);
1080 hmp_handle_error(mon
, err
);
1083 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1085 int saved_vm_running
= runstate_is_running();
1086 const char *name
= qdict_get_str(qdict
, "name");
1089 vm_stop(RUN_STATE_RESTORE_VM
);
1091 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1094 hmp_handle_error(mon
, err
);
1097 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1101 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1102 hmp_handle_error(mon
, err
);
1105 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1107 BlockDriverState
*bs
;
1109 const char *name
= qdict_get_str(qdict
, "name");
1111 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1113 "deleting snapshot on device '%s': ",
1114 bdrv_get_device_name(bs
));
1116 hmp_handle_error(mon
, err
);
1119 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1121 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1122 const char *id
= qdict_get_try_str(qdict
, "id");
1123 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1124 migrate_announce_params());
1126 qapi_free_strList(params
->interfaces
);
1127 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1128 params
->has_interfaces
= params
->interfaces
!= NULL
;
1129 params
->id
= g_strdup(id
);
1130 params
->has_id
= !!params
->id
;
1131 qmp_announce_self(params
, NULL
);
1132 qapi_free_AnnounceParameters(params
);
1135 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1137 qmp_migrate_cancel(NULL
);
1140 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1143 const char *state
= qdict_get_str(qdict
, "state");
1144 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1147 qmp_migrate_continue(val
, &err
);
1150 hmp_handle_error(mon
, err
);
1153 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1156 const char *uri
= qdict_get_str(qdict
, "uri");
1158 qmp_migrate_incoming(uri
, &err
);
1160 hmp_handle_error(mon
, err
);
1163 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1166 const char *uri
= qdict_get_str(qdict
, "uri");
1168 qmp_migrate_recover(uri
, &err
);
1170 hmp_handle_error(mon
, err
);
1173 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1177 qmp_migrate_pause(&err
);
1179 hmp_handle_error(mon
, err
);
1182 /* Kept for backwards compatibility */
1183 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1185 double value
= qdict_get_double(qdict
, "value");
1186 qmp_migrate_set_downtime(value
, NULL
);
1189 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1191 int64_t value
= qdict_get_int(qdict
, "value");
1194 qmp_migrate_set_cache_size(value
, &err
);
1195 hmp_handle_error(mon
, err
);
1198 /* Kept for backwards compatibility */
1199 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1201 int64_t value
= qdict_get_int(qdict
, "value");
1202 qmp_migrate_set_speed(value
, NULL
);
1205 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1207 const char *cap
= qdict_get_str(qdict
, "capability");
1208 bool state
= qdict_get_bool(qdict
, "state");
1210 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1213 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1218 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1219 caps
->value
->capability
= val
;
1220 caps
->value
->state
= state
;
1222 qmp_migrate_set_capabilities(caps
, &err
);
1225 qapi_free_MigrationCapabilityStatusList(caps
);
1226 hmp_handle_error(mon
, err
);
1229 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1231 const char *param
= qdict_get_str(qdict
, "parameter");
1232 const char *valuestr
= qdict_get_str(qdict
, "value");
1233 Visitor
*v
= string_input_visitor_new(valuestr
);
1234 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1235 uint64_t valuebw
= 0;
1236 uint64_t cache_size
;
1237 MultiFDCompression compress_type
;
1241 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1247 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1248 p
->has_compress_level
= true;
1249 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1251 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1252 p
->has_compress_threads
= true;
1253 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1255 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1256 p
->has_compress_wait_thread
= true;
1257 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1259 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1260 p
->has_decompress_threads
= true;
1261 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1263 case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
:
1264 p
->has_throttle_trigger_threshold
= true;
1265 visit_type_int(v
, param
, &p
->throttle_trigger_threshold
, &err
);
1267 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1268 p
->has_cpu_throttle_initial
= true;
1269 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1271 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1272 p
->has_cpu_throttle_increment
= true;
1273 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1275 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1276 p
->has_max_cpu_throttle
= true;
1277 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1279 case MIGRATION_PARAMETER_TLS_CREDS
:
1280 p
->has_tls_creds
= true;
1281 p
->tls_creds
= g_new0(StrOrNull
, 1);
1282 p
->tls_creds
->type
= QTYPE_QSTRING
;
1283 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1285 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1286 p
->has_tls_hostname
= true;
1287 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1288 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1289 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1291 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1292 p
->has_tls_authz
= true;
1293 p
->tls_authz
= g_new0(StrOrNull
, 1);
1294 p
->tls_authz
->type
= QTYPE_QSTRING
;
1295 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1297 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1298 p
->has_max_bandwidth
= true;
1300 * Can't use visit_type_size() here, because it
1301 * defaults to Bytes rather than Mebibytes.
1303 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1304 if (ret
< 0 || valuebw
> INT64_MAX
1305 || (size_t)valuebw
!= valuebw
) {
1306 error_setg(&err
, "Invalid size %s", valuestr
);
1309 p
->max_bandwidth
= valuebw
;
1311 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1312 p
->has_downtime_limit
= true;
1313 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1315 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1316 p
->has_x_checkpoint_delay
= true;
1317 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1319 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1320 p
->has_block_incremental
= true;
1321 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1323 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1324 p
->has_multifd_channels
= true;
1325 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1327 case MIGRATION_PARAMETER_MULTIFD_COMPRESSION
:
1328 p
->has_multifd_compression
= true;
1329 visit_type_MultiFDCompression(v
, param
, &compress_type
, &err
);
1333 p
->multifd_compression
= compress_type
;
1335 case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL
:
1336 p
->has_multifd_zlib_level
= true;
1337 visit_type_int(v
, param
, &p
->multifd_zlib_level
, &err
);
1339 case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL
:
1340 p
->has_multifd_zstd_level
= true;
1341 visit_type_int(v
, param
, &p
->multifd_zstd_level
, &err
);
1343 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1344 p
->has_xbzrle_cache_size
= true;
1345 visit_type_size(v
, param
, &cache_size
, &err
);
1349 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1350 error_setg(&err
, "Invalid size %s", valuestr
);
1353 p
->xbzrle_cache_size
= cache_size
;
1355 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1356 p
->has_max_postcopy_bandwidth
= true;
1357 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1359 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1360 p
->has_announce_initial
= true;
1361 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1363 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1364 p
->has_announce_max
= true;
1365 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1367 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1368 p
->has_announce_rounds
= true;
1369 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1371 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1372 p
->has_announce_step
= true;
1373 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1383 qmp_migrate_set_parameters(p
, &err
);
1386 qapi_free_MigrateSetParameters(p
);
1388 hmp_handle_error(mon
, err
);
1391 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1394 const char *protocol
= qdict_get_str(qdict
, "protocol");
1395 const char *hostname
= qdict_get_str(qdict
, "hostname");
1396 bool has_port
= qdict_haskey(qdict
, "port");
1397 int port
= qdict_get_try_int(qdict
, "port", -1);
1398 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1399 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1400 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1402 qmp_client_migrate_info(protocol
, hostname
,
1403 has_port
, port
, has_tls_port
, tls_port
,
1404 !!cert_subject
, cert_subject
, &err
);
1405 hmp_handle_error(mon
, err
);
1408 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1411 qmp_migrate_start_postcopy(&err
);
1412 hmp_handle_error(mon
, err
);
1415 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1419 qmp_x_colo_lost_heartbeat(&err
);
1420 hmp_handle_error(mon
, err
);
1423 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1425 const char *protocol
= qdict_get_str(qdict
, "protocol");
1426 const char *password
= qdict_get_str(qdict
, "password");
1427 const char *connected
= qdict_get_try_str(qdict
, "connected");
1430 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1431 hmp_handle_error(mon
, err
);
1434 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1436 const char *protocol
= qdict_get_str(qdict
, "protocol");
1437 const char *whenstr
= qdict_get_str(qdict
, "time");
1440 qmp_expire_password(protocol
, whenstr
, &err
);
1441 hmp_handle_error(mon
, err
);
1446 static void hmp_change_read_arg(void *opaque
, const char *password
,
1447 void *readline_opaque
)
1449 qmp_change_vnc_password(password
, NULL
);
1450 monitor_read_command(opaque
, 1);
1454 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1456 const char *device
= qdict_get_str(qdict
, "device");
1457 const char *target
= qdict_get_str(qdict
, "target");
1458 const char *arg
= qdict_get_try_str(qdict
, "arg");
1459 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1460 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1464 if (strcmp(device
, "vnc") == 0) {
1467 "Parameter 'read-only-mode' is invalid for VNC\n");
1470 if (strcmp(target
, "passwd") == 0 ||
1471 strcmp(target
, "password") == 0) {
1473 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1474 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1478 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1484 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1486 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1488 hmp_handle_error(mon
, err
);
1493 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1494 !!arg
, arg
, !!read_only
, read_only_mode
,
1498 hmp_handle_error(mon
, err
);
1501 typedef struct HMPMigrationStatus
1505 bool is_block_migration
;
1506 } HMPMigrationStatus
;
1508 static void hmp_migrate_status_cb(void *opaque
)
1510 HMPMigrationStatus
*status
= opaque
;
1511 MigrationInfo
*info
;
1513 info
= qmp_query_migrate(NULL
);
1514 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1515 info
->status
== MIGRATION_STATUS_SETUP
) {
1516 if (info
->has_disk
) {
1519 if (info
->disk
->remaining
) {
1520 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1525 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1526 monitor_flush(status
->mon
);
1529 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1531 if (status
->is_block_migration
) {
1532 monitor_printf(status
->mon
, "\n");
1534 if (info
->has_error_desc
) {
1535 error_report("%s", info
->error_desc
);
1537 monitor_resume(status
->mon
);
1538 timer_del(status
->timer
);
1539 timer_free(status
->timer
);
1543 qapi_free_MigrationInfo(info
);
1546 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1548 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1549 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1550 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1551 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1552 const char *uri
= qdict_get_str(qdict
, "uri");
1555 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1556 false, false, true, resume
, &err
);
1558 hmp_handle_error(mon
, err
);
1563 HMPMigrationStatus
*status
;
1565 if (monitor_suspend(mon
) < 0) {
1566 monitor_printf(mon
, "terminal does not allow synchronous "
1567 "migration, continuing detached\n");
1571 status
= g_malloc0(sizeof(*status
));
1573 status
->is_block_migration
= blk
|| inc
;
1574 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1576 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1580 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1585 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1590 netdev_add(opts
, &err
);
1592 qemu_opts_del(opts
);
1596 hmp_handle_error(mon
, err
);
1599 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1601 const char *id
= qdict_get_str(qdict
, "id");
1604 qmp_netdev_del(id
, &err
);
1605 hmp_handle_error(mon
, err
);
1608 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1614 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1616 hmp_handle_error(mon
, err
);
1620 obj
= user_creatable_add_opts(opts
, &err
);
1621 qemu_opts_del(opts
);
1624 hmp_handle_error(mon
, err
);
1631 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1633 const char *fdname
= qdict_get_str(qdict
, "fdname");
1636 qmp_getfd(fdname
, &err
);
1637 hmp_handle_error(mon
, err
);
1640 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1642 const char *fdname
= qdict_get_str(qdict
, "fdname");
1645 qmp_closefd(fdname
, &err
);
1646 hmp_handle_error(mon
, err
);
1649 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1651 const char *keys
= qdict_get_str(qdict
, "keys");
1652 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1653 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1654 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1656 const char *separator
;
1660 separator
= qemu_strchrnul(keys
, '-');
1661 keyname_len
= separator
- keys
;
1663 /* Be compatible with old interface, convert user inputted "<" */
1664 if (keys
[0] == '<' && keyname_len
== 1) {
1669 keylist
= g_malloc0(sizeof(*keylist
));
1670 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1676 tmp
->next
= keylist
;
1680 if (strstart(keys
, "0x", NULL
)) {
1682 int value
= strtoul(keys
, &endp
, 0);
1683 assert(endp
<= keys
+ keyname_len
);
1684 if (endp
!= keys
+ keyname_len
) {
1687 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1688 keylist
->value
->u
.number
.data
= value
;
1690 int idx
= index_from_key(keys
, keyname_len
);
1691 if (idx
== Q_KEY_CODE__MAX
) {
1694 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1695 keylist
->value
->u
.qcode
.data
= idx
;
1701 keys
= separator
+ 1;
1704 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1705 hmp_handle_error(mon
, err
);
1708 qapi_free_KeyValueList(head
);
1712 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1716 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1718 const char *filename
= qdict_get_str(qdict
, "filename");
1719 const char *id
= qdict_get_try_str(qdict
, "device");
1720 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
1723 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
1724 hmp_handle_error(mon
, err
);
1727 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1729 const char *args
= qdict_get_str(qdict
, "args");
1733 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1735 error_setg(&err
, "Parsing chardev args failed");
1737 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1738 qemu_opts_del(opts
);
1740 hmp_handle_error(mon
, err
);
1743 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
1745 const char *args
= qdict_get_str(qdict
, "args");
1748 ChardevBackend
*backend
= NULL
;
1749 ChardevReturn
*ret
= NULL
;
1750 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
1753 error_setg(&err
, "Parsing chardev args failed");
1757 id
= qdict_get_str(qdict
, "id");
1758 if (qemu_opts_id(opts
)) {
1759 error_setg(&err
, "Unexpected 'id' parameter");
1763 backend
= qemu_chr_parse_opts(opts
, &err
);
1768 ret
= qmp_chardev_change(id
, backend
, &err
);
1771 qapi_free_ChardevReturn(ret
);
1772 qapi_free_ChardevBackend(backend
);
1773 qemu_opts_del(opts
);
1774 hmp_handle_error(mon
, err
);
1777 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1779 Error
*local_err
= NULL
;
1781 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1782 hmp_handle_error(mon
, local_err
);
1785 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
1787 Error
*local_err
= NULL
;
1789 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
1790 hmp_handle_error(mon
, local_err
);
1793 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1795 const char *id
= qdict_get_str(qdict
, "id");
1798 user_creatable_del(id
, &err
);
1799 hmp_handle_error(mon
, err
);
1802 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1805 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1806 MemoryDeviceInfoList
*info
;
1807 VirtioPMEMDeviceInfo
*vpi
;
1808 MemoryDeviceInfo
*value
;
1809 PCDIMMDeviceInfo
*di
;
1811 for (info
= info_list
; info
; info
= info
->next
) {
1812 value
= info
->value
;
1815 switch (value
->type
) {
1816 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1817 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
1818 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
1819 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
1820 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1821 MemoryDeviceInfoKind_str(value
->type
),
1822 di
->id
? di
->id
: "");
1823 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1824 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1825 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1826 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1827 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1828 monitor_printf(mon
, " hotplugged: %s\n",
1829 di
->hotplugged
? "true" : "false");
1830 monitor_printf(mon
, " hotpluggable: %s\n",
1831 di
->hotpluggable
? "true" : "false");
1833 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
1834 vpi
= value
->u
.virtio_pmem
.data
;
1835 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1836 MemoryDeviceInfoKind_str(value
->type
),
1837 vpi
->id
? vpi
->id
: "");
1838 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
1839 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
1840 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
1843 g_assert_not_reached();
1848 qapi_free_MemoryDeviceInfoList(info_list
);
1849 hmp_handle_error(mon
, err
);
1852 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
1854 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
1855 IOThreadInfoList
*info
;
1856 IOThreadInfo
*value
;
1858 for (info
= info_list
; info
; info
= info
->next
) {
1859 value
= info
->value
;
1860 monitor_printf(mon
, "%s:\n", value
->id
);
1861 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
1862 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
1863 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
1864 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
1867 qapi_free_IOThreadInfoList(info_list
);
1870 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
1872 const char *name
= qdict_get_str(qdict
, "name");
1873 RockerSwitch
*rocker
;
1876 rocker
= qmp_query_rocker(name
, &err
);
1878 hmp_handle_error(mon
, err
);
1882 monitor_printf(mon
, "name: %s\n", rocker
->name
);
1883 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
1884 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
1886 qapi_free_RockerSwitch(rocker
);
1889 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
1891 RockerPortList
*list
, *port
;
1892 const char *name
= qdict_get_str(qdict
, "name");
1895 list
= qmp_query_rocker_ports(name
, &err
);
1897 hmp_handle_error(mon
, err
);
1901 monitor_printf(mon
, " ena/ speed/ auto\n");
1902 monitor_printf(mon
, " port link duplex neg?\n");
1904 for (port
= list
; port
; port
= port
->next
) {
1905 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
1907 port
->value
->enabled
? port
->value
->link_up
?
1908 "up" : "down" : "!ena",
1909 port
->value
->speed
== 10000 ? "10G" : "??",
1910 port
->value
->duplex
? "FD" : "HD",
1911 port
->value
->autoneg
? "Yes" : "No");
1914 qapi_free_RockerPortList(list
);
1917 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
1919 RockerOfDpaFlowList
*list
, *info
;
1920 const char *name
= qdict_get_str(qdict
, "name");
1921 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
1924 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
1926 hmp_handle_error(mon
, err
);
1930 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
1932 for (info
= list
; info
; info
= info
->next
) {
1933 RockerOfDpaFlow
*flow
= info
->value
;
1934 RockerOfDpaFlowKey
*key
= flow
->key
;
1935 RockerOfDpaFlowMask
*mask
= flow
->mask
;
1936 RockerOfDpaFlowAction
*action
= flow
->action
;
1939 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
1940 key
->priority
, key
->tbl_id
, flow
->hits
);
1942 monitor_printf(mon
, "%-4d %-3d ",
1943 key
->priority
, key
->tbl_id
);
1946 if (key
->has_in_pport
) {
1947 monitor_printf(mon
, " pport %d", key
->in_pport
);
1948 if (mask
->has_in_pport
) {
1949 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
1953 if (key
->has_vlan_id
) {
1954 monitor_printf(mon
, " vlan %d",
1955 key
->vlan_id
& VLAN_VID_MASK
);
1956 if (mask
->has_vlan_id
) {
1957 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
1961 if (key
->has_tunnel_id
) {
1962 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
1963 if (mask
->has_tunnel_id
) {
1964 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
1968 if (key
->has_eth_type
) {
1969 switch (key
->eth_type
) {
1971 monitor_printf(mon
, " ARP");
1974 monitor_printf(mon
, " IP");
1977 monitor_printf(mon
, " IPv6");
1980 monitor_printf(mon
, " LACP");
1983 monitor_printf(mon
, " LLDP");
1986 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
1991 if (key
->has_eth_src
) {
1992 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
1993 (mask
->has_eth_src
) &&
1994 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
1995 monitor_printf(mon
, " src <any mcast/bcast>");
1996 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
1997 (mask
->has_eth_src
) &&
1998 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
1999 monitor_printf(mon
, " src <any ucast>");
2001 monitor_printf(mon
, " src %s", key
->eth_src
);
2002 if (mask
->has_eth_src
) {
2003 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2008 if (key
->has_eth_dst
) {
2009 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2010 (mask
->has_eth_dst
) &&
2011 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2012 monitor_printf(mon
, " dst <any mcast/bcast>");
2013 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2014 (mask
->has_eth_dst
) &&
2015 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2016 monitor_printf(mon
, " dst <any ucast>");
2018 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2019 if (mask
->has_eth_dst
) {
2020 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2025 if (key
->has_ip_proto
) {
2026 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2027 if (mask
->has_ip_proto
) {
2028 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2032 if (key
->has_ip_tos
) {
2033 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2034 if (mask
->has_ip_tos
) {
2035 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2039 if (key
->has_ip_dst
) {
2040 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2043 if (action
->has_goto_tbl
|| action
->has_group_id
||
2044 action
->has_new_vlan_id
) {
2045 monitor_printf(mon
, " -->");
2048 if (action
->has_new_vlan_id
) {
2049 monitor_printf(mon
, " apply new vlan %d",
2050 ntohs(action
->new_vlan_id
));
2053 if (action
->has_group_id
) {
2054 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2057 if (action
->has_goto_tbl
) {
2058 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2061 monitor_printf(mon
, "\n");
2064 qapi_free_RockerOfDpaFlowList(list
);
2067 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2069 RockerOfDpaGroupList
*list
, *g
;
2070 const char *name
= qdict_get_str(qdict
, "name");
2071 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2074 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2076 hmp_handle_error(mon
, err
);
2080 monitor_printf(mon
, "id (decode) --> buckets\n");
2082 for (g
= list
; g
; g
= g
->next
) {
2083 RockerOfDpaGroup
*group
= g
->value
;
2086 monitor_printf(mon
, "0x%08x", group
->id
);
2088 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2089 group
->type
== 1 ? "L2 rewrite" :
2090 group
->type
== 2 ? "L3 unicast" :
2091 group
->type
== 3 ? "L2 multicast" :
2092 group
->type
== 4 ? "L2 flood" :
2093 group
->type
== 5 ? "L3 interface" :
2094 group
->type
== 6 ? "L3 multicast" :
2095 group
->type
== 7 ? "L3 ECMP" :
2096 group
->type
== 8 ? "L2 overlay" :
2099 if (group
->has_vlan_id
) {
2100 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2103 if (group
->has_pport
) {
2104 monitor_printf(mon
, " pport %d", group
->pport
);
2107 if (group
->has_index
) {
2108 monitor_printf(mon
, " index %d", group
->index
);
2111 monitor_printf(mon
, ") -->");
2113 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2115 monitor_printf(mon
, " set vlan %d",
2116 group
->set_vlan_id
& VLAN_VID_MASK
);
2119 if (group
->has_set_eth_src
) {
2122 monitor_printf(mon
, " set");
2124 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2127 if (group
->has_set_eth_dst
) {
2129 monitor_printf(mon
, " set");
2131 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2134 if (group
->has_ttl_check
&& group
->ttl_check
) {
2135 monitor_printf(mon
, " check TTL");
2138 if (group
->has_group_id
&& group
->group_id
) {
2139 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2142 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2143 monitor_printf(mon
, " pop vlan");
2146 if (group
->has_out_pport
) {
2147 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2150 if (group
->has_group_ids
) {
2151 struct uint32List
*id
;
2153 monitor_printf(mon
, " groups [");
2154 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2155 monitor_printf(mon
, "0x%08x", id
->value
);
2157 monitor_printf(mon
, ",");
2160 monitor_printf(mon
, "]");
2163 monitor_printf(mon
, "\n");
2166 qapi_free_RockerOfDpaGroupList(list
);
2169 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2171 ram_block_dump(mon
);
2174 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2177 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2179 monitor_printf(mon
, "%s\n", info
->guid
);
2181 hmp_handle_error(mon
, err
);
2182 qapi_free_GuidInfo(info
);
2185 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2188 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2190 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2193 if (info
->has_plugged_memory
) {
2194 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2195 info
->plugged_memory
);
2198 qapi_free_MemoryInfo(info
);
2200 hmp_handle_error(mon
, err
);