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
= NULL
;
1259 MigrationCapabilityStatus
*value
;
1262 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1267 value
= g_malloc0(sizeof(*value
));
1268 value
->capability
= val
;
1269 value
->state
= state
;
1270 QAPI_LIST_PREPEND(caps
, value
);
1271 qmp_migrate_set_capabilities(caps
, &err
);
1272 qapi_free_MigrationCapabilityStatusList(caps
);
1275 hmp_handle_error(mon
, err
);
1278 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1280 const char *param
= qdict_get_str(qdict
, "parameter");
1281 const char *valuestr
= qdict_get_str(qdict
, "value");
1282 Visitor
*v
= string_input_visitor_new(valuestr
);
1283 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1284 uint64_t valuebw
= 0;
1285 uint64_t cache_size
;
1289 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1295 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1296 p
->has_compress_level
= true;
1297 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1299 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1300 p
->has_compress_threads
= true;
1301 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1303 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1304 p
->has_compress_wait_thread
= true;
1305 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1307 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1308 p
->has_decompress_threads
= true;
1309 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1311 case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD
:
1312 p
->has_throttle_trigger_threshold
= true;
1313 visit_type_int(v
, param
, &p
->throttle_trigger_threshold
, &err
);
1315 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1316 p
->has_cpu_throttle_initial
= true;
1317 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1319 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1320 p
->has_cpu_throttle_increment
= true;
1321 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1323 case MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW
:
1324 p
->has_cpu_throttle_tailslow
= true;
1325 visit_type_bool(v
, param
, &p
->cpu_throttle_tailslow
, &err
);
1327 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1328 p
->has_max_cpu_throttle
= true;
1329 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1331 case MIGRATION_PARAMETER_TLS_CREDS
:
1332 p
->has_tls_creds
= true;
1333 p
->tls_creds
= g_new0(StrOrNull
, 1);
1334 p
->tls_creds
->type
= QTYPE_QSTRING
;
1335 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1337 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1338 p
->has_tls_hostname
= true;
1339 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1340 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1341 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1343 case MIGRATION_PARAMETER_TLS_AUTHZ
:
1344 p
->has_tls_authz
= true;
1345 p
->tls_authz
= g_new0(StrOrNull
, 1);
1346 p
->tls_authz
->type
= QTYPE_QSTRING
;
1347 visit_type_str(v
, param
, &p
->tls_authz
->u
.s
, &err
);
1349 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1350 p
->has_max_bandwidth
= true;
1352 * Can't use visit_type_size() here, because it
1353 * defaults to Bytes rather than Mebibytes.
1355 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1356 if (ret
< 0 || valuebw
> INT64_MAX
1357 || (size_t)valuebw
!= valuebw
) {
1358 error_setg(&err
, "Invalid size %s", valuestr
);
1361 p
->max_bandwidth
= valuebw
;
1363 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1364 p
->has_downtime_limit
= true;
1365 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1367 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1368 p
->has_x_checkpoint_delay
= true;
1369 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1371 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1372 p
->has_block_incremental
= true;
1373 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1375 case MIGRATION_PARAMETER_MULTIFD_CHANNELS
:
1376 p
->has_multifd_channels
= true;
1377 visit_type_int(v
, param
, &p
->multifd_channels
, &err
);
1379 case MIGRATION_PARAMETER_MULTIFD_COMPRESSION
:
1380 p
->has_multifd_compression
= true;
1381 visit_type_MultiFDCompression(v
, param
, &p
->multifd_compression
,
1384 case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL
:
1385 p
->has_multifd_zlib_level
= true;
1386 visit_type_int(v
, param
, &p
->multifd_zlib_level
, &err
);
1388 case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL
:
1389 p
->has_multifd_zstd_level
= true;
1390 visit_type_int(v
, param
, &p
->multifd_zstd_level
, &err
);
1392 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1393 p
->has_xbzrle_cache_size
= true;
1394 if (!visit_type_size(v
, param
, &cache_size
, &err
)) {
1397 if (cache_size
> INT64_MAX
|| (size_t)cache_size
!= cache_size
) {
1398 error_setg(&err
, "Invalid size %s", valuestr
);
1401 p
->xbzrle_cache_size
= cache_size
;
1403 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1404 p
->has_max_postcopy_bandwidth
= true;
1405 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1407 case MIGRATION_PARAMETER_ANNOUNCE_INITIAL
:
1408 p
->has_announce_initial
= true;
1409 visit_type_size(v
, param
, &p
->announce_initial
, &err
);
1411 case MIGRATION_PARAMETER_ANNOUNCE_MAX
:
1412 p
->has_announce_max
= true;
1413 visit_type_size(v
, param
, &p
->announce_max
, &err
);
1415 case MIGRATION_PARAMETER_ANNOUNCE_ROUNDS
:
1416 p
->has_announce_rounds
= true;
1417 visit_type_size(v
, param
, &p
->announce_rounds
, &err
);
1419 case MIGRATION_PARAMETER_ANNOUNCE_STEP
:
1420 p
->has_announce_step
= true;
1421 visit_type_size(v
, param
, &p
->announce_step
, &err
);
1423 case MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING
:
1424 error_setg(&err
, "The block-bitmap-mapping parameter can only be set "
1435 qmp_migrate_set_parameters(p
, &err
);
1438 qapi_free_MigrateSetParameters(p
);
1440 hmp_handle_error(mon
, err
);
1443 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1446 const char *protocol
= qdict_get_str(qdict
, "protocol");
1447 const char *hostname
= qdict_get_str(qdict
, "hostname");
1448 bool has_port
= qdict_haskey(qdict
, "port");
1449 int port
= qdict_get_try_int(qdict
, "port", -1);
1450 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1451 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1452 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1454 qmp_client_migrate_info(protocol
, hostname
,
1455 has_port
, port
, has_tls_port
, tls_port
,
1456 !!cert_subject
, cert_subject
, &err
);
1457 hmp_handle_error(mon
, err
);
1460 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1463 qmp_migrate_start_postcopy(&err
);
1464 hmp_handle_error(mon
, err
);
1467 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1471 qmp_x_colo_lost_heartbeat(&err
);
1472 hmp_handle_error(mon
, err
);
1475 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1477 const char *protocol
= qdict_get_str(qdict
, "protocol");
1478 const char *password
= qdict_get_str(qdict
, "password");
1479 const char *connected
= qdict_get_try_str(qdict
, "connected");
1482 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1483 hmp_handle_error(mon
, err
);
1486 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1488 const char *protocol
= qdict_get_str(qdict
, "protocol");
1489 const char *whenstr
= qdict_get_str(qdict
, "time");
1492 qmp_expire_password(protocol
, whenstr
, &err
);
1493 hmp_handle_error(mon
, err
);
1498 static void hmp_change_read_arg(void *opaque
, const char *password
,
1499 void *readline_opaque
)
1501 qmp_change_vnc_password(password
, NULL
);
1502 monitor_read_command(opaque
, 1);
1506 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1508 const char *device
= qdict_get_str(qdict
, "device");
1509 const char *target
= qdict_get_str(qdict
, "target");
1510 const char *arg
= qdict_get_try_str(qdict
, "arg");
1511 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1512 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1516 if (strcmp(device
, "vnc") == 0) {
1519 "Parameter 'read-only-mode' is invalid for VNC\n");
1522 if (strcmp(target
, "passwd") == 0 ||
1523 strcmp(target
, "password") == 0) {
1525 MonitorHMP
*hmp_mon
= container_of(mon
, MonitorHMP
, common
);
1526 monitor_read_password(hmp_mon
, hmp_change_read_arg
, NULL
);
1530 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1536 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1538 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1544 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1545 !!arg
, arg
, !!read_only
, read_only_mode
,
1550 hmp_handle_error(mon
, err
);
1553 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_free(status
->timer
);
1593 qapi_free_MigrationInfo(info
);
1596 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1598 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1599 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1600 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1601 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
1602 const char *uri
= qdict_get_str(qdict
, "uri");
1605 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
1606 false, false, true, resume
, &err
);
1608 hmp_handle_error(mon
, err
);
1613 HMPMigrationStatus
*status
;
1615 if (monitor_suspend(mon
) < 0) {
1616 monitor_printf(mon
, "terminal does not allow synchronous "
1617 "migration, continuing detached\n");
1621 status
= g_malloc0(sizeof(*status
));
1623 status
->is_block_migration
= blk
|| inc
;
1624 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1626 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1630 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1634 const char *type
= qdict_get_try_str(qdict
, "type");
1636 if (type
&& is_help_option(type
)) {
1640 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1645 netdev_add(opts
, &err
);
1647 qemu_opts_del(opts
);
1651 hmp_handle_error(mon
, err
);
1654 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1656 const char *id
= qdict_get_str(qdict
, "id");
1659 qmp_netdev_del(id
, &err
);
1660 hmp_handle_error(mon
, err
);
1663 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1669 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1674 obj
= user_creatable_add_opts(opts
, &err
);
1675 qemu_opts_del(opts
);
1678 hmp_handle_error(mon
, err
);
1685 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1687 const char *fdname
= qdict_get_str(qdict
, "fdname");
1690 qmp_getfd(fdname
, &err
);
1691 hmp_handle_error(mon
, err
);
1694 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1696 const char *fdname
= qdict_get_str(qdict
, "fdname");
1699 qmp_closefd(fdname
, &err
);
1700 hmp_handle_error(mon
, err
);
1703 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1705 const char *keys
= qdict_get_str(qdict
, "keys");
1706 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1707 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1708 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1710 const char *separator
;
1714 separator
= qemu_strchrnul(keys
, '-');
1715 keyname_len
= separator
- keys
;
1717 /* Be compatible with old interface, convert user inputted "<" */
1718 if (keys
[0] == '<' && keyname_len
== 1) {
1723 keylist
= g_malloc0(sizeof(*keylist
));
1724 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1730 tmp
->next
= keylist
;
1734 if (strstart(keys
, "0x", NULL
)) {
1736 int value
= strtoul(keys
, &endp
, 0);
1737 assert(endp
<= keys
+ keyname_len
);
1738 if (endp
!= keys
+ keyname_len
) {
1741 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1742 keylist
->value
->u
.number
.data
= value
;
1744 int idx
= index_from_key(keys
, keyname_len
);
1745 if (idx
== Q_KEY_CODE__MAX
) {
1748 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1749 keylist
->value
->u
.qcode
.data
= idx
;
1755 keys
= separator
+ 1;
1758 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1759 hmp_handle_error(mon
, err
);
1762 qapi_free_KeyValueList(head
);
1766 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1771 hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1773 const char *filename
= qdict_get_str(qdict
, "filename");
1774 const char *id
= qdict_get_try_str(qdict
, "device");
1775 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
1778 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
1779 hmp_handle_error(mon
, err
);
1782 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1784 const char *args
= qdict_get_str(qdict
, "args");
1788 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1790 error_setg(&err
, "Parsing chardev args failed");
1792 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1793 qemu_opts_del(opts
);
1795 hmp_handle_error(mon
, err
);
1798 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
1800 const char *args
= qdict_get_str(qdict
, "args");
1803 ChardevBackend
*backend
= NULL
;
1804 ChardevReturn
*ret
= NULL
;
1805 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
1808 error_setg(&err
, "Parsing chardev args failed");
1812 id
= qdict_get_str(qdict
, "id");
1813 if (qemu_opts_id(opts
)) {
1814 error_setg(&err
, "Unexpected 'id' parameter");
1818 backend
= qemu_chr_parse_opts(opts
, &err
);
1823 ret
= qmp_chardev_change(id
, backend
, &err
);
1826 qapi_free_ChardevReturn(ret
);
1827 qapi_free_ChardevBackend(backend
);
1828 qemu_opts_del(opts
);
1829 hmp_handle_error(mon
, err
);
1832 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1834 Error
*local_err
= NULL
;
1836 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1837 hmp_handle_error(mon
, local_err
);
1840 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
1842 Error
*local_err
= NULL
;
1844 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
1845 hmp_handle_error(mon
, local_err
);
1848 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1850 const char *id
= qdict_get_str(qdict
, "id");
1853 user_creatable_del(id
, &err
);
1854 hmp_handle_error(mon
, err
);
1857 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1860 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1861 MemoryDeviceInfoList
*info
;
1862 VirtioPMEMDeviceInfo
*vpi
;
1863 VirtioMEMDeviceInfo
*vmi
;
1864 MemoryDeviceInfo
*value
;
1865 PCDIMMDeviceInfo
*di
;
1867 for (info
= info_list
; info
; info
= info
->next
) {
1868 value
= info
->value
;
1871 switch (value
->type
) {
1872 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1873 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
1874 di
= value
->type
== MEMORY_DEVICE_INFO_KIND_DIMM
?
1875 value
->u
.dimm
.data
: value
->u
.nvdimm
.data
;
1876 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1877 MemoryDeviceInfoKind_str(value
->type
),
1878 di
->id
? di
->id
: "");
1879 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1880 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1881 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1882 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1883 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1884 monitor_printf(mon
, " hotplugged: %s\n",
1885 di
->hotplugged
? "true" : "false");
1886 monitor_printf(mon
, " hotpluggable: %s\n",
1887 di
->hotpluggable
? "true" : "false");
1889 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM
:
1890 vpi
= value
->u
.virtio_pmem
.data
;
1891 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1892 MemoryDeviceInfoKind_str(value
->type
),
1893 vpi
->id
? vpi
->id
: "");
1894 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vpi
->memaddr
);
1895 monitor_printf(mon
, " size: %" PRIu64
"\n", vpi
->size
);
1896 monitor_printf(mon
, " memdev: %s\n", vpi
->memdev
);
1898 case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM
:
1899 vmi
= value
->u
.virtio_mem
.data
;
1900 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1901 MemoryDeviceInfoKind_str(value
->type
),
1902 vmi
->id
? vmi
->id
: "");
1903 monitor_printf(mon
, " memaddr: 0x%" PRIx64
"\n", vmi
->memaddr
);
1904 monitor_printf(mon
, " node: %" PRId64
"\n", vmi
->node
);
1905 monitor_printf(mon
, " requested-size: %" PRIu64
"\n",
1906 vmi
->requested_size
);
1907 monitor_printf(mon
, " size: %" PRIu64
"\n", vmi
->size
);
1908 monitor_printf(mon
, " max-size: %" PRIu64
"\n", vmi
->max_size
);
1909 monitor_printf(mon
, " block-size: %" PRIu64
"\n",
1911 monitor_printf(mon
, " memdev: %s\n", vmi
->memdev
);
1914 g_assert_not_reached();
1919 qapi_free_MemoryDeviceInfoList(info_list
);
1920 hmp_handle_error(mon
, err
);
1923 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
1925 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
1926 IOThreadInfoList
*info
;
1927 IOThreadInfo
*value
;
1929 for (info
= info_list
; info
; info
= info
->next
) {
1930 value
= info
->value
;
1931 monitor_printf(mon
, "%s:\n", value
->id
);
1932 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
1933 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
1934 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
1935 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
1938 qapi_free_IOThreadInfoList(info_list
);
1941 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
1943 const char *name
= qdict_get_str(qdict
, "name");
1944 RockerSwitch
*rocker
;
1947 rocker
= qmp_query_rocker(name
, &err
);
1949 hmp_handle_error(mon
, err
);
1953 monitor_printf(mon
, "name: %s\n", rocker
->name
);
1954 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
1955 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
1957 qapi_free_RockerSwitch(rocker
);
1960 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
1962 RockerPortList
*list
, *port
;
1963 const char *name
= qdict_get_str(qdict
, "name");
1966 list
= qmp_query_rocker_ports(name
, &err
);
1968 hmp_handle_error(mon
, err
);
1972 monitor_printf(mon
, " ena/ speed/ auto\n");
1973 monitor_printf(mon
, " port link duplex neg?\n");
1975 for (port
= list
; port
; port
= port
->next
) {
1976 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
1978 port
->value
->enabled
? port
->value
->link_up
?
1979 "up" : "down" : "!ena",
1980 port
->value
->speed
== 10000 ? "10G" : "??",
1981 port
->value
->duplex
? "FD" : "HD",
1982 port
->value
->autoneg
? "Yes" : "No");
1985 qapi_free_RockerPortList(list
);
1988 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
1990 RockerOfDpaFlowList
*list
, *info
;
1991 const char *name
= qdict_get_str(qdict
, "name");
1992 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
1995 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
1997 hmp_handle_error(mon
, err
);
2001 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2003 for (info
= list
; info
; info
= info
->next
) {
2004 RockerOfDpaFlow
*flow
= info
->value
;
2005 RockerOfDpaFlowKey
*key
= flow
->key
;
2006 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2007 RockerOfDpaFlowAction
*action
= flow
->action
;
2010 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2011 key
->priority
, key
->tbl_id
, flow
->hits
);
2013 monitor_printf(mon
, "%-4d %-3d ",
2014 key
->priority
, key
->tbl_id
);
2017 if (key
->has_in_pport
) {
2018 monitor_printf(mon
, " pport %d", key
->in_pport
);
2019 if (mask
->has_in_pport
) {
2020 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2024 if (key
->has_vlan_id
) {
2025 monitor_printf(mon
, " vlan %d",
2026 key
->vlan_id
& VLAN_VID_MASK
);
2027 if (mask
->has_vlan_id
) {
2028 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2032 if (key
->has_tunnel_id
) {
2033 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2034 if (mask
->has_tunnel_id
) {
2035 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2039 if (key
->has_eth_type
) {
2040 switch (key
->eth_type
) {
2042 monitor_printf(mon
, " ARP");
2045 monitor_printf(mon
, " IP");
2048 monitor_printf(mon
, " IPv6");
2051 monitor_printf(mon
, " LACP");
2054 monitor_printf(mon
, " LLDP");
2057 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2062 if (key
->has_eth_src
) {
2063 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2064 (mask
->has_eth_src
) &&
2065 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2066 monitor_printf(mon
, " src <any mcast/bcast>");
2067 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2068 (mask
->has_eth_src
) &&
2069 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2070 monitor_printf(mon
, " src <any ucast>");
2072 monitor_printf(mon
, " src %s", key
->eth_src
);
2073 if (mask
->has_eth_src
) {
2074 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2079 if (key
->has_eth_dst
) {
2080 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2081 (mask
->has_eth_dst
) &&
2082 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2083 monitor_printf(mon
, " dst <any mcast/bcast>");
2084 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2085 (mask
->has_eth_dst
) &&
2086 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2087 monitor_printf(mon
, " dst <any ucast>");
2089 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2090 if (mask
->has_eth_dst
) {
2091 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2096 if (key
->has_ip_proto
) {
2097 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2098 if (mask
->has_ip_proto
) {
2099 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2103 if (key
->has_ip_tos
) {
2104 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2105 if (mask
->has_ip_tos
) {
2106 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2110 if (key
->has_ip_dst
) {
2111 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2114 if (action
->has_goto_tbl
|| action
->has_group_id
||
2115 action
->has_new_vlan_id
) {
2116 monitor_printf(mon
, " -->");
2119 if (action
->has_new_vlan_id
) {
2120 monitor_printf(mon
, " apply new vlan %d",
2121 ntohs(action
->new_vlan_id
));
2124 if (action
->has_group_id
) {
2125 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2128 if (action
->has_goto_tbl
) {
2129 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2132 monitor_printf(mon
, "\n");
2135 qapi_free_RockerOfDpaFlowList(list
);
2138 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2140 RockerOfDpaGroupList
*list
, *g
;
2141 const char *name
= qdict_get_str(qdict
, "name");
2142 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2145 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2147 hmp_handle_error(mon
, err
);
2151 monitor_printf(mon
, "id (decode) --> buckets\n");
2153 for (g
= list
; g
; g
= g
->next
) {
2154 RockerOfDpaGroup
*group
= g
->value
;
2157 monitor_printf(mon
, "0x%08x", group
->id
);
2159 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2160 group
->type
== 1 ? "L2 rewrite" :
2161 group
->type
== 2 ? "L3 unicast" :
2162 group
->type
== 3 ? "L2 multicast" :
2163 group
->type
== 4 ? "L2 flood" :
2164 group
->type
== 5 ? "L3 interface" :
2165 group
->type
== 6 ? "L3 multicast" :
2166 group
->type
== 7 ? "L3 ECMP" :
2167 group
->type
== 8 ? "L2 overlay" :
2170 if (group
->has_vlan_id
) {
2171 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2174 if (group
->has_pport
) {
2175 monitor_printf(mon
, " pport %d", group
->pport
);
2178 if (group
->has_index
) {
2179 monitor_printf(mon
, " index %d", group
->index
);
2182 monitor_printf(mon
, ") -->");
2184 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2186 monitor_printf(mon
, " set vlan %d",
2187 group
->set_vlan_id
& VLAN_VID_MASK
);
2190 if (group
->has_set_eth_src
) {
2193 monitor_printf(mon
, " set");
2195 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2198 if (group
->has_set_eth_dst
) {
2200 monitor_printf(mon
, " set");
2202 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2205 if (group
->has_ttl_check
&& group
->ttl_check
) {
2206 monitor_printf(mon
, " check TTL");
2209 if (group
->has_group_id
&& group
->group_id
) {
2210 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2213 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2214 monitor_printf(mon
, " pop vlan");
2217 if (group
->has_out_pport
) {
2218 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2221 if (group
->has_group_ids
) {
2222 struct uint32List
*id
;
2224 monitor_printf(mon
, " groups [");
2225 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2226 monitor_printf(mon
, "0x%08x", id
->value
);
2228 monitor_printf(mon
, ",");
2231 monitor_printf(mon
, "]");
2234 monitor_printf(mon
, "\n");
2237 qapi_free_RockerOfDpaGroupList(list
);
2240 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2242 ram_block_dump(mon
);
2245 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
2248 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
2250 monitor_printf(mon
, "%s\n", info
->guid
);
2252 hmp_handle_error(mon
, err
);
2253 qapi_free_GuidInfo(info
);
2256 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
2259 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
2261 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
2264 if (info
->has_plugged_memory
) {
2265 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
2266 info
->plugged_memory
);
2269 qapi_free_MemoryInfo(info
);
2271 hmp_handle_error(mon
, err
);