2 * Human Monitor Interface
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"
20 #include "chardev/char.h"
21 #include "sysemu/block-backend.h"
22 #include "sysemu/sysemu.h"
23 #include "qemu/config-file.h"
24 #include "qemu/option.h"
25 #include "qemu/timer.h"
26 #include "qemu/sockets.h"
27 #include "monitor/monitor.h"
28 #include "monitor/qdev.h"
29 #include "qapi/error.h"
30 #include "qapi/opts-visitor.h"
31 #include "qapi/qapi-builtin-visit.h"
32 #include "qapi/qapi-commands-block.h"
33 #include "qapi/qapi-commands-char.h"
34 #include "qapi/qapi-commands-migration.h"
35 #include "qapi/qapi-commands-misc.h"
36 #include "qapi/qapi-commands-net.h"
37 #include "qapi/qapi-commands-rocker.h"
38 #include "qapi/qapi-commands-run-state.h"
39 #include "qapi/qapi-commands-tpm.h"
40 #include "qapi/qapi-commands-ui.h"
41 #include "qapi/qmp/qdict.h"
42 #include "qapi/qmp/qerror.h"
43 #include "qapi/string-input-visitor.h"
44 #include "qapi/string-output-visitor.h"
45 #include "qom/object_interfaces.h"
46 #include "ui/console.h"
47 #include "block/nbd.h"
48 #include "block/qapi.h"
50 #include "qemu/cutils.h"
51 #include "qemu/error-report.h"
52 #include "exec/ramlist.h"
53 #include "hw/intc/intc.h"
54 #include "migration/snapshot.h"
55 #include "migration/misc.h"
58 #include <spice/enums.h>
61 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
65 error_report_err(*errp
);
69 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
73 info
= qmp_query_name(NULL
);
75 monitor_printf(mon
, "%s\n", info
->name
);
77 qapi_free_NameInfo(info
);
80 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
84 info
= qmp_query_version(NULL
);
86 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
87 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
90 qapi_free_VersionInfo(info
);
93 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
97 info
= qmp_query_kvm(NULL
);
98 monitor_printf(mon
, "kvm support: ");
100 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
102 monitor_printf(mon
, "not compiled\n");
105 qapi_free_KvmInfo(info
);
108 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
112 info
= qmp_query_status(NULL
);
114 monitor_printf(mon
, "VM status: %s%s",
115 info
->running
? "running" : "paused",
116 info
->singlestep
? " (single step mode)" : "");
118 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
119 monitor_printf(mon
, " (%s)", RunState_str(info
->status
));
122 monitor_printf(mon
, "\n");
124 qapi_free_StatusInfo(info
);
127 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
131 info
= qmp_query_uuid(NULL
);
132 monitor_printf(mon
, "%s\n", info
->UUID
);
133 qapi_free_UuidInfo(info
);
136 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
138 ChardevInfoList
*char_info
, *info
;
140 char_info
= qmp_query_chardev(NULL
);
141 for (info
= char_info
; info
; info
= info
->next
) {
142 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
143 info
->value
->filename
);
146 qapi_free_ChardevInfoList(char_info
);
149 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
151 MouseInfoList
*mice_list
, *mouse
;
153 mice_list
= qmp_query_mice(NULL
);
155 monitor_printf(mon
, "No mouse devices connected\n");
159 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
160 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
161 mouse
->value
->current
? '*' : ' ',
162 mouse
->value
->index
, mouse
->value
->name
,
163 mouse
->value
->absolute
? " (absolute)" : "");
166 qapi_free_MouseInfoList(mice_list
);
169 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
172 MigrationCapabilityStatusList
*caps
, *cap
;
174 info
= qmp_query_migrate(NULL
);
175 caps
= qmp_query_migrate_capabilities(NULL
);
177 migration_global_dump(mon
);
179 /* do not display parameters during setup */
180 if (info
->has_status
&& caps
) {
181 monitor_printf(mon
, "capabilities: ");
182 for (cap
= caps
; cap
; cap
= cap
->next
) {
183 monitor_printf(mon
, "%s: %s ",
184 MigrationCapability_str(cap
->value
->capability
),
185 cap
->value
->state
? "on" : "off");
187 monitor_printf(mon
, "\n");
190 if (info
->has_status
) {
191 monitor_printf(mon
, "Migration status: %s",
192 MigrationStatus_str(info
->status
));
193 if (info
->status
== MIGRATION_STATUS_FAILED
&&
194 info
->has_error_desc
) {
195 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
197 monitor_printf(mon
, "\n");
200 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
202 if (info
->has_expected_downtime
) {
203 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
204 info
->expected_downtime
);
206 if (info
->has_downtime
) {
207 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
210 if (info
->has_setup_time
) {
211 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
217 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
218 info
->ram
->transferred
>> 10);
219 monitor_printf(mon
, "throughput: %0.2f mbps\n",
221 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
222 info
->ram
->remaining
>> 10);
223 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
224 info
->ram
->total
>> 10);
225 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
226 info
->ram
->duplicate
);
227 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
229 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
231 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
232 info
->ram
->normal_bytes
>> 10);
233 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
234 info
->ram
->dirty_sync_count
);
235 monitor_printf(mon
, "page size: %" PRIu64
" kbytes\n",
236 info
->ram
->page_size
>> 10);
237 monitor_printf(mon
, "multifd bytes: %" PRIu64
" kbytes\n",
238 info
->ram
->multifd_bytes
>> 10);
239 monitor_printf(mon
, "pages-per-second: %" PRIu64
"\n",
240 info
->ram
->pages_per_second
);
242 if (info
->ram
->dirty_pages_rate
) {
243 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
244 info
->ram
->dirty_pages_rate
);
246 if (info
->ram
->postcopy_requests
) {
247 monitor_printf(mon
, "postcopy request count: %" PRIu64
"\n",
248 info
->ram
->postcopy_requests
);
252 if (info
->has_disk
) {
253 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
254 info
->disk
->transferred
>> 10);
255 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
256 info
->disk
->remaining
>> 10);
257 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
258 info
->disk
->total
>> 10);
261 if (info
->has_xbzrle_cache
) {
262 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
263 info
->xbzrle_cache
->cache_size
);
264 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
265 info
->xbzrle_cache
->bytes
>> 10);
266 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
267 info
->xbzrle_cache
->pages
);
268 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
269 info
->xbzrle_cache
->cache_miss
);
270 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
271 info
->xbzrle_cache
->cache_miss_rate
);
272 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
273 info
->xbzrle_cache
->overflow
);
276 if (info
->has_compression
) {
277 monitor_printf(mon
, "compression pages: %" PRIu64
" pages\n",
278 info
->compression
->pages
);
279 monitor_printf(mon
, "compression busy: %" PRIu64
"\n",
280 info
->compression
->busy
);
281 monitor_printf(mon
, "compression busy rate: %0.2f\n",
282 info
->compression
->busy_rate
);
283 monitor_printf(mon
, "compressed size: %" PRIu64
"\n",
284 info
->compression
->compressed_size
);
285 monitor_printf(mon
, "compression rate: %0.2f\n",
286 info
->compression
->compression_rate
);
289 if (info
->has_cpu_throttle_percentage
) {
290 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
291 info
->cpu_throttle_percentage
);
294 if (info
->has_postcopy_blocktime
) {
295 monitor_printf(mon
, "postcopy blocktime: %u\n",
296 info
->postcopy_blocktime
);
299 if (info
->has_postcopy_vcpu_blocktime
) {
302 v
= string_output_visitor_new(false, &str
);
303 visit_type_uint32List(v
, NULL
, &info
->postcopy_vcpu_blocktime
, NULL
);
304 visit_complete(v
, &str
);
305 monitor_printf(mon
, "postcopy vcpu blocktime: %s\n", str
);
309 qapi_free_MigrationInfo(info
);
310 qapi_free_MigrationCapabilityStatusList(caps
);
313 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
315 MigrationCapabilityStatusList
*caps
, *cap
;
317 caps
= qmp_query_migrate_capabilities(NULL
);
320 for (cap
= caps
; cap
; cap
= cap
->next
) {
321 monitor_printf(mon
, "%s: %s\n",
322 MigrationCapability_str(cap
->value
->capability
),
323 cap
->value
->state
? "on" : "off");
327 qapi_free_MigrationCapabilityStatusList(caps
);
330 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
332 MigrationParameters
*params
;
334 params
= qmp_query_migrate_parameters(NULL
);
337 assert(params
->has_compress_level
);
338 monitor_printf(mon
, "%s: %u\n",
339 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL
),
340 params
->compress_level
);
341 assert(params
->has_compress_threads
);
342 monitor_printf(mon
, "%s: %u\n",
343 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS
),
344 params
->compress_threads
);
345 assert(params
->has_compress_wait_thread
);
346 monitor_printf(mon
, "%s: %s\n",
347 MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
),
348 params
->compress_wait_thread
? "on" : "off");
349 assert(params
->has_decompress_threads
);
350 monitor_printf(mon
, "%s: %u\n",
351 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS
),
352 params
->decompress_threads
);
353 assert(params
->has_cpu_throttle_initial
);
354 monitor_printf(mon
, "%s: %u\n",
355 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
),
356 params
->cpu_throttle_initial
);
357 assert(params
->has_cpu_throttle_increment
);
358 monitor_printf(mon
, "%s: %u\n",
359 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
),
360 params
->cpu_throttle_increment
);
361 assert(params
->has_max_cpu_throttle
);
362 monitor_printf(mon
, "%s: %u\n",
363 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE
),
364 params
->max_cpu_throttle
);
365 assert(params
->has_tls_creds
);
366 monitor_printf(mon
, "%s: '%s'\n",
367 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS
),
369 assert(params
->has_tls_hostname
);
370 monitor_printf(mon
, "%s: '%s'\n",
371 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME
),
372 params
->tls_hostname
);
373 assert(params
->has_max_bandwidth
);
374 monitor_printf(mon
, "%s: %" PRIu64
" bytes/second\n",
375 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH
),
376 params
->max_bandwidth
);
377 assert(params
->has_downtime_limit
);
378 monitor_printf(mon
, "%s: %" PRIu64
" milliseconds\n",
379 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT
),
380 params
->downtime_limit
);
381 assert(params
->has_x_checkpoint_delay
);
382 monitor_printf(mon
, "%s: %u\n",
383 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
),
384 params
->x_checkpoint_delay
);
385 assert(params
->has_block_incremental
);
386 monitor_printf(mon
, "%s: %s\n",
387 MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL
),
388 params
->block_incremental
? "on" : "off");
389 monitor_printf(mon
, "%s: %u\n",
390 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
),
391 params
->x_multifd_channels
);
392 monitor_printf(mon
, "%s: %u\n",
393 MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
),
394 params
->x_multifd_page_count
);
395 monitor_printf(mon
, "%s: %" PRIu64
"\n",
396 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
),
397 params
->xbzrle_cache_size
);
398 monitor_printf(mon
, "%s: %" PRIu64
"\n",
399 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
),
400 params
->max_postcopy_bandwidth
);
403 qapi_free_MigrationParameters(params
);
406 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
408 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
409 qmp_query_migrate_cache_size(NULL
) >> 10);
412 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
414 CpuInfoFastList
*cpu_list
, *cpu
;
416 cpu_list
= qmp_query_cpus_fast(NULL
);
418 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
421 if (cpu
->value
->cpu_index
== monitor_get_cpu_index()) {
425 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
,
426 cpu
->value
->cpu_index
);
427 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
430 qapi_free_CpuInfoFastList(cpu_list
);
433 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
434 BlockDeviceInfo
*inserted
, bool verbose
)
436 ImageInfo
*image_info
;
438 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
440 if (info
&& *info
->device
) {
441 monitor_printf(mon
, "%s", info
->device
);
442 if (inserted
&& inserted
->has_node_name
) {
443 monitor_printf(mon
, " (%s)", inserted
->node_name
);
446 assert(info
|| inserted
);
447 monitor_printf(mon
, "%s",
448 inserted
&& inserted
->has_node_name
? inserted
->node_name
449 : info
&& info
->has_qdev
? info
->qdev
454 monitor_printf(mon
, ": %s (%s%s%s)\n",
457 inserted
->ro
? ", read-only" : "",
458 inserted
->encrypted
? ", encrypted" : "");
460 monitor_printf(mon
, ": [not inserted]\n");
464 if (info
->has_qdev
) {
465 monitor_printf(mon
, " Attached to: %s\n", info
->qdev
);
467 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
468 monitor_printf(mon
, " I/O status: %s\n",
469 BlockDeviceIoStatus_str(info
->io_status
));
472 if (info
->removable
) {
473 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
474 info
->locked
? "" : "not ",
475 info
->tray_open
? "open" : "closed");
484 monitor_printf(mon
, " Cache mode: %s%s%s\n",
485 inserted
->cache
->writeback
? "writeback" : "writethrough",
486 inserted
->cache
->direct
? ", direct" : "",
487 inserted
->cache
->no_flush
? ", ignore flushes" : "");
489 if (inserted
->has_backing_file
) {
492 "(chain depth: %" PRId64
")\n",
493 inserted
->backing_file
,
494 inserted
->backing_file_depth
);
497 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
498 monitor_printf(mon
, " Detect zeroes: %s\n",
499 BlockdevDetectZeroesOptions_str(inserted
->detect_zeroes
));
502 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
503 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
505 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
506 " bps_rd=%" PRId64
" bps_wr=%" PRId64
508 " bps_rd_max=%" PRId64
509 " bps_wr_max=%" PRId64
510 " iops=%" PRId64
" iops_rd=%" PRId64
513 " iops_rd_max=%" PRId64
514 " iops_wr_max=%" PRId64
515 " iops_size=%" PRId64
521 inserted
->bps_rd_max
,
522 inserted
->bps_wr_max
,
527 inserted
->iops_rd_max
,
528 inserted
->iops_wr_max
,
534 monitor_printf(mon
, "\nImages:\n");
535 image_info
= inserted
->image
;
537 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
539 if (image_info
->has_backing_image
) {
540 image_info
= image_info
->backing_image
;
548 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
550 BlockInfoList
*block_list
, *info
;
551 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
552 const char *device
= qdict_get_try_str(qdict
, "device");
553 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
554 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
555 bool printed
= false;
557 /* Print BlockBackend information */
559 block_list
= qmp_query_block(NULL
);
564 for (info
= block_list
; info
; info
= info
->next
) {
565 if (device
&& strcmp(device
, info
->value
->device
)) {
569 if (info
!= block_list
) {
570 monitor_printf(mon
, "\n");
573 print_block_info(mon
, info
->value
, info
->value
->has_inserted
574 ? info
->value
->inserted
: NULL
,
579 qapi_free_BlockInfoList(block_list
);
581 if ((!device
&& !nodes
) || printed
) {
585 /* Print node information */
586 blockdev_list
= qmp_query_named_block_nodes(NULL
);
587 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
588 assert(blockdev
->value
->has_node_name
);
589 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
593 if (blockdev
!= blockdev_list
) {
594 monitor_printf(mon
, "\n");
597 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
599 qapi_free_BlockDeviceInfoList(blockdev_list
);
602 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
604 BlockStatsList
*stats_list
, *stats
;
606 stats_list
= qmp_query_blockstats(false, false, NULL
);
608 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
609 if (!stats
->value
->has_device
) {
613 monitor_printf(mon
, "%s:", stats
->value
->device
);
614 monitor_printf(mon
, " rd_bytes=%" PRId64
616 " rd_operations=%" PRId64
617 " wr_operations=%" PRId64
618 " flush_operations=%" PRId64
619 " wr_total_time_ns=%" PRId64
620 " rd_total_time_ns=%" PRId64
621 " flush_total_time_ns=%" PRId64
622 " rd_merged=%" PRId64
623 " wr_merged=%" PRId64
624 " idle_time_ns=%" PRId64
626 stats
->value
->stats
->rd_bytes
,
627 stats
->value
->stats
->wr_bytes
,
628 stats
->value
->stats
->rd_operations
,
629 stats
->value
->stats
->wr_operations
,
630 stats
->value
->stats
->flush_operations
,
631 stats
->value
->stats
->wr_total_time_ns
,
632 stats
->value
->stats
->rd_total_time_ns
,
633 stats
->value
->stats
->flush_total_time_ns
,
634 stats
->value
->stats
->rd_merged
,
635 stats
->value
->stats
->wr_merged
,
636 stats
->value
->stats
->idle_time_ns
);
639 qapi_free_BlockStatsList(stats_list
);
643 /* Helper for hmp_info_vnc_clients, _servers */
644 static void hmp_info_VncBasicInfo(Monitor
*mon
, VncBasicInfo
*info
,
647 monitor_printf(mon
, " %s: %s:%s (%s%s)\n",
651 NetworkAddressFamily_str(info
->family
),
652 info
->websocket
? " (Websocket)" : "");
655 /* Helper displaying and auth and crypt info */
656 static void hmp_info_vnc_authcrypt(Monitor
*mon
, const char *indent
,
658 VncVencryptSubAuth
*vencrypt
)
660 monitor_printf(mon
, "%sAuth: %s (Sub: %s)\n", indent
,
661 VncPrimaryAuth_str(auth
),
662 vencrypt
? VncVencryptSubAuth_str(*vencrypt
) : "none");
665 static void hmp_info_vnc_clients(Monitor
*mon
, VncClientInfoList
*client
)
668 VncClientInfo
*cinfo
= client
->value
;
670 hmp_info_VncBasicInfo(mon
, qapi_VncClientInfo_base(cinfo
), "Client");
671 monitor_printf(mon
, " x509_dname: %s\n",
672 cinfo
->has_x509_dname
?
673 cinfo
->x509_dname
: "none");
674 monitor_printf(mon
, " sasl_username: %s\n",
675 cinfo
->has_sasl_username
?
676 cinfo
->sasl_username
: "none");
678 client
= client
->next
;
682 static void hmp_info_vnc_servers(Monitor
*mon
, VncServerInfo2List
*server
)
685 VncServerInfo2
*sinfo
= server
->value
;
686 hmp_info_VncBasicInfo(mon
, qapi_VncServerInfo2_base(sinfo
), "Server");
687 hmp_info_vnc_authcrypt(mon
, " ", sinfo
->auth
,
688 sinfo
->has_vencrypt
? &sinfo
->vencrypt
: NULL
);
689 server
= server
->next
;
693 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
695 VncInfo2List
*info2l
;
698 info2l
= qmp_query_vnc_servers(&err
);
700 hmp_handle_error(mon
, &err
);
704 monitor_printf(mon
, "None\n");
709 VncInfo2
*info
= info2l
->value
;
710 monitor_printf(mon
, "%s:\n", info
->id
);
711 hmp_info_vnc_servers(mon
, info
->server
);
712 hmp_info_vnc_clients(mon
, info
->clients
);
714 /* The server entry displays its auth, we only
715 * need to display in the case of 'reverse' connections
716 * where there's no server.
718 hmp_info_vnc_authcrypt(mon
, " ", info
->auth
,
719 info
->has_vencrypt
? &info
->vencrypt
: NULL
);
721 if (info
->has_display
) {
722 monitor_printf(mon
, " Display: %s\n", info
->display
);
724 info2l
= info2l
->next
;
727 qapi_free_VncInfo2List(info2l
);
733 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
735 SpiceChannelList
*chan
;
737 const char *channel_name
;
738 const char * const channel_names
[] = {
739 [SPICE_CHANNEL_MAIN
] = "main",
740 [SPICE_CHANNEL_DISPLAY
] = "display",
741 [SPICE_CHANNEL_INPUTS
] = "inputs",
742 [SPICE_CHANNEL_CURSOR
] = "cursor",
743 [SPICE_CHANNEL_PLAYBACK
] = "playback",
744 [SPICE_CHANNEL_RECORD
] = "record",
745 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
746 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
747 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
748 [SPICE_CHANNEL_PORT
] = "port",
750 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
751 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
752 * as quick fix for build failures with older versions. */
753 [SPICE_CHANNEL_WEBDAV
] = "webdav",
757 info
= qmp_query_spice(NULL
);
759 if (!info
->enabled
) {
760 monitor_printf(mon
, "Server: disabled\n");
764 monitor_printf(mon
, "Server:\n");
765 if (info
->has_port
) {
766 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
767 info
->host
, info
->port
);
769 if (info
->has_tls_port
) {
770 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
771 info
->host
, info
->tls_port
);
773 monitor_printf(mon
, " migrated: %s\n",
774 info
->migrated
? "true" : "false");
775 monitor_printf(mon
, " auth: %s\n", info
->auth
);
776 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
777 monitor_printf(mon
, " mouse-mode: %s\n",
778 SpiceQueryMouseMode_str(info
->mouse_mode
));
780 if (!info
->has_channels
|| info
->channels
== NULL
) {
781 monitor_printf(mon
, "Channels: none\n");
783 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
784 monitor_printf(mon
, "Channel:\n");
785 monitor_printf(mon
, " address: %s:%s%s\n",
786 chan
->value
->host
, chan
->value
->port
,
787 chan
->value
->tls
? " [tls]" : "");
788 monitor_printf(mon
, " session: %" PRId64
"\n",
789 chan
->value
->connection_id
);
790 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
791 chan
->value
->channel_type
, chan
->value
->channel_id
);
793 channel_name
= "unknown";
794 if (chan
->value
->channel_type
> 0 &&
795 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
796 channel_names
[chan
->value
->channel_type
]) {
797 channel_name
= channel_names
[chan
->value
->channel_type
];
800 monitor_printf(mon
, " channel name: %s\n", channel_name
);
805 qapi_free_SpiceInfo(info
);
809 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
814 info
= qmp_query_balloon(&err
);
816 hmp_handle_error(mon
, &err
);
820 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
822 qapi_free_BalloonInfo(info
);
825 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
827 PciMemoryRegionList
*region
;
829 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
830 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
831 dev
->slot
, dev
->function
);
832 monitor_printf(mon
, " ");
834 if (dev
->class_info
->has_desc
) {
835 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
837 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
840 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
841 dev
->id
->vendor
, dev
->id
->device
);
842 if (dev
->id
->has_subsystem_vendor
&& dev
->id
->has_subsystem
) {
843 monitor_printf(mon
, " PCI subsystem %04" PRIx64
":%04" PRIx64
"\n",
844 dev
->id
->subsystem_vendor
, dev
->id
->subsystem
);
848 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
851 if (dev
->has_pci_bridge
) {
852 monitor_printf(mon
, " BUS %" PRId64
".\n",
853 dev
->pci_bridge
->bus
->number
);
854 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
855 dev
->pci_bridge
->bus
->secondary
);
856 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
857 dev
->pci_bridge
->bus
->subordinate
);
859 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
860 dev
->pci_bridge
->bus
->io_range
->base
,
861 dev
->pci_bridge
->bus
->io_range
->limit
);
864 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
865 dev
->pci_bridge
->bus
->memory_range
->base
,
866 dev
->pci_bridge
->bus
->memory_range
->limit
);
868 monitor_printf(mon
, " prefetchable memory range "
869 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
870 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
871 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
874 for (region
= dev
->regions
; region
; region
= region
->next
) {
877 addr
= region
->value
->address
;
878 size
= region
->value
->size
;
880 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
882 if (!strcmp(region
->value
->type
, "io")) {
883 monitor_printf(mon
, "I/O at 0x%04" PRIx64
884 " [0x%04" PRIx64
"].\n",
885 addr
, addr
+ size
- 1);
887 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
888 " [0x%08" PRIx64
"].\n",
889 region
->value
->mem_type_64
? 64 : 32,
890 region
->value
->prefetch
? " prefetchable" : "",
891 addr
, addr
+ size
- 1);
895 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
897 if (dev
->has_pci_bridge
) {
898 if (dev
->pci_bridge
->has_devices
) {
899 PciDeviceInfoList
*cdev
;
900 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
901 hmp_info_pci_device(mon
, cdev
->value
);
907 static int hmp_info_irq_foreach(Object
*obj
, void *opaque
)
909 InterruptStatsProvider
*intc
;
910 InterruptStatsProviderClass
*k
;
911 Monitor
*mon
= opaque
;
913 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
914 intc
= INTERRUPT_STATS_PROVIDER(obj
);
915 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
916 uint64_t *irq_counts
;
917 unsigned int nb_irqs
, i
;
918 if (k
->get_statistics
&&
919 k
->get_statistics(intc
, &irq_counts
, &nb_irqs
)) {
921 monitor_printf(mon
, "IRQ statistics for %s:\n",
922 object_get_typename(obj
));
923 for (i
= 0; i
< nb_irqs
; i
++) {
924 if (irq_counts
[i
] > 0) {
925 monitor_printf(mon
, "%2d: %" PRId64
"\n", i
,
931 monitor_printf(mon
, "IRQ statistics not available for %s.\n",
932 object_get_typename(obj
));
939 void hmp_info_irq(Monitor
*mon
, const QDict
*qdict
)
941 object_child_foreach_recursive(object_get_root(),
942 hmp_info_irq_foreach
, mon
);
945 static int hmp_info_pic_foreach(Object
*obj
, void *opaque
)
947 InterruptStatsProvider
*intc
;
948 InterruptStatsProviderClass
*k
;
949 Monitor
*mon
= opaque
;
951 if (object_dynamic_cast(obj
, TYPE_INTERRUPT_STATS_PROVIDER
)) {
952 intc
= INTERRUPT_STATS_PROVIDER(obj
);
953 k
= INTERRUPT_STATS_PROVIDER_GET_CLASS(obj
);
955 k
->print_info(intc
, mon
);
957 monitor_printf(mon
, "Interrupt controller information not available for %s.\n",
958 object_get_typename(obj
));
965 void hmp_info_pic(Monitor
*mon
, const QDict
*qdict
)
967 object_child_foreach_recursive(object_get_root(),
968 hmp_info_pic_foreach
, mon
);
971 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
973 PciInfoList
*info_list
, *info
;
976 info_list
= qmp_query_pci(&err
);
978 monitor_printf(mon
, "PCI devices not supported\n");
983 for (info
= info_list
; info
; info
= info
->next
) {
984 PciDeviceInfoList
*dev
;
986 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
987 hmp_info_pci_device(mon
, dev
->value
);
991 qapi_free_PciInfoList(info_list
);
994 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
996 BlockJobInfoList
*list
;
999 list
= qmp_query_block_jobs(&err
);
1003 monitor_printf(mon
, "No active jobs\n");
1008 if (strcmp(list
->value
->type
, "stream") == 0) {
1009 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
1010 " of %" PRId64
" bytes, speed limit %" PRId64
1012 list
->value
->device
,
1013 list
->value
->offset
,
1015 list
->value
->speed
);
1017 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
1018 " of %" PRId64
" bytes, speed limit %" PRId64
1021 list
->value
->device
,
1022 list
->value
->offset
,
1024 list
->value
->speed
);
1029 qapi_free_BlockJobInfoList(list
);
1032 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
1034 TPMInfoList
*info_list
, *info
;
1037 TPMPassthroughOptions
*tpo
;
1038 TPMEmulatorOptions
*teo
;
1040 info_list
= qmp_query_tpm(&err
);
1042 monitor_printf(mon
, "TPM device not supported\n");
1048 monitor_printf(mon
, "TPM device:\n");
1051 for (info
= info_list
; info
; info
= info
->next
) {
1052 TPMInfo
*ti
= info
->value
;
1053 monitor_printf(mon
, " tpm%d: model=%s\n",
1054 c
, TpmModel_str(ti
->model
));
1056 monitor_printf(mon
, " \\ %s: type=%s",
1057 ti
->id
, TpmTypeOptionsKind_str(ti
->options
->type
));
1059 switch (ti
->options
->type
) {
1060 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
1061 tpo
= ti
->options
->u
.passthrough
.data
;
1062 monitor_printf(mon
, "%s%s%s%s",
1063 tpo
->has_path
? ",path=" : "",
1064 tpo
->has_path
? tpo
->path
: "",
1065 tpo
->has_cancel_path
? ",cancel-path=" : "",
1066 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
1068 case TPM_TYPE_OPTIONS_KIND_EMULATOR
:
1069 teo
= ti
->options
->u
.emulator
.data
;
1070 monitor_printf(mon
, ",chardev=%s", teo
->chardev
);
1072 case TPM_TYPE_OPTIONS_KIND__MAX
:
1075 monitor_printf(mon
, "\n");
1078 qapi_free_TPMInfoList(info_list
);
1081 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
1083 monitor_suspend(mon
);
1087 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
1092 void hmp_sync_profile(Monitor
*mon
, const QDict
*qdict
)
1094 const char *op
= qdict_get_try_str(qdict
, "op");
1097 bool on
= qsp_is_enabled();
1099 monitor_printf(mon
, "sync-profile is %s\n", on
? "on" : "off");
1102 if (!strcmp(op
, "on")) {
1104 } else if (!strcmp(op
, "off")) {
1106 } else if (!strcmp(op
, "reset")) {
1111 error_setg(&err
, QERR_INVALID_PARAMETER
, op
);
1112 hmp_handle_error(mon
, &err
);
1116 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
1118 qmp_system_reset(NULL
);
1121 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
1123 qmp_system_powerdown(NULL
);
1126 void hmp_exit_preconfig(Monitor
*mon
, const QDict
*qdict
)
1130 qmp_x_exit_preconfig(&err
);
1131 hmp_handle_error(mon
, &err
);
1134 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
1138 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
1139 use it are converted to the QAPI */
1140 cpu_index
= qdict_get_int(qdict
, "index");
1141 if (monitor_set_cpu(cpu_index
) < 0) {
1142 monitor_printf(mon
, "invalid CPU index\n");
1146 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
1148 uint32_t size
= qdict_get_int(qdict
, "size");
1149 const char *filename
= qdict_get_str(qdict
, "filename");
1150 uint64_t addr
= qdict_get_int(qdict
, "val");
1152 int cpu_index
= monitor_get_cpu_index();
1154 if (cpu_index
< 0) {
1155 monitor_printf(mon
, "No CPU available\n");
1159 qmp_memsave(addr
, size
, filename
, true, cpu_index
, &err
);
1160 hmp_handle_error(mon
, &err
);
1163 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
1165 uint32_t size
= qdict_get_int(qdict
, "size");
1166 const char *filename
= qdict_get_str(qdict
, "filename");
1167 uint64_t addr
= qdict_get_int(qdict
, "val");
1170 qmp_pmemsave(addr
, size
, filename
, &err
);
1171 hmp_handle_error(mon
, &err
);
1174 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
1176 const char *chardev
= qdict_get_str(qdict
, "device");
1177 const char *data
= qdict_get_str(qdict
, "data");
1180 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
1182 hmp_handle_error(mon
, &err
);
1185 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
1187 uint32_t size
= qdict_get_int(qdict
, "size");
1188 const char *chardev
= qdict_get_str(qdict
, "device");
1193 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
1195 hmp_handle_error(mon
, &err
);
1199 for (i
= 0; data
[i
]; i
++) {
1200 unsigned char ch
= data
[i
];
1203 monitor_printf(mon
, "\\\\");
1204 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
1205 monitor_printf(mon
, "\\u%04X", ch
);
1207 monitor_printf(mon
, "%c", ch
);
1211 monitor_printf(mon
, "\n");
1215 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1220 hmp_handle_error(mon
, &err
);
1223 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1227 qmp_system_wakeup(&err
);
1228 hmp_handle_error(mon
, &err
);
1231 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1235 qmp_inject_nmi(&err
);
1236 hmp_handle_error(mon
, &err
);
1239 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1241 const char *name
= qdict_get_str(qdict
, "name");
1242 bool up
= qdict_get_bool(qdict
, "up");
1245 qmp_set_link(name
, up
, &err
);
1246 hmp_handle_error(mon
, &err
);
1249 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1251 const char *device
= qdict_get_str(qdict
, "device");
1252 const char *password
= qdict_get_str(qdict
, "password");
1255 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1256 hmp_handle_error(mon
, &err
);
1259 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1261 int64_t value
= qdict_get_int(qdict
, "value");
1264 qmp_balloon(value
, &err
);
1265 hmp_handle_error(mon
, &err
);
1268 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1270 const char *device
= qdict_get_str(qdict
, "device");
1271 int64_t size
= qdict_get_int(qdict
, "size");
1274 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1275 hmp_handle_error(mon
, &err
);
1278 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1280 const char *filename
= qdict_get_str(qdict
, "target");
1281 const char *format
= qdict_get_try_str(qdict
, "format");
1282 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1283 bool full
= qdict_get_try_bool(qdict
, "full", false);
1285 DriveMirror mirror
= {
1286 .device
= (char *)qdict_get_str(qdict
, "device"),
1287 .target
= (char *)filename
,
1288 .has_format
= !!format
,
1289 .format
= (char *)format
,
1290 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1292 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1297 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1298 hmp_handle_error(mon
, &err
);
1301 qmp_drive_mirror(&mirror
, &err
);
1302 hmp_handle_error(mon
, &err
);
1305 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1307 const char *device
= qdict_get_str(qdict
, "device");
1308 const char *filename
= qdict_get_str(qdict
, "target");
1309 const char *format
= qdict_get_try_str(qdict
, "format");
1310 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1311 bool full
= qdict_get_try_bool(qdict
, "full", false);
1312 bool compress
= qdict_get_try_bool(qdict
, "compress", false);
1314 DriveBackup backup
= {
1315 .device
= (char *)device
,
1316 .target
= (char *)filename
,
1317 .has_format
= !!format
,
1318 .format
= (char *)format
,
1319 .sync
= full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1321 .mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
,
1322 .has_compress
= !!compress
,
1323 .compress
= compress
,
1327 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1328 hmp_handle_error(mon
, &err
);
1332 qmp_drive_backup(&backup
, &err
);
1333 hmp_handle_error(mon
, &err
);
1336 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1338 const char *device
= qdict_get_str(qdict
, "device");
1339 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1340 const char *format
= qdict_get_try_str(qdict
, "format");
1341 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1342 enum NewImageMode mode
;
1346 /* In the future, if 'snapshot-file' is not specified, the snapshot
1347 will be taken internally. Today it's actually required. */
1348 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1349 hmp_handle_error(mon
, &err
);
1353 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1354 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1355 filename
, false, NULL
,
1358 hmp_handle_error(mon
, &err
);
1361 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1363 const char *device
= qdict_get_str(qdict
, "device");
1364 const char *name
= qdict_get_str(qdict
, "name");
1367 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1368 hmp_handle_error(mon
, &err
);
1371 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1373 const char *device
= qdict_get_str(qdict
, "device");
1374 const char *name
= qdict_get_str(qdict
, "name");
1375 const char *id
= qdict_get_try_str(qdict
, "id");
1378 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1380 hmp_handle_error(mon
, &err
);
1383 void hmp_loadvm(Monitor
*mon
, const QDict
*qdict
)
1385 int saved_vm_running
= runstate_is_running();
1386 const char *name
= qdict_get_str(qdict
, "name");
1389 vm_stop(RUN_STATE_RESTORE_VM
);
1391 if (load_snapshot(name
, &err
) == 0 && saved_vm_running
) {
1394 hmp_handle_error(mon
, &err
);
1397 void hmp_savevm(Monitor
*mon
, const QDict
*qdict
)
1401 save_snapshot(qdict_get_try_str(qdict
, "name"), &err
);
1402 hmp_handle_error(mon
, &err
);
1405 void hmp_delvm(Monitor
*mon
, const QDict
*qdict
)
1407 BlockDriverState
*bs
;
1409 const char *name
= qdict_get_str(qdict
, "name");
1411 if (bdrv_all_delete_snapshot(name
, &bs
, &err
) < 0) {
1412 error_reportf_err(err
,
1413 "Error while deleting snapshot on device '%s': ",
1414 bdrv_get_device_name(bs
));
1418 void hmp_info_snapshots(Monitor
*mon
, const QDict
*qdict
)
1420 BlockDriverState
*bs
, *bs1
;
1421 BdrvNextIterator it1
;
1422 QEMUSnapshotInfo
*sn_tab
, *sn
;
1423 bool no_snapshot
= true;
1426 int *global_snapshots
;
1427 AioContext
*aio_context
;
1429 typedef struct SnapshotEntry
{
1430 QEMUSnapshotInfo sn
;
1431 QTAILQ_ENTRY(SnapshotEntry
) next
;
1434 typedef struct ImageEntry
{
1435 const char *imagename
;
1436 QTAILQ_ENTRY(ImageEntry
) next
;
1437 QTAILQ_HEAD(, SnapshotEntry
) snapshots
;
1440 QTAILQ_HEAD(, ImageEntry
) image_list
=
1441 QTAILQ_HEAD_INITIALIZER(image_list
);
1443 ImageEntry
*image_entry
, *next_ie
;
1444 SnapshotEntry
*snapshot_entry
;
1446 bs
= bdrv_all_find_vmstate_bs();
1448 monitor_printf(mon
, "No available block device supports snapshots\n");
1451 aio_context
= bdrv_get_aio_context(bs
);
1453 aio_context_acquire(aio_context
);
1454 nb_sns
= bdrv_snapshot_list(bs
, &sn_tab
);
1455 aio_context_release(aio_context
);
1458 monitor_printf(mon
, "bdrv_snapshot_list: error %d\n", nb_sns
);
1462 for (bs1
= bdrv_first(&it1
); bs1
; bs1
= bdrv_next(&it1
)) {
1466 AioContext
*ctx
= bdrv_get_aio_context(bs1
);
1468 aio_context_acquire(ctx
);
1469 if (bdrv_can_snapshot(bs1
)) {
1471 bs1_nb_sns
= bdrv_snapshot_list(bs1
, &sn
);
1472 if (bs1_nb_sns
> 0) {
1473 no_snapshot
= false;
1474 ie
= g_new0(ImageEntry
, 1);
1475 ie
->imagename
= bdrv_get_device_name(bs1
);
1476 QTAILQ_INIT(&ie
->snapshots
);
1477 QTAILQ_INSERT_TAIL(&image_list
, ie
, next
);
1478 for (i
= 0; i
< bs1_nb_sns
; i
++) {
1479 se
= g_new0(SnapshotEntry
, 1);
1481 QTAILQ_INSERT_TAIL(&ie
->snapshots
, se
, next
);
1486 aio_context_release(ctx
);
1490 monitor_printf(mon
, "There is no snapshot available.\n");
1494 global_snapshots
= g_new0(int, nb_sns
);
1496 for (i
= 0; i
< nb_sns
; i
++) {
1497 SnapshotEntry
*next_sn
;
1498 if (bdrv_all_find_snapshot(sn_tab
[i
].name
, &bs1
) == 0) {
1499 global_snapshots
[total
] = i
;
1501 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1502 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
,
1504 if (!strcmp(sn_tab
[i
].name
, snapshot_entry
->sn
.name
)) {
1505 QTAILQ_REMOVE(&image_entry
->snapshots
, snapshot_entry
,
1507 g_free(snapshot_entry
);
1514 monitor_printf(mon
, "List of snapshots present on all disks:\n");
1517 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1518 monitor_printf(mon
, "\n");
1519 for (i
= 0; i
< total
; i
++) {
1520 sn
= &sn_tab
[global_snapshots
[i
]];
1521 /* The ID is not guaranteed to be the same on all images, so
1524 pstrcpy(sn
->id_str
, sizeof(sn
->id_str
), "--");
1525 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, sn
);
1526 monitor_printf(mon
, "\n");
1529 monitor_printf(mon
, "None\n");
1532 QTAILQ_FOREACH(image_entry
, &image_list
, next
) {
1533 if (QTAILQ_EMPTY(&image_entry
->snapshots
)) {
1537 "\nList of partial (non-loadable) snapshots on '%s':\n",
1538 image_entry
->imagename
);
1539 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
, NULL
);
1540 monitor_printf(mon
, "\n");
1541 QTAILQ_FOREACH(snapshot_entry
, &image_entry
->snapshots
, next
) {
1542 bdrv_snapshot_dump((fprintf_function
)monitor_printf
, mon
,
1543 &snapshot_entry
->sn
);
1544 monitor_printf(mon
, "\n");
1548 QTAILQ_FOREACH_SAFE(image_entry
, &image_list
, next
, next_ie
) {
1549 SnapshotEntry
*next_sn
;
1550 QTAILQ_FOREACH_SAFE(snapshot_entry
, &image_entry
->snapshots
, next
,
1552 g_free(snapshot_entry
);
1554 g_free(image_entry
);
1557 g_free(global_snapshots
);
1561 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1563 qmp_migrate_cancel(NULL
);
1566 void hmp_migrate_continue(Monitor
*mon
, const QDict
*qdict
)
1569 const char *state
= qdict_get_str(qdict
, "state");
1570 int val
= qapi_enum_parse(&MigrationStatus_lookup
, state
, -1, &err
);
1573 qmp_migrate_continue(val
, &err
);
1576 hmp_handle_error(mon
, &err
);
1579 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1582 const char *uri
= qdict_get_str(qdict
, "uri");
1584 qmp_migrate_incoming(uri
, &err
);
1586 hmp_handle_error(mon
, &err
);
1589 void hmp_migrate_recover(Monitor
*mon
, const QDict
*qdict
)
1592 const char *uri
= qdict_get_str(qdict
, "uri");
1594 qmp_migrate_recover(uri
, &err
);
1596 hmp_handle_error(mon
, &err
);
1599 void hmp_migrate_pause(Monitor
*mon
, const QDict
*qdict
)
1603 qmp_migrate_pause(&err
);
1605 hmp_handle_error(mon
, &err
);
1608 /* Kept for backwards compatibility */
1609 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1611 double value
= qdict_get_double(qdict
, "value");
1612 qmp_migrate_set_downtime(value
, NULL
);
1615 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1617 int64_t value
= qdict_get_int(qdict
, "value");
1620 qmp_migrate_set_cache_size(value
, &err
);
1621 hmp_handle_error(mon
, &err
);
1624 /* Kept for backwards compatibility */
1625 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1627 int64_t value
= qdict_get_int(qdict
, "value");
1628 qmp_migrate_set_speed(value
, NULL
);
1631 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1633 const char *cap
= qdict_get_str(qdict
, "capability");
1634 bool state
= qdict_get_bool(qdict
, "state");
1636 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1639 val
= qapi_enum_parse(&MigrationCapability_lookup
, cap
, -1, &err
);
1644 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1645 caps
->value
->capability
= val
;
1646 caps
->value
->state
= state
;
1648 qmp_migrate_set_capabilities(caps
, &err
);
1651 qapi_free_MigrationCapabilityStatusList(caps
);
1652 hmp_handle_error(mon
, &err
);
1655 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1657 const char *param
= qdict_get_str(qdict
, "parameter");
1658 const char *valuestr
= qdict_get_str(qdict
, "value");
1659 Visitor
*v
= string_input_visitor_new(valuestr
);
1660 MigrateSetParameters
*p
= g_new0(MigrateSetParameters
, 1);
1661 uint64_t valuebw
= 0;
1662 uint64_t cache_size
;
1666 val
= qapi_enum_parse(&MigrationParameter_lookup
, param
, -1, &err
);
1672 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1673 p
->has_compress_level
= true;
1674 visit_type_int(v
, param
, &p
->compress_level
, &err
);
1676 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1677 p
->has_compress_threads
= true;
1678 visit_type_int(v
, param
, &p
->compress_threads
, &err
);
1680 case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD
:
1681 p
->has_compress_wait_thread
= true;
1682 visit_type_bool(v
, param
, &p
->compress_wait_thread
, &err
);
1684 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1685 p
->has_decompress_threads
= true;
1686 visit_type_int(v
, param
, &p
->decompress_threads
, &err
);
1688 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1689 p
->has_cpu_throttle_initial
= true;
1690 visit_type_int(v
, param
, &p
->cpu_throttle_initial
, &err
);
1692 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1693 p
->has_cpu_throttle_increment
= true;
1694 visit_type_int(v
, param
, &p
->cpu_throttle_increment
, &err
);
1696 case MIGRATION_PARAMETER_MAX_CPU_THROTTLE
:
1697 p
->has_max_cpu_throttle
= true;
1698 visit_type_int(v
, param
, &p
->max_cpu_throttle
, &err
);
1700 case MIGRATION_PARAMETER_TLS_CREDS
:
1701 p
->has_tls_creds
= true;
1702 p
->tls_creds
= g_new0(StrOrNull
, 1);
1703 p
->tls_creds
->type
= QTYPE_QSTRING
;
1704 visit_type_str(v
, param
, &p
->tls_creds
->u
.s
, &err
);
1706 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1707 p
->has_tls_hostname
= true;
1708 p
->tls_hostname
= g_new0(StrOrNull
, 1);
1709 p
->tls_hostname
->type
= QTYPE_QSTRING
;
1710 visit_type_str(v
, param
, &p
->tls_hostname
->u
.s
, &err
);
1712 case MIGRATION_PARAMETER_MAX_BANDWIDTH
:
1713 p
->has_max_bandwidth
= true;
1715 * Can't use visit_type_size() here, because it
1716 * defaults to Bytes rather than Mebibytes.
1718 ret
= qemu_strtosz_MiB(valuestr
, NULL
, &valuebw
);
1719 if (ret
< 0 || valuebw
> INT64_MAX
1720 || (size_t)valuebw
!= valuebw
) {
1721 error_setg(&err
, "Invalid size %s", valuestr
);
1724 p
->max_bandwidth
= valuebw
;
1726 case MIGRATION_PARAMETER_DOWNTIME_LIMIT
:
1727 p
->has_downtime_limit
= true;
1728 visit_type_int(v
, param
, &p
->downtime_limit
, &err
);
1730 case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY
:
1731 p
->has_x_checkpoint_delay
= true;
1732 visit_type_int(v
, param
, &p
->x_checkpoint_delay
, &err
);
1734 case MIGRATION_PARAMETER_BLOCK_INCREMENTAL
:
1735 p
->has_block_incremental
= true;
1736 visit_type_bool(v
, param
, &p
->block_incremental
, &err
);
1738 case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS
:
1739 p
->has_x_multifd_channels
= true;
1740 visit_type_int(v
, param
, &p
->x_multifd_channels
, &err
);
1742 case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT
:
1743 p
->has_x_multifd_page_count
= true;
1744 visit_type_int(v
, param
, &p
->x_multifd_page_count
, &err
);
1746 case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE
:
1747 p
->has_xbzrle_cache_size
= true;
1748 visit_type_size(v
, param
, &cache_size
, &err
);
1749 if (err
|| cache_size
> INT64_MAX
1750 || (size_t)cache_size
!= cache_size
) {
1751 error_setg(&err
, "Invalid size %s", valuestr
);
1754 p
->xbzrle_cache_size
= cache_size
;
1756 case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH
:
1757 p
->has_max_postcopy_bandwidth
= true;
1758 visit_type_size(v
, param
, &p
->max_postcopy_bandwidth
, &err
);
1768 qmp_migrate_set_parameters(p
, &err
);
1771 qapi_free_MigrateSetParameters(p
);
1773 hmp_handle_error(mon
, &err
);
1776 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1779 const char *protocol
= qdict_get_str(qdict
, "protocol");
1780 const char *hostname
= qdict_get_str(qdict
, "hostname");
1781 bool has_port
= qdict_haskey(qdict
, "port");
1782 int port
= qdict_get_try_int(qdict
, "port", -1);
1783 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1784 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1785 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1787 qmp_client_migrate_info(protocol
, hostname
,
1788 has_port
, port
, has_tls_port
, tls_port
,
1789 !!cert_subject
, cert_subject
, &err
);
1790 hmp_handle_error(mon
, &err
);
1793 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1796 qmp_migrate_start_postcopy(&err
);
1797 hmp_handle_error(mon
, &err
);
1800 void hmp_x_colo_lost_heartbeat(Monitor
*mon
, const QDict
*qdict
)
1804 qmp_x_colo_lost_heartbeat(&err
);
1805 hmp_handle_error(mon
, &err
);
1808 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1810 const char *protocol
= qdict_get_str(qdict
, "protocol");
1811 const char *password
= qdict_get_str(qdict
, "password");
1812 const char *connected
= qdict_get_try_str(qdict
, "connected");
1815 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1816 hmp_handle_error(mon
, &err
);
1819 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1821 const char *protocol
= qdict_get_str(qdict
, "protocol");
1822 const char *whenstr
= qdict_get_str(qdict
, "time");
1825 qmp_expire_password(protocol
, whenstr
, &err
);
1826 hmp_handle_error(mon
, &err
);
1829 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1831 bool force
= qdict_get_try_bool(qdict
, "force", false);
1832 const char *device
= qdict_get_str(qdict
, "device");
1835 qmp_eject(true, device
, false, NULL
, true, force
, &err
);
1836 hmp_handle_error(mon
, &err
);
1840 static void hmp_change_read_arg(void *opaque
, const char *password
,
1841 void *readline_opaque
)
1843 qmp_change_vnc_password(password
, NULL
);
1844 monitor_read_command(opaque
, 1);
1848 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1850 const char *device
= qdict_get_str(qdict
, "device");
1851 const char *target
= qdict_get_str(qdict
, "target");
1852 const char *arg
= qdict_get_try_str(qdict
, "arg");
1853 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1854 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1858 if (strcmp(device
, "vnc") == 0) {
1861 "Parameter 'read-only-mode' is invalid for VNC\n");
1864 if (strcmp(target
, "passwd") == 0 ||
1865 strcmp(target
, "password") == 0) {
1867 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1871 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1877 qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup
,
1879 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1881 hmp_handle_error(mon
, &err
);
1886 qmp_blockdev_change_medium(true, device
, false, NULL
, target
,
1887 !!arg
, arg
, !!read_only
, read_only_mode
,
1891 hmp_handle_error(mon
, &err
);
1894 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1897 char *device
= (char *) qdict_get_str(qdict
, "device");
1898 BlockIOThrottle throttle
= {
1899 .bps
= qdict_get_int(qdict
, "bps"),
1900 .bps_rd
= qdict_get_int(qdict
, "bps_rd"),
1901 .bps_wr
= qdict_get_int(qdict
, "bps_wr"),
1902 .iops
= qdict_get_int(qdict
, "iops"),
1903 .iops_rd
= qdict_get_int(qdict
, "iops_rd"),
1904 .iops_wr
= qdict_get_int(qdict
, "iops_wr"),
1907 /* qmp_block_set_io_throttle has separate parameters for the
1908 * (deprecated) block device name and the qdev ID but the HMP
1909 * version has only one, so we must decide which one to pass. */
1910 if (blk_by_name(device
)) {
1911 throttle
.has_device
= true;
1912 throttle
.device
= device
;
1914 throttle
.has_id
= true;
1915 throttle
.id
= device
;
1918 qmp_block_set_io_throttle(&throttle
, &err
);
1919 hmp_handle_error(mon
, &err
);
1922 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1924 Error
*error
= NULL
;
1925 const char *device
= qdict_get_str(qdict
, "device");
1926 const char *base
= qdict_get_try_str(qdict
, "base");
1927 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1929 qmp_block_stream(true, device
, device
, base
!= NULL
, base
, false, NULL
,
1930 false, NULL
, qdict_haskey(qdict
, "speed"), speed
, true,
1931 BLOCKDEV_ON_ERROR_REPORT
, false, false, false, false,
1934 hmp_handle_error(mon
, &error
);
1937 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1939 Error
*error
= NULL
;
1940 const char *device
= qdict_get_str(qdict
, "device");
1941 int64_t value
= qdict_get_int(qdict
, "speed");
1943 qmp_block_job_set_speed(device
, value
, &error
);
1945 hmp_handle_error(mon
, &error
);
1948 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1950 Error
*error
= NULL
;
1951 const char *device
= qdict_get_str(qdict
, "device");
1952 bool force
= qdict_get_try_bool(qdict
, "force", false);
1954 qmp_block_job_cancel(device
, true, force
, &error
);
1956 hmp_handle_error(mon
, &error
);
1959 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1961 Error
*error
= NULL
;
1962 const char *device
= qdict_get_str(qdict
, "device");
1964 qmp_block_job_pause(device
, &error
);
1966 hmp_handle_error(mon
, &error
);
1969 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1971 Error
*error
= NULL
;
1972 const char *device
= qdict_get_str(qdict
, "device");
1974 qmp_block_job_resume(device
, &error
);
1976 hmp_handle_error(mon
, &error
);
1979 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1981 Error
*error
= NULL
;
1982 const char *device
= qdict_get_str(qdict
, "device");
1984 qmp_block_job_complete(device
, &error
);
1986 hmp_handle_error(mon
, &error
);
1989 typedef struct HMPMigrationStatus
1993 bool is_block_migration
;
1994 } HMPMigrationStatus
;
1996 static void hmp_migrate_status_cb(void *opaque
)
1998 HMPMigrationStatus
*status
= opaque
;
1999 MigrationInfo
*info
;
2001 info
= qmp_query_migrate(NULL
);
2002 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
2003 info
->status
== MIGRATION_STATUS_SETUP
) {
2004 if (info
->has_disk
) {
2007 if (info
->disk
->remaining
) {
2008 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
2013 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
2014 monitor_flush(status
->mon
);
2017 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
2019 if (status
->is_block_migration
) {
2020 monitor_printf(status
->mon
, "\n");
2022 if (info
->has_error_desc
) {
2023 error_report("%s", info
->error_desc
);
2025 monitor_resume(status
->mon
);
2026 timer_del(status
->timer
);
2027 timer_free(status
->timer
);
2031 qapi_free_MigrationInfo(info
);
2034 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
2036 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
2037 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
2038 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
2039 bool resume
= qdict_get_try_bool(qdict
, "resume", false);
2040 const char *uri
= qdict_get_str(qdict
, "uri");
2043 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
,
2044 false, false, true, resume
, &err
);
2046 hmp_handle_error(mon
, &err
);
2051 HMPMigrationStatus
*status
;
2053 if (monitor_suspend(mon
) < 0) {
2054 monitor_printf(mon
, "terminal does not allow synchronous "
2055 "migration, continuing detached\n");
2059 status
= g_malloc0(sizeof(*status
));
2061 status
->is_block_migration
= blk
|| inc
;
2062 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
2064 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
2068 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
2072 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
2073 hmp_handle_error(mon
, &err
);
2076 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
2078 const char *id
= qdict_get_str(qdict
, "id");
2081 qmp_device_del(id
, &err
);
2082 hmp_handle_error(mon
, &err
);
2085 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
2088 bool win_dmp
= qdict_get_try_bool(qdict
, "windmp", false);
2089 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
2090 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
2091 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
2092 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
2093 const char *file
= qdict_get_str(qdict
, "filename");
2094 bool has_begin
= qdict_haskey(qdict
, "begin");
2095 bool has_length
= qdict_haskey(qdict
, "length");
2096 bool has_detach
= qdict_haskey(qdict
, "detach");
2099 bool detach
= false;
2100 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
2103 if (zlib
+ lzo
+ snappy
+ win_dmp
> 1) {
2104 error_setg(&err
, "only one of '-z|-l|-s|-w' can be set");
2105 hmp_handle_error(mon
, &err
);
2110 dump_format
= DUMP_GUEST_MEMORY_FORMAT_WIN_DMP
;
2114 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
2118 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
2122 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
2126 begin
= qdict_get_int(qdict
, "begin");
2129 length
= qdict_get_int(qdict
, "length");
2132 detach
= qdict_get_bool(qdict
, "detach");
2135 prot
= g_strconcat("file:", file
, NULL
);
2137 qmp_dump_guest_memory(paging
, prot
, true, detach
, has_begin
, begin
,
2138 has_length
, length
, true, dump_format
, &err
);
2139 hmp_handle_error(mon
, &err
);
2143 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
2148 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
2153 netdev_add(opts
, &err
);
2155 qemu_opts_del(opts
);
2159 hmp_handle_error(mon
, &err
);
2162 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
2164 const char *id
= qdict_get_str(qdict
, "id");
2167 qmp_netdev_del(id
, &err
);
2168 hmp_handle_error(mon
, &err
);
2171 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
2177 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
2179 hmp_handle_error(mon
, &err
);
2183 obj
= user_creatable_add_opts(opts
, &err
);
2184 qemu_opts_del(opts
);
2187 hmp_handle_error(mon
, &err
);
2194 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
2196 const char *fdname
= qdict_get_str(qdict
, "fdname");
2199 qmp_getfd(fdname
, &err
);
2200 hmp_handle_error(mon
, &err
);
2203 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
2205 const char *fdname
= qdict_get_str(qdict
, "fdname");
2208 qmp_closefd(fdname
, &err
);
2209 hmp_handle_error(mon
, &err
);
2212 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
2214 const char *keys
= qdict_get_str(qdict
, "keys");
2215 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
2216 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
2217 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
2219 const char *separator
;
2223 separator
= qemu_strchrnul(keys
, '-');
2224 keyname_len
= separator
- keys
;
2226 /* Be compatible with old interface, convert user inputted "<" */
2227 if (keys
[0] == '<' && keyname_len
== 1) {
2232 keylist
= g_malloc0(sizeof(*keylist
));
2233 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
2239 tmp
->next
= keylist
;
2243 if (strstart(keys
, "0x", NULL
)) {
2245 int value
= strtoul(keys
, &endp
, 0);
2246 assert(endp
<= keys
+ keyname_len
);
2247 if (endp
!= keys
+ keyname_len
) {
2250 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
2251 keylist
->value
->u
.number
.data
= value
;
2253 int idx
= index_from_key(keys
, keyname_len
);
2254 if (idx
== Q_KEY_CODE__MAX
) {
2257 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
2258 keylist
->value
->u
.qcode
.data
= idx
;
2264 keys
= separator
+ 1;
2267 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
2268 hmp_handle_error(mon
, &err
);
2271 qapi_free_KeyValueList(head
);
2275 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
2279 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
2281 const char *filename
= qdict_get_str(qdict
, "filename");
2282 const char *id
= qdict_get_try_str(qdict
, "device");
2283 int64_t head
= qdict_get_try_int(qdict
, "head", 0);
2286 qmp_screendump(filename
, id
!= NULL
, id
, id
!= NULL
, head
, &err
);
2287 hmp_handle_error(mon
, &err
);
2290 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
2292 const char *uri
= qdict_get_str(qdict
, "uri");
2293 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2294 bool all
= qdict_get_try_bool(qdict
, "all", false);
2295 Error
*local_err
= NULL
;
2296 BlockInfoList
*block_list
, *info
;
2297 SocketAddress
*addr
;
2299 if (writable
&& !all
) {
2300 error_setg(&local_err
, "-w only valid together with -a");
2304 /* First check if the address is valid and start the server. */
2305 addr
= socket_parse(uri
, &local_err
);
2306 if (local_err
!= NULL
) {
2310 nbd_server_start(addr
, NULL
, &local_err
);
2311 qapi_free_SocketAddress(addr
);
2312 if (local_err
!= NULL
) {
2320 /* Then try adding all block devices. If one fails, close all and
2323 block_list
= qmp_query_block(NULL
);
2325 for (info
= block_list
; info
; info
= info
->next
) {
2326 if (!info
->value
->has_inserted
) {
2330 qmp_nbd_server_add(info
->value
->device
, false, NULL
,
2331 true, writable
, false, NULL
, &local_err
);
2333 if (local_err
!= NULL
) {
2334 qmp_nbd_server_stop(NULL
);
2339 qapi_free_BlockInfoList(block_list
);
2342 hmp_handle_error(mon
, &local_err
);
2345 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
2347 const char *device
= qdict_get_str(qdict
, "device");
2348 const char *name
= qdict_get_try_str(qdict
, "name");
2349 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
2350 Error
*local_err
= NULL
;
2352 qmp_nbd_server_add(device
, !!name
, name
, true, writable
,
2353 false, NULL
, &local_err
);
2354 hmp_handle_error(mon
, &local_err
);
2357 void hmp_nbd_server_remove(Monitor
*mon
, const QDict
*qdict
)
2359 const char *name
= qdict_get_str(qdict
, "name");
2360 bool force
= qdict_get_try_bool(qdict
, "force", false);
2363 /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
2364 qmp_nbd_server_remove(name
, force
, NBD_SERVER_REMOVE_MODE_HARD
, &err
);
2365 hmp_handle_error(mon
, &err
);
2368 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
2372 qmp_nbd_server_stop(&err
);
2373 hmp_handle_error(mon
, &err
);
2376 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
2381 error_report("cpu_add is deprecated, please use device_add instead");
2383 cpuid
= qdict_get_int(qdict
, "id");
2384 qmp_cpu_add(cpuid
, &err
);
2385 hmp_handle_error(mon
, &err
);
2388 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
2390 const char *args
= qdict_get_str(qdict
, "args");
2394 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
2396 error_setg(&err
, "Parsing chardev args failed");
2398 qemu_chr_new_from_opts(opts
, &err
);
2399 qemu_opts_del(opts
);
2401 hmp_handle_error(mon
, &err
);
2404 void hmp_chardev_change(Monitor
*mon
, const QDict
*qdict
)
2406 const char *args
= qdict_get_str(qdict
, "args");
2409 ChardevBackend
*backend
= NULL
;
2410 ChardevReturn
*ret
= NULL
;
2411 QemuOpts
*opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
,
2414 error_setg(&err
, "Parsing chardev args failed");
2418 id
= qdict_get_str(qdict
, "id");
2419 if (qemu_opts_id(opts
)) {
2420 error_setg(&err
, "Unexpected 'id' parameter");
2424 backend
= qemu_chr_parse_opts(opts
, &err
);
2429 ret
= qmp_chardev_change(id
, backend
, &err
);
2432 qapi_free_ChardevReturn(ret
);
2433 qapi_free_ChardevBackend(backend
);
2434 qemu_opts_del(opts
);
2435 hmp_handle_error(mon
, &err
);
2438 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
2440 Error
*local_err
= NULL
;
2442 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
2443 hmp_handle_error(mon
, &local_err
);
2446 void hmp_chardev_send_break(Monitor
*mon
, const QDict
*qdict
)
2448 Error
*local_err
= NULL
;
2450 qmp_chardev_send_break(qdict_get_str(qdict
, "id"), &local_err
);
2451 hmp_handle_error(mon
, &local_err
);
2454 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
2457 BlockBackend
*local_blk
= NULL
;
2458 const char* device
= qdict_get_str(qdict
, "device");
2459 const char* command
= qdict_get_str(qdict
, "command");
2463 blk
= blk_by_name(device
);
2465 BlockDriverState
*bs
= bdrv_lookup_bs(NULL
, device
, &err
);
2467 blk
= local_blk
= blk_new(0, BLK_PERM_ALL
);
2468 ret
= blk_insert_bs(blk
, bs
, &err
);
2478 * Notably absent: Proper permission management. This is sad, but it seems
2479 * almost impossible to achieve without changing the semantics and thereby
2480 * limiting the use cases of the qemu-io HMP command.
2482 * In an ideal world we would unconditionally create a new BlockBackend for
2483 * qemuio_command(), but we have commands like 'reopen' and want them to
2484 * take effect on the exact BlockBackend whose name the user passed instead
2485 * of just on a temporary copy of it.
2487 * Another problem is that deleting the temporary BlockBackend involves
2488 * draining all requests on it first, but some qemu-iotests cases want to
2489 * issue multiple aio_read/write requests and expect them to complete in
2490 * the background while the monitor has already returned.
2492 * This is also what prevents us from saving the original permissions and
2493 * restoring them later: We can't revoke permissions until all requests
2494 * have completed, and we don't know when that is nor can we really let
2495 * anything else run before we have revoken them to avoid race conditions.
2497 * What happens now is that command() in qemu-io-cmds.c can extend the
2498 * permissions if necessary for the qemu-io command. And they simply stay
2499 * extended, possibly resulting in a read-only guest device keeping write
2500 * permissions. Ugly, but it appears to be the lesser evil.
2502 qemuio_command(blk
, command
);
2505 blk_unref(local_blk
);
2506 hmp_handle_error(mon
, &err
);
2509 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
2511 const char *id
= qdict_get_str(qdict
, "id");
2514 user_creatable_del(id
, &err
);
2515 hmp_handle_error(mon
, &err
);
2518 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
2521 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
2522 MemdevList
*m
= memdev_list
;
2527 v
= string_output_visitor_new(false, &str
);
2528 visit_type_uint16List(v
, NULL
, &m
->value
->host_nodes
, NULL
);
2529 monitor_printf(mon
, "memory backend: %s\n", m
->value
->id
);
2530 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
2531 monitor_printf(mon
, " merge: %s\n",
2532 m
->value
->merge
? "true" : "false");
2533 monitor_printf(mon
, " dump: %s\n",
2534 m
->value
->dump
? "true" : "false");
2535 monitor_printf(mon
, " prealloc: %s\n",
2536 m
->value
->prealloc
? "true" : "false");
2537 monitor_printf(mon
, " policy: %s\n",
2538 HostMemPolicy_str(m
->value
->policy
));
2539 visit_complete(v
, &str
);
2540 monitor_printf(mon
, " host nodes: %s\n", str
);
2547 monitor_printf(mon
, "\n");
2549 qapi_free_MemdevList(memdev_list
);
2550 hmp_handle_error(mon
, &err
);
2553 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2556 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2557 MemoryDeviceInfoList
*info
;
2558 MemoryDeviceInfo
*value
;
2559 PCDIMMDeviceInfo
*di
;
2561 for (info
= info_list
; info
; info
= info
->next
) {
2562 value
= info
->value
;
2565 switch (value
->type
) {
2566 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2567 di
= value
->u
.dimm
.data
;
2570 case MEMORY_DEVICE_INFO_KIND_NVDIMM
:
2571 di
= value
->u
.nvdimm
.data
;
2580 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2581 MemoryDeviceInfoKind_str(value
->type
),
2582 di
->id
? di
->id
: "");
2583 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2584 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2585 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2586 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2587 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2588 monitor_printf(mon
, " hotplugged: %s\n",
2589 di
->hotplugged
? "true" : "false");
2590 monitor_printf(mon
, " hotpluggable: %s\n",
2591 di
->hotpluggable
? "true" : "false");
2596 qapi_free_MemoryDeviceInfoList(info_list
);
2597 hmp_handle_error(mon
, &err
);
2600 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2602 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2603 IOThreadInfoList
*info
;
2604 IOThreadInfo
*value
;
2606 for (info
= info_list
; info
; info
= info
->next
) {
2607 value
= info
->value
;
2608 monitor_printf(mon
, "%s:\n", value
->id
);
2609 monitor_printf(mon
, " thread_id=%" PRId64
"\n", value
->thread_id
);
2610 monitor_printf(mon
, " poll-max-ns=%" PRId64
"\n", value
->poll_max_ns
);
2611 monitor_printf(mon
, " poll-grow=%" PRId64
"\n", value
->poll_grow
);
2612 monitor_printf(mon
, " poll-shrink=%" PRId64
"\n", value
->poll_shrink
);
2615 qapi_free_IOThreadInfoList(info_list
);
2618 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2620 const char *path
= qdict_get_try_str(qdict
, "path");
2621 ObjectPropertyInfoList
*list
;
2625 monitor_printf(mon
, "/\n");
2629 list
= qmp_qom_list(path
, &err
);
2631 ObjectPropertyInfoList
*start
= list
;
2632 while (list
!= NULL
) {
2633 ObjectPropertyInfo
*value
= list
->value
;
2635 monitor_printf(mon
, "%s (%s)\n",
2636 value
->name
, value
->type
);
2639 qapi_free_ObjectPropertyInfoList(start
);
2641 hmp_handle_error(mon
, &err
);
2644 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2646 const char *path
= qdict_get_str(qdict
, "path");
2647 const char *property
= qdict_get_str(qdict
, "property");
2648 const char *value
= qdict_get_str(qdict
, "value");
2650 bool ambiguous
= false;
2653 obj
= object_resolve_path(path
, &ambiguous
);
2655 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2656 "Device '%s' not found", path
);
2659 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2661 object_property_parse(obj
, value
, property
, &err
);
2663 hmp_handle_error(mon
, &err
);
2666 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2668 const char *name
= qdict_get_str(qdict
, "name");
2669 RockerSwitch
*rocker
;
2672 rocker
= qmp_query_rocker(name
, &err
);
2674 hmp_handle_error(mon
, &err
);
2678 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2679 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2680 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2682 qapi_free_RockerSwitch(rocker
);
2685 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2687 RockerPortList
*list
, *port
;
2688 const char *name
= qdict_get_str(qdict
, "name");
2691 list
= qmp_query_rocker_ports(name
, &err
);
2693 hmp_handle_error(mon
, &err
);
2697 monitor_printf(mon
, " ena/ speed/ auto\n");
2698 monitor_printf(mon
, " port link duplex neg?\n");
2700 for (port
= list
; port
; port
= port
->next
) {
2701 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2703 port
->value
->enabled
? port
->value
->link_up
?
2704 "up" : "down" : "!ena",
2705 port
->value
->speed
== 10000 ? "10G" : "??",
2706 port
->value
->duplex
? "FD" : "HD",
2707 port
->value
->autoneg
? "Yes" : "No");
2710 qapi_free_RockerPortList(list
);
2713 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2715 RockerOfDpaFlowList
*list
, *info
;
2716 const char *name
= qdict_get_str(qdict
, "name");
2717 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2720 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2722 hmp_handle_error(mon
, &err
);
2726 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2728 for (info
= list
; info
; info
= info
->next
) {
2729 RockerOfDpaFlow
*flow
= info
->value
;
2730 RockerOfDpaFlowKey
*key
= flow
->key
;
2731 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2732 RockerOfDpaFlowAction
*action
= flow
->action
;
2735 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2736 key
->priority
, key
->tbl_id
, flow
->hits
);
2738 monitor_printf(mon
, "%-4d %-3d ",
2739 key
->priority
, key
->tbl_id
);
2742 if (key
->has_in_pport
) {
2743 monitor_printf(mon
, " pport %d", key
->in_pport
);
2744 if (mask
->has_in_pport
) {
2745 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2749 if (key
->has_vlan_id
) {
2750 monitor_printf(mon
, " vlan %d",
2751 key
->vlan_id
& VLAN_VID_MASK
);
2752 if (mask
->has_vlan_id
) {
2753 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2757 if (key
->has_tunnel_id
) {
2758 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2759 if (mask
->has_tunnel_id
) {
2760 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2764 if (key
->has_eth_type
) {
2765 switch (key
->eth_type
) {
2767 monitor_printf(mon
, " ARP");
2770 monitor_printf(mon
, " IP");
2773 monitor_printf(mon
, " IPv6");
2776 monitor_printf(mon
, " LACP");
2779 monitor_printf(mon
, " LLDP");
2782 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2787 if (key
->has_eth_src
) {
2788 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2789 (mask
->has_eth_src
) &&
2790 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2791 monitor_printf(mon
, " src <any mcast/bcast>");
2792 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2793 (mask
->has_eth_src
) &&
2794 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2795 monitor_printf(mon
, " src <any ucast>");
2797 monitor_printf(mon
, " src %s", key
->eth_src
);
2798 if (mask
->has_eth_src
) {
2799 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2804 if (key
->has_eth_dst
) {
2805 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2806 (mask
->has_eth_dst
) &&
2807 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2808 monitor_printf(mon
, " dst <any mcast/bcast>");
2809 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2810 (mask
->has_eth_dst
) &&
2811 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2812 monitor_printf(mon
, " dst <any ucast>");
2814 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2815 if (mask
->has_eth_dst
) {
2816 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2821 if (key
->has_ip_proto
) {
2822 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2823 if (mask
->has_ip_proto
) {
2824 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2828 if (key
->has_ip_tos
) {
2829 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2830 if (mask
->has_ip_tos
) {
2831 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2835 if (key
->has_ip_dst
) {
2836 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2839 if (action
->has_goto_tbl
|| action
->has_group_id
||
2840 action
->has_new_vlan_id
) {
2841 monitor_printf(mon
, " -->");
2844 if (action
->has_new_vlan_id
) {
2845 monitor_printf(mon
, " apply new vlan %d",
2846 ntohs(action
->new_vlan_id
));
2849 if (action
->has_group_id
) {
2850 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2853 if (action
->has_goto_tbl
) {
2854 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2857 monitor_printf(mon
, "\n");
2860 qapi_free_RockerOfDpaFlowList(list
);
2863 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2865 RockerOfDpaGroupList
*list
, *g
;
2866 const char *name
= qdict_get_str(qdict
, "name");
2867 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2871 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2873 hmp_handle_error(mon
, &err
);
2877 monitor_printf(mon
, "id (decode) --> buckets\n");
2879 for (g
= list
; g
; g
= g
->next
) {
2880 RockerOfDpaGroup
*group
= g
->value
;
2882 monitor_printf(mon
, "0x%08x", group
->id
);
2884 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2885 group
->type
== 1 ? "L2 rewrite" :
2886 group
->type
== 2 ? "L3 unicast" :
2887 group
->type
== 3 ? "L2 multicast" :
2888 group
->type
== 4 ? "L2 flood" :
2889 group
->type
== 5 ? "L3 interface" :
2890 group
->type
== 6 ? "L3 multicast" :
2891 group
->type
== 7 ? "L3 ECMP" :
2892 group
->type
== 8 ? "L2 overlay" :
2895 if (group
->has_vlan_id
) {
2896 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2899 if (group
->has_pport
) {
2900 monitor_printf(mon
, " pport %d", group
->pport
);
2903 if (group
->has_index
) {
2904 monitor_printf(mon
, " index %d", group
->index
);
2907 monitor_printf(mon
, ") -->");
2909 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2911 monitor_printf(mon
, " set vlan %d",
2912 group
->set_vlan_id
& VLAN_VID_MASK
);
2915 if (group
->has_set_eth_src
) {
2918 monitor_printf(mon
, " set");
2920 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2923 if (group
->has_set_eth_dst
) {
2926 monitor_printf(mon
, " set");
2928 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2933 if (group
->has_ttl_check
&& group
->ttl_check
) {
2934 monitor_printf(mon
, " check TTL");
2937 if (group
->has_group_id
&& group
->group_id
) {
2938 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2941 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2942 monitor_printf(mon
, " pop vlan");
2945 if (group
->has_out_pport
) {
2946 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2949 if (group
->has_group_ids
) {
2950 struct uint32List
*id
;
2952 monitor_printf(mon
, " groups [");
2953 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2954 monitor_printf(mon
, "0x%08x", id
->value
);
2956 monitor_printf(mon
, ",");
2959 monitor_printf(mon
, "]");
2962 monitor_printf(mon
, "\n");
2965 qapi_free_RockerOfDpaGroupList(list
);
2968 void hmp_info_dump(Monitor
*mon
, const QDict
*qdict
)
2970 DumpQueryResult
*result
= qmp_query_dump(NULL
);
2972 assert(result
&& result
->status
< DUMP_STATUS__MAX
);
2973 monitor_printf(mon
, "Status: %s\n", DumpStatus_str(result
->status
));
2975 if (result
->status
== DUMP_STATUS_ACTIVE
) {
2977 assert(result
->total
!= 0);
2978 percent
= 100.0 * result
->completed
/ result
->total
;
2979 monitor_printf(mon
, "Finished: %.2f %%\n", percent
);
2982 qapi_free_DumpQueryResult(result
);
2985 void hmp_info_ramblock(Monitor
*mon
, const QDict
*qdict
)
2987 ram_block_dump(mon
);
2990 void hmp_hotpluggable_cpus(Monitor
*mon
, const QDict
*qdict
)
2993 HotpluggableCPUList
*l
= qmp_query_hotpluggable_cpus(&err
);
2994 HotpluggableCPUList
*saved
= l
;
2995 CpuInstanceProperties
*c
;
2998 hmp_handle_error(mon
, &err
);
3002 monitor_printf(mon
, "Hotpluggable CPUs:\n");
3004 monitor_printf(mon
, " type: \"%s\"\n", l
->value
->type
);
3005 monitor_printf(mon
, " vcpus_count: \"%" PRIu64
"\"\n",
3006 l
->value
->vcpus_count
);
3007 if (l
->value
->has_qom_path
) {
3008 monitor_printf(mon
, " qom_path: \"%s\"\n", l
->value
->qom_path
);
3011 c
= l
->value
->props
;
3012 monitor_printf(mon
, " CPUInstance Properties:\n");
3013 if (c
->has_node_id
) {
3014 monitor_printf(mon
, " node-id: \"%" PRIu64
"\"\n", c
->node_id
);
3016 if (c
->has_socket_id
) {
3017 monitor_printf(mon
, " socket-id: \"%" PRIu64
"\"\n", c
->socket_id
);
3019 if (c
->has_core_id
) {
3020 monitor_printf(mon
, " core-id: \"%" PRIu64
"\"\n", c
->core_id
);
3022 if (c
->has_thread_id
) {
3023 monitor_printf(mon
, " thread-id: \"%" PRIu64
"\"\n", c
->thread_id
);
3029 qapi_free_HotpluggableCPUList(saved
);
3032 void hmp_info_vm_generation_id(Monitor
*mon
, const QDict
*qdict
)
3035 GuidInfo
*info
= qmp_query_vm_generation_id(&err
);
3037 monitor_printf(mon
, "%s\n", info
->guid
);
3039 hmp_handle_error(mon
, &err
);
3040 qapi_free_GuidInfo(info
);
3043 void hmp_info_memory_size_summary(Monitor
*mon
, const QDict
*qdict
)
3046 MemoryInfo
*info
= qmp_query_memory_size_summary(&err
);
3048 monitor_printf(mon
, "base memory: %" PRIu64
"\n",
3051 if (info
->has_plugged_memory
) {
3052 monitor_printf(mon
, "plugged memory: %" PRIu64
"\n",
3053 info
->plugged_memory
);
3056 qapi_free_MemoryInfo(info
);
3058 hmp_handle_error(mon
, &err
);