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
" ms\n",
236 if (info
->has_expected_downtime
) {
237 monitor_printf(mon
, "expected downtime: %" PRIu64
" ms\n",
238 info
->expected_downtime
);
240 if (info
->has_downtime
) {
241 monitor_printf(mon
, "downtime: %" PRIu64
" ms\n",
244 if (info
->has_setup_time
) {
245 monitor_printf(mon
, "setup: %" PRIu64
" ms\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 encoding rate: %0.2f\n",
307 info
->xbzrle_cache
->encoding_rate
);
308 monitor_printf(mon
, "xbzrle overflow: %" PRIu64
"\n",
309 info
->xbzrle_cache
->overflow
);
312 if (info
->has_compression
) {
313 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
314 info
->compression
->pages
);
315 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
316 info
->compression
->busy
);
317 monitor_printf(mon
, "compression busy rate: %0.2f\n",
318 info
->compression
->busy_rate
);
319 monitor_printf(mon
, "compressed size: %" PRIu64
"\n",
320 info
->compression
->compressed_size
);
321 monitor_printf(mon
, "compression rate: %0.2f\n",
322 info
->compression
->compression_rate
);
325 if (info
->has_cpu_throttle_percentage
) {
326 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
327 info
->cpu_throttle_percentage
);
330 if (info
->has_postcopy_blocktime
) {
331 monitor_printf(mon
, "postcopy blocktime: %u\n",
332 info
->postcopy_blocktime
);
335 if (info
->has_postcopy_vcpu_blocktime
) {
338 v
= string_output_visitor_new(false, &str
);
339 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
,
341 visit_complete(v
, &str
);
342 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
346 if (info
->has_socket_address
) {
347 SocketAddressList
*addr
;
349 monitor_printf(mon
, "socket address: [\n");
351 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
352 char *s
= SocketAddress_to_str(addr
->value
);
353 monitor_printf(mon
, "\t%s\n", s
);
356 monitor_printf(mon
, "]\n");
358 qapi_free_MigrationInfo(info
);
361 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
363 MigrationCapabilityStatusList
*caps
, *cap
;
365 caps
= qmp_query_migrate_capabilities(NULL
);
368 for (cap
= caps
; cap
; cap
= cap
->next
) {
369 monitor_printf(mon
, "%s: %s\n",
370 MigrationCapability_str(cap
->value
->capability
),
371 cap
->value
->state
? "on" : "off");
375 qapi_free_MigrationCapabilityStatusList(caps
);
378 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
380 MigrationParameters
*params
;
382 params
= qmp_query_migrate_parameters(NULL
);
385 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
386 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
387 params
->announce_initial
);
388 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
389 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
390 params
->announce_max
);
391 monitor_printf(mon
, "%s: %" PRIu64
"\n",
392 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
393 params
->announce_rounds
);
394 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
395 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
396 params
->announce_step
);
397 assert(params
->has_compress_level
);
398 monitor_printf(mon
, "%s: %u\n",
399 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
400 params
->compress_level
);
401 assert(params
->has_compress_threads
);
402 monitor_printf(mon
, "%s: %u\n",
403 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
404 params
->compress_threads
);
405 assert(params
->has_compress_wait_thread
);
406 monitor_printf(mon
, "%s: %s\n",
407 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
408 params
->compress_wait_thread
? "on" : "off");
409 assert(params
->has_decompress_threads
);
410 monitor_printf(mon
, "%s: %u\n",
411 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
412 params
->decompress_threads
);
413 assert(params
->has_throttle_trigger_threshold
);
414 monitor_printf(mon
, "%s: %u\n",
415 MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
),
416 params
->throttle_trigger_threshold
);
417 assert(params
->has_cpu_throttle_initial
);
418 monitor_printf(mon
, "%s: %u\n",
419 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
420 params
->cpu_throttle_initial
);
421 assert(params
->has_cpu_throttle_increment
);
422 monitor_printf(mon
, "%s: %u\n",
423 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
424 params
->cpu_throttle_increment
);
425 assert(params
->has_cpu_throttle_tailslow
);
426 monitor_printf(mon
, "%s: %s\n",
427 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW
),
428 params
->cpu_throttle_tailslow
? "on" : "off");
429 assert(params
->has_max_cpu_throttle
);
430 monitor_printf(mon
, "%s: %u\n",
431 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
432 params
->max_cpu_throttle
);
433 assert(params
->has_tls_creds
);
434 monitor_printf(mon
, "%s: '%s'\n",
435 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
437 assert(params
->has_tls_hostname
);
438 monitor_printf(mon
, "%s: '%s'\n",
439 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
440 params
->tls_hostname
);
441 assert(params
->has_max_bandwidth
);
442 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
443 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
444 params
->max_bandwidth
);
445 assert(params
->has_downtime_limit
);
446 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
447 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
448 params
->downtime_limit
);
449 assert(params
->has_x_checkpoint_delay
);
450 monitor_printf(mon
, "%s: %u\n",
451 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
452 params
->x_checkpoint_delay
);
453 assert(params
->has_block_incremental
);
454 monitor_printf(mon
, "%s: %s\n",
455 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
456 params
->block_incremental
? "on" : "off");
457 monitor_printf(mon
, "%s: %u\n",
458 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS
),
459 params
->multifd_channels
);
460 monitor_printf(mon
, "%s: %s\n",
461 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION
),
462 MultiFDCompression_str(params
->multifd_compression
));
463 monitor_printf(mon
, "%s: %" PRIu64
"\n",
464 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
465 params
->xbzrle_cache_size
);
466 monitor_printf(mon
, "%s: %" PRIu64
"\n",
467 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
468 params
->max_postcopy_bandwidth
);
469 monitor_printf(mon
, "%s: '%s'\n",
470 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
474 qapi_free_MigrationParameters(params
);
477 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
479 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
480 qmp_query_migrate_cache_size(NULL
) >> 10);
485 /* Helper for hmp_info_vnc_clients, _servers */
486 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
489 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
493 NetworkAddressFamily_str(info
->family
),
494 info
->websocket
? " (Websocket)" : "");
497 /* Helper displaying and auth and crypt info */
498 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
500 VncVencryptSubAuth
*vencrypt
)
502 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
503 VncPrimaryAuth_str(auth
),
504 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
507 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
510 VncClientInfo
*cinfo
= client
->value
;
512 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
513 monitor_printf(mon
, " x509_dname: %s\n",
514 cinfo
->has_x509_dname
?
515 cinfo
->x509_dname
: "none");
516 monitor_printf(mon
, " sasl_username: %s\n",
517 cinfo
->has_sasl_username
?
518 cinfo
->sasl_username
: "none");
520 client
= client
->next
;
524 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
527 VncServerInfo2
*sinfo
= server
->value
;
528 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
529 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
530 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
531 server
= server
->next
;
535 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
537 VncInfo2List
*info2l
, *info2l_head
;
540 info2l
= qmp_query_vnc_servers(&err
);
541 info2l_head
= info2l
;
543 hmp_handle_error(mon
, err
);
547 monitor_printf(mon
, "None\n");
552 VncInfo2
*info
= info2l
->value
;
553 monitor_printf(mon
, "%s:\n", info
->id
);
554 hmp_info_vnc_servers(mon
, info
->server
);
555 hmp_info_vnc_clients(mon
, info
->clients
);
557 /* The server entry displays its auth, we only
558 * need to display in the case of 'reverse' connections
559 * where there's no server.
561 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
562 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
564 if (info
->has_display
) {
565 monitor_printf(mon
, " Display: %s\n", info
->display
);
567 info2l
= info2l
->next
;
570 qapi_free_VncInfo2List(info2l_head
);
576 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
578 SpiceChannelList
*chan
;
580 const char *channel_name
;
581 const char * const channel_names
[] = {
582 [SPICE_CHANNEL_MAIN
] = "main",
583 [SPICE_CHANNEL_DISPLAY
] = "display",
584 [SPICE_CHANNEL_INPUTS
] = "inputs",
585 [SPICE_CHANNEL_CURSOR
] = "cursor",
586 [SPICE_CHANNEL_PLAYBACK
] = "playback",
587 [SPICE_CHANNEL_RECORD
] = "record",
588 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
589 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
590 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
591 [SPICE_CHANNEL_PORT
] = "port",
593 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
594 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
595 * as quick fix for build failures with older versions. */
596 [SPICE_CHANNEL_WEBDAV
] = "webdav",
600 info
= qmp_query_spice(NULL
);
602 if (!info
->enabled
) {
603 monitor_printf(mon
, "Server: disabled\n");
607 monitor_printf(mon
, "Server:\n");
608 if (info
->has_port
) {
609 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
610 info
->host
, info
->port
);
612 if (info
->has_tls_port
) {
613 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
614 info
->host
, info
->tls_port
);
616 monitor_printf(mon
, " migrated: %s\n",
617 info
->migrated
? "true" : "false");
618 monitor_printf(mon
, " auth: %s\n", info
->auth
);
619 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
620 monitor_printf(mon
, " mouse-mode: %s\n",
621 SpiceQueryMouseMode_str(info
->mouse_mode
));
623 if (!info
->has_channels
|| info
->channels
== NULL
) {
624 monitor_printf(mon
, "Channels: none\n");
626 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
627 monitor_printf(mon
, "Channel:\n");
628 monitor_printf(mon
, " address: %s:%s%s\n",
629 chan
->value
->host
, chan
->value
->port
,
630 chan
->value
->tls
? " [tls]" : "");
631 monitor_printf(mon
, " session: %" PRId64
"\n",
632 chan
->value
->connection_id
);
633 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
634 chan
->value
->channel_type
, chan
->value
->channel_id
);
636 channel_name
= "unknown";
637 if (chan
->value
->channel_type
> 0 &&
638 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
639 channel_names
[chan
->value
->channel_type
]) {
640 channel_name
= channel_names
[chan
->value
->channel_type
];
643 monitor_printf(mon
, " channel name: %s\n", channel_name
);
648 qapi_free_SpiceInfo(info
);
652 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
657 info
= qmp_query_balloon(&err
);
659 hmp_handle_error(mon
, err
);
663 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
665 qapi_free_BalloonInfo(info
);
668 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
670 PciMemoryRegionList
*region
;
672 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
673 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
674 dev
->slot
, dev
->function
);
675 monitor_printf(mon
, " ");
677 if (dev
->class_info
->has_desc
) {
678 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
680 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
683 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
684 dev
->id
->vendor
, dev
->id
->device
);
685 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
686 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
687 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
691 monitor_printf(mon
, " IRQ %" PRId64
", pin %c\n",
692 dev
->irq
, (char)('A' + dev
->irq_pin
- 1));
695 if (dev
->has_pci_bridge
) {
696 monitor_printf(mon
, " BUS %" PRId64
".\n",
697 dev
->pci_bridge
->bus
->number
);
698 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
699 dev
->pci_bridge
->bus
->secondary
);
700 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
701 dev
->pci_bridge
->bus
->subordinate
);
703 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
704 dev
->pci_bridge
->bus
->io_range
->base
,
705 dev
->pci_bridge
->bus
->io_range
->limit
);
708 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
709 dev
->pci_bridge
->bus
->memory_range
->base
,
710 dev
->pci_bridge
->bus
->memory_range
->limit
);
712 monitor_printf(mon
, " prefetchable memory range "
713 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
714 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
715 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
718 for (region
= dev
->regions
; region
; region
= region
->next
) {
721 addr
= region
->value
->address
;
722 size
= region
->value
->size
;
724 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
726 if (!strcmp(region
->value
->type
, "io")) {
727 monitor_printf(mon
, "I/O at 0x%04" PRIx64
728 " [0x%04" PRIx64
"].\n",
729 addr
, addr
+ size
- 1);
731 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
732 " [0x%08" PRIx64
"].\n",
733 region
->value
->mem_type_64
? 64 : 32,
734 region
->value
->prefetch
? " prefetchable" : "",
735 addr
, addr
+ size
- 1);
739 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
741 if (dev
->has_pci_bridge
) {
742 if (dev
->pci_bridge
->has_devices
) {
743 PciDeviceInfoList
*cdev
;
744 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
745 hmp_info_pci_device(mon
, cdev
->value
);
751 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
753 InterruptStatsProvider
*intc
;
754 InterruptStatsProviderClass
*k
;
755 Monitor
*mon
= opaque
;
757 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
758 intc
= INTERRUPT_STATS_PROVIDER(obj
);
759 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
760 uint64_t *irq_counts
;
761 unsigned int nb_irqs
, i
;
762 if (k
->get_statistics
&&
763 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
765 monitor_printf(mon
, "IRQ statistics for %s:\n",
766 object_get_typename(obj
));
767 for (i
= 0; i
< nb_irqs
; i
++) {
768 if (irq_counts
[i
] > 0) {
769 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
775 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
776 object_get_typename(obj
));
783 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
785 object_child_foreach_recursive(object_get_root(),
786 hmp_info_irq_foreach
, mon
);
789 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
791 InterruptStatsProvider
*intc
;
792 InterruptStatsProviderClass
*k
;
793 Monitor
*mon
= opaque
;
795 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
796 intc
= INTERRUPT_STATS_PROVIDER(obj
);
797 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
799 k
->print_info(intc
, mon
);
801 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
802 object_get_typename(obj
));
809 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
811 object_child_foreach_recursive(object_get_root(),
812 hmp_info_pic_foreach
, mon
);
815 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
818 RdmaProviderClass
*k
;
819 Monitor
*mon
= opaque
;
821 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
822 rdma
= RDMA_PROVIDER(obj
);
823 k
= RDMA_PROVIDER_GET_CLASS(obj
);
824 if (k
->print_statistics
) {
825 k
->print_statistics(mon
, rdma
);
827 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
828 object_get_typename(obj
));
835 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
837 object_child_foreach_recursive(object_get_root(),
838 hmp_info_rdma_foreach
, mon
);
841 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
843 PciInfoList
*info_list
, *info
;
846 info_list
= qmp_query_pci(&err
);
848 monitor_printf(mon
, "PCI devices not supported\n");
853 for (info
= info_list
; info
; info
= info
->next
) {
854 PciDeviceInfoList
*dev
;
856 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
857 hmp_info_pci_device(mon
, dev
->value
);
861 qapi_free_PciInfoList(info_list
);
864 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
866 TPMInfoList
*info_list
, *info
;
869 TPMPassthroughOptions
*tpo
;
870 TPMEmulatorOptions
*teo
;
872 info_list
= qmp_query_tpm(&err
);
874 monitor_printf(mon
, "TPM device not supported\n");
880 monitor_printf(mon
, "TPM device:\n");
883 for (info
= info_list
; info
; info
= info
->next
) {
884 TPMInfo
*ti
= info
->value
;
885 monitor_printf(mon
, " tpm%d: model=%s\n",
886 c
, TpmModel_str(ti
->model
));
888 monitor_printf(mon
, " \\ %s: type=%s",
889 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
891 switch (ti
->options
->type
) {
892 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
893 tpo
= ti
->options
->u
.passthrough
.data
;
894 monitor_printf(mon
, "%s%s%s%s",
895 tpo
->has_path
? ",path=" : "",
896 tpo
->has_path
? tpo
->path
: "",
897 tpo
->has_cancel_path
? ",cancel-path=" : "",
898 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
900 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
901 teo
= ti
->options
->u
.emulator
.data
;
902 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
904 case TPM_TYPE_OPTIONS_KIND__MAX
:
907 monitor_printf(mon
, "\n");
910 qapi_free_TPMInfoList(info_list
);
913 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
915 monitor_suspend(mon
);
919 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
924 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
926 const char *op
= qdict_get_try_str(qdict
, "op");
929 bool on
= qsp_is_enabled();
931 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
934 if (!strcmp(op
, "on")) {
936 } else if (!strcmp(op
, "off")) {
938 } else if (!strcmp(op
, "reset")) {
943 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
944 hmp_handle_error(mon
, err
);
948 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
950 qmp_system_reset(NULL
);
953 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
955 qmp_system_powerdown(NULL
);
958 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
962 qmp_x_exit_preconfig(&err
);
963 hmp_handle_error(mon
, err
);
966 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
970 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
971 use it are converted to the QAPI */
972 cpu_index
= qdict_get_int(qdict
, "index");
973 if (monitor_set_cpu(cpu_index
) < 0) {
974 monitor_printf(mon
, "invalid CPU index\n");
978 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
980 uint32_t size
= qdict_get_int(qdict
, "size");
981 const char *filename
= qdict_get_str(qdict
, "filename");
982 uint64_t addr
= qdict_get_int(qdict
, "val");
984 int cpu_index
= monitor_get_cpu_index();
987 monitor_printf(mon
, "No CPU available\n");
991 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
992 hmp_handle_error(mon
, err
);
995 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
997 uint32_t size
= qdict_get_int(qdict
, "size");
998 const char *filename
= qdict_get_str(qdict
, "filename");
999 uint64_t addr
= qdict_get_int(qdict
, "val");
1002 qmp_pmemsave(addr
, size
, filename
, &err
);
1003 hmp_handle_error(mon
, err
);
1006 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1008 const char *chardev
= qdict_get_str(qdict
, "device");
1009 const char *data
= qdict_get_str(qdict
, "data");
1012 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1014 hmp_handle_error(mon
, err
);
1017 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1019 uint32_t size
= qdict_get_int(qdict
, "size");
1020 const char *chardev
= qdict_get_str(qdict
, "device");
1025 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1027 hmp_handle_error(mon
, err
);
1031 for (i
= 0; data
[i
]; i
++) {
1032 unsigned char ch
= data
[i
];
1035 monitor_printf(mon
, "\\\\");
1036 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1037 monitor_printf(mon
, "\\u%04X", ch
);
1039 monitor_printf(mon
, "%c", ch
);
1043 monitor_printf(mon
, "\n");
1047 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1052 hmp_handle_error(mon
, err
);
1055 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1059 qmp_system_wakeup(&err
);
1060 hmp_handle_error(mon
, err
);
1063 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1067 qmp_inject_nmi(&err
);
1068 hmp_handle_error(mon
, err
);
1071 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1073 const char *name
= qdict_get_str(qdict
, "name");
1074 bool up
= qdict_get_bool(qdict
, "up");
1077 qmp_set_link(name
, up
, &err
);
1078 hmp_handle_error(mon
, err
);
1081 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1083 int64_t value
= qdict_get_int(qdict
, "value");
1086 qmp_balloon(value
, &err
);
1087 hmp_handle_error(mon
, err
);
1090 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1092 int saved_vm_running
= runstate_is_running();
1093 const char *name
= qdict_get_str(qdict
, "name");
1096 vm_stop(RUN_STATE_RESTORE_VM
);
1098 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1101 hmp_handle_error(mon
, err
);
1104 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1108 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1109 hmp_handle_error(mon
, err
);
1112 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1114 BlockDriverState
*bs
;
1116 const char *name
= qdict_get_str(qdict
, "name");
1118 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1120 "deleting snapshot on device '%s': ",
1121 bdrv_get_device_name(bs
));
1123 hmp_handle_error(mon
, err
);
1126 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1128 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1129 const char *id
= qdict_get_try_str(qdict
, "id");
1130 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1131 migrate_announce_params());
1133 qapi_free_strList(params
->interfaces
);
1134 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1135 params
->has_interfaces
= params
->interfaces
!= NULL
;
1136 params
->id
= g_strdup(id
);
1137 params
->has_id
= !!params
->id
;
1138 qmp_announce_self(params
, NULL
);
1139 qapi_free_AnnounceParameters(params
);
1142 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1144 qmp_migrate_cancel(NULL
);
1147 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1150 const char *state
= qdict_get_str(qdict
, "state");
1151 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1154 qmp_migrate_continue(val
, &err
);
1157 hmp_handle_error(mon
, err
);
1160 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1163 const char *uri
= qdict_get_str(qdict
, "uri");
1165 qmp_migrate_incoming(uri
, &err
);
1167 hmp_handle_error(mon
, err
);
1170 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1173 const char *uri
= qdict_get_str(qdict
, "uri");
1175 qmp_migrate_recover(uri
, &err
);
1177 hmp_handle_error(mon
, err
);
1180 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1184 qmp_migrate_pause(&err
);
1186 hmp_handle_error(mon
, err
);
1189 /* Kept for backwards compatibility */
1190 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1192 double value
= qdict_get_double(qdict
, "value");
1193 qmp_migrate_set_downtime(value
, NULL
);
1196 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1198 int64_t value
= qdict_get_int(qdict
, "value");
1201 qmp_migrate_set_cache_size(value
, &err
);
1202 hmp_handle_error(mon
, err
);
1205 /* Kept for backwards compatibility */
1206 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1210 int64_t value
= qdict_get_int(qdict
, "value");
1211 qmp_migrate_set_speed(value
, &err
);
1212 hmp_handle_error(mon
, err
);
1215 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1217 const char *cap
= qdict_get_str(qdict
, "capability");
1218 bool state
= qdict_get_bool(qdict
, "state");
1220 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1223 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1228 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1229 caps
->value
->capability
= val
;
1230 caps
->value
->state
= state
;
1232 qmp_migrate_set_capabilities(caps
, &err
);
1235 qapi_free_MigrationCapabilityStatusList(caps
);
1236 hmp_handle_error(mon
, err
);
1239 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1241 const char *param
= qdict_get_str(qdict
, "parameter");
1242 const char *valuestr
= qdict_get_str(qdict
, "value");
1243 Visitor
*v
= string_input_visitor_new(valuestr
);
1244 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1245 uint64_t valuebw
= 0;
1246 uint64_t cache_size
;
1247 MultiFDCompression compress_type
;
1251 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1257 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1258 p
->has_compress_level
= true;
1259 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1261 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1262 p
->has_compress_threads
= true;
1263 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1265 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1266 p
->has_compress_wait_thread
= true;
1267 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1269 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1270 p
->has_decompress_threads
= true;
1271 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1273 case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
:
1274 p
->has_throttle_trigger_threshold
= true;
1275 visit_type_int(v
, param
, &p
->throttle_trigger_threshold
, &err
);
1277 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1278 p
->has_cpu_throttle_initial
= true;
1279 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1281 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1282 p
->has_cpu_throttle_increment
= true;
1283 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1285 case MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW
:
1286 p
->has_cpu_throttle_tailslow
= true;
1287 visit_type_bool(v
, param
, &p
->cpu_throttle_tailslow
, &err
);
1289 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1290 p
->has_max_cpu_throttle
= true;
1291 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1293 case MIGRATION_PARAMETER_TLS_CREDS
:
1294 p
->has_tls_creds
= true;
1295 p
->tls_creds
= g_new0(StrOrNull
, 1);
1296 p
->tls_creds
->type
= QTYPE_QSTRING
;
1297 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1299 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1300 p
->has_tls_hostname
= true;
1301 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1302 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1303 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1305 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1306 p
->has_tls_authz
= true;
1307 p
->tls_authz
= g_new0(StrOrNull
, 1);
1308 p
->tls_authz
->type
= QTYPE_QSTRING
;
1309 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1311 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1312 p
->has_max_bandwidth
= true;
1314 * Can't use visit_type_size() here, because it
1315 * defaults to Bytes rather than Mebibytes.
1317 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1318 if (ret
< 0 || valuebw
> INT64_MAX
1319 || (size_t)valuebw
!= valuebw
) {
1320 error_setg(&err
, "Invalid size %s", valuestr
);
1323 p
->max_bandwidth
= valuebw
;
1325 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1326 p
->has_downtime_limit
= true;
1327 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1329 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1330 p
->has_x_checkpoint_delay
= true;
1331 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1333 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1334 p
->has_block_incremental
= true;
1335 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1337 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1338 p
->has_multifd_channels
= true;
1339 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1341 case MIGRATION_PARAMETER_MULTIFD_COMPRESSION
:
1342 p
->has_multifd_compression
= true;
1343 visit_type_MultiFDCompression(v
, param
, &compress_type
, &err
);
1347 p
->multifd_compression
= compress_type
;
1349 case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL
:
1350 p
->has_multifd_zlib_level
= true;
1351 visit_type_int(v
, param
, &p
->multifd_zlib_level
, &err
);
1353 case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL
:
1354 p
->has_multifd_zstd_level
= true;
1355 visit_type_int(v
, param
, &p
->multifd_zstd_level
, &err
);
1357 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1358 p
->has_xbzrle_cache_size
= true;
1359 visit_type_size(v
, param
, &cache_size
, &err
);
1363 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1364 error_setg(&err
, "Invalid size %s", valuestr
);
1367 p
->xbzrle_cache_size
= cache_size
;
1369 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1370 p
->has_max_postcopy_bandwidth
= true;
1371 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1373 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1374 p
->has_announce_initial
= true;
1375 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1377 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1378 p
->has_announce_max
= true;
1379 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1381 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1382 p
->has_announce_rounds
= true;
1383 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1385 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1386 p
->has_announce_step
= true;
1387 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1397 qmp_migrate_set_parameters(p
, &err
);
1400 qapi_free_MigrateSetParameters(p
);
1402 hmp_handle_error(mon
, err
);
1405 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1408 const char *protocol
= qdict_get_str(qdict
, "protocol");
1409 const char *hostname
= qdict_get_str(qdict
, "hostname");
1410 bool has_port
= qdict_haskey(qdict
, "port");
1411 int port
= qdict_get_try_int(qdict
, "port", -1);
1412 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1413 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1414 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1416 qmp_client_migrate_info(protocol
, hostname
,
1417 has_port
, port
, has_tls_port
, tls_port
,
1418 !!cert_subject
, cert_subject
, &err
);
1419 hmp_handle_error(mon
, err
);
1422 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1425 qmp_migrate_start_postcopy(&err
);
1426 hmp_handle_error(mon
, err
);
1429 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1433 qmp_x_colo_lost_heartbeat(&err
);
1434 hmp_handle_error(mon
, err
);
1437 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1439 const char *protocol
= qdict_get_str(qdict
, "protocol");
1440 const char *password
= qdict_get_str(qdict
, "password");
1441 const char *connected
= qdict_get_try_str(qdict
, "connected");
1444 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1445 hmp_handle_error(mon
, err
);
1448 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1450 const char *protocol
= qdict_get_str(qdict
, "protocol");
1451 const char *whenstr
= qdict_get_str(qdict
, "time");
1454 qmp_expire_password(protocol
, whenstr
, &err
);
1455 hmp_handle_error(mon
, err
);
1460 static void hmp_change_read_arg(void *opaque
, const char *password
,
1461 void *readline_opaque
)
1463 qmp_change_vnc_password(password
, NULL
);
1464 monitor_read_command(opaque
, 1);
1468 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1470 const char *device
= qdict_get_str(qdict
, "device");
1471 const char *target
= qdict_get_str(qdict
, "target");
1472 const char *arg
= qdict_get_try_str(qdict
, "arg");
1473 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1474 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1478 if (strcmp(device
, "vnc") == 0) {
1481 "Parameter 'read-only-mode' is invalid for VNC\n");
1484 if (strcmp(target
, "passwd") == 0 ||
1485 strcmp(target
, "password") == 0) {
1487 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1488 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1492 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1498 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1500 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1502 hmp_handle_error(mon
, err
);
1507 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1508 !!arg
, arg
, !!read_only
, read_only_mode
,
1512 hmp_handle_error(mon
, err
);
1515 typedef struct HMPMigrationStatus
1519 bool is_block_migration
;
1520 } HMPMigrationStatus
;
1522 static void hmp_migrate_status_cb(void *opaque
)
1524 HMPMigrationStatus
*status
= opaque
;
1525 MigrationInfo
*info
;
1527 info
= qmp_query_migrate(NULL
);
1528 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1529 info
->status
== MIGRATION_STATUS_SETUP
) {
1530 if (info
->has_disk
) {
1533 if (info
->disk
->remaining
) {
1534 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1539 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1540 monitor_flush(status
->mon
);
1543 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1545 if (status
->is_block_migration
) {
1546 monitor_printf(status
->mon
, "\n");
1548 if (info
->has_error_desc
) {
1549 error_report("%s", info
->error_desc
);
1551 monitor_resume(status
->mon
);
1552 timer_del(status
->timer
);
1553 timer_free(status
->timer
);
1557 qapi_free_MigrationInfo(info
);
1560 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1562 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1563 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1564 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1565 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1566 const char *uri
= qdict_get_str(qdict
, "uri");
1569 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1570 false, false, true, resume
, &err
);
1572 hmp_handle_error(mon
, err
);
1577 HMPMigrationStatus
*status
;
1579 if (monitor_suspend(mon
) < 0) {
1580 monitor_printf(mon
, "terminal does not allow synchronous "
1581 "migration, continuing detached\n");
1585 status
= g_malloc0(sizeof(*status
));
1587 status
->is_block_migration
= blk
|| inc
;
1588 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1590 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1594 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1599 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1604 netdev_add(opts
, &err
);
1606 qemu_opts_del(opts
);
1610 hmp_handle_error(mon
, err
);
1613 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1615 const char *id
= qdict_get_str(qdict
, "id");
1618 qmp_netdev_del(id
, &err
);
1619 hmp_handle_error(mon
, err
);
1622 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1628 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1630 hmp_handle_error(mon
, err
);
1634 obj
= user_creatable_add_opts(opts
, &err
);
1635 qemu_opts_del(opts
);
1638 hmp_handle_error(mon
, err
);
1645 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1647 const char *fdname
= qdict_get_str(qdict
, "fdname");
1650 qmp_getfd(fdname
, &err
);
1651 hmp_handle_error(mon
, err
);
1654 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1656 const char *fdname
= qdict_get_str(qdict
, "fdname");
1659 qmp_closefd(fdname
, &err
);
1660 hmp_handle_error(mon
, err
);
1663 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1665 const char *keys
= qdict_get_str(qdict
, "keys");
1666 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1667 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1668 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1670 const char *separator
;
1674 separator
= qemu_strchrnul(keys
, '-');
1675 keyname_len
= separator
- keys
;
1677 /* Be compatible with old interface, convert user inputted "<" */
1678 if (keys
[0] == '<' && keyname_len
== 1) {
1683 keylist
= g_malloc0(sizeof(*keylist
));
1684 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1690 tmp
->next
= keylist
;
1694 if (strstart(keys
, "0x", NULL
)) {
1696 int value
= strtoul(keys
, &endp
, 0);
1697 assert(endp
<= keys
+ keyname_len
);
1698 if (endp
!= keys
+ keyname_len
) {
1701 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1702 keylist
->value
->u
.number
.data
= value
;
1704 int idx
= index_from_key(keys
, keyname_len
);
1705 if (idx
== Q_KEY_CODE__MAX
) {
1708 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1709 keylist
->value
->u
.qcode
.data
= idx
;
1715 keys
= separator
+ 1;
1718 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1719 hmp_handle_error(mon
, err
);
1722 qapi_free_KeyValueList(head
);
1726 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1730 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1732 const char *filename
= qdict_get_str(qdict
, "filename");
1733 const char *id
= qdict_get_try_str(qdict
, "device");
1734 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
1737 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
1738 hmp_handle_error(mon
, err
);
1741 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1743 const char *args
= qdict_get_str(qdict
, "args");
1747 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1749 error_setg(&err
, "Parsing chardev args failed");
1751 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1752 qemu_opts_del(opts
);
1754 hmp_handle_error(mon
, err
);
1757 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
1759 const char *args
= qdict_get_str(qdict
, "args");
1762 ChardevBackend
*backend
= NULL
;
1763 ChardevReturn
*ret
= NULL
;
1764 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
1767 error_setg(&err
, "Parsing chardev args failed");
1771 id
= qdict_get_str(qdict
, "id");
1772 if (qemu_opts_id(opts
)) {
1773 error_setg(&err
, "Unexpected 'id' parameter");
1777 backend
= qemu_chr_parse_opts(opts
, &err
);
1782 ret
= qmp_chardev_change(id
, backend
, &err
);
1785 qapi_free_ChardevReturn(ret
);
1786 qapi_free_ChardevBackend(backend
);
1787 qemu_opts_del(opts
);
1788 hmp_handle_error(mon
, err
);
1791 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1793 Error
*local_err
= NULL
;
1795 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1796 hmp_handle_error(mon
, local_err
);
1799 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
1801 Error
*local_err
= NULL
;
1803 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
1804 hmp_handle_error(mon
, local_err
);
1807 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1809 const char *id
= qdict_get_str(qdict
, "id");
1812 user_creatable_del(id
, &err
);
1813 hmp_handle_error(mon
, err
);
1816 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1819 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1820 MemoryDeviceInfoList
*info
;
1821 VirtioPMEMDeviceInfo
*vpi
;
1822 MemoryDeviceInfo
*value
;
1823 PCDIMMDeviceInfo
*di
;
1825 for (info
= info_list
; info
; info
= info
->next
) {
1826 value
= info
->value
;
1829 switch (value
->type
) {
1830 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1831 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
1832 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
1833 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
1834 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1835 MemoryDeviceInfoKind_str(value
->type
),
1836 di
->id
? di
->id
: "");
1837 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1838 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1839 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1840 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1841 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1842 monitor_printf(mon
, " hotplugged: %s\n",
1843 di
->hotplugged
? "true" : "false");
1844 monitor_printf(mon
, " hotpluggable: %s\n",
1845 di
->hotpluggable
? "true" : "false");
1847 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
1848 vpi
= value
->u
.virtio_pmem
.data
;
1849 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1850 MemoryDeviceInfoKind_str(value
->type
),
1851 vpi
->id
? vpi
->id
: "");
1852 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
1853 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
1854 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
1857 g_assert_not_reached();
1862 qapi_free_MemoryDeviceInfoList(info_list
);
1863 hmp_handle_error(mon
, err
);
1866 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
1868 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
1869 IOThreadInfoList
*info
;
1870 IOThreadInfo
*value
;
1872 for (info
= info_list
; info
; info
= info
->next
) {
1873 value
= info
->value
;
1874 monitor_printf(mon
, "%s:\n", value
->id
);
1875 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
1876 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
1877 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
1878 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
1881 qapi_free_IOThreadInfoList(info_list
);
1884 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
1886 const char *name
= qdict_get_str(qdict
, "name");
1887 RockerSwitch
*rocker
;
1890 rocker
= qmp_query_rocker(name
, &err
);
1892 hmp_handle_error(mon
, err
);
1896 monitor_printf(mon
, "name: %s\n", rocker
->name
);
1897 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
1898 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
1900 qapi_free_RockerSwitch(rocker
);
1903 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
1905 RockerPortList
*list
, *port
;
1906 const char *name
= qdict_get_str(qdict
, "name");
1909 list
= qmp_query_rocker_ports(name
, &err
);
1911 hmp_handle_error(mon
, err
);
1915 monitor_printf(mon
, " ena/ speed/ auto\n");
1916 monitor_printf(mon
, " port link duplex neg?\n");
1918 for (port
= list
; port
; port
= port
->next
) {
1919 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
1921 port
->value
->enabled
? port
->value
->link_up
?
1922 "up" : "down" : "!ena",
1923 port
->value
->speed
== 10000 ? "10G" : "??",
1924 port
->value
->duplex
? "FD" : "HD",
1925 port
->value
->autoneg
? "Yes" : "No");
1928 qapi_free_RockerPortList(list
);
1931 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
1933 RockerOfDpaFlowList
*list
, *info
;
1934 const char *name
= qdict_get_str(qdict
, "name");
1935 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
1938 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
1940 hmp_handle_error(mon
, err
);
1944 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
1946 for (info
= list
; info
; info
= info
->next
) {
1947 RockerOfDpaFlow
*flow
= info
->value
;
1948 RockerOfDpaFlowKey
*key
= flow
->key
;
1949 RockerOfDpaFlowMask
*mask
= flow
->mask
;
1950 RockerOfDpaFlowAction
*action
= flow
->action
;
1953 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
1954 key
->priority
, key
->tbl_id
, flow
->hits
);
1956 monitor_printf(mon
, "%-4d %-3d ",
1957 key
->priority
, key
->tbl_id
);
1960 if (key
->has_in_pport
) {
1961 monitor_printf(mon
, " pport %d", key
->in_pport
);
1962 if (mask
->has_in_pport
) {
1963 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
1967 if (key
->has_vlan_id
) {
1968 monitor_printf(mon
, " vlan %d",
1969 key
->vlan_id
& VLAN_VID_MASK
);
1970 if (mask
->has_vlan_id
) {
1971 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
1975 if (key
->has_tunnel_id
) {
1976 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
1977 if (mask
->has_tunnel_id
) {
1978 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
1982 if (key
->has_eth_type
) {
1983 switch (key
->eth_type
) {
1985 monitor_printf(mon
, " ARP");
1988 monitor_printf(mon
, " IP");
1991 monitor_printf(mon
, " IPv6");
1994 monitor_printf(mon
, " LACP");
1997 monitor_printf(mon
, " LLDP");
2000 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2005 if (key
->has_eth_src
) {
2006 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2007 (mask
->has_eth_src
) &&
2008 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2009 monitor_printf(mon
, " src <any mcast/bcast>");
2010 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2011 (mask
->has_eth_src
) &&
2012 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2013 monitor_printf(mon
, " src <any ucast>");
2015 monitor_printf(mon
, " src %s", key
->eth_src
);
2016 if (mask
->has_eth_src
) {
2017 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2022 if (key
->has_eth_dst
) {
2023 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2024 (mask
->has_eth_dst
) &&
2025 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2026 monitor_printf(mon
, " dst <any mcast/bcast>");
2027 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2028 (mask
->has_eth_dst
) &&
2029 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2030 monitor_printf(mon
, " dst <any ucast>");
2032 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2033 if (mask
->has_eth_dst
) {
2034 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2039 if (key
->has_ip_proto
) {
2040 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2041 if (mask
->has_ip_proto
) {
2042 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2046 if (key
->has_ip_tos
) {
2047 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2048 if (mask
->has_ip_tos
) {
2049 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2053 if (key
->has_ip_dst
) {
2054 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2057 if (action
->has_goto_tbl
|| action
->has_group_id
||
2058 action
->has_new_vlan_id
) {
2059 monitor_printf(mon
, " -->");
2062 if (action
->has_new_vlan_id
) {
2063 monitor_printf(mon
, " apply new vlan %d",
2064 ntohs(action
->new_vlan_id
));
2067 if (action
->has_group_id
) {
2068 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2071 if (action
->has_goto_tbl
) {
2072 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2075 monitor_printf(mon
, "\n");
2078 qapi_free_RockerOfDpaFlowList(list
);
2081 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2083 RockerOfDpaGroupList
*list
, *g
;
2084 const char *name
= qdict_get_str(qdict
, "name");
2085 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2088 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2090 hmp_handle_error(mon
, err
);
2094 monitor_printf(mon
, "id (decode) --> buckets\n");
2096 for (g
= list
; g
; g
= g
->next
) {
2097 RockerOfDpaGroup
*group
= g
->value
;
2100 monitor_printf(mon
, "0x%08x", group
->id
);
2102 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2103 group
->type
== 1 ? "L2 rewrite" :
2104 group
->type
== 2 ? "L3 unicast" :
2105 group
->type
== 3 ? "L2 multicast" :
2106 group
->type
== 4 ? "L2 flood" :
2107 group
->type
== 5 ? "L3 interface" :
2108 group
->type
== 6 ? "L3 multicast" :
2109 group
->type
== 7 ? "L3 ECMP" :
2110 group
->type
== 8 ? "L2 overlay" :
2113 if (group
->has_vlan_id
) {
2114 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2117 if (group
->has_pport
) {
2118 monitor_printf(mon
, " pport %d", group
->pport
);
2121 if (group
->has_index
) {
2122 monitor_printf(mon
, " index %d", group
->index
);
2125 monitor_printf(mon
, ") -->");
2127 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2129 monitor_printf(mon
, " set vlan %d",
2130 group
->set_vlan_id
& VLAN_VID_MASK
);
2133 if (group
->has_set_eth_src
) {
2136 monitor_printf(mon
, " set");
2138 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2141 if (group
->has_set_eth_dst
) {
2143 monitor_printf(mon
, " set");
2145 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2148 if (group
->has_ttl_check
&& group
->ttl_check
) {
2149 monitor_printf(mon
, " check TTL");
2152 if (group
->has_group_id
&& group
->group_id
) {
2153 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2156 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2157 monitor_printf(mon
, " pop vlan");
2160 if (group
->has_out_pport
) {
2161 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2164 if (group
->has_group_ids
) {
2165 struct uint32List
*id
;
2167 monitor_printf(mon
, " groups [");
2168 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2169 monitor_printf(mon
, "0x%08x", id
->value
);
2171 monitor_printf(mon
, ",");
2174 monitor_printf(mon
, "]");
2177 monitor_printf(mon
, "\n");
2180 qapi_free_RockerOfDpaGroupList(list
);
2183 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2185 ram_block_dump(mon
);
2188 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2191 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2193 monitor_printf(mon
, "%s\n", info
->guid
);
2195 hmp_handle_error(mon
, err
);
2196 qapi_free_GuidInfo(info
);
2199 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2202 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2204 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2207 if (info
->has_plugged_memory
) {
2208 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2209 info
->plugged_memory
);
2212 qapi_free_MemoryInfo(info
);
2214 hmp_handle_error(mon
, err
);