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
, " %s: '%s'",
298 MigrationParameter_lookup
[MIGRATION_PARAMETER_TLS_CREDS
],
299 params
->tls_creds
? : "");
300 monitor_printf(mon
, " %s: '%s'",
301 MigrationParameter_lookup
[MIGRATION_PARAMETER_TLS_HOSTNAME
],
302 params
->tls_hostname
? : "");
303 monitor_printf(mon
, "\n");
306 qapi_free_MigrationParameters(params
);
309 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
311 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
312 qmp_query_migrate_cache_size(NULL
) >> 10);
315 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
317 CpuInfoList
*cpu_list
, *cpu
;
319 cpu_list
= qmp_query_cpus(NULL
);
321 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
324 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
328 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
, cpu
->value
->CPU
);
330 switch (cpu
->value
->arch
) {
331 case CPU_INFO_ARCH_X86
:
332 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->u
.x86
.pc
);
334 case CPU_INFO_ARCH_PPC
:
335 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->u
.ppc
.nip
);
337 case CPU_INFO_ARCH_SPARC
:
338 monitor_printf(mon
, " pc=0x%016" PRIx64
,
339 cpu
->value
->u
.q_sparc
.pc
);
340 monitor_printf(mon
, " npc=0x%016" PRIx64
,
341 cpu
->value
->u
.q_sparc
.npc
);
343 case CPU_INFO_ARCH_MIPS
:
344 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.q_mips
.PC
);
346 case CPU_INFO_ARCH_TRICORE
:
347 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.tricore
.PC
);
353 if (cpu
->value
->halted
) {
354 monitor_printf(mon
, " (halted)");
357 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
360 qapi_free_CpuInfoList(cpu_list
);
363 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
364 BlockDeviceInfo
*inserted
, bool verbose
)
366 ImageInfo
*image_info
;
368 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
371 monitor_printf(mon
, "%s", info
->device
);
372 if (inserted
&& inserted
->has_node_name
) {
373 monitor_printf(mon
, " (%s)", inserted
->node_name
);
377 monitor_printf(mon
, "%s",
378 inserted
->has_node_name
379 ? inserted
->node_name
384 monitor_printf(mon
, ": %s (%s%s%s)\n",
387 inserted
->ro
? ", read-only" : "",
388 inserted
->encrypted
? ", encrypted" : "");
390 monitor_printf(mon
, ": [not inserted]\n");
394 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
395 monitor_printf(mon
, " I/O status: %s\n",
396 BlockDeviceIoStatus_lookup
[info
->io_status
]);
399 if (info
->removable
) {
400 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
401 info
->locked
? "" : "not ",
402 info
->tray_open
? "open" : "closed");
411 monitor_printf(mon
, " Cache mode: %s%s%s\n",
412 inserted
->cache
->writeback
? "writeback" : "writethrough",
413 inserted
->cache
->direct
? ", direct" : "",
414 inserted
->cache
->no_flush
? ", ignore flushes" : "");
416 if (inserted
->has_backing_file
) {
419 "(chain depth: %" PRId64
")\n",
420 inserted
->backing_file
,
421 inserted
->backing_file_depth
);
424 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
425 monitor_printf(mon
, " Detect zeroes: %s\n",
426 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
429 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
430 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
432 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
433 " bps_rd=%" PRId64
" bps_wr=%" PRId64
435 " bps_rd_max=%" PRId64
436 " bps_wr_max=%" PRId64
437 " iops=%" PRId64
" iops_rd=%" PRId64
440 " iops_rd_max=%" PRId64
441 " iops_wr_max=%" PRId64
442 " iops_size=%" PRId64
448 inserted
->bps_rd_max
,
449 inserted
->bps_wr_max
,
454 inserted
->iops_rd_max
,
455 inserted
->iops_wr_max
,
461 monitor_printf(mon
, "\nImages:\n");
462 image_info
= inserted
->image
;
464 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
466 if (image_info
->has_backing_image
) {
467 image_info
= image_info
->backing_image
;
475 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
477 BlockInfoList
*block_list
, *info
;
478 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
479 const char *device
= qdict_get_try_str(qdict
, "device");
480 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
481 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
482 bool printed
= false;
484 /* Print BlockBackend information */
486 block_list
= qmp_query_block(NULL
);
491 for (info
= block_list
; info
; info
= info
->next
) {
492 if (device
&& strcmp(device
, info
->value
->device
)) {
496 if (info
!= block_list
) {
497 monitor_printf(mon
, "\n");
500 print_block_info(mon
, info
->value
, info
->value
->has_inserted
501 ? info
->value
->inserted
: NULL
,
506 qapi_free_BlockInfoList(block_list
);
508 if ((!device
&& !nodes
) || printed
) {
512 /* Print node information */
513 blockdev_list
= qmp_query_named_block_nodes(NULL
);
514 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
515 assert(blockdev
->value
->has_node_name
);
516 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
520 if (blockdev
!= blockdev_list
) {
521 monitor_printf(mon
, "\n");
524 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
526 qapi_free_BlockDeviceInfoList(blockdev_list
);
529 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
531 BlockStatsList
*stats_list
, *stats
;
533 stats_list
= qmp_query_blockstats(false, false, NULL
);
535 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
536 if (!stats
->value
->has_device
) {
540 monitor_printf(mon
, "%s:", stats
->value
->device
);
541 monitor_printf(mon
, " rd_bytes=%" PRId64
543 " rd_operations=%" PRId64
544 " wr_operations=%" PRId64
545 " flush_operations=%" PRId64
546 " wr_total_time_ns=%" PRId64
547 " rd_total_time_ns=%" PRId64
548 " flush_total_time_ns=%" PRId64
549 " rd_merged=%" PRId64
550 " wr_merged=%" PRId64
551 " idle_time_ns=%" PRId64
553 stats
->value
->stats
->rd_bytes
,
554 stats
->value
->stats
->wr_bytes
,
555 stats
->value
->stats
->rd_operations
,
556 stats
->value
->stats
->wr_operations
,
557 stats
->value
->stats
->flush_operations
,
558 stats
->value
->stats
->wr_total_time_ns
,
559 stats
->value
->stats
->rd_total_time_ns
,
560 stats
->value
->stats
->flush_total_time_ns
,
561 stats
->value
->stats
->rd_merged
,
562 stats
->value
->stats
->wr_merged
,
563 stats
->value
->stats
->idle_time_ns
);
566 qapi_free_BlockStatsList(stats_list
);
569 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
573 VncClientInfoList
*client
;
575 info
= qmp_query_vnc(&err
);
577 error_report_err(err
);
581 if (!info
->enabled
) {
582 monitor_printf(mon
, "Server: disabled\n");
586 monitor_printf(mon
, "Server:\n");
587 if (info
->has_host
&& info
->has_service
) {
588 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
590 if (info
->has_auth
) {
591 monitor_printf(mon
, " auth: %s\n", info
->auth
);
594 if (!info
->has_clients
|| info
->clients
== NULL
) {
595 monitor_printf(mon
, "Client: none\n");
597 for (client
= info
->clients
; client
; client
= client
->next
) {
598 monitor_printf(mon
, "Client:\n");
599 monitor_printf(mon
, " address: %s:%s\n",
601 client
->value
->service
);
602 monitor_printf(mon
, " x509_dname: %s\n",
603 client
->value
->x509_dname
?
604 client
->value
->x509_dname
: "none");
605 monitor_printf(mon
, " username: %s\n",
606 client
->value
->has_sasl_username
?
607 client
->value
->sasl_username
: "none");
612 qapi_free_VncInfo(info
);
616 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
618 SpiceChannelList
*chan
;
620 const char *channel_name
;
621 const char * const channel_names
[] = {
622 [SPICE_CHANNEL_MAIN
] = "main",
623 [SPICE_CHANNEL_DISPLAY
] = "display",
624 [SPICE_CHANNEL_INPUTS
] = "inputs",
625 [SPICE_CHANNEL_CURSOR
] = "cursor",
626 [SPICE_CHANNEL_PLAYBACK
] = "playback",
627 [SPICE_CHANNEL_RECORD
] = "record",
628 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
629 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
630 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
631 [SPICE_CHANNEL_PORT
] = "port",
633 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
634 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
635 * as quick fix for build failures with older versions. */
636 [SPICE_CHANNEL_WEBDAV
] = "webdav",
640 info
= qmp_query_spice(NULL
);
642 if (!info
->enabled
) {
643 monitor_printf(mon
, "Server: disabled\n");
647 monitor_printf(mon
, "Server:\n");
648 if (info
->has_port
) {
649 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
650 info
->host
, info
->port
);
652 if (info
->has_tls_port
) {
653 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
654 info
->host
, info
->tls_port
);
656 monitor_printf(mon
, " migrated: %s\n",
657 info
->migrated
? "true" : "false");
658 monitor_printf(mon
, " auth: %s\n", info
->auth
);
659 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
660 monitor_printf(mon
, " mouse-mode: %s\n",
661 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
663 if (!info
->has_channels
|| info
->channels
== NULL
) {
664 monitor_printf(mon
, "Channels: none\n");
666 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
667 monitor_printf(mon
, "Channel:\n");
668 monitor_printf(mon
, " address: %s:%s%s\n",
669 chan
->value
->host
, chan
->value
->port
,
670 chan
->value
->tls
? " [tls]" : "");
671 monitor_printf(mon
, " session: %" PRId64
"\n",
672 chan
->value
->connection_id
);
673 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
674 chan
->value
->channel_type
, chan
->value
->channel_id
);
676 channel_name
= "unknown";
677 if (chan
->value
->channel_type
> 0 &&
678 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
679 channel_names
[chan
->value
->channel_type
]) {
680 channel_name
= channel_names
[chan
->value
->channel_type
];
683 monitor_printf(mon
, " channel name: %s\n", channel_name
);
688 qapi_free_SpiceInfo(info
);
692 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
697 info
= qmp_query_balloon(&err
);
699 error_report_err(err
);
703 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
705 qapi_free_BalloonInfo(info
);
708 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
710 PciMemoryRegionList
*region
;
712 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
713 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
714 dev
->slot
, dev
->function
);
715 monitor_printf(mon
, " ");
717 if (dev
->class_info
->has_desc
) {
718 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
720 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
723 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
724 dev
->id
->vendor
, dev
->id
->device
);
727 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
730 if (dev
->has_pci_bridge
) {
731 monitor_printf(mon
, " BUS %" PRId64
".\n",
732 dev
->pci_bridge
->bus
->number
);
733 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
734 dev
->pci_bridge
->bus
->secondary
);
735 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
736 dev
->pci_bridge
->bus
->subordinate
);
738 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
739 dev
->pci_bridge
->bus
->io_range
->base
,
740 dev
->pci_bridge
->bus
->io_range
->limit
);
743 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
744 dev
->pci_bridge
->bus
->memory_range
->base
,
745 dev
->pci_bridge
->bus
->memory_range
->limit
);
747 monitor_printf(mon
, " prefetchable memory range "
748 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
749 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
750 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
753 for (region
= dev
->regions
; region
; region
= region
->next
) {
756 addr
= region
->value
->address
;
757 size
= region
->value
->size
;
759 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
761 if (!strcmp(region
->value
->type
, "io")) {
762 monitor_printf(mon
, "I/O at 0x%04" PRIx64
763 " [0x%04" PRIx64
"].\n",
764 addr
, addr
+ size
- 1);
766 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
767 " [0x%08" PRIx64
"].\n",
768 region
->value
->mem_type_64
? 64 : 32,
769 region
->value
->prefetch
? " prefetchable" : "",
770 addr
, addr
+ size
- 1);
774 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
776 if (dev
->has_pci_bridge
) {
777 if (dev
->pci_bridge
->has_devices
) {
778 PciDeviceInfoList
*cdev
;
779 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
780 hmp_info_pci_device(mon
, cdev
->value
);
786 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
788 PciInfoList
*info_list
, *info
;
791 info_list
= qmp_query_pci(&err
);
793 monitor_printf(mon
, "PCI devices not supported\n");
798 for (info
= info_list
; info
; info
= info
->next
) {
799 PciDeviceInfoList
*dev
;
801 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
802 hmp_info_pci_device(mon
, dev
->value
);
806 qapi_free_PciInfoList(info_list
);
809 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
811 BlockJobInfoList
*list
;
814 list
= qmp_query_block_jobs(&err
);
818 monitor_printf(mon
, "No active jobs\n");
823 if (strcmp(list
->value
->type
, "stream") == 0) {
824 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
825 " of %" PRId64
" bytes, speed limit %" PRId64
832 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
833 " of %" PRId64
" bytes, speed limit %" PRId64
844 qapi_free_BlockJobInfoList(list
);
847 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
849 TPMInfoList
*info_list
, *info
;
852 TPMPassthroughOptions
*tpo
;
854 info_list
= qmp_query_tpm(&err
);
856 monitor_printf(mon
, "TPM device not supported\n");
862 monitor_printf(mon
, "TPM device:\n");
865 for (info
= info_list
; info
; info
= info
->next
) {
866 TPMInfo
*ti
= info
->value
;
867 monitor_printf(mon
, " tpm%d: model=%s\n",
868 c
, TpmModel_lookup
[ti
->model
]);
870 monitor_printf(mon
, " \\ %s: type=%s",
871 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
873 switch (ti
->options
->type
) {
874 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
875 tpo
= ti
->options
->u
.passthrough
.data
;
876 monitor_printf(mon
, "%s%s%s%s",
877 tpo
->has_path
? ",path=" : "",
878 tpo
->has_path
? tpo
->path
: "",
879 tpo
->has_cancel_path
? ",cancel-path=" : "",
880 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
882 case TPM_TYPE_OPTIONS_KIND__MAX
:
885 monitor_printf(mon
, "\n");
888 qapi_free_TPMInfoList(info_list
);
891 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
893 monitor_suspend(mon
);
897 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
902 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
904 qmp_system_reset(NULL
);
907 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
909 qmp_system_powerdown(NULL
);
912 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
916 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
917 use it are converted to the QAPI */
918 cpu_index
= qdict_get_int(qdict
, "index");
919 if (monitor_set_cpu(cpu_index
) < 0) {
920 monitor_printf(mon
, "invalid CPU index\n");
924 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
926 uint32_t size
= qdict_get_int(qdict
, "size");
927 const char *filename
= qdict_get_str(qdict
, "filename");
928 uint64_t addr
= qdict_get_int(qdict
, "val");
931 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
932 hmp_handle_error(mon
, &err
);
935 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
937 uint32_t size
= qdict_get_int(qdict
, "size");
938 const char *filename
= qdict_get_str(qdict
, "filename");
939 uint64_t addr
= qdict_get_int(qdict
, "val");
942 qmp_pmemsave(addr
, size
, filename
, &err
);
943 hmp_handle_error(mon
, &err
);
946 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
948 const char *chardev
= qdict_get_str(qdict
, "device");
949 const char *data
= qdict_get_str(qdict
, "data");
952 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
954 hmp_handle_error(mon
, &err
);
957 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
959 uint32_t size
= qdict_get_int(qdict
, "size");
960 const char *chardev
= qdict_get_str(qdict
, "device");
965 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
967 error_report_err(err
);
971 for (i
= 0; data
[i
]; i
++) {
972 unsigned char ch
= data
[i
];
975 monitor_printf(mon
, "\\\\");
976 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
977 monitor_printf(mon
, "\\u%04X", ch
);
979 monitor_printf(mon
, "%c", ch
);
983 monitor_printf(mon
, "\n");
987 static void hmp_cont_cb(void *opaque
, int err
)
994 static bool key_is_missing(const BlockInfo
*bdev
)
996 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
999 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
1001 BlockInfoList
*bdev_list
, *bdev
;
1004 bdev_list
= qmp_query_block(NULL
);
1005 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
1006 if (key_is_missing(bdev
->value
)) {
1007 monitor_read_block_device_key(mon
, bdev
->value
->device
,
1014 hmp_handle_error(mon
, &err
);
1017 qapi_free_BlockInfoList(bdev_list
);
1020 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1022 qmp_system_wakeup(NULL
);
1025 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1029 qmp_inject_nmi(&err
);
1030 hmp_handle_error(mon
, &err
);
1033 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1035 const char *name
= qdict_get_str(qdict
, "name");
1036 bool up
= qdict_get_bool(qdict
, "up");
1039 qmp_set_link(name
, up
, &err
);
1040 hmp_handle_error(mon
, &err
);
1043 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1045 const char *device
= qdict_get_str(qdict
, "device");
1046 const char *password
= qdict_get_str(qdict
, "password");
1049 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1050 hmp_handle_error(mon
, &err
);
1053 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1055 int64_t value
= qdict_get_int(qdict
, "value");
1058 qmp_balloon(value
, &err
);
1060 error_report_err(err
);
1064 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1066 const char *device
= qdict_get_str(qdict
, "device");
1067 int64_t size
= qdict_get_int(qdict
, "size");
1070 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1071 hmp_handle_error(mon
, &err
);
1074 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1076 const char *device
= qdict_get_str(qdict
, "device");
1077 const char *filename
= qdict_get_str(qdict
, "target");
1078 const char *format
= qdict_get_try_str(qdict
, "format");
1079 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1080 bool full
= qdict_get_try_bool(qdict
, "full", false);
1081 enum NewImageMode mode
;
1085 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1086 hmp_handle_error(mon
, &err
);
1091 mode
= NEW_IMAGE_MODE_EXISTING
;
1093 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1096 qmp_drive_mirror(device
, filename
, !!format
, format
,
1097 false, NULL
, false, NULL
,
1098 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1099 true, mode
, false, 0, false, 0, false, 0,
1100 false, 0, false, 0, false, true, &err
);
1101 hmp_handle_error(mon
, &err
);
1104 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1106 const char *device
= qdict_get_str(qdict
, "device");
1107 const char *filename
= qdict_get_str(qdict
, "target");
1108 const char *format
= qdict_get_try_str(qdict
, "format");
1109 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1110 bool full
= qdict_get_try_bool(qdict
, "full", false);
1111 enum NewImageMode mode
;
1115 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1116 hmp_handle_error(mon
, &err
);
1121 mode
= NEW_IMAGE_MODE_EXISTING
;
1123 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1126 qmp_drive_backup(device
, filename
, !!format
, format
,
1127 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1128 true, mode
, false, 0, false, NULL
,
1129 false, 0, false, 0, &err
);
1130 hmp_handle_error(mon
, &err
);
1133 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1135 const char *device
= qdict_get_str(qdict
, "device");
1136 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1137 const char *format
= qdict_get_try_str(qdict
, "format");
1138 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1139 enum NewImageMode mode
;
1143 /* In the future, if 'snapshot-file' is not specified, the snapshot
1144 will be taken internally. Today it's actually required. */
1145 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1146 hmp_handle_error(mon
, &err
);
1150 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1151 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1152 filename
, false, NULL
,
1155 hmp_handle_error(mon
, &err
);
1158 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1160 const char *device
= qdict_get_str(qdict
, "device");
1161 const char *name
= qdict_get_str(qdict
, "name");
1164 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1165 hmp_handle_error(mon
, &err
);
1168 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1170 const char *device
= qdict_get_str(qdict
, "device");
1171 const char *name
= qdict_get_str(qdict
, "name");
1172 const char *id
= qdict_get_try_str(qdict
, "id");
1175 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1177 hmp_handle_error(mon
, &err
);
1180 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1182 qmp_migrate_cancel(NULL
);
1185 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1188 const char *uri
= qdict_get_str(qdict
, "uri");
1190 qmp_migrate_incoming(uri
, &err
);
1192 hmp_handle_error(mon
, &err
);
1195 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1197 double value
= qdict_get_double(qdict
, "value");
1198 qmp_migrate_set_downtime(value
, NULL
);
1201 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1203 int64_t value
= qdict_get_int(qdict
, "value");
1206 qmp_migrate_set_cache_size(value
, &err
);
1208 error_report_err(err
);
1213 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1215 int64_t value
= qdict_get_int(qdict
, "value");
1216 qmp_migrate_set_speed(value
, NULL
);
1219 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1221 const char *cap
= qdict_get_str(qdict
, "capability");
1222 bool state
= qdict_get_bool(qdict
, "state");
1224 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1227 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1228 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1229 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1230 caps
->value
->capability
= i
;
1231 caps
->value
->state
= state
;
1233 qmp_migrate_set_capabilities(caps
, &err
);
1238 if (i
== MIGRATION_CAPABILITY__MAX
) {
1239 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1242 qapi_free_MigrationCapabilityStatusList(caps
);
1245 error_report_err(err
);
1249 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1251 const char *param
= qdict_get_str(qdict
, "parameter");
1252 const char *valuestr
= qdict_get_str(qdict
, "value");
1255 bool has_compress_level
= false;
1256 bool has_compress_threads
= false;
1257 bool has_decompress_threads
= false;
1258 bool has_cpu_throttle_initial
= false;
1259 bool has_cpu_throttle_increment
= false;
1260 bool has_tls_creds
= false;
1261 bool has_tls_hostname
= false;
1262 bool use_int_value
= false;
1265 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1266 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1268 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1269 has_compress_level
= true;
1270 use_int_value
= true;
1272 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1273 has_compress_threads
= true;
1274 use_int_value
= true;
1276 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1277 has_decompress_threads
= true;
1278 use_int_value
= true;
1280 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL
:
1281 has_cpu_throttle_initial
= true;
1282 use_int_value
= true;
1284 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT
:
1285 has_cpu_throttle_increment
= true;
1287 case MIGRATION_PARAMETER_TLS_CREDS
:
1288 has_tls_creds
= true;
1290 case MIGRATION_PARAMETER_TLS_HOSTNAME
:
1291 has_tls_hostname
= true;
1295 if (use_int_value
) {
1296 if (qemu_strtol(valuestr
, NULL
, 10, &valueint
) < 0) {
1297 error_setg(&err
, "Unable to parse '%s' as an int",
1303 qmp_migrate_set_parameters(has_compress_level
, valueint
,
1304 has_compress_threads
, valueint
,
1305 has_decompress_threads
, valueint
,
1306 has_cpu_throttle_initial
, valueint
,
1307 has_cpu_throttle_increment
, valueint
,
1308 has_tls_creds
, valuestr
,
1309 has_tls_hostname
, valuestr
,
1315 if (i
== MIGRATION_PARAMETER__MAX
) {
1316 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1321 error_report_err(err
);
1325 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1328 const char *protocol
= qdict_get_str(qdict
, "protocol");
1329 const char *hostname
= qdict_get_str(qdict
, "hostname");
1330 bool has_port
= qdict_haskey(qdict
, "port");
1331 int port
= qdict_get_try_int(qdict
, "port", -1);
1332 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1333 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1334 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1336 qmp_client_migrate_info(protocol
, hostname
,
1337 has_port
, port
, has_tls_port
, tls_port
,
1338 !!cert_subject
, cert_subject
, &err
);
1339 hmp_handle_error(mon
, &err
);
1342 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1345 qmp_migrate_start_postcopy(&err
);
1346 hmp_handle_error(mon
, &err
);
1349 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1351 const char *protocol
= qdict_get_str(qdict
, "protocol");
1352 const char *password
= qdict_get_str(qdict
, "password");
1353 const char *connected
= qdict_get_try_str(qdict
, "connected");
1356 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1357 hmp_handle_error(mon
, &err
);
1360 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1362 const char *protocol
= qdict_get_str(qdict
, "protocol");
1363 const char *whenstr
= qdict_get_str(qdict
, "time");
1366 qmp_expire_password(protocol
, whenstr
, &err
);
1367 hmp_handle_error(mon
, &err
);
1370 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1372 bool force
= qdict_get_try_bool(qdict
, "force", false);
1373 const char *device
= qdict_get_str(qdict
, "device");
1376 qmp_eject(device
, true, force
, &err
);
1377 hmp_handle_error(mon
, &err
);
1380 static void hmp_change_read_arg(void *opaque
, const char *password
,
1381 void *readline_opaque
)
1383 qmp_change_vnc_password(password
, NULL
);
1384 monitor_read_command(opaque
, 1);
1387 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1389 const char *device
= qdict_get_str(qdict
, "device");
1390 const char *target
= qdict_get_str(qdict
, "target");
1391 const char *arg
= qdict_get_try_str(qdict
, "arg");
1392 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1393 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1396 if (strcmp(device
, "vnc") == 0) {
1399 "Parameter 'read-only-mode' is invalid for VNC\n");
1402 if (strcmp(target
, "passwd") == 0 ||
1403 strcmp(target
, "password") == 0) {
1405 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1409 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1413 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1414 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1415 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1417 hmp_handle_error(mon
, &err
);
1422 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1423 !!read_only
, read_only_mode
, &err
);
1425 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1427 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1432 hmp_handle_error(mon
, &err
);
1435 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1439 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1440 qdict_get_int(qdict
, "bps"),
1441 qdict_get_int(qdict
, "bps_rd"),
1442 qdict_get_int(qdict
, "bps_wr"),
1443 qdict_get_int(qdict
, "iops"),
1444 qdict_get_int(qdict
, "iops_rd"),
1445 qdict_get_int(qdict
, "iops_wr"),
1446 false, /* no burst max via HMP */
1458 false, /* no burst length via HMP */
1470 false, /* No default I/O size */
1474 hmp_handle_error(mon
, &err
);
1477 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1479 Error
*error
= NULL
;
1480 const char *device
= qdict_get_str(qdict
, "device");
1481 const char *base
= qdict_get_try_str(qdict
, "base");
1482 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1484 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1485 qdict_haskey(qdict
, "speed"), speed
,
1486 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1488 hmp_handle_error(mon
, &error
);
1491 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1493 Error
*error
= NULL
;
1494 const char *device
= qdict_get_str(qdict
, "device");
1495 int64_t value
= qdict_get_int(qdict
, "speed");
1497 qmp_block_job_set_speed(device
, value
, &error
);
1499 hmp_handle_error(mon
, &error
);
1502 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1504 Error
*error
= NULL
;
1505 const char *device
= qdict_get_str(qdict
, "device");
1506 bool force
= qdict_get_try_bool(qdict
, "force", false);
1508 qmp_block_job_cancel(device
, true, force
, &error
);
1510 hmp_handle_error(mon
, &error
);
1513 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1515 Error
*error
= NULL
;
1516 const char *device
= qdict_get_str(qdict
, "device");
1518 qmp_block_job_pause(device
, &error
);
1520 hmp_handle_error(mon
, &error
);
1523 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1525 Error
*error
= NULL
;
1526 const char *device
= qdict_get_str(qdict
, "device");
1528 qmp_block_job_resume(device
, &error
);
1530 hmp_handle_error(mon
, &error
);
1533 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1535 Error
*error
= NULL
;
1536 const char *device
= qdict_get_str(qdict
, "device");
1538 qmp_block_job_complete(device
, &error
);
1540 hmp_handle_error(mon
, &error
);
1543 typedef struct HMPMigrationStatus
1547 bool is_block_migration
;
1548 } HMPMigrationStatus
;
1550 static void hmp_migrate_status_cb(void *opaque
)
1552 HMPMigrationStatus
*status
= opaque
;
1553 MigrationInfo
*info
;
1555 info
= qmp_query_migrate(NULL
);
1556 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1557 info
->status
== MIGRATION_STATUS_SETUP
) {
1558 if (info
->has_disk
) {
1561 if (info
->disk
->remaining
) {
1562 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1567 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1568 monitor_flush(status
->mon
);
1571 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1573 if (status
->is_block_migration
) {
1574 monitor_printf(status
->mon
, "\n");
1576 if (info
->has_error_desc
) {
1577 error_report("%s", info
->error_desc
);
1579 monitor_resume(status
->mon
);
1580 timer_del(status
->timer
);
1584 qapi_free_MigrationInfo(info
);
1587 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1589 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1590 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1591 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1592 const char *uri
= qdict_get_str(qdict
, "uri");
1595 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1597 error_report_err(err
);
1602 HMPMigrationStatus
*status
;
1604 if (monitor_suspend(mon
) < 0) {
1605 monitor_printf(mon
, "terminal does not allow synchronous "
1606 "migration, continuing detached\n");
1610 status
= g_malloc0(sizeof(*status
));
1612 status
->is_block_migration
= blk
|| inc
;
1613 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1615 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1619 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1623 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1624 hmp_handle_error(mon
, &err
);
1627 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1629 const char *id
= qdict_get_str(qdict
, "id");
1632 qmp_device_del(id
, &err
);
1633 hmp_handle_error(mon
, &err
);
1636 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1639 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1640 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1641 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1642 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1643 const char *file
= qdict_get_str(qdict
, "filename");
1644 bool has_begin
= qdict_haskey(qdict
, "begin");
1645 bool has_length
= qdict_haskey(qdict
, "length");
1646 bool has_detach
= qdict_haskey(qdict
, "detach");
1649 bool detach
= false;
1650 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1653 if (zlib
+ lzo
+ snappy
> 1) {
1654 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1655 hmp_handle_error(mon
, &err
);
1660 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1664 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1668 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1672 begin
= qdict_get_int(qdict
, "begin");
1675 length
= qdict_get_int(qdict
, "length");
1678 detach
= qdict_get_bool(qdict
, "detach");
1681 prot
= g_strconcat("file:", file
, NULL
);
1683 qmp_dump_guest_memory(paging
, prot
, true, detach
, has_begin
, begin
,
1684 has_length
, length
, true, dump_format
, &err
);
1685 hmp_handle_error(mon
, &err
);
1689 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1694 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1699 netdev_add(opts
, &err
);
1701 qemu_opts_del(opts
);
1705 hmp_handle_error(mon
, &err
);
1708 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1710 const char *id
= qdict_get_str(qdict
, "id");
1713 qmp_netdev_del(id
, &err
);
1714 hmp_handle_error(mon
, &err
);
1717 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1724 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1726 hmp_handle_error(mon
, &err
);
1730 ov
= opts_visitor_new(opts
);
1731 obj
= user_creatable_add(qdict
, opts_get_visitor(ov
), &err
);
1732 opts_visitor_cleanup(ov
);
1733 qemu_opts_del(opts
);
1736 hmp_handle_error(mon
, &err
);
1743 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1745 const char *fdname
= qdict_get_str(qdict
, "fdname");
1748 qmp_getfd(fdname
, &err
);
1749 hmp_handle_error(mon
, &err
);
1752 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1754 const char *fdname
= qdict_get_str(qdict
, "fdname");
1757 qmp_closefd(fdname
, &err
);
1758 hmp_handle_error(mon
, &err
);
1761 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1763 const char *keys
= qdict_get_str(qdict
, "keys");
1764 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1765 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1766 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1772 separator
= strchr(keys
, '-');
1773 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1775 /* Be compatible with old interface, convert user inputted "<" */
1776 if (keys
[0] == '<' && keyname_len
== 1) {
1781 keylist
= g_malloc0(sizeof(*keylist
));
1782 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1788 tmp
->next
= keylist
;
1792 if (strstart(keys
, "0x", NULL
)) {
1794 int value
= strtoul(keys
, &endp
, 0);
1795 assert(endp
<= keys
+ keyname_len
);
1796 if (endp
!= keys
+ keyname_len
) {
1799 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1800 keylist
->value
->u
.number
.data
= value
;
1802 int idx
= index_from_key(keys
, keyname_len
);
1803 if (idx
== Q_KEY_CODE__MAX
) {
1806 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1807 keylist
->value
->u
.qcode
.data
= idx
;
1813 keys
= separator
+ 1;
1816 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1817 hmp_handle_error(mon
, &err
);
1820 qapi_free_KeyValueList(head
);
1824 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1828 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1830 const char *filename
= qdict_get_str(qdict
, "filename");
1833 qmp_screendump(filename
, &err
);
1834 hmp_handle_error(mon
, &err
);
1837 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1839 const char *uri
= qdict_get_str(qdict
, "uri");
1840 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1841 bool all
= qdict_get_try_bool(qdict
, "all", false);
1842 Error
*local_err
= NULL
;
1843 BlockInfoList
*block_list
, *info
;
1844 SocketAddress
*addr
;
1846 if (writable
&& !all
) {
1847 error_setg(&local_err
, "-w only valid together with -a");
1851 /* First check if the address is valid and start the server. */
1852 addr
= socket_parse(uri
, &local_err
);
1853 if (local_err
!= NULL
) {
1857 qmp_nbd_server_start(addr
, false, NULL
, &local_err
);
1858 qapi_free_SocketAddress(addr
);
1859 if (local_err
!= NULL
) {
1867 /* Then try adding all block devices. If one fails, close all and
1870 block_list
= qmp_query_block(NULL
);
1872 for (info
= block_list
; info
; info
= info
->next
) {
1873 if (!info
->value
->has_inserted
) {
1877 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1879 if (local_err
!= NULL
) {
1880 qmp_nbd_server_stop(NULL
);
1885 qapi_free_BlockInfoList(block_list
);
1888 hmp_handle_error(mon
, &local_err
);
1891 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1893 const char *device
= qdict_get_str(qdict
, "device");
1894 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1895 Error
*local_err
= NULL
;
1897 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1899 if (local_err
!= NULL
) {
1900 hmp_handle_error(mon
, &local_err
);
1904 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1908 qmp_nbd_server_stop(&err
);
1909 hmp_handle_error(mon
, &err
);
1912 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1917 cpuid
= qdict_get_int(qdict
, "id");
1918 qmp_cpu_add(cpuid
, &err
);
1919 hmp_handle_error(mon
, &err
);
1922 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1924 const char *args
= qdict_get_str(qdict
, "args");
1928 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1930 error_setg(&err
, "Parsing chardev args failed");
1932 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1934 hmp_handle_error(mon
, &err
);
1937 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1939 Error
*local_err
= NULL
;
1941 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1942 hmp_handle_error(mon
, &local_err
);
1945 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1948 const char* device
= qdict_get_str(qdict
, "device");
1949 const char* command
= qdict_get_str(qdict
, "command");
1952 blk
= blk_by_name(device
);
1954 qemuio_command(blk
, command
);
1956 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1957 "Device '%s' not found", device
);
1960 hmp_handle_error(mon
, &err
);
1963 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1965 const char *id
= qdict_get_str(qdict
, "id");
1968 user_creatable_del(id
, &err
);
1969 hmp_handle_error(mon
, &err
);
1972 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1975 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1976 MemdevList
*m
= memdev_list
;
1977 StringOutputVisitor
*ov
;
1983 ov
= string_output_visitor_new(false);
1984 visit_type_uint16List(string_output_get_visitor(ov
), NULL
,
1985 &m
->value
->host_nodes
, NULL
);
1986 monitor_printf(mon
, "memory backend: %d\n", i
);
1987 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1988 monitor_printf(mon
, " merge: %s\n",
1989 m
->value
->merge
? "true" : "false");
1990 monitor_printf(mon
, " dump: %s\n",
1991 m
->value
->dump
? "true" : "false");
1992 monitor_printf(mon
, " prealloc: %s\n",
1993 m
->value
->prealloc
? "true" : "false");
1994 monitor_printf(mon
, " policy: %s\n",
1995 HostMemPolicy_lookup
[m
->value
->policy
]);
1996 str
= string_output_get_string(ov
);
1997 monitor_printf(mon
, " host nodes: %s\n", str
);
2000 string_output_visitor_cleanup(ov
);
2005 monitor_printf(mon
, "\n");
2007 qapi_free_MemdevList(memdev_list
);
2010 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
2013 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
2014 MemoryDeviceInfoList
*info
;
2015 MemoryDeviceInfo
*value
;
2016 PCDIMMDeviceInfo
*di
;
2018 for (info
= info_list
; info
; info
= info
->next
) {
2019 value
= info
->value
;
2022 switch (value
->type
) {
2023 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2024 di
= value
->u
.dimm
.data
;
2026 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2027 MemoryDeviceInfoKind_lookup
[value
->type
],
2028 di
->id
? di
->id
: "");
2029 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2030 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2031 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2032 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2033 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2034 monitor_printf(mon
, " hotplugged: %s\n",
2035 di
->hotplugged
? "true" : "false");
2036 monitor_printf(mon
, " hotpluggable: %s\n",
2037 di
->hotpluggable
? "true" : "false");
2045 qapi_free_MemoryDeviceInfoList(info_list
);
2048 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2050 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2051 IOThreadInfoList
*info
;
2053 for (info
= info_list
; info
; info
= info
->next
) {
2054 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2055 info
->value
->id
, info
->value
->thread_id
);
2058 qapi_free_IOThreadInfoList(info_list
);
2061 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2063 const char *path
= qdict_get_try_str(qdict
, "path");
2064 ObjectPropertyInfoList
*list
;
2068 monitor_printf(mon
, "/\n");
2072 list
= qmp_qom_list(path
, &err
);
2074 ObjectPropertyInfoList
*start
= list
;
2075 while (list
!= NULL
) {
2076 ObjectPropertyInfo
*value
= list
->value
;
2078 monitor_printf(mon
, "%s (%s)\n",
2079 value
->name
, value
->type
);
2082 qapi_free_ObjectPropertyInfoList(start
);
2084 hmp_handle_error(mon
, &err
);
2087 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2089 const char *path
= qdict_get_str(qdict
, "path");
2090 const char *property
= qdict_get_str(qdict
, "property");
2091 const char *value
= qdict_get_str(qdict
, "value");
2093 bool ambiguous
= false;
2096 obj
= object_resolve_path(path
, &ambiguous
);
2098 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2099 "Device '%s' not found", path
);
2102 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2104 object_property_parse(obj
, value
, property
, &err
);
2106 hmp_handle_error(mon
, &err
);
2109 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2111 const char *name
= qdict_get_str(qdict
, "name");
2112 RockerSwitch
*rocker
;
2115 rocker
= qmp_query_rocker(name
, &err
);
2117 hmp_handle_error(mon
, &err
);
2121 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2122 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2123 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2125 qapi_free_RockerSwitch(rocker
);
2128 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2130 RockerPortList
*list
, *port
;
2131 const char *name
= qdict_get_str(qdict
, "name");
2134 list
= qmp_query_rocker_ports(name
, &err
);
2136 hmp_handle_error(mon
, &err
);
2140 monitor_printf(mon
, " ena/ speed/ auto\n");
2141 monitor_printf(mon
, " port link duplex neg?\n");
2143 for (port
= list
; port
; port
= port
->next
) {
2144 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2146 port
->value
->enabled
? port
->value
->link_up
?
2147 "up" : "down" : "!ena",
2148 port
->value
->speed
== 10000 ? "10G" : "??",
2149 port
->value
->duplex
? "FD" : "HD",
2150 port
->value
->autoneg
? "Yes" : "No");
2153 qapi_free_RockerPortList(list
);
2156 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2158 RockerOfDpaFlowList
*list
, *info
;
2159 const char *name
= qdict_get_str(qdict
, "name");
2160 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2163 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2165 hmp_handle_error(mon
, &err
);
2169 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2171 for (info
= list
; info
; info
= info
->next
) {
2172 RockerOfDpaFlow
*flow
= info
->value
;
2173 RockerOfDpaFlowKey
*key
= flow
->key
;
2174 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2175 RockerOfDpaFlowAction
*action
= flow
->action
;
2178 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2179 key
->priority
, key
->tbl_id
, flow
->hits
);
2181 monitor_printf(mon
, "%-4d %-3d ",
2182 key
->priority
, key
->tbl_id
);
2185 if (key
->has_in_pport
) {
2186 monitor_printf(mon
, " pport %d", key
->in_pport
);
2187 if (mask
->has_in_pport
) {
2188 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2192 if (key
->has_vlan_id
) {
2193 monitor_printf(mon
, " vlan %d",
2194 key
->vlan_id
& VLAN_VID_MASK
);
2195 if (mask
->has_vlan_id
) {
2196 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2200 if (key
->has_tunnel_id
) {
2201 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2202 if (mask
->has_tunnel_id
) {
2203 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2207 if (key
->has_eth_type
) {
2208 switch (key
->eth_type
) {
2210 monitor_printf(mon
, " ARP");
2213 monitor_printf(mon
, " IP");
2216 monitor_printf(mon
, " IPv6");
2219 monitor_printf(mon
, " LACP");
2222 monitor_printf(mon
, " LLDP");
2225 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2230 if (key
->has_eth_src
) {
2231 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2232 (mask
->has_eth_src
) &&
2233 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2234 monitor_printf(mon
, " src <any mcast/bcast>");
2235 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2236 (mask
->has_eth_src
) &&
2237 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2238 monitor_printf(mon
, " src <any ucast>");
2240 monitor_printf(mon
, " src %s", key
->eth_src
);
2241 if (mask
->has_eth_src
) {
2242 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2247 if (key
->has_eth_dst
) {
2248 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2249 (mask
->has_eth_dst
) &&
2250 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2251 monitor_printf(mon
, " dst <any mcast/bcast>");
2252 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2253 (mask
->has_eth_dst
) &&
2254 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2255 monitor_printf(mon
, " dst <any ucast>");
2257 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2258 if (mask
->has_eth_dst
) {
2259 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2264 if (key
->has_ip_proto
) {
2265 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2266 if (mask
->has_ip_proto
) {
2267 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2271 if (key
->has_ip_tos
) {
2272 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2273 if (mask
->has_ip_tos
) {
2274 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2278 if (key
->has_ip_dst
) {
2279 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2282 if (action
->has_goto_tbl
|| action
->has_group_id
||
2283 action
->has_new_vlan_id
) {
2284 monitor_printf(mon
, " -->");
2287 if (action
->has_new_vlan_id
) {
2288 monitor_printf(mon
, " apply new vlan %d",
2289 ntohs(action
->new_vlan_id
));
2292 if (action
->has_group_id
) {
2293 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2296 if (action
->has_goto_tbl
) {
2297 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2300 monitor_printf(mon
, "\n");
2303 qapi_free_RockerOfDpaFlowList(list
);
2306 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2308 RockerOfDpaGroupList
*list
, *g
;
2309 const char *name
= qdict_get_str(qdict
, "name");
2310 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2314 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2316 hmp_handle_error(mon
, &err
);
2320 monitor_printf(mon
, "id (decode) --> buckets\n");
2322 for (g
= list
; g
; g
= g
->next
) {
2323 RockerOfDpaGroup
*group
= g
->value
;
2325 monitor_printf(mon
, "0x%08x", group
->id
);
2327 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2328 group
->type
== 1 ? "L2 rewrite" :
2329 group
->type
== 2 ? "L3 unicast" :
2330 group
->type
== 3 ? "L2 multicast" :
2331 group
->type
== 4 ? "L2 flood" :
2332 group
->type
== 5 ? "L3 interface" :
2333 group
->type
== 6 ? "L3 multicast" :
2334 group
->type
== 7 ? "L3 ECMP" :
2335 group
->type
== 8 ? "L2 overlay" :
2338 if (group
->has_vlan_id
) {
2339 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2342 if (group
->has_pport
) {
2343 monitor_printf(mon
, " pport %d", group
->pport
);
2346 if (group
->has_index
) {
2347 monitor_printf(mon
, " index %d", group
->index
);
2350 monitor_printf(mon
, ") -->");
2352 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2354 monitor_printf(mon
, " set vlan %d",
2355 group
->set_vlan_id
& VLAN_VID_MASK
);
2358 if (group
->has_set_eth_src
) {
2361 monitor_printf(mon
, " set");
2363 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2366 if (group
->has_set_eth_dst
) {
2369 monitor_printf(mon
, " set");
2371 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2376 if (group
->has_ttl_check
&& group
->ttl_check
) {
2377 monitor_printf(mon
, " check TTL");
2380 if (group
->has_group_id
&& group
->group_id
) {
2381 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2384 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2385 monitor_printf(mon
, " pop vlan");
2388 if (group
->has_out_pport
) {
2389 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2392 if (group
->has_group_ids
) {
2393 struct uint32List
*id
;
2395 monitor_printf(mon
, " groups [");
2396 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2397 monitor_printf(mon
, "0x%08x", id
->value
);
2399 monitor_printf(mon
, ",");
2402 monitor_printf(mon
, "]");
2405 monitor_printf(mon
, "\n");
2408 qapi_free_RockerOfDpaGroupList(list
);
2411 void hmp_info_dump(Monitor
*mon
, const QDict
*qdict
)
2413 DumpQueryResult
*result
= qmp_query_dump(NULL
);
2415 assert(result
&& result
->status
< DUMP_STATUS__MAX
);
2416 monitor_printf(mon
, "Status: %s\n", DumpStatus_lookup
[result
->status
]);
2418 if (result
->status
== DUMP_STATUS_ACTIVE
) {
2420 assert(result
->total
!= 0);
2421 percent
= 100.0 * result
->completed
/ result
->total
;
2422 monitor_printf(mon
, "Finished: %.2f %%\n", percent
);
2425 qapi_free_DumpQueryResult(result
);