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 "sysemu/char.h"
21 #include "sysemu/block-backend.h"
22 #include "qemu/option.h"
23 #include "qemu/timer.h"
24 #include "qmp-commands.h"
25 #include "qemu/sockets.h"
26 #include "monitor/monitor.h"
27 #include "monitor/qdev.h"
28 #include "qapi/opts-visitor.h"
29 #include "qapi/qmp/qerror.h"
30 #include "qapi/string-output-visitor.h"
31 #include "qapi/util.h"
32 #include "qapi-visit.h"
33 #include "qom/object_interfaces.h"
34 #include "ui/console.h"
35 #include "block/qapi.h"
37 #include "qemu/cutils.h"
38 #include "qemu/error-report.h"
41 #include <spice/enums.h>
44 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
48 error_report_err(*errp
);
52 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
56 info
= qmp_query_name(NULL
);
58 monitor_printf(mon
, "%s\n", info
->name
);
60 qapi_free_NameInfo(info
);
63 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
67 info
= qmp_query_version(NULL
);
69 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
70 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
73 qapi_free_VersionInfo(info
);
76 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
80 info
= qmp_query_kvm(NULL
);
81 monitor_printf(mon
, "kvm support: ");
83 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
85 monitor_printf(mon
, "not compiled\n");
88 qapi_free_KvmInfo(info
);
91 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
95 info
= qmp_query_status(NULL
);
97 monitor_printf(mon
, "VM status: %s%s",
98 info
->running
? "running" : "paused",
99 info
->singlestep
? " (single step mode)" : "");
101 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
102 monitor_printf(mon
, " (%s)", RunState_lookup
[info
->status
]);
105 monitor_printf(mon
, "\n");
107 qapi_free_StatusInfo(info
);
110 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
114 info
= qmp_query_uuid(NULL
);
115 monitor_printf(mon
, "%s\n", info
->UUID
);
116 qapi_free_UuidInfo(info
);
119 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
121 ChardevInfoList
*char_info
, *info
;
123 char_info
= qmp_query_chardev(NULL
);
124 for (info
= char_info
; info
; info
= info
->next
) {
125 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
126 info
->value
->filename
);
129 qapi_free_ChardevInfoList(char_info
);
132 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
134 MouseInfoList
*mice_list
, *mouse
;
136 mice_list
= qmp_query_mice(NULL
);
138 monitor_printf(mon
, "No mouse devices connected\n");
142 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
143 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
144 mouse
->value
->current
? '*' : ' ',
145 mouse
->value
->index
, mouse
->value
->name
,
146 mouse
->value
->absolute
? " (absolute)" : "");
149 qapi_free_MouseInfoList(mice_list
);
152 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
155 MigrationCapabilityStatusList
*caps
, *cap
;
157 info
= qmp_query_migrate(NULL
);
158 caps
= qmp_query_migrate_capabilities(NULL
);
160 /* do not display parameters during setup */
161 if (info
->has_status
&& caps
) {
162 monitor_printf(mon
, "capabilities: ");
163 for (cap
= caps
; cap
; cap
= cap
->next
) {
164 monitor_printf(mon
, "%s: %s ",
165 MigrationCapability_lookup
[cap
->value
->capability
],
166 cap
->value
->state
? "on" : "off");
168 monitor_printf(mon
, "\n");
171 if (info
->has_status
) {
172 monitor_printf(mon
, "Migration status: %s",
173 MigrationStatus_lookup
[info
->status
]);
174 if (info
->status
== MIGRATION_STATUS_FAILED
&&
175 info
->has_error_desc
) {
176 monitor_printf(mon
, " (%s)\n", info
->error_desc
);
178 monitor_printf(mon
, "\n");
181 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
183 if (info
->has_expected_downtime
) {
184 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
185 info
->expected_downtime
);
187 if (info
->has_downtime
) {
188 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
191 if (info
->has_setup_time
) {
192 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
198 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
199 info
->ram
->transferred
>> 10);
200 monitor_printf(mon
, "throughput: %0.2f mbps\n",
202 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
203 info
->ram
->remaining
>> 10);
204 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
205 info
->ram
->total
>> 10);
206 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
207 info
->ram
->duplicate
);
208 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
210 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
212 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
213 info
->ram
->normal_bytes
>> 10);
214 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
215 info
->ram
->dirty_sync_count
);
216 if (info
->ram
->dirty_pages_rate
) {
217 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
218 info
->ram
->dirty_pages_rate
);
222 if (info
->has_disk
) {
223 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
224 info
->disk
->transferred
>> 10);
225 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
226 info
->disk
->remaining
>> 10);
227 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
228 info
->disk
->total
>> 10);
231 if (info
->has_xbzrle_cache
) {
232 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
233 info
->xbzrle_cache
->cache_size
);
234 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
235 info
->xbzrle_cache
->bytes
>> 10);
236 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
237 info
->xbzrle_cache
->pages
);
238 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
239 info
->xbzrle_cache
->cache_miss
);
240 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
241 info
->xbzrle_cache
->cache_miss_rate
);
242 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
243 info
->xbzrle_cache
->overflow
);
246 if (info
->has_cpu_throttle_percentage
) {
247 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
248 info
->cpu_throttle_percentage
);
251 qapi_free_MigrationInfo(info
);
252 qapi_free_MigrationCapabilityStatusList(caps
);
255 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
257 MigrationCapabilityStatusList
*caps
, *cap
;
259 caps
= qmp_query_migrate_capabilities(NULL
);
262 monitor_printf(mon
, "capabilities: ");
263 for (cap
= caps
; cap
; cap
= cap
->next
) {
264 monitor_printf(mon
, "%s: %s ",
265 MigrationCapability_lookup
[cap
->value
->capability
],
266 cap
->value
->state
? "on" : "off");
268 monitor_printf(mon
, "\n");
271 qapi_free_MigrationCapabilityStatusList(caps
);
274 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
276 MigrationParameters
*params
;
278 params
= qmp_query_migrate_parameters(NULL
);
281 monitor_printf(mon
, "parameters:");
282 monitor_printf(mon
, " %s: %" PRId64
,
283 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_LEVEL
],
284 params
->compress_level
);
285 monitor_printf(mon
, " %s: %" PRId64
,
286 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_THREADS
],
287 params
->compress_threads
);
288 monitor_printf(mon
, " %s: %" PRId64
,
289 MigrationParameter_lookup
[MIGRATION_PARAMETER_DECOMPRESS_THREADS
],
290 params
->decompress_threads
);
291 monitor_printf(mon
, " %s: %" PRId64
,
292 MigrationParameter_lookup
[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
],
293 params
->cpu_throttle_initial
);
294 monitor_printf(mon
, " %s: %" PRId64
,
295 MigrationParameter_lookup
[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
],
296 params
->cpu_throttle_increment
);
297 monitor_printf(mon
, "\n");
300 qapi_free_MigrationParameters(params
);
303 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
305 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
306 qmp_query_migrate_cache_size(NULL
) >> 10);
309 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
311 CpuInfoList
*cpu_list
, *cpu
;
313 cpu_list
= qmp_query_cpus(NULL
);
315 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
318 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
322 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
, cpu
->value
->CPU
);
324 switch (cpu
->value
->arch
) {
325 case CPU_INFO_ARCH_X86
:
326 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->u
.x86
.pc
);
328 case CPU_INFO_ARCH_PPC
:
329 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->u
.ppc
.nip
);
331 case CPU_INFO_ARCH_SPARC
:
332 monitor_printf(mon
, " pc=0x%016" PRIx64
,
333 cpu
->value
->u
.q_sparc
.pc
);
334 monitor_printf(mon
, " npc=0x%016" PRIx64
,
335 cpu
->value
->u
.q_sparc
.npc
);
337 case CPU_INFO_ARCH_MIPS
:
338 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.q_mips
.PC
);
340 case CPU_INFO_ARCH_TRICORE
:
341 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.tricore
.PC
);
347 if (cpu
->value
->halted
) {
348 monitor_printf(mon
, " (halted)");
351 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
354 qapi_free_CpuInfoList(cpu_list
);
357 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
358 BlockDeviceInfo
*inserted
, bool verbose
)
360 ImageInfo
*image_info
;
362 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
365 monitor_printf(mon
, "%s", info
->device
);
366 if (inserted
&& inserted
->has_node_name
) {
367 monitor_printf(mon
, " (%s)", inserted
->node_name
);
371 monitor_printf(mon
, "%s",
372 inserted
->has_node_name
373 ? inserted
->node_name
378 monitor_printf(mon
, ": %s (%s%s%s)\n",
381 inserted
->ro
? ", read-only" : "",
382 inserted
->encrypted
? ", encrypted" : "");
384 monitor_printf(mon
, ": [not inserted]\n");
388 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
389 monitor_printf(mon
, " I/O status: %s\n",
390 BlockDeviceIoStatus_lookup
[info
->io_status
]);
393 if (info
->removable
) {
394 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
395 info
->locked
? "" : "not ",
396 info
->tray_open
? "open" : "closed");
405 monitor_printf(mon
, " Cache mode: %s%s%s\n",
406 inserted
->cache
->writeback
? "writeback" : "writethrough",
407 inserted
->cache
->direct
? ", direct" : "",
408 inserted
->cache
->no_flush
? ", ignore flushes" : "");
410 if (inserted
->has_backing_file
) {
413 "(chain depth: %" PRId64
")\n",
414 inserted
->backing_file
,
415 inserted
->backing_file_depth
);
418 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
419 monitor_printf(mon
, " Detect zeroes: %s\n",
420 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
423 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
424 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
426 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
427 " bps_rd=%" PRId64
" bps_wr=%" PRId64
429 " bps_rd_max=%" PRId64
430 " bps_wr_max=%" PRId64
431 " iops=%" PRId64
" iops_rd=%" PRId64
434 " iops_rd_max=%" PRId64
435 " iops_wr_max=%" PRId64
436 " iops_size=%" PRId64
442 inserted
->bps_rd_max
,
443 inserted
->bps_wr_max
,
448 inserted
->iops_rd_max
,
449 inserted
->iops_wr_max
,
455 monitor_printf(mon
, "\nImages:\n");
456 image_info
= inserted
->image
;
458 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
460 if (image_info
->has_backing_image
) {
461 image_info
= image_info
->backing_image
;
469 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
471 BlockInfoList
*block_list
, *info
;
472 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
473 const char *device
= qdict_get_try_str(qdict
, "device");
474 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
475 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
476 bool printed
= false;
478 /* Print BlockBackend information */
480 block_list
= qmp_query_block(NULL
);
485 for (info
= block_list
; info
; info
= info
->next
) {
486 if (device
&& strcmp(device
, info
->value
->device
)) {
490 if (info
!= block_list
) {
491 monitor_printf(mon
, "\n");
494 print_block_info(mon
, info
->value
, info
->value
->has_inserted
495 ? info
->value
->inserted
: NULL
,
500 qapi_free_BlockInfoList(block_list
);
502 if ((!device
&& !nodes
) || printed
) {
506 /* Print node information */
507 blockdev_list
= qmp_query_named_block_nodes(NULL
);
508 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
509 assert(blockdev
->value
->has_node_name
);
510 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
514 if (blockdev
!= blockdev_list
) {
515 monitor_printf(mon
, "\n");
518 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
520 qapi_free_BlockDeviceInfoList(blockdev_list
);
523 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
525 BlockStatsList
*stats_list
, *stats
;
527 stats_list
= qmp_query_blockstats(false, false, NULL
);
529 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
530 if (!stats
->value
->has_device
) {
534 monitor_printf(mon
, "%s:", stats
->value
->device
);
535 monitor_printf(mon
, " rd_bytes=%" PRId64
537 " rd_operations=%" PRId64
538 " wr_operations=%" PRId64
539 " flush_operations=%" PRId64
540 " wr_total_time_ns=%" PRId64
541 " rd_total_time_ns=%" PRId64
542 " flush_total_time_ns=%" PRId64
543 " rd_merged=%" PRId64
544 " wr_merged=%" PRId64
545 " idle_time_ns=%" PRId64
547 stats
->value
->stats
->rd_bytes
,
548 stats
->value
->stats
->wr_bytes
,
549 stats
->value
->stats
->rd_operations
,
550 stats
->value
->stats
->wr_operations
,
551 stats
->value
->stats
->flush_operations
,
552 stats
->value
->stats
->wr_total_time_ns
,
553 stats
->value
->stats
->rd_total_time_ns
,
554 stats
->value
->stats
->flush_total_time_ns
,
555 stats
->value
->stats
->rd_merged
,
556 stats
->value
->stats
->wr_merged
,
557 stats
->value
->stats
->idle_time_ns
);
560 qapi_free_BlockStatsList(stats_list
);
563 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
567 VncClientInfoList
*client
;
569 info
= qmp_query_vnc(&err
);
571 error_report_err(err
);
575 if (!info
->enabled
) {
576 monitor_printf(mon
, "Server: disabled\n");
580 monitor_printf(mon
, "Server:\n");
581 if (info
->has_host
&& info
->has_service
) {
582 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
584 if (info
->has_auth
) {
585 monitor_printf(mon
, " auth: %s\n", info
->auth
);
588 if (!info
->has_clients
|| info
->clients
== NULL
) {
589 monitor_printf(mon
, "Client: none\n");
591 for (client
= info
->clients
; client
; client
= client
->next
) {
592 monitor_printf(mon
, "Client:\n");
593 monitor_printf(mon
, " address: %s:%s\n",
595 client
->value
->service
);
596 monitor_printf(mon
, " x509_dname: %s\n",
597 client
->value
->x509_dname
?
598 client
->value
->x509_dname
: "none");
599 monitor_printf(mon
, " username: %s\n",
600 client
->value
->has_sasl_username
?
601 client
->value
->sasl_username
: "none");
606 qapi_free_VncInfo(info
);
610 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
612 SpiceChannelList
*chan
;
614 const char *channel_name
;
615 const char * const channel_names
[] = {
616 [SPICE_CHANNEL_MAIN
] = "main",
617 [SPICE_CHANNEL_DISPLAY
] = "display",
618 [SPICE_CHANNEL_INPUTS
] = "inputs",
619 [SPICE_CHANNEL_CURSOR
] = "cursor",
620 [SPICE_CHANNEL_PLAYBACK
] = "playback",
621 [SPICE_CHANNEL_RECORD
] = "record",
622 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
623 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
624 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
625 [SPICE_CHANNEL_PORT
] = "port",
627 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
628 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
629 * as quick fix for build failures with older versions. */
630 [SPICE_CHANNEL_WEBDAV
] = "webdav",
634 info
= qmp_query_spice(NULL
);
636 if (!info
->enabled
) {
637 monitor_printf(mon
, "Server: disabled\n");
641 monitor_printf(mon
, "Server:\n");
642 if (info
->has_port
) {
643 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
644 info
->host
, info
->port
);
646 if (info
->has_tls_port
) {
647 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
648 info
->host
, info
->tls_port
);
650 monitor_printf(mon
, " migrated: %s\n",
651 info
->migrated
? "true" : "false");
652 monitor_printf(mon
, " auth: %s\n", info
->auth
);
653 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
654 monitor_printf(mon
, " mouse-mode: %s\n",
655 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
657 if (!info
->has_channels
|| info
->channels
== NULL
) {
658 monitor_printf(mon
, "Channels: none\n");
660 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
661 monitor_printf(mon
, "Channel:\n");
662 monitor_printf(mon
, " address: %s:%s%s\n",
663 chan
->value
->host
, chan
->value
->port
,
664 chan
->value
->tls
? " [tls]" : "");
665 monitor_printf(mon
, " session: %" PRId64
"\n",
666 chan
->value
->connection_id
);
667 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
668 chan
->value
->channel_type
, chan
->value
->channel_id
);
670 channel_name
= "unknown";
671 if (chan
->value
->channel_type
> 0 &&
672 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
673 channel_names
[chan
->value
->channel_type
]) {
674 channel_name
= channel_names
[chan
->value
->channel_type
];
677 monitor_printf(mon
, " channel name: %s\n", channel_name
);
682 qapi_free_SpiceInfo(info
);
686 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
691 info
= qmp_query_balloon(&err
);
693 error_report_err(err
);
697 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
699 qapi_free_BalloonInfo(info
);
702 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
704 PciMemoryRegionList
*region
;
706 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
707 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
708 dev
->slot
, dev
->function
);
709 monitor_printf(mon
, " ");
711 if (dev
->class_info
->has_desc
) {
712 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
714 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
717 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
718 dev
->id
->vendor
, dev
->id
->device
);
721 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
724 if (dev
->has_pci_bridge
) {
725 monitor_printf(mon
, " BUS %" PRId64
".\n",
726 dev
->pci_bridge
->bus
->number
);
727 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
728 dev
->pci_bridge
->bus
->secondary
);
729 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
730 dev
->pci_bridge
->bus
->subordinate
);
732 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
733 dev
->pci_bridge
->bus
->io_range
->base
,
734 dev
->pci_bridge
->bus
->io_range
->limit
);
737 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
738 dev
->pci_bridge
->bus
->memory_range
->base
,
739 dev
->pci_bridge
->bus
->memory_range
->limit
);
741 monitor_printf(mon
, " prefetchable memory range "
742 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
743 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
744 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
747 for (region
= dev
->regions
; region
; region
= region
->next
) {
750 addr
= region
->value
->address
;
751 size
= region
->value
->size
;
753 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
755 if (!strcmp(region
->value
->type
, "io")) {
756 monitor_printf(mon
, "I/O at 0x%04" PRIx64
757 " [0x%04" PRIx64
"].\n",
758 addr
, addr
+ size
- 1);
760 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
761 " [0x%08" PRIx64
"].\n",
762 region
->value
->mem_type_64
? 64 : 32,
763 region
->value
->prefetch
? " prefetchable" : "",
764 addr
, addr
+ size
- 1);
768 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
770 if (dev
->has_pci_bridge
) {
771 if (dev
->pci_bridge
->has_devices
) {
772 PciDeviceInfoList
*cdev
;
773 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
774 hmp_info_pci_device(mon
, cdev
->value
);
780 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
782 PciInfoList
*info_list
, *info
;
785 info_list
= qmp_query_pci(&err
);
787 monitor_printf(mon
, "PCI devices not supported\n");
792 for (info
= info_list
; info
; info
= info
->next
) {
793 PciDeviceInfoList
*dev
;
795 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
796 hmp_info_pci_device(mon
, dev
->value
);
800 qapi_free_PciInfoList(info_list
);
803 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
805 BlockJobInfoList
*list
;
808 list
= qmp_query_block_jobs(&err
);
812 monitor_printf(mon
, "No active jobs\n");
817 if (strcmp(list
->value
->type
, "stream") == 0) {
818 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
819 " of %" PRId64
" bytes, speed limit %" PRId64
826 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
827 " of %" PRId64
" bytes, speed limit %" PRId64
838 qapi_free_BlockJobInfoList(list
);
841 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
843 TPMInfoList
*info_list
, *info
;
846 TPMPassthroughOptions
*tpo
;
848 info_list
= qmp_query_tpm(&err
);
850 monitor_printf(mon
, "TPM device not supported\n");
856 monitor_printf(mon
, "TPM device:\n");
859 for (info
= info_list
; info
; info
= info
->next
) {
860 TPMInfo
*ti
= info
->value
;
861 monitor_printf(mon
, " tpm%d: model=%s\n",
862 c
, TpmModel_lookup
[ti
->model
]);
864 monitor_printf(mon
, " \\ %s: type=%s",
865 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
867 switch (ti
->options
->type
) {
868 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
869 tpo
= ti
->options
->u
.passthrough
.data
;
870 monitor_printf(mon
, "%s%s%s%s",
871 tpo
->has_path
? ",path=" : "",
872 tpo
->has_path
? tpo
->path
: "",
873 tpo
->has_cancel_path
? ",cancel-path=" : "",
874 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
876 case TPM_TYPE_OPTIONS_KIND__MAX
:
879 monitor_printf(mon
, "\n");
882 qapi_free_TPMInfoList(info_list
);
885 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
887 monitor_suspend(mon
);
891 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
896 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
898 qmp_system_reset(NULL
);
901 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
903 qmp_system_powerdown(NULL
);
906 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
910 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
911 use it are converted to the QAPI */
912 cpu_index
= qdict_get_int(qdict
, "index");
913 if (monitor_set_cpu(cpu_index
) < 0) {
914 monitor_printf(mon
, "invalid CPU index\n");
918 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
920 uint32_t size
= qdict_get_int(qdict
, "size");
921 const char *filename
= qdict_get_str(qdict
, "filename");
922 uint64_t addr
= qdict_get_int(qdict
, "val");
925 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
926 hmp_handle_error(mon
, &err
);
929 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
931 uint32_t size
= qdict_get_int(qdict
, "size");
932 const char *filename
= qdict_get_str(qdict
, "filename");
933 uint64_t addr
= qdict_get_int(qdict
, "val");
936 qmp_pmemsave(addr
, size
, filename
, &err
);
937 hmp_handle_error(mon
, &err
);
940 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
942 const char *chardev
= qdict_get_str(qdict
, "device");
943 const char *data
= qdict_get_str(qdict
, "data");
946 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
948 hmp_handle_error(mon
, &err
);
951 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
953 uint32_t size
= qdict_get_int(qdict
, "size");
954 const char *chardev
= qdict_get_str(qdict
, "device");
959 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
961 error_report_err(err
);
965 for (i
= 0; data
[i
]; i
++) {
966 unsigned char ch
= data
[i
];
969 monitor_printf(mon
, "\\\\");
970 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
971 monitor_printf(mon
, "\\u%04X", ch
);
973 monitor_printf(mon
, "%c", ch
);
977 monitor_printf(mon
, "\n");
981 static void hmp_cont_cb(void *opaque
, int err
)
988 static bool key_is_missing(const BlockInfo
*bdev
)
990 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
993 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
995 BlockInfoList
*bdev_list
, *bdev
;
998 bdev_list
= qmp_query_block(NULL
);
999 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
1000 if (key_is_missing(bdev
->value
)) {
1001 monitor_read_block_device_key(mon
, bdev
->value
->device
,
1008 hmp_handle_error(mon
, &err
);
1011 qapi_free_BlockInfoList(bdev_list
);
1014 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1016 qmp_system_wakeup(NULL
);
1019 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1023 qmp_inject_nmi(&err
);
1024 hmp_handle_error(mon
, &err
);
1027 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1029 const char *name
= qdict_get_str(qdict
, "name");
1030 bool up
= qdict_get_bool(qdict
, "up");
1033 qmp_set_link(name
, up
, &err
);
1034 hmp_handle_error(mon
, &err
);
1037 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1039 const char *device
= qdict_get_str(qdict
, "device");
1040 const char *password
= qdict_get_str(qdict
, "password");
1043 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1044 hmp_handle_error(mon
, &err
);
1047 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1049 int64_t value
= qdict_get_int(qdict
, "value");
1052 qmp_balloon(value
, &err
);
1054 error_report_err(err
);
1058 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1060 const char *device
= qdict_get_str(qdict
, "device");
1061 int64_t size
= qdict_get_int(qdict
, "size");
1064 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1065 hmp_handle_error(mon
, &err
);
1068 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1070 const char *device
= qdict_get_str(qdict
, "device");
1071 const char *filename
= qdict_get_str(qdict
, "target");
1072 const char *format
= qdict_get_try_str(qdict
, "format");
1073 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1074 bool full
= qdict_get_try_bool(qdict
, "full", false);
1075 enum NewImageMode mode
;
1079 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1080 hmp_handle_error(mon
, &err
);
1085 mode
= NEW_IMAGE_MODE_EXISTING
;
1087 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1090 qmp_drive_mirror(device
, filename
, !!format
, format
,
1091 false, NULL
, false, NULL
,
1092 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1093 true, mode
, false, 0, false, 0, false, 0,
1094 false, 0, false, 0, false, true, &err
);
1095 hmp_handle_error(mon
, &err
);
1098 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1100 const char *device
= qdict_get_str(qdict
, "device");
1101 const char *filename
= qdict_get_str(qdict
, "target");
1102 const char *format
= qdict_get_try_str(qdict
, "format");
1103 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1104 bool full
= qdict_get_try_bool(qdict
, "full", false);
1105 enum NewImageMode mode
;
1109 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1110 hmp_handle_error(mon
, &err
);
1115 mode
= NEW_IMAGE_MODE_EXISTING
;
1117 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1120 qmp_drive_backup(device
, filename
, !!format
, format
,
1121 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1122 true, mode
, false, 0, false, NULL
,
1123 false, 0, false, 0, &err
);
1124 hmp_handle_error(mon
, &err
);
1127 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1129 const char *device
= qdict_get_str(qdict
, "device");
1130 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1131 const char *format
= qdict_get_try_str(qdict
, "format");
1132 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1133 enum NewImageMode mode
;
1137 /* In the future, if 'snapshot-file' is not specified, the snapshot
1138 will be taken internally. Today it's actually required. */
1139 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1140 hmp_handle_error(mon
, &err
);
1144 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1145 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1146 filename
, false, NULL
,
1149 hmp_handle_error(mon
, &err
);
1152 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1154 const char *device
= qdict_get_str(qdict
, "device");
1155 const char *name
= qdict_get_str(qdict
, "name");
1158 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1159 hmp_handle_error(mon
, &err
);
1162 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1164 const char *device
= qdict_get_str(qdict
, "device");
1165 const char *name
= qdict_get_str(qdict
, "name");
1166 const char *id
= qdict_get_try_str(qdict
, "id");
1169 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1171 hmp_handle_error(mon
, &err
);
1174 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1176 qmp_migrate_cancel(NULL
);
1179 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1182 const char *uri
= qdict_get_str(qdict
, "uri");
1184 qmp_migrate_incoming(uri
, &err
);
1186 hmp_handle_error(mon
, &err
);
1189 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1191 double value
= qdict_get_double(qdict
, "value");
1192 qmp_migrate_set_downtime(value
, NULL
);
1195 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1197 int64_t value
= qdict_get_int(qdict
, "value");
1200 qmp_migrate_set_cache_size(value
, &err
);
1202 error_report_err(err
);
1207 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1209 int64_t value
= qdict_get_int(qdict
, "value");
1210 qmp_migrate_set_speed(value
, NULL
);
1213 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1215 const char *cap
= qdict_get_str(qdict
, "capability");
1216 bool state
= qdict_get_bool(qdict
, "state");
1218 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1221 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1222 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1223 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1224 caps
->value
->capability
= i
;
1225 caps
->value
->state
= state
;
1227 qmp_migrate_set_capabilities(caps
, &err
);
1232 if (i
== MIGRATION_CAPABILITY__MAX
) {
1233 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1236 qapi_free_MigrationCapabilityStatusList(caps
);
1239 error_report_err(err
);
1243 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1245 const char *param
= qdict_get_str(qdict
, "parameter");
1246 int value
= qdict_get_int(qdict
, "value");
1248 bool has_compress_level
= false;
1249 bool has_compress_threads
= false;
1250 bool has_decompress_threads
= false;
1251 bool has_cpu_throttle_initial
= false;
1252 bool has_cpu_throttle_increment
= false;
1255 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1256 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1258 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1259 has_compress_level
= true;
1261 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1262 has_compress_threads
= true;
1264 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1265 has_decompress_threads
= true;
1267 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1268 has_cpu_throttle_initial
= true;
1270 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1271 has_cpu_throttle_increment
= true;
1274 qmp_migrate_set_parameters(has_compress_level
, value
,
1275 has_compress_threads
, value
,
1276 has_decompress_threads
, value
,
1277 has_cpu_throttle_initial
, value
,
1278 has_cpu_throttle_increment
, value
,
1284 if (i
== MIGRATION_PARAMETER__MAX
) {
1285 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1289 error_report_err(err
);
1293 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1296 const char *protocol
= qdict_get_str(qdict
, "protocol");
1297 const char *hostname
= qdict_get_str(qdict
, "hostname");
1298 bool has_port
= qdict_haskey(qdict
, "port");
1299 int port
= qdict_get_try_int(qdict
, "port", -1);
1300 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1301 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1302 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1304 qmp_client_migrate_info(protocol
, hostname
,
1305 has_port
, port
, has_tls_port
, tls_port
,
1306 !!cert_subject
, cert_subject
, &err
);
1307 hmp_handle_error(mon
, &err
);
1310 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1313 qmp_migrate_start_postcopy(&err
);
1314 hmp_handle_error(mon
, &err
);
1317 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1319 const char *protocol
= qdict_get_str(qdict
, "protocol");
1320 const char *password
= qdict_get_str(qdict
, "password");
1321 const char *connected
= qdict_get_try_str(qdict
, "connected");
1324 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1325 hmp_handle_error(mon
, &err
);
1328 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1330 const char *protocol
= qdict_get_str(qdict
, "protocol");
1331 const char *whenstr
= qdict_get_str(qdict
, "time");
1334 qmp_expire_password(protocol
, whenstr
, &err
);
1335 hmp_handle_error(mon
, &err
);
1338 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1340 bool force
= qdict_get_try_bool(qdict
, "force", false);
1341 const char *device
= qdict_get_str(qdict
, "device");
1344 qmp_eject(device
, true, force
, &err
);
1345 hmp_handle_error(mon
, &err
);
1348 static void hmp_change_read_arg(void *opaque
, const char *password
,
1349 void *readline_opaque
)
1351 qmp_change_vnc_password(password
, NULL
);
1352 monitor_read_command(opaque
, 1);
1355 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1357 const char *device
= qdict_get_str(qdict
, "device");
1358 const char *target
= qdict_get_str(qdict
, "target");
1359 const char *arg
= qdict_get_try_str(qdict
, "arg");
1360 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1361 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1364 if (strcmp(device
, "vnc") == 0) {
1367 "Parameter 'read-only-mode' is invalid for VNC\n");
1370 if (strcmp(target
, "passwd") == 0 ||
1371 strcmp(target
, "password") == 0) {
1373 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1377 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1381 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1382 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1383 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1385 hmp_handle_error(mon
, &err
);
1390 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1391 !!read_only
, read_only_mode
, &err
);
1393 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1395 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1400 hmp_handle_error(mon
, &err
);
1403 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1407 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1408 qdict_get_int(qdict
, "bps"),
1409 qdict_get_int(qdict
, "bps_rd"),
1410 qdict_get_int(qdict
, "bps_wr"),
1411 qdict_get_int(qdict
, "iops"),
1412 qdict_get_int(qdict
, "iops_rd"),
1413 qdict_get_int(qdict
, "iops_wr"),
1414 false, /* no burst max via HMP */
1426 false, /* no burst length via HMP */
1438 false, /* No default I/O size */
1442 hmp_handle_error(mon
, &err
);
1445 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1447 Error
*error
= NULL
;
1448 const char *device
= qdict_get_str(qdict
, "device");
1449 const char *base
= qdict_get_try_str(qdict
, "base");
1450 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1452 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1453 qdict_haskey(qdict
, "speed"), speed
,
1454 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1456 hmp_handle_error(mon
, &error
);
1459 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1461 Error
*error
= NULL
;
1462 const char *device
= qdict_get_str(qdict
, "device");
1463 int64_t value
= qdict_get_int(qdict
, "speed");
1465 qmp_block_job_set_speed(device
, value
, &error
);
1467 hmp_handle_error(mon
, &error
);
1470 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1472 Error
*error
= NULL
;
1473 const char *device
= qdict_get_str(qdict
, "device");
1474 bool force
= qdict_get_try_bool(qdict
, "force", false);
1476 qmp_block_job_cancel(device
, true, force
, &error
);
1478 hmp_handle_error(mon
, &error
);
1481 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1483 Error
*error
= NULL
;
1484 const char *device
= qdict_get_str(qdict
, "device");
1486 qmp_block_job_pause(device
, &error
);
1488 hmp_handle_error(mon
, &error
);
1491 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1493 Error
*error
= NULL
;
1494 const char *device
= qdict_get_str(qdict
, "device");
1496 qmp_block_job_resume(device
, &error
);
1498 hmp_handle_error(mon
, &error
);
1501 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1503 Error
*error
= NULL
;
1504 const char *device
= qdict_get_str(qdict
, "device");
1506 qmp_block_job_complete(device
, &error
);
1508 hmp_handle_error(mon
, &error
);
1511 typedef struct HMPMigrationStatus
1515 bool is_block_migration
;
1516 } HMPMigrationStatus
;
1518 static void hmp_migrate_status_cb(void *opaque
)
1520 HMPMigrationStatus
*status
= opaque
;
1521 MigrationInfo
*info
;
1523 info
= qmp_query_migrate(NULL
);
1524 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1525 info
->status
== MIGRATION_STATUS_SETUP
) {
1526 if (info
->has_disk
) {
1529 if (info
->disk
->remaining
) {
1530 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1535 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1536 monitor_flush(status
->mon
);
1539 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1541 if (status
->is_block_migration
) {
1542 monitor_printf(status
->mon
, "\n");
1544 if (info
->has_error_desc
) {
1545 error_report("%s", info
->error_desc
);
1547 monitor_resume(status
->mon
);
1548 timer_del(status
->timer
);
1552 qapi_free_MigrationInfo(info
);
1555 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1557 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1558 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1559 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1560 const char *uri
= qdict_get_str(qdict
, "uri");
1563 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1565 error_report_err(err
);
1570 HMPMigrationStatus
*status
;
1572 if (monitor_suspend(mon
) < 0) {
1573 monitor_printf(mon
, "terminal does not allow synchronous "
1574 "migration, continuing detached\n");
1578 status
= g_malloc0(sizeof(*status
));
1580 status
->is_block_migration
= blk
|| inc
;
1581 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1583 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1587 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1591 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1592 hmp_handle_error(mon
, &err
);
1595 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1597 const char *id
= qdict_get_str(qdict
, "id");
1600 qmp_device_del(id
, &err
);
1601 hmp_handle_error(mon
, &err
);
1604 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1607 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1608 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1609 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1610 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1611 const char *file
= qdict_get_str(qdict
, "filename");
1612 bool has_begin
= qdict_haskey(qdict
, "begin");
1613 bool has_length
= qdict_haskey(qdict
, "length");
1614 bool has_detach
= qdict_haskey(qdict
, "detach");
1617 bool detach
= false;
1618 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1621 if (zlib
+ lzo
+ snappy
> 1) {
1622 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1623 hmp_handle_error(mon
, &err
);
1628 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1632 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1636 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1640 begin
= qdict_get_int(qdict
, "begin");
1643 length
= qdict_get_int(qdict
, "length");
1646 detach
= qdict_get_bool(qdict
, "detach");
1649 prot
= g_strconcat("file:", file
, NULL
);
1651 qmp_dump_guest_memory(paging
, prot
, true, detach
, has_begin
, begin
,
1652 has_length
, length
, true, dump_format
, &err
);
1653 hmp_handle_error(mon
, &err
);
1657 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1662 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1667 netdev_add(opts
, &err
);
1669 qemu_opts_del(opts
);
1673 hmp_handle_error(mon
, &err
);
1676 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1678 const char *id
= qdict_get_str(qdict
, "id");
1681 qmp_netdev_del(id
, &err
);
1682 hmp_handle_error(mon
, &err
);
1685 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1692 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1694 hmp_handle_error(mon
, &err
);
1698 ov
= opts_visitor_new(opts
);
1699 obj
= user_creatable_add(qdict
, opts_get_visitor(ov
), &err
);
1700 opts_visitor_cleanup(ov
);
1701 qemu_opts_del(opts
);
1704 hmp_handle_error(mon
, &err
);
1711 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1713 const char *fdname
= qdict_get_str(qdict
, "fdname");
1716 qmp_getfd(fdname
, &err
);
1717 hmp_handle_error(mon
, &err
);
1720 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1722 const char *fdname
= qdict_get_str(qdict
, "fdname");
1725 qmp_closefd(fdname
, &err
);
1726 hmp_handle_error(mon
, &err
);
1729 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1731 const char *keys
= qdict_get_str(qdict
, "keys");
1732 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1733 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1734 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1740 separator
= strchr(keys
, '-');
1741 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1743 /* Be compatible with old interface, convert user inputted "<" */
1744 if (keys
[0] == '<' && keyname_len
== 1) {
1749 keylist
= g_malloc0(sizeof(*keylist
));
1750 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1756 tmp
->next
= keylist
;
1760 if (strstart(keys
, "0x", NULL
)) {
1762 int value
= strtoul(keys
, &endp
, 0);
1763 assert(endp
<= keys
+ keyname_len
);
1764 if (endp
!= keys
+ keyname_len
) {
1767 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1768 keylist
->value
->u
.number
.data
= value
;
1770 int idx
= index_from_key(keys
, keyname_len
);
1771 if (idx
== Q_KEY_CODE__MAX
) {
1774 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1775 keylist
->value
->u
.qcode
.data
= idx
;
1781 keys
= separator
+ 1;
1784 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1785 hmp_handle_error(mon
, &err
);
1788 qapi_free_KeyValueList(head
);
1792 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1796 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1798 const char *filename
= qdict_get_str(qdict
, "filename");
1801 qmp_screendump(filename
, &err
);
1802 hmp_handle_error(mon
, &err
);
1805 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1807 const char *uri
= qdict_get_str(qdict
, "uri");
1808 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1809 bool all
= qdict_get_try_bool(qdict
, "all", false);
1810 Error
*local_err
= NULL
;
1811 BlockInfoList
*block_list
, *info
;
1812 SocketAddress
*addr
;
1814 if (writable
&& !all
) {
1815 error_setg(&local_err
, "-w only valid together with -a");
1819 /* First check if the address is valid and start the server. */
1820 addr
= socket_parse(uri
, &local_err
);
1821 if (local_err
!= NULL
) {
1825 qmp_nbd_server_start(addr
, false, NULL
, &local_err
);
1826 qapi_free_SocketAddress(addr
);
1827 if (local_err
!= NULL
) {
1835 /* Then try adding all block devices. If one fails, close all and
1838 block_list
= qmp_query_block(NULL
);
1840 for (info
= block_list
; info
; info
= info
->next
) {
1841 if (!info
->value
->has_inserted
) {
1845 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1847 if (local_err
!= NULL
) {
1848 qmp_nbd_server_stop(NULL
);
1853 qapi_free_BlockInfoList(block_list
);
1856 hmp_handle_error(mon
, &local_err
);
1859 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1861 const char *device
= qdict_get_str(qdict
, "device");
1862 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1863 Error
*local_err
= NULL
;
1865 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1867 if (local_err
!= NULL
) {
1868 hmp_handle_error(mon
, &local_err
);
1872 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1876 qmp_nbd_server_stop(&err
);
1877 hmp_handle_error(mon
, &err
);
1880 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1885 cpuid
= qdict_get_int(qdict
, "id");
1886 qmp_cpu_add(cpuid
, &err
);
1887 hmp_handle_error(mon
, &err
);
1890 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1892 const char *args
= qdict_get_str(qdict
, "args");
1896 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1898 error_setg(&err
, "Parsing chardev args failed");
1900 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1902 hmp_handle_error(mon
, &err
);
1905 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1907 Error
*local_err
= NULL
;
1909 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1910 hmp_handle_error(mon
, &local_err
);
1913 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1916 const char* device
= qdict_get_str(qdict
, "device");
1917 const char* command
= qdict_get_str(qdict
, "command");
1920 blk
= blk_by_name(device
);
1922 qemuio_command(blk
, command
);
1924 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1925 "Device '%s' not found", device
);
1928 hmp_handle_error(mon
, &err
);
1931 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1933 const char *id
= qdict_get_str(qdict
, "id");
1936 user_creatable_del(id
, &err
);
1937 hmp_handle_error(mon
, &err
);
1940 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1943 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1944 MemdevList
*m
= memdev_list
;
1945 StringOutputVisitor
*ov
;
1951 ov
= string_output_visitor_new(false);
1952 visit_type_uint16List(string_output_get_visitor(ov
), NULL
,
1953 &m
->value
->host_nodes
, NULL
);
1954 monitor_printf(mon
, "memory backend: %d\n", i
);
1955 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1956 monitor_printf(mon
, " merge: %s\n",
1957 m
->value
->merge
? "true" : "false");
1958 monitor_printf(mon
, " dump: %s\n",
1959 m
->value
->dump
? "true" : "false");
1960 monitor_printf(mon
, " prealloc: %s\n",
1961 m
->value
->prealloc
? "true" : "false");
1962 monitor_printf(mon
, " policy: %s\n",
1963 HostMemPolicy_lookup
[m
->value
->policy
]);
1964 str
= string_output_get_string(ov
);
1965 monitor_printf(mon
, " host nodes: %s\n", str
);
1968 string_output_visitor_cleanup(ov
);
1973 monitor_printf(mon
, "\n");
1975 qapi_free_MemdevList(memdev_list
);
1978 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1981 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1982 MemoryDeviceInfoList
*info
;
1983 MemoryDeviceInfo
*value
;
1984 PCDIMMDeviceInfo
*di
;
1986 for (info
= info_list
; info
; info
= info
->next
) {
1987 value
= info
->value
;
1990 switch (value
->type
) {
1991 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1992 di
= value
->u
.dimm
.data
;
1994 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1995 MemoryDeviceInfoKind_lookup
[value
->type
],
1996 di
->id
? di
->id
: "");
1997 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1998 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1999 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2000 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2001 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2002 monitor_printf(mon
, " hotplugged: %s\n",
2003 di
->hotplugged
? "true" : "false");
2004 monitor_printf(mon
, " hotpluggable: %s\n",
2005 di
->hotpluggable
? "true" : "false");
2013 qapi_free_MemoryDeviceInfoList(info_list
);
2016 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2018 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2019 IOThreadInfoList
*info
;
2021 for (info
= info_list
; info
; info
= info
->next
) {
2022 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2023 info
->value
->id
, info
->value
->thread_id
);
2026 qapi_free_IOThreadInfoList(info_list
);
2029 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2031 const char *path
= qdict_get_try_str(qdict
, "path");
2032 ObjectPropertyInfoList
*list
;
2036 monitor_printf(mon
, "/\n");
2040 list
= qmp_qom_list(path
, &err
);
2042 ObjectPropertyInfoList
*start
= list
;
2043 while (list
!= NULL
) {
2044 ObjectPropertyInfo
*value
= list
->value
;
2046 monitor_printf(mon
, "%s (%s)\n",
2047 value
->name
, value
->type
);
2050 qapi_free_ObjectPropertyInfoList(start
);
2052 hmp_handle_error(mon
, &err
);
2055 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2057 const char *path
= qdict_get_str(qdict
, "path");
2058 const char *property
= qdict_get_str(qdict
, "property");
2059 const char *value
= qdict_get_str(qdict
, "value");
2061 bool ambiguous
= false;
2064 obj
= object_resolve_path(path
, &ambiguous
);
2066 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2067 "Device '%s' not found", path
);
2070 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2072 object_property_parse(obj
, value
, property
, &err
);
2074 hmp_handle_error(mon
, &err
);
2077 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2079 const char *name
= qdict_get_str(qdict
, "name");
2080 RockerSwitch
*rocker
;
2083 rocker
= qmp_query_rocker(name
, &err
);
2085 hmp_handle_error(mon
, &err
);
2089 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2090 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2091 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2093 qapi_free_RockerSwitch(rocker
);
2096 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2098 RockerPortList
*list
, *port
;
2099 const char *name
= qdict_get_str(qdict
, "name");
2102 list
= qmp_query_rocker_ports(name
, &err
);
2104 hmp_handle_error(mon
, &err
);
2108 monitor_printf(mon
, " ena/ speed/ auto\n");
2109 monitor_printf(mon
, " port link duplex neg?\n");
2111 for (port
= list
; port
; port
= port
->next
) {
2112 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2114 port
->value
->enabled
? port
->value
->link_up
?
2115 "up" : "down" : "!ena",
2116 port
->value
->speed
== 10000 ? "10G" : "??",
2117 port
->value
->duplex
? "FD" : "HD",
2118 port
->value
->autoneg
? "Yes" : "No");
2121 qapi_free_RockerPortList(list
);
2124 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2126 RockerOfDpaFlowList
*list
, *info
;
2127 const char *name
= qdict_get_str(qdict
, "name");
2128 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2131 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2133 hmp_handle_error(mon
, &err
);
2137 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2139 for (info
= list
; info
; info
= info
->next
) {
2140 RockerOfDpaFlow
*flow
= info
->value
;
2141 RockerOfDpaFlowKey
*key
= flow
->key
;
2142 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2143 RockerOfDpaFlowAction
*action
= flow
->action
;
2146 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2147 key
->priority
, key
->tbl_id
, flow
->hits
);
2149 monitor_printf(mon
, "%-4d %-3d ",
2150 key
->priority
, key
->tbl_id
);
2153 if (key
->has_in_pport
) {
2154 monitor_printf(mon
, " pport %d", key
->in_pport
);
2155 if (mask
->has_in_pport
) {
2156 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2160 if (key
->has_vlan_id
) {
2161 monitor_printf(mon
, " vlan %d",
2162 key
->vlan_id
& VLAN_VID_MASK
);
2163 if (mask
->has_vlan_id
) {
2164 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2168 if (key
->has_tunnel_id
) {
2169 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2170 if (mask
->has_tunnel_id
) {
2171 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2175 if (key
->has_eth_type
) {
2176 switch (key
->eth_type
) {
2178 monitor_printf(mon
, " ARP");
2181 monitor_printf(mon
, " IP");
2184 monitor_printf(mon
, " IPv6");
2187 monitor_printf(mon
, " LACP");
2190 monitor_printf(mon
, " LLDP");
2193 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2198 if (key
->has_eth_src
) {
2199 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2200 (mask
->has_eth_src
) &&
2201 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2202 monitor_printf(mon
, " src <any mcast/bcast>");
2203 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2204 (mask
->has_eth_src
) &&
2205 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2206 monitor_printf(mon
, " src <any ucast>");
2208 monitor_printf(mon
, " src %s", key
->eth_src
);
2209 if (mask
->has_eth_src
) {
2210 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2215 if (key
->has_eth_dst
) {
2216 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2217 (mask
->has_eth_dst
) &&
2218 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2219 monitor_printf(mon
, " dst <any mcast/bcast>");
2220 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2221 (mask
->has_eth_dst
) &&
2222 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2223 monitor_printf(mon
, " dst <any ucast>");
2225 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2226 if (mask
->has_eth_dst
) {
2227 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2232 if (key
->has_ip_proto
) {
2233 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2234 if (mask
->has_ip_proto
) {
2235 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2239 if (key
->has_ip_tos
) {
2240 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2241 if (mask
->has_ip_tos
) {
2242 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2246 if (key
->has_ip_dst
) {
2247 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2250 if (action
->has_goto_tbl
|| action
->has_group_id
||
2251 action
->has_new_vlan_id
) {
2252 monitor_printf(mon
, " -->");
2255 if (action
->has_new_vlan_id
) {
2256 monitor_printf(mon
, " apply new vlan %d",
2257 ntohs(action
->new_vlan_id
));
2260 if (action
->has_group_id
) {
2261 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2264 if (action
->has_goto_tbl
) {
2265 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2268 monitor_printf(mon
, "\n");
2271 qapi_free_RockerOfDpaFlowList(list
);
2274 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2276 RockerOfDpaGroupList
*list
, *g
;
2277 const char *name
= qdict_get_str(qdict
, "name");
2278 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2282 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2284 hmp_handle_error(mon
, &err
);
2288 monitor_printf(mon
, "id (decode) --> buckets\n");
2290 for (g
= list
; g
; g
= g
->next
) {
2291 RockerOfDpaGroup
*group
= g
->value
;
2293 monitor_printf(mon
, "0x%08x", group
->id
);
2295 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2296 group
->type
== 1 ? "L2 rewrite" :
2297 group
->type
== 2 ? "L3 unicast" :
2298 group
->type
== 3 ? "L2 multicast" :
2299 group
->type
== 4 ? "L2 flood" :
2300 group
->type
== 5 ? "L3 interface" :
2301 group
->type
== 6 ? "L3 multicast" :
2302 group
->type
== 7 ? "L3 ECMP" :
2303 group
->type
== 8 ? "L2 overlay" :
2306 if (group
->has_vlan_id
) {
2307 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2310 if (group
->has_pport
) {
2311 monitor_printf(mon
, " pport %d", group
->pport
);
2314 if (group
->has_index
) {
2315 monitor_printf(mon
, " index %d", group
->index
);
2318 monitor_printf(mon
, ") -->");
2320 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2322 monitor_printf(mon
, " set vlan %d",
2323 group
->set_vlan_id
& VLAN_VID_MASK
);
2326 if (group
->has_set_eth_src
) {
2329 monitor_printf(mon
, " set");
2331 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2334 if (group
->has_set_eth_dst
) {
2337 monitor_printf(mon
, " set");
2339 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2344 if (group
->has_ttl_check
&& group
->ttl_check
) {
2345 monitor_printf(mon
, " check TTL");
2348 if (group
->has_group_id
&& group
->group_id
) {
2349 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2352 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2353 monitor_printf(mon
, " pop vlan");
2356 if (group
->has_out_pport
) {
2357 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2360 if (group
->has_group_ids
) {
2361 struct uint32List
*id
;
2363 monitor_printf(mon
, " groups [");
2364 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2365 monitor_printf(mon
, "0x%08x", id
->value
);
2367 monitor_printf(mon
, ",");
2370 monitor_printf(mon
, "]");
2373 monitor_printf(mon
, "\n");
2376 qapi_free_RockerOfDpaGroupList(list
);
2379 void hmp_info_dump(Monitor
*mon
, const QDict
*qdict
)
2381 DumpQueryResult
*result
= qmp_query_dump(NULL
);
2383 assert(result
&& result
->status
< DUMP_STATUS__MAX
);
2384 monitor_printf(mon
, "Status: %s\n", DumpStatus_lookup
[result
->status
]);
2386 if (result
->status
== DUMP_STATUS_ACTIVE
) {
2388 assert(result
->total
!= 0);
2389 percent
= 100.0 * result
->completed
/ result
->total
;
2390 monitor_printf(mon
, "Finished: %.2f %%\n", percent
);
2393 qapi_free_DumpQueryResult(result
);