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 "qemu/help_option.h"
28 #include "monitor/monitor-internal.h"
29 #include "qapi/error.h"
30 #include "qapi/clone-visitor.h"
31 #include "qapi/opts-visitor.h"
32 #include "qapi/qapi-builtin-visit.h"
33 #include "qapi/qapi-commands-block.h"
34 #include "qapi/qapi-commands-char.h"
35 #include "qapi/qapi-commands-control.h"
36 #include "qapi/qapi-commands-machine.h"
37 #include "qapi/qapi-commands-migration.h"
38 #include "qapi/qapi-commands-misc.h"
39 #include "qapi/qapi-commands-net.h"
40 #include "qapi/qapi-commands-pci.h"
41 #include "qapi/qapi-commands-rocker.h"
42 #include "qapi/qapi-commands-run-state.h"
43 #include "qapi/qapi-commands-tpm.h"
44 #include "qapi/qapi-commands-ui.h"
45 #include "qapi/qapi-visit-net.h"
46 #include "qapi/qapi-visit-migration.h"
47 #include "qapi/qmp/qdict.h"
48 #include "qapi/qmp/qerror.h"
49 #include "qapi/string-input-visitor.h"
50 #include "qapi/string-output-visitor.h"
51 #include "qom/object_interfaces.h"
52 #include "ui/console.h"
53 #include "qemu/cutils.h"
54 #include "qemu/error-report.h"
55 #include "exec/ramlist.h"
56 #include "hw/intc/intc.h"
57 #include "hw/rdma/rdma.h"
58 #include "migration/snapshot.h"
59 #include "migration/misc.h"
62 #include <spice/enums.h>
65 void hmp_handle_error(Monitor
*mon
, Error
*err
)
68 error_reportf_err(err
, "Error: ");
73 * Produce a strList from a comma separated list.
74 * A NULL or empty input string return NULL.
76 static strList
*strList_from_comma_list(const char *in
)
79 strList
**hook
= &res
;
82 char *comma
= strchr(in
, ',');
83 *hook
= g_new0(strList
, 1);
86 (*hook
)->value
= g_strndup(in
, comma
- in
);
87 in
= comma
+ 1; /* skip the , */
89 (*hook
)->value
= g_strdup(in
);
92 hook
= &(*hook
)->next
;
98 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
102 info
= qmp_query_name(NULL
);
103 if (info
->has_name
) {
104 monitor_printf(mon
, "%s\n", info
->name
);
106 qapi_free_NameInfo(info
);
109 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
113 info
= qmp_query_version(NULL
);
115 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
116 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
119 qapi_free_VersionInfo(info
);
122 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
126 info
= qmp_query_kvm(NULL
);
127 monitor_printf(mon
, "kvm support: ");
129 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
131 monitor_printf(mon
, "not compiled\n");
134 qapi_free_KvmInfo(info
);
137 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
141 info
= qmp_query_status(NULL
);
143 monitor_printf(mon
, "VM status: %s%s",
144 info
->running
? "running" : "paused",
145 info
->singlestep
? " (single step mode)" : "");
147 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
148 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
151 monitor_printf(mon
, "\n");
153 qapi_free_StatusInfo(info
);
156 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
160 info
= qmp_query_uuid(NULL
);
161 monitor_printf(mon
, "%s\n", info
->UUID
);
162 qapi_free_UuidInfo(info
);
165 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
167 ChardevInfoList
*char_info
, *info
;
169 char_info
= qmp_query_chardev(NULL
);
170 for (info
= char_info
; info
; info
= info
->next
) {
171 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
172 info
->value
->filename
);
175 qapi_free_ChardevInfoList(char_info
);
178 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
180 MouseInfoList
*mice_list
, *mouse
;
182 mice_list
= qmp_query_mice(NULL
);
184 monitor_printf(mon
, "No mouse devices connected\n");
188 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
189 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
190 mouse
->value
->current
? '*' : ' ',
191 mouse
->value
->index
, mouse
->value
->name
,
192 mouse
->value
->absolute
? " (absolute)" : "");
195 qapi_free_MouseInfoList(mice_list
);
198 static char *SocketAddress_to_str(SocketAddress
*addr
)
200 switch (addr
->type
) {
201 case SOCKET_ADDRESS_TYPE_INET
:
202 return g_strdup_printf("tcp:%s:%s",
205 case SOCKET_ADDRESS_TYPE_UNIX
:
206 return g_strdup_printf("unix:%s",
207 addr
->u
.q_unix
.path
);
208 case SOCKET_ADDRESS_TYPE_FD
:
209 return g_strdup_printf("fd:%s", addr
->u
.fd
.str
);
210 case SOCKET_ADDRESS_TYPE_VSOCK
:
211 return g_strdup_printf("tcp:%s:%s",
215 return g_strdup("unknown address type");
219 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
223 info
= qmp_query_migrate(NULL
);
225 migration_global_dump(mon
);
227 if (info
->has_status
) {
228 monitor_printf(mon
, "Migration status: %s",
229 MigrationStatus_str(info
->status
));
230 if (info
->status
== MIGRATION_STATUS_FAILED
&&
231 info
->has_error_desc
) {
232 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
234 monitor_printf(mon
, "\n");
237 monitor_printf(mon
, "total time: %" PRIu64
" ms\n",
239 if (info
->has_expected_downtime
) {
240 monitor_printf(mon
, "expected downtime: %" PRIu64
" ms\n",
241 info
->expected_downtime
);
243 if (info
->has_downtime
) {
244 monitor_printf(mon
, "downtime: %" PRIu64
" ms\n",
247 if (info
->has_setup_time
) {
248 monitor_printf(mon
, "setup: %" PRIu64
" ms\n",
254 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
255 info
->ram
->transferred
>> 10);
256 monitor_printf(mon
, "throughput: %0.2f mbps\n",
258 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
259 info
->ram
->remaining
>> 10);
260 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
261 info
->ram
->total
>> 10);
262 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
263 info
->ram
->duplicate
);
264 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
266 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
268 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
269 info
->ram
->normal_bytes
>> 10);
270 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
271 info
->ram
->dirty_sync_count
);
272 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
273 info
->ram
->page_size
>> 10);
274 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
275 info
->ram
->multifd_bytes
>> 10);
276 monitor_printf(mon
, "pages-per-second: %" PRIu64
"\n",
277 info
->ram
->pages_per_second
);
279 if (info
->ram
->dirty_pages_rate
) {
280 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
281 info
->ram
->dirty_pages_rate
);
283 if (info
->ram
->postcopy_requests
) {
284 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
285 info
->ram
->postcopy_requests
);
289 if (info
->has_disk
) {
290 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
291 info
->disk
->transferred
>> 10);
292 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
293 info
->disk
->remaining
>> 10);
294 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
295 info
->disk
->total
>> 10);
298 if (info
->has_xbzrle_cache
) {
299 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
300 info
->xbzrle_cache
->cache_size
);
301 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
302 info
->xbzrle_cache
->bytes
>> 10);
303 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
304 info
->xbzrle_cache
->pages
);
305 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
" pages\n",
306 info
->xbzrle_cache
->cache_miss
);
307 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
308 info
->xbzrle_cache
->cache_miss_rate
);
309 monitor_printf(mon
, "xbzrle encoding rate: %0.2f\n",
310 info
->xbzrle_cache
->encoding_rate
);
311 monitor_printf(mon
, "xbzrle overflow: %" PRIu64
"\n",
312 info
->xbzrle_cache
->overflow
);
315 if (info
->has_compression
) {
316 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
317 info
->compression
->pages
);
318 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
319 info
->compression
->busy
);
320 monitor_printf(mon
, "compression busy rate: %0.2f\n",
321 info
->compression
->busy_rate
);
322 monitor_printf(mon
, "compressed size: %" PRIu64
" kbytes\n",
323 info
->compression
->compressed_size
>> 10);
324 monitor_printf(mon
, "compression rate: %0.2f\n",
325 info
->compression
->compression_rate
);
328 if (info
->has_cpu_throttle_percentage
) {
329 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
330 info
->cpu_throttle_percentage
);
333 if (info
->has_postcopy_blocktime
) {
334 monitor_printf(mon
, "postcopy blocktime: %u\n",
335 info
->postcopy_blocktime
);
338 if (info
->has_postcopy_vcpu_blocktime
) {
341 v
= string_output_visitor_new(false, &str
);
342 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
,
344 visit_complete(v
, &str
);
345 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
349 if (info
->has_socket_address
) {
350 SocketAddressList
*addr
;
352 monitor_printf(mon
, "socket address: [\n");
354 for (addr
= info
->socket_address
; addr
; addr
= addr
->next
) {
355 char *s
= SocketAddress_to_str(addr
->value
);
356 monitor_printf(mon
, "\t%s\n", s
);
359 monitor_printf(mon
, "]\n");
362 if (info
->has_vfio
) {
363 monitor_printf(mon
, "vfio device transferred: %" PRIu64
" kbytes\n",
364 info
->vfio
->transferred
>> 10);
367 qapi_free_MigrationInfo(info
);
370 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
372 MigrationCapabilityStatusList
*caps
, *cap
;
374 caps
= qmp_query_migrate_capabilities(NULL
);
377 for (cap
= caps
; cap
; cap
= cap
->next
) {
378 monitor_printf(mon
, "%s: %s\n",
379 MigrationCapability_str(cap
->value
->capability
),
380 cap
->value
->state
? "on" : "off");
384 qapi_free_MigrationCapabilityStatusList(caps
);
387 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
389 MigrationParameters
*params
;
391 params
= qmp_query_migrate_parameters(NULL
);
394 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
395 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL
),
396 params
->announce_initial
);
397 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
398 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX
),
399 params
->announce_max
);
400 monitor_printf(mon
, "%s: %" PRIu64
"\n",
401 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
),
402 params
->announce_rounds
);
403 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
404 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP
),
405 params
->announce_step
);
406 assert(params
->has_compress_level
);
407 monitor_printf(mon
, "%s: %u\n",
408 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
409 params
->compress_level
);
410 assert(params
->has_compress_threads
);
411 monitor_printf(mon
, "%s: %u\n",
412 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
413 params
->compress_threads
);
414 assert(params
->has_compress_wait_thread
);
415 monitor_printf(mon
, "%s: %s\n",
416 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
417 params
->compress_wait_thread
? "on" : "off");
418 assert(params
->has_decompress_threads
);
419 monitor_printf(mon
, "%s: %u\n",
420 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
421 params
->decompress_threads
);
422 assert(params
->has_throttle_trigger_threshold
);
423 monitor_printf(mon
, "%s: %u\n",
424 MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
),
425 params
->throttle_trigger_threshold
);
426 assert(params
->has_cpu_throttle_initial
);
427 monitor_printf(mon
, "%s: %u\n",
428 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
429 params
->cpu_throttle_initial
);
430 assert(params
->has_cpu_throttle_increment
);
431 monitor_printf(mon
, "%s: %u\n",
432 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
433 params
->cpu_throttle_increment
);
434 assert(params
->has_cpu_throttle_tailslow
);
435 monitor_printf(mon
, "%s: %s\n",
436 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW
),
437 params
->cpu_throttle_tailslow
? "on" : "off");
438 assert(params
->has_max_cpu_throttle
);
439 monitor_printf(mon
, "%s: %u\n",
440 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
441 params
->max_cpu_throttle
);
442 assert(params
->has_tls_creds
);
443 monitor_printf(mon
, "%s: '%s'\n",
444 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
446 assert(params
->has_tls_hostname
);
447 monitor_printf(mon
, "%s: '%s'\n",
448 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
449 params
->tls_hostname
);
450 assert(params
->has_max_bandwidth
);
451 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
452 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
453 params
->max_bandwidth
);
454 assert(params
->has_downtime_limit
);
455 monitor_printf(mon
, "%s: %" PRIu64
" ms\n",
456 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
457 params
->downtime_limit
);
458 assert(params
->has_x_checkpoint_delay
);
459 monitor_printf(mon
, "%s: %u ms\n",
460 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
461 params
->x_checkpoint_delay
);
462 assert(params
->has_block_incremental
);
463 monitor_printf(mon
, "%s: %s\n",
464 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
465 params
->block_incremental
? "on" : "off");
466 monitor_printf(mon
, "%s: %u\n",
467 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS
),
468 params
->multifd_channels
);
469 monitor_printf(mon
, "%s: %s\n",
470 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION
),
471 MultiFDCompression_str(params
->multifd_compression
));
472 monitor_printf(mon
, "%s: %" PRIu64
" bytes\n",
473 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
474 params
->xbzrle_cache_size
);
475 monitor_printf(mon
, "%s: %" PRIu64
"\n",
476 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
477 params
->max_postcopy_bandwidth
);
478 monitor_printf(mon
, "%s: '%s'\n",
479 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ
),
482 if (params
->has_block_bitmap_mapping
) {
483 const BitmapMigrationNodeAliasList
*bmnal
;
485 monitor_printf(mon
, "%s:\n",
486 MigrationParameter_str(
487 MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING
));
489 for (bmnal
= params
->block_bitmap_mapping
;
493 const BitmapMigrationNodeAlias
*bmna
= bmnal
->value
;
494 const BitmapMigrationBitmapAliasList
*bmbal
;
496 monitor_printf(mon
, " '%s' -> '%s'\n",
497 bmna
->node_name
, bmna
->alias
);
499 for (bmbal
= bmna
->bitmaps
; bmbal
; bmbal
= bmbal
->next
) {
500 const BitmapMigrationBitmapAlias
*bmba
= bmbal
->value
;
502 monitor_printf(mon
, " '%s' -> '%s'\n",
503 bmba
->name
, bmba
->alias
);
509 qapi_free_MigrationParameters(params
);
512 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
514 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
515 qmp_query_migrate_cache_size(NULL
) >> 10);
520 /* Helper for hmp_info_vnc_clients, _servers */
521 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
524 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
528 NetworkAddressFamily_str(info
->family
),
529 info
->websocket
? " (Websocket)" : "");
532 /* Helper displaying and auth and crypt info */
533 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
535 VncVencryptSubAuth
*vencrypt
)
537 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
538 VncPrimaryAuth_str(auth
),
539 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
542 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
545 VncClientInfo
*cinfo
= client
->value
;
547 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
548 monitor_printf(mon
, " x509_dname: %s\n",
549 cinfo
->has_x509_dname
?
550 cinfo
->x509_dname
: "none");
551 monitor_printf(mon
, " sasl_username: %s\n",
552 cinfo
->has_sasl_username
?
553 cinfo
->sasl_username
: "none");
555 client
= client
->next
;
559 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
562 VncServerInfo2
*sinfo
= server
->value
;
563 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
564 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
565 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
566 server
= server
->next
;
570 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
572 VncInfo2List
*info2l
, *info2l_head
;
575 info2l
= qmp_query_vnc_servers(&err
);
576 info2l_head
= info2l
;
578 hmp_handle_error(mon
, err
);
582 monitor_printf(mon
, "None\n");
587 VncInfo2
*info
= info2l
->value
;
588 monitor_printf(mon
, "%s:\n", info
->id
);
589 hmp_info_vnc_servers(mon
, info
->server
);
590 hmp_info_vnc_clients(mon
, info
->clients
);
592 /* The server entry displays its auth, we only
593 * need to display in the case of 'reverse' connections
594 * where there's no server.
596 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
597 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
599 if (info
->has_display
) {
600 monitor_printf(mon
, " Display: %s\n", info
->display
);
602 info2l
= info2l
->next
;
605 qapi_free_VncInfo2List(info2l_head
);
611 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
613 SpiceChannelList
*chan
;
615 const char *channel_name
;
616 const char * const channel_names
[] = {
617 [SPICE_CHANNEL_MAIN
] = "main",
618 [SPICE_CHANNEL_DISPLAY
] = "display",
619 [SPICE_CHANNEL_INPUTS
] = "inputs",
620 [SPICE_CHANNEL_CURSOR
] = "cursor",
621 [SPICE_CHANNEL_PLAYBACK
] = "playback",
622 [SPICE_CHANNEL_RECORD
] = "record",
623 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
624 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
625 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
626 [SPICE_CHANNEL_PORT
] = "port",
628 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
629 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
630 * as quick fix for build failures with older versions. */
631 [SPICE_CHANNEL_WEBDAV
] = "webdav",
635 info
= qmp_query_spice(NULL
);
637 if (!info
->enabled
) {
638 monitor_printf(mon
, "Server: disabled\n");
642 monitor_printf(mon
, "Server:\n");
643 if (info
->has_port
) {
644 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
645 info
->host
, info
->port
);
647 if (info
->has_tls_port
) {
648 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
649 info
->host
, info
->tls_port
);
651 monitor_printf(mon
, " migrated: %s\n",
652 info
->migrated
? "true" : "false");
653 monitor_printf(mon
, " auth: %s\n", info
->auth
);
654 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
655 monitor_printf(mon
, " mouse-mode: %s\n",
656 SpiceQueryMouseMode_str(info
->mouse_mode
));
658 if (!info
->has_channels
|| info
->channels
== NULL
) {
659 monitor_printf(mon
, "Channels: none\n");
661 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
662 monitor_printf(mon
, "Channel:\n");
663 monitor_printf(mon
, " address: %s:%s%s\n",
664 chan
->value
->host
, chan
->value
->port
,
665 chan
->value
->tls
? " [tls]" : "");
666 monitor_printf(mon
, " session: %" PRId64
"\n",
667 chan
->value
->connection_id
);
668 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
669 chan
->value
->channel_type
, chan
->value
->channel_id
);
671 channel_name
= "unknown";
672 if (chan
->value
->channel_type
> 0 &&
673 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
674 channel_names
[chan
->value
->channel_type
]) {
675 channel_name
= channel_names
[chan
->value
->channel_type
];
678 monitor_printf(mon
, " channel name: %s\n", channel_name
);
683 qapi_free_SpiceInfo(info
);
687 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
692 info
= qmp_query_balloon(&err
);
694 hmp_handle_error(mon
, err
);
698 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
700 qapi_free_BalloonInfo(info
);
703 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
705 PciMemoryRegionList
*region
;
707 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
708 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
709 dev
->slot
, dev
->function
);
710 monitor_printf(mon
, " ");
712 if (dev
->class_info
->has_desc
) {
713 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
715 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
718 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
719 dev
->id
->vendor
, dev
->id
->device
);
720 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
721 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
722 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
726 monitor_printf(mon
, " IRQ %" PRId64
", pin %c\n",
727 dev
->irq
, (char)('A' + dev
->irq_pin
- 1));
730 if (dev
->has_pci_bridge
) {
731 monitor_printf(mon
, " BUS %" PRId64
".\n",
732 dev
->pci_bridge
->bus
->number
);
733 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
734 dev
->pci_bridge
->bus
->secondary
);
735 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
736 dev
->pci_bridge
->bus
->subordinate
);
738 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
739 dev
->pci_bridge
->bus
->io_range
->base
,
740 dev
->pci_bridge
->bus
->io_range
->limit
);
743 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
744 dev
->pci_bridge
->bus
->memory_range
->base
,
745 dev
->pci_bridge
->bus
->memory_range
->limit
);
747 monitor_printf(mon
, " prefetchable memory range "
748 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
749 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
750 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
753 for (region
= dev
->regions
; region
; region
= region
->next
) {
756 addr
= region
->value
->address
;
757 size
= region
->value
->size
;
759 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
761 if (!strcmp(region
->value
->type
, "io")) {
762 monitor_printf(mon
, "I/O at 0x%04" PRIx64
763 " [0x%04" PRIx64
"].\n",
764 addr
, addr
+ size
- 1);
766 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
767 " [0x%08" PRIx64
"].\n",
768 region
->value
->mem_type_64
? 64 : 32,
769 region
->value
->prefetch
? " prefetchable" : "",
770 addr
, addr
+ size
- 1);
774 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
776 if (dev
->has_pci_bridge
) {
777 if (dev
->pci_bridge
->has_devices
) {
778 PciDeviceInfoList
*cdev
;
779 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
780 hmp_info_pci_device(mon
, cdev
->value
);
786 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
788 InterruptStatsProvider
*intc
;
789 InterruptStatsProviderClass
*k
;
790 Monitor
*mon
= opaque
;
792 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
793 intc
= INTERRUPT_STATS_PROVIDER(obj
);
794 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
795 uint64_t *irq_counts
;
796 unsigned int nb_irqs
, i
;
797 if (k
->get_statistics
&&
798 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
800 monitor_printf(mon
, "IRQ statistics for %s:\n",
801 object_get_typename(obj
));
802 for (i
= 0; i
< nb_irqs
; i
++) {
803 if (irq_counts
[i
] > 0) {
804 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
810 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
811 object_get_typename(obj
));
818 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
820 object_child_foreach_recursive(object_get_root(),
821 hmp_info_irq_foreach
, mon
);
824 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
826 InterruptStatsProvider
*intc
;
827 InterruptStatsProviderClass
*k
;
828 Monitor
*mon
= opaque
;
830 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
831 intc
= INTERRUPT_STATS_PROVIDER(obj
);
832 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
834 k
->print_info(intc
, mon
);
836 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
837 object_get_typename(obj
));
844 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
846 object_child_foreach_recursive(object_get_root(),
847 hmp_info_pic_foreach
, mon
);
850 static int hmp_info_rdma_foreach(Object
*obj
, void *opaque
)
853 RdmaProviderClass
*k
;
854 Monitor
*mon
= opaque
;
856 if (object_dynamic_cast(obj
, INTERFACE_RDMA_PROVIDER
)) {
857 rdma
= RDMA_PROVIDER(obj
);
858 k
= RDMA_PROVIDER_GET_CLASS(obj
);
859 if (k
->print_statistics
) {
860 k
->print_statistics(mon
, rdma
);
862 monitor_printf(mon
, "RDMA statistics not available for %s.\n",
863 object_get_typename(obj
));
870 void hmp_info_rdma(Monitor
*mon
, const QDict
*qdict
)
872 object_child_foreach_recursive(object_get_root(),
873 hmp_info_rdma_foreach
, mon
);
876 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
878 PciInfoList
*info_list
, *info
;
881 info_list
= qmp_query_pci(&err
);
883 monitor_printf(mon
, "PCI devices not supported\n");
888 for (info
= info_list
; info
; info
= info
->next
) {
889 PciDeviceInfoList
*dev
;
891 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
892 hmp_info_pci_device(mon
, dev
->value
);
896 qapi_free_PciInfoList(info_list
);
899 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
901 TPMInfoList
*info_list
, *info
;
904 TPMPassthroughOptions
*tpo
;
905 TPMEmulatorOptions
*teo
;
907 info_list
= qmp_query_tpm(&err
);
909 monitor_printf(mon
, "TPM device not supported\n");
915 monitor_printf(mon
, "TPM device:\n");
918 for (info
= info_list
; info
; info
= info
->next
) {
919 TPMInfo
*ti
= info
->value
;
920 monitor_printf(mon
, " tpm%d: model=%s\n",
921 c
, TpmModel_str(ti
->model
));
923 monitor_printf(mon
, " \\ %s: type=%s",
924 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
926 switch (ti
->options
->type
) {
927 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
928 tpo
= ti
->options
->u
.passthrough
.data
;
929 monitor_printf(mon
, "%s%s%s%s",
930 tpo
->has_path
? ",path=" : "",
931 tpo
->has_path
? tpo
->path
: "",
932 tpo
->has_cancel_path
? ",cancel-path=" : "",
933 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
935 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
936 teo
= ti
->options
->u
.emulator
.data
;
937 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
939 case TPM_TYPE_OPTIONS_KIND__MAX
:
942 monitor_printf(mon
, "\n");
945 qapi_free_TPMInfoList(info_list
);
948 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
950 monitor_suspend(mon
);
954 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
959 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
961 const char *op
= qdict_get_try_str(qdict
, "op");
964 bool on
= qsp_is_enabled();
966 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
969 if (!strcmp(op
, "on")) {
971 } else if (!strcmp(op
, "off")) {
973 } else if (!strcmp(op
, "reset")) {
978 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
979 hmp_handle_error(mon
, err
);
983 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
985 qmp_system_reset(NULL
);
988 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
990 qmp_system_powerdown(NULL
);
993 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
997 qmp_x_exit_preconfig(&err
);
998 hmp_handle_error(mon
, err
);
1001 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1005 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1006 use it are converted to the QAPI */
1007 cpu_index
= qdict_get_int(qdict
, "index");
1008 if (monitor_set_cpu(mon
, cpu_index
) < 0) {
1009 monitor_printf(mon
, "invalid CPU index\n");
1013 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1015 uint32_t size
= qdict_get_int(qdict
, "size");
1016 const char *filename
= qdict_get_str(qdict
, "filename");
1017 uint64_t addr
= qdict_get_int(qdict
, "val");
1019 int cpu_index
= monitor_get_cpu_index(mon
);
1021 if (cpu_index
< 0) {
1022 monitor_printf(mon
, "No CPU available\n");
1026 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1027 hmp_handle_error(mon
, err
);
1030 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1032 uint32_t size
= qdict_get_int(qdict
, "size");
1033 const char *filename
= qdict_get_str(qdict
, "filename");
1034 uint64_t addr
= qdict_get_int(qdict
, "val");
1037 qmp_pmemsave(addr
, size
, filename
, &err
);
1038 hmp_handle_error(mon
, err
);
1041 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1043 const char *chardev
= qdict_get_str(qdict
, "device");
1044 const char *data
= qdict_get_str(qdict
, "data");
1047 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1049 hmp_handle_error(mon
, err
);
1052 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1054 uint32_t size
= qdict_get_int(qdict
, "size");
1055 const char *chardev
= qdict_get_str(qdict
, "device");
1060 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1062 hmp_handle_error(mon
, err
);
1066 for (i
= 0; data
[i
]; i
++) {
1067 unsigned char ch
= data
[i
];
1070 monitor_printf(mon
, "\\\\");
1071 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1072 monitor_printf(mon
, "\\u%04X", ch
);
1074 monitor_printf(mon
, "%c", ch
);
1078 monitor_printf(mon
, "\n");
1082 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1087 hmp_handle_error(mon
, err
);
1090 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1094 qmp_system_wakeup(&err
);
1095 hmp_handle_error(mon
, err
);
1098 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1102 qmp_inject_nmi(&err
);
1103 hmp_handle_error(mon
, err
);
1106 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1108 const char *name
= qdict_get_str(qdict
, "name");
1109 bool up
= qdict_get_bool(qdict
, "up");
1112 qmp_set_link(name
, up
, &err
);
1113 hmp_handle_error(mon
, err
);
1116 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1118 int64_t value
= qdict_get_int(qdict
, "value");
1121 qmp_balloon(value
, &err
);
1122 hmp_handle_error(mon
, err
);
1125 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1127 int saved_vm_running
= runstate_is_running();
1128 const char *name
= qdict_get_str(qdict
, "name");
1131 vm_stop(RUN_STATE_RESTORE_VM
);
1133 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1136 hmp_handle_error(mon
, err
);
1139 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1143 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1144 hmp_handle_error(mon
, err
);
1147 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1149 BlockDriverState
*bs
;
1151 const char *name
= qdict_get_str(qdict
, "name");
1153 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1155 "deleting snapshot on device '%s': ",
1156 bdrv_get_device_name(bs
));
1158 hmp_handle_error(mon
, err
);
1161 void hmp_announce_self(Monitor
*mon
, const QDict
*qdict
)
1163 const char *interfaces_str
= qdict_get_try_str(qdict
, "interfaces");
1164 const char *id
= qdict_get_try_str(qdict
, "id");
1165 AnnounceParameters
*params
= QAPI_CLONE(AnnounceParameters
,
1166 migrate_announce_params());
1168 qapi_free_strList(params
->interfaces
);
1169 params
->interfaces
= strList_from_comma_list(interfaces_str
);
1170 params
->has_interfaces
= params
->interfaces
!= NULL
;
1171 params
->id
= g_strdup(id
);
1172 params
->has_id
= !!params
->id
;
1173 qmp_announce_self(params
, NULL
);
1174 qapi_free_AnnounceParameters(params
);
1177 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1179 qmp_migrate_cancel(NULL
);
1182 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1185 const char *state
= qdict_get_str(qdict
, "state");
1186 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1189 qmp_migrate_continue(val
, &err
);
1192 hmp_handle_error(mon
, err
);
1195 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1198 const char *uri
= qdict_get_str(qdict
, "uri");
1200 qmp_migrate_incoming(uri
, &err
);
1202 hmp_handle_error(mon
, err
);
1205 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1208 const char *uri
= qdict_get_str(qdict
, "uri");
1210 qmp_migrate_recover(uri
, &err
);
1212 hmp_handle_error(mon
, err
);
1215 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1219 qmp_migrate_pause(&err
);
1221 hmp_handle_error(mon
, err
);
1224 /* Kept for backwards compatibility */
1225 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1229 double value
= qdict_get_double(qdict
, "value");
1230 qmp_migrate_set_downtime(value
, &err
);
1231 hmp_handle_error(mon
, err
);
1234 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1236 int64_t value
= qdict_get_int(qdict
, "value");
1239 qmp_migrate_set_cache_size(value
, &err
);
1240 hmp_handle_error(mon
, err
);
1243 /* Kept for backwards compatibility */
1244 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1248 int64_t value
= qdict_get_int(qdict
, "value");
1249 qmp_migrate_set_speed(value
, &err
);
1250 hmp_handle_error(mon
, err
);
1253 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1255 const char *cap
= qdict_get_str(qdict
, "capability");
1256 bool state
= qdict_get_bool(qdict
, "state");
1258 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1261 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1266 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1267 caps
->value
->capability
= val
;
1268 caps
->value
->state
= state
;
1270 qmp_migrate_set_capabilities(caps
, &err
);
1273 qapi_free_MigrationCapabilityStatusList(caps
);
1274 hmp_handle_error(mon
, err
);
1277 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1279 const char *param
= qdict_get_str(qdict
, "parameter");
1280 const char *valuestr
= qdict_get_str(qdict
, "value");
1281 Visitor
*v
= string_input_visitor_new(valuestr
);
1282 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1283 uint64_t valuebw
= 0;
1284 uint64_t cache_size
;
1288 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1294 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1295 p
->has_compress_level
= true;
1296 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1298 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1299 p
->has_compress_threads
= true;
1300 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1302 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1303 p
->has_compress_wait_thread
= true;
1304 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1306 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1307 p
->has_decompress_threads
= true;
1308 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1310 case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
:
1311 p
->has_throttle_trigger_threshold
= true;
1312 visit_type_int(v
, param
, &p
->throttle_trigger_threshold
, &err
);
1314 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1315 p
->has_cpu_throttle_initial
= true;
1316 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1318 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1319 p
->has_cpu_throttle_increment
= true;
1320 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1322 case MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW
:
1323 p
->has_cpu_throttle_tailslow
= true;
1324 visit_type_bool(v
, param
, &p
->cpu_throttle_tailslow
, &err
);
1326 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1327 p
->has_max_cpu_throttle
= true;
1328 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1330 case MIGRATION_PARAMETER_TLS_CREDS
:
1331 p
->has_tls_creds
= true;
1332 p
->tls_creds
= g_new0(StrOrNull
, 1);
1333 p
->tls_creds
->type
= QTYPE_QSTRING
;
1334 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1336 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1337 p
->has_tls_hostname
= true;
1338 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1339 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1340 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1342 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1343 p
->has_tls_authz
= true;
1344 p
->tls_authz
= g_new0(StrOrNull
, 1);
1345 p
->tls_authz
->type
= QTYPE_QSTRING
;
1346 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1348 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1349 p
->has_max_bandwidth
= true;
1351 * Can't use visit_type_size() here, because it
1352 * defaults to Bytes rather than Mebibytes.
1354 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1355 if (ret
< 0 || valuebw
> INT64_MAX
1356 || (size_t)valuebw
!= valuebw
) {
1357 error_setg(&err
, "Invalid size %s", valuestr
);
1360 p
->max_bandwidth
= valuebw
;
1362 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1363 p
->has_downtime_limit
= true;
1364 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1366 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1367 p
->has_x_checkpoint_delay
= true;
1368 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1370 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1371 p
->has_block_incremental
= true;
1372 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1374 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1375 p
->has_multifd_channels
= true;
1376 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1378 case MIGRATION_PARAMETER_MULTIFD_COMPRESSION
:
1379 p
->has_multifd_compression
= true;
1380 visit_type_MultiFDCompression(v
, param
, &p
->multifd_compression
,
1383 case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL
:
1384 p
->has_multifd_zlib_level
= true;
1385 visit_type_int(v
, param
, &p
->multifd_zlib_level
, &err
);
1387 case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL
:
1388 p
->has_multifd_zstd_level
= true;
1389 visit_type_int(v
, param
, &p
->multifd_zstd_level
, &err
);
1391 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1392 p
->has_xbzrle_cache_size
= true;
1393 if (!visit_type_size(v
, param
, &cache_size
, &err
)) {
1396 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1397 error_setg(&err
, "Invalid size %s", valuestr
);
1400 p
->xbzrle_cache_size
= cache_size
;
1402 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1403 p
->has_max_postcopy_bandwidth
= true;
1404 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1406 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1407 p
->has_announce_initial
= true;
1408 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1410 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1411 p
->has_announce_max
= true;
1412 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1414 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1415 p
->has_announce_rounds
= true;
1416 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1418 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1419 p
->has_announce_step
= true;
1420 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1422 case MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING
:
1423 error_setg(&err
, "The block-bitmap-mapping parameter can only be set "
1434 qmp_migrate_set_parameters(p
, &err
);
1437 qapi_free_MigrateSetParameters(p
);
1439 hmp_handle_error(mon
, err
);
1442 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1445 const char *protocol
= qdict_get_str(qdict
, "protocol");
1446 const char *hostname
= qdict_get_str(qdict
, "hostname");
1447 bool has_port
= qdict_haskey(qdict
, "port");
1448 int port
= qdict_get_try_int(qdict
, "port", -1);
1449 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1450 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1451 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1453 qmp_client_migrate_info(protocol
, hostname
,
1454 has_port
, port
, has_tls_port
, tls_port
,
1455 !!cert_subject
, cert_subject
, &err
);
1456 hmp_handle_error(mon
, err
);
1459 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1462 qmp_migrate_start_postcopy(&err
);
1463 hmp_handle_error(mon
, err
);
1466 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1470 qmp_x_colo_lost_heartbeat(&err
);
1471 hmp_handle_error(mon
, err
);
1474 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1476 const char *protocol
= qdict_get_str(qdict
, "protocol");
1477 const char *password
= qdict_get_str(qdict
, "password");
1478 const char *connected
= qdict_get_try_str(qdict
, "connected");
1481 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1482 hmp_handle_error(mon
, err
);
1485 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1487 const char *protocol
= qdict_get_str(qdict
, "protocol");
1488 const char *whenstr
= qdict_get_str(qdict
, "time");
1491 qmp_expire_password(protocol
, whenstr
, &err
);
1492 hmp_handle_error(mon
, err
);
1497 static void hmp_change_read_arg(void *opaque
, const char *password
,
1498 void *readline_opaque
)
1500 qmp_change_vnc_password(password
, NULL
);
1501 monitor_read_command(opaque
, 1);
1505 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1507 const char *device
= qdict_get_str(qdict
, "device");
1508 const char *target
= qdict_get_str(qdict
, "target");
1509 const char *arg
= qdict_get_try_str(qdict
, "arg");
1510 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1511 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1515 if (strcmp(device
, "vnc") == 0) {
1518 "Parameter 'read-only-mode' is invalid for VNC\n");
1521 if (strcmp(target
, "passwd") == 0 ||
1522 strcmp(target
, "password") == 0) {
1524 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1525 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1529 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1535 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1537 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1543 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1544 !!arg
, arg
, !!read_only
, read_only_mode
,
1549 hmp_handle_error(mon
, err
);
1552 typedef struct HMPMigrationStatus
1556 bool is_block_migration
;
1557 } HMPMigrationStatus
;
1559 static void hmp_migrate_status_cb(void *opaque
)
1561 HMPMigrationStatus
*status
= opaque
;
1562 MigrationInfo
*info
;
1564 info
= qmp_query_migrate(NULL
);
1565 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1566 info
->status
== MIGRATION_STATUS_SETUP
) {
1567 if (info
->has_disk
) {
1570 if (info
->disk
->remaining
) {
1571 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1576 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1577 monitor_flush(status
->mon
);
1580 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1582 if (status
->is_block_migration
) {
1583 monitor_printf(status
->mon
, "\n");
1585 if (info
->has_error_desc
) {
1586 error_report("%s", info
->error_desc
);
1588 monitor_resume(status
->mon
);
1589 timer_del(status
->timer
);
1590 timer_free(status
->timer
);
1594 qapi_free_MigrationInfo(info
);
1597 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1599 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1600 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1601 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1602 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1603 const char *uri
= qdict_get_str(qdict
, "uri");
1606 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1607 false, false, true, resume
, &err
);
1609 hmp_handle_error(mon
, err
);
1614 HMPMigrationStatus
*status
;
1616 if (monitor_suspend(mon
) < 0) {
1617 monitor_printf(mon
, "terminal does not allow synchronous "
1618 "migration, continuing detached\n");
1622 status
= g_malloc0(sizeof(*status
));
1624 status
->is_block_migration
= blk
|| inc
;
1625 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1627 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1631 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1635 const char *type
= qdict_get_try_str(qdict
, "type");
1637 if (type
&& is_help_option(type
)) {
1641 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1646 netdev_add(opts
, &err
);
1648 qemu_opts_del(opts
);
1652 hmp_handle_error(mon
, err
);
1655 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1657 const char *id
= qdict_get_str(qdict
, "id");
1660 qmp_netdev_del(id
, &err
);
1661 hmp_handle_error(mon
, err
);
1664 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1670 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1675 obj
= user_creatable_add_opts(opts
, &err
);
1676 qemu_opts_del(opts
);
1679 hmp_handle_error(mon
, err
);
1686 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1688 const char *fdname
= qdict_get_str(qdict
, "fdname");
1691 qmp_getfd(fdname
, &err
);
1692 hmp_handle_error(mon
, err
);
1695 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1697 const char *fdname
= qdict_get_str(qdict
, "fdname");
1700 qmp_closefd(fdname
, &err
);
1701 hmp_handle_error(mon
, err
);
1704 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1706 const char *keys
= qdict_get_str(qdict
, "keys");
1707 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1708 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1709 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1711 const char *separator
;
1715 separator
= qemu_strchrnul(keys
, '-');
1716 keyname_len
= separator
- keys
;
1718 /* Be compatible with old interface, convert user inputted "<" */
1719 if (keys
[0] == '<' && keyname_len
== 1) {
1724 keylist
= g_malloc0(sizeof(*keylist
));
1725 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1731 tmp
->next
= keylist
;
1735 if (strstart(keys
, "0x", NULL
)) {
1737 int value
= strtoul(keys
, &endp
, 0);
1738 assert(endp
<= keys
+ keyname_len
);
1739 if (endp
!= keys
+ keyname_len
) {
1742 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1743 keylist
->value
->u
.number
.data
= value
;
1745 int idx
= index_from_key(keys
, keyname_len
);
1746 if (idx
== Q_KEY_CODE__MAX
) {
1749 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1750 keylist
->value
->u
.qcode
.data
= idx
;
1756 keys
= separator
+ 1;
1759 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1760 hmp_handle_error(mon
, err
);
1763 qapi_free_KeyValueList(head
);
1767 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1772 hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1774 const char *filename
= qdict_get_str(qdict
, "filename");
1775 const char *id
= qdict_get_try_str(qdict
, "device");
1776 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
1779 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
1780 hmp_handle_error(mon
, err
);
1783 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1785 const char *args
= qdict_get_str(qdict
, "args");
1789 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1791 error_setg(&err
, "Parsing chardev args failed");
1793 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1794 qemu_opts_del(opts
);
1796 hmp_handle_error(mon
, err
);
1799 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
1801 const char *args
= qdict_get_str(qdict
, "args");
1804 ChardevBackend
*backend
= NULL
;
1805 ChardevReturn
*ret
= NULL
;
1806 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
1809 error_setg(&err
, "Parsing chardev args failed");
1813 id
= qdict_get_str(qdict
, "id");
1814 if (qemu_opts_id(opts
)) {
1815 error_setg(&err
, "Unexpected 'id' parameter");
1819 backend
= qemu_chr_parse_opts(opts
, &err
);
1824 ret
= qmp_chardev_change(id
, backend
, &err
);
1827 qapi_free_ChardevReturn(ret
);
1828 qapi_free_ChardevBackend(backend
);
1829 qemu_opts_del(opts
);
1830 hmp_handle_error(mon
, err
);
1833 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1835 Error
*local_err
= NULL
;
1837 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1838 hmp_handle_error(mon
, local_err
);
1841 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
1843 Error
*local_err
= NULL
;
1845 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
1846 hmp_handle_error(mon
, local_err
);
1849 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1851 const char *id
= qdict_get_str(qdict
, "id");
1854 user_creatable_del(id
, &err
);
1855 hmp_handle_error(mon
, err
);
1858 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1861 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1862 MemoryDeviceInfoList
*info
;
1863 VirtioPMEMDeviceInfo
*vpi
;
1864 VirtioMEMDeviceInfo
*vmi
;
1865 MemoryDeviceInfo
*value
;
1866 PCDIMMDeviceInfo
*di
;
1868 for (info
= info_list
; info
; info
= info
->next
) {
1869 value
= info
->value
;
1872 switch (value
->type
) {
1873 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1874 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
1875 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
1876 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
1877 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1878 MemoryDeviceInfoKind_str(value
->type
),
1879 di
->id
? di
->id
: "");
1880 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1881 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1882 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1883 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1884 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1885 monitor_printf(mon
, " hotplugged: %s\n",
1886 di
->hotplugged
? "true" : "false");
1887 monitor_printf(mon
, " hotpluggable: %s\n",
1888 di
->hotpluggable
? "true" : "false");
1890 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
1891 vpi
= value
->u
.virtio_pmem
.data
;
1892 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1893 MemoryDeviceInfoKind_str(value
->type
),
1894 vpi
->id
? vpi
->id
: "");
1895 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
1896 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
1897 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
1899 case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM
:
1900 vmi
= value
->u
.virtio_mem
.data
;
1901 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1902 MemoryDeviceInfoKind_str(value
->type
),
1903 vmi
->id
? vmi
->id
: "");
1904 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vmi
->memaddr
);
1905 monitor_printf(mon
, " node: %" PRId64
"\n", vmi
->node
);
1906 monitor_printf(mon
, " requested-size: %" PRIu64
"\n",
1907 vmi
->requested_size
);
1908 monitor_printf(mon
, " size: %" PRIu64
"\n", vmi
->size
);
1909 monitor_printf(mon
, " max-size: %" PRIu64
"\n", vmi
->max_size
);
1910 monitor_printf(mon
, " block-size: %" PRIu64
"\n",
1912 monitor_printf(mon
, " memdev: %s\n", vmi
->memdev
);
1915 g_assert_not_reached();
1920 qapi_free_MemoryDeviceInfoList(info_list
);
1921 hmp_handle_error(mon
, err
);
1924 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
1926 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
1927 IOThreadInfoList
*info
;
1928 IOThreadInfo
*value
;
1930 for (info
= info_list
; info
; info
= info
->next
) {
1931 value
= info
->value
;
1932 monitor_printf(mon
, "%s:\n", value
->id
);
1933 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
1934 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
1935 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
1936 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
1939 qapi_free_IOThreadInfoList(info_list
);
1942 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
1944 const char *name
= qdict_get_str(qdict
, "name");
1945 RockerSwitch
*rocker
;
1948 rocker
= qmp_query_rocker(name
, &err
);
1950 hmp_handle_error(mon
, err
);
1954 monitor_printf(mon
, "name: %s\n", rocker
->name
);
1955 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
1956 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
1958 qapi_free_RockerSwitch(rocker
);
1961 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
1963 RockerPortList
*list
, *port
;
1964 const char *name
= qdict_get_str(qdict
, "name");
1967 list
= qmp_query_rocker_ports(name
, &err
);
1969 hmp_handle_error(mon
, err
);
1973 monitor_printf(mon
, " ena/ speed/ auto\n");
1974 monitor_printf(mon
, " port link duplex neg?\n");
1976 for (port
= list
; port
; port
= port
->next
) {
1977 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
1979 port
->value
->enabled
? port
->value
->link_up
?
1980 "up" : "down" : "!ena",
1981 port
->value
->speed
== 10000 ? "10G" : "??",
1982 port
->value
->duplex
? "FD" : "HD",
1983 port
->value
->autoneg
? "Yes" : "No");
1986 qapi_free_RockerPortList(list
);
1989 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
1991 RockerOfDpaFlowList
*list
, *info
;
1992 const char *name
= qdict_get_str(qdict
, "name");
1993 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
1996 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
1998 hmp_handle_error(mon
, err
);
2002 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2004 for (info
= list
; info
; info
= info
->next
) {
2005 RockerOfDpaFlow
*flow
= info
->value
;
2006 RockerOfDpaFlowKey
*key
= flow
->key
;
2007 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2008 RockerOfDpaFlowAction
*action
= flow
->action
;
2011 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2012 key
->priority
, key
->tbl_id
, flow
->hits
);
2014 monitor_printf(mon
, "%-4d %-3d ",
2015 key
->priority
, key
->tbl_id
);
2018 if (key
->has_in_pport
) {
2019 monitor_printf(mon
, " pport %d", key
->in_pport
);
2020 if (mask
->has_in_pport
) {
2021 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2025 if (key
->has_vlan_id
) {
2026 monitor_printf(mon
, " vlan %d",
2027 key
->vlan_id
& VLAN_VID_MASK
);
2028 if (mask
->has_vlan_id
) {
2029 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2033 if (key
->has_tunnel_id
) {
2034 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2035 if (mask
->has_tunnel_id
) {
2036 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2040 if (key
->has_eth_type
) {
2041 switch (key
->eth_type
) {
2043 monitor_printf(mon
, " ARP");
2046 monitor_printf(mon
, " IP");
2049 monitor_printf(mon
, " IPv6");
2052 monitor_printf(mon
, " LACP");
2055 monitor_printf(mon
, " LLDP");
2058 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2063 if (key
->has_eth_src
) {
2064 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2065 (mask
->has_eth_src
) &&
2066 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2067 monitor_printf(mon
, " src <any mcast/bcast>");
2068 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2069 (mask
->has_eth_src
) &&
2070 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2071 monitor_printf(mon
, " src <any ucast>");
2073 monitor_printf(mon
, " src %s", key
->eth_src
);
2074 if (mask
->has_eth_src
) {
2075 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2080 if (key
->has_eth_dst
) {
2081 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2082 (mask
->has_eth_dst
) &&
2083 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2084 monitor_printf(mon
, " dst <any mcast/bcast>");
2085 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2086 (mask
->has_eth_dst
) &&
2087 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2088 monitor_printf(mon
, " dst <any ucast>");
2090 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2091 if (mask
->has_eth_dst
) {
2092 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2097 if (key
->has_ip_proto
) {
2098 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2099 if (mask
->has_ip_proto
) {
2100 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2104 if (key
->has_ip_tos
) {
2105 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2106 if (mask
->has_ip_tos
) {
2107 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2111 if (key
->has_ip_dst
) {
2112 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2115 if (action
->has_goto_tbl
|| action
->has_group_id
||
2116 action
->has_new_vlan_id
) {
2117 monitor_printf(mon
, " -->");
2120 if (action
->has_new_vlan_id
) {
2121 monitor_printf(mon
, " apply new vlan %d",
2122 ntohs(action
->new_vlan_id
));
2125 if (action
->has_group_id
) {
2126 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2129 if (action
->has_goto_tbl
) {
2130 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2133 monitor_printf(mon
, "\n");
2136 qapi_free_RockerOfDpaFlowList(list
);
2139 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2141 RockerOfDpaGroupList
*list
, *g
;
2142 const char *name
= qdict_get_str(qdict
, "name");
2143 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2146 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2148 hmp_handle_error(mon
, err
);
2152 monitor_printf(mon
, "id (decode) --> buckets\n");
2154 for (g
= list
; g
; g
= g
->next
) {
2155 RockerOfDpaGroup
*group
= g
->value
;
2158 monitor_printf(mon
, "0x%08x", group
->id
);
2160 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2161 group
->type
== 1 ? "L2 rewrite" :
2162 group
->type
== 2 ? "L3 unicast" :
2163 group
->type
== 3 ? "L2 multicast" :
2164 group
->type
== 4 ? "L2 flood" :
2165 group
->type
== 5 ? "L3 interface" :
2166 group
->type
== 6 ? "L3 multicast" :
2167 group
->type
== 7 ? "L3 ECMP" :
2168 group
->type
== 8 ? "L2 overlay" :
2171 if (group
->has_vlan_id
) {
2172 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2175 if (group
->has_pport
) {
2176 monitor_printf(mon
, " pport %d", group
->pport
);
2179 if (group
->has_index
) {
2180 monitor_printf(mon
, " index %d", group
->index
);
2183 monitor_printf(mon
, ") -->");
2185 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2187 monitor_printf(mon
, " set vlan %d",
2188 group
->set_vlan_id
& VLAN_VID_MASK
);
2191 if (group
->has_set_eth_src
) {
2194 monitor_printf(mon
, " set");
2196 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2199 if (group
->has_set_eth_dst
) {
2201 monitor_printf(mon
, " set");
2203 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2206 if (group
->has_ttl_check
&& group
->ttl_check
) {
2207 monitor_printf(mon
, " check TTL");
2210 if (group
->has_group_id
&& group
->group_id
) {
2211 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2214 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2215 monitor_printf(mon
, " pop vlan");
2218 if (group
->has_out_pport
) {
2219 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2222 if (group
->has_group_ids
) {
2223 struct uint32List
*id
;
2225 monitor_printf(mon
, " groups [");
2226 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2227 monitor_printf(mon
, "0x%08x", id
->value
);
2229 monitor_printf(mon
, ",");
2232 monitor_printf(mon
, "]");
2235 monitor_printf(mon
, "\n");
2238 qapi_free_RockerOfDpaGroupList(list
);
2241 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2243 ram_block_dump(mon
);
2246 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2249 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2251 monitor_printf(mon
, "%s\n", info
->guid
);
2253 hmp_handle_error(mon
, err
);
2254 qapi_free_GuidInfo(info
);
2257 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2260 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2262 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2265 if (info
->has_plugged_memory
) {
2266 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2267 info
->plugged_memory
);
2270 qapi_free_MemoryInfo(info
);
2272 hmp_handle_error(mon
, err
);