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"
39 #include <spice/enums.h>
42 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
46 error_report_err(*errp
);
50 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
54 info
= qmp_query_name(NULL
);
56 monitor_printf(mon
, "%s\n", info
->name
);
58 qapi_free_NameInfo(info
);
61 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
65 info
= qmp_query_version(NULL
);
67 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
68 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
71 qapi_free_VersionInfo(info
);
74 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
78 info
= qmp_query_kvm(NULL
);
79 monitor_printf(mon
, "kvm support: ");
81 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
83 monitor_printf(mon
, "not compiled\n");
86 qapi_free_KvmInfo(info
);
89 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
93 info
= qmp_query_status(NULL
);
95 monitor_printf(mon
, "VM status: %s%s",
96 info
->running
? "running" : "paused",
97 info
->singlestep
? " (single step mode)" : "");
99 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
100 monitor_printf(mon
, " (%s)", RunState_lookup
[info
->status
]);
103 monitor_printf(mon
, "\n");
105 qapi_free_StatusInfo(info
);
108 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
112 info
= qmp_query_uuid(NULL
);
113 monitor_printf(mon
, "%s\n", info
->UUID
);
114 qapi_free_UuidInfo(info
);
117 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
119 ChardevInfoList
*char_info
, *info
;
121 char_info
= qmp_query_chardev(NULL
);
122 for (info
= char_info
; info
; info
= info
->next
) {
123 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
124 info
->value
->filename
);
127 qapi_free_ChardevInfoList(char_info
);
130 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
132 MouseInfoList
*mice_list
, *mouse
;
134 mice_list
= qmp_query_mice(NULL
);
136 monitor_printf(mon
, "No mouse devices connected\n");
140 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
141 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
142 mouse
->value
->current
? '*' : ' ',
143 mouse
->value
->index
, mouse
->value
->name
,
144 mouse
->value
->absolute
? " (absolute)" : "");
147 qapi_free_MouseInfoList(mice_list
);
150 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
153 MigrationCapabilityStatusList
*caps
, *cap
;
155 info
= qmp_query_migrate(NULL
);
156 caps
= qmp_query_migrate_capabilities(NULL
);
158 /* do not display parameters during setup */
159 if (info
->has_status
&& caps
) {
160 monitor_printf(mon
, "capabilities: ");
161 for (cap
= caps
; cap
; cap
= cap
->next
) {
162 monitor_printf(mon
, "%s: %s ",
163 MigrationCapability_lookup
[cap
->value
->capability
],
164 cap
->value
->state
? "on" : "off");
166 monitor_printf(mon
, "\n");
169 if (info
->has_status
) {
170 monitor_printf(mon
, "Migration status: %s\n",
171 MigrationStatus_lookup
[info
->status
]);
172 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
174 if (info
->has_expected_downtime
) {
175 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
176 info
->expected_downtime
);
178 if (info
->has_downtime
) {
179 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
182 if (info
->has_setup_time
) {
183 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
189 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
190 info
->ram
->transferred
>> 10);
191 monitor_printf(mon
, "throughput: %0.2f mbps\n",
193 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
194 info
->ram
->remaining
>> 10);
195 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
196 info
->ram
->total
>> 10);
197 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
198 info
->ram
->duplicate
);
199 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
201 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
203 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
204 info
->ram
->normal_bytes
>> 10);
205 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
206 info
->ram
->dirty_sync_count
);
207 if (info
->ram
->dirty_pages_rate
) {
208 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
209 info
->ram
->dirty_pages_rate
);
213 if (info
->has_disk
) {
214 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
215 info
->disk
->transferred
>> 10);
216 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
217 info
->disk
->remaining
>> 10);
218 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
219 info
->disk
->total
>> 10);
222 if (info
->has_xbzrle_cache
) {
223 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
224 info
->xbzrle_cache
->cache_size
);
225 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
226 info
->xbzrle_cache
->bytes
>> 10);
227 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
228 info
->xbzrle_cache
->pages
);
229 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
230 info
->xbzrle_cache
->cache_miss
);
231 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
232 info
->xbzrle_cache
->cache_miss_rate
);
233 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
234 info
->xbzrle_cache
->overflow
);
237 if (info
->has_x_cpu_throttle_percentage
) {
238 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
239 info
->x_cpu_throttle_percentage
);
242 qapi_free_MigrationInfo(info
);
243 qapi_free_MigrationCapabilityStatusList(caps
);
246 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
248 MigrationCapabilityStatusList
*caps
, *cap
;
250 caps
= qmp_query_migrate_capabilities(NULL
);
253 monitor_printf(mon
, "capabilities: ");
254 for (cap
= caps
; cap
; cap
= cap
->next
) {
255 monitor_printf(mon
, "%s: %s ",
256 MigrationCapability_lookup
[cap
->value
->capability
],
257 cap
->value
->state
? "on" : "off");
259 monitor_printf(mon
, "\n");
262 qapi_free_MigrationCapabilityStatusList(caps
);
265 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
267 MigrationParameters
*params
;
269 params
= qmp_query_migrate_parameters(NULL
);
272 monitor_printf(mon
, "parameters:");
273 monitor_printf(mon
, " %s: %" PRId64
,
274 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_LEVEL
],
275 params
->compress_level
);
276 monitor_printf(mon
, " %s: %" PRId64
,
277 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_THREADS
],
278 params
->compress_threads
);
279 monitor_printf(mon
, " %s: %" PRId64
,
280 MigrationParameter_lookup
[MIGRATION_PARAMETER_DECOMPRESS_THREADS
],
281 params
->decompress_threads
);
282 monitor_printf(mon
, " %s: %" PRId64
,
283 MigrationParameter_lookup
[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
],
284 params
->x_cpu_throttle_initial
);
285 monitor_printf(mon
, " %s: %" PRId64
,
286 MigrationParameter_lookup
[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
],
287 params
->x_cpu_throttle_increment
);
288 monitor_printf(mon
, "\n");
291 qapi_free_MigrationParameters(params
);
294 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
296 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
297 qmp_query_migrate_cache_size(NULL
) >> 10);
300 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
302 CpuInfoList
*cpu_list
, *cpu
;
304 cpu_list
= qmp_query_cpus(NULL
);
306 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
309 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
313 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
, cpu
->value
->CPU
);
315 switch (cpu
->value
->arch
) {
316 case CPU_INFO_ARCH_X86
:
317 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->u
.x86
.pc
);
319 case CPU_INFO_ARCH_PPC
:
320 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->u
.ppc
.nip
);
322 case CPU_INFO_ARCH_SPARC
:
323 monitor_printf(mon
, " pc=0x%016" PRIx64
,
324 cpu
->value
->u
.q_sparc
.pc
);
325 monitor_printf(mon
, " npc=0x%016" PRIx64
,
326 cpu
->value
->u
.q_sparc
.npc
);
328 case CPU_INFO_ARCH_MIPS
:
329 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.q_mips
.PC
);
331 case CPU_INFO_ARCH_TRICORE
:
332 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.tricore
.PC
);
338 if (cpu
->value
->halted
) {
339 monitor_printf(mon
, " (halted)");
342 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
345 qapi_free_CpuInfoList(cpu_list
);
348 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
349 BlockDeviceInfo
*inserted
, bool verbose
)
351 ImageInfo
*image_info
;
353 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
356 monitor_printf(mon
, "%s", info
->device
);
357 if (inserted
&& inserted
->has_node_name
) {
358 monitor_printf(mon
, " (%s)", inserted
->node_name
);
362 monitor_printf(mon
, "%s",
363 inserted
->has_node_name
364 ? inserted
->node_name
369 monitor_printf(mon
, ": %s (%s%s%s)\n",
372 inserted
->ro
? ", read-only" : "",
373 inserted
->encrypted
? ", encrypted" : "");
375 monitor_printf(mon
, ": [not inserted]\n");
379 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
380 monitor_printf(mon
, " I/O status: %s\n",
381 BlockDeviceIoStatus_lookup
[info
->io_status
]);
384 if (info
->removable
) {
385 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
386 info
->locked
? "" : "not ",
387 info
->tray_open
? "open" : "closed");
396 monitor_printf(mon
, " Cache mode: %s%s%s\n",
397 inserted
->cache
->writeback
? "writeback" : "writethrough",
398 inserted
->cache
->direct
? ", direct" : "",
399 inserted
->cache
->no_flush
? ", ignore flushes" : "");
401 if (inserted
->has_backing_file
) {
404 "(chain depth: %" PRId64
")\n",
405 inserted
->backing_file
,
406 inserted
->backing_file_depth
);
409 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
410 monitor_printf(mon
, " Detect zeroes: %s\n",
411 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
414 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
415 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
417 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
418 " bps_rd=%" PRId64
" bps_wr=%" PRId64
420 " bps_rd_max=%" PRId64
421 " bps_wr_max=%" PRId64
422 " iops=%" PRId64
" iops_rd=%" PRId64
425 " iops_rd_max=%" PRId64
426 " iops_wr_max=%" PRId64
427 " iops_size=%" PRId64
433 inserted
->bps_rd_max
,
434 inserted
->bps_wr_max
,
439 inserted
->iops_rd_max
,
440 inserted
->iops_wr_max
,
446 monitor_printf(mon
, "\nImages:\n");
447 image_info
= inserted
->image
;
449 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
451 if (image_info
->has_backing_image
) {
452 image_info
= image_info
->backing_image
;
460 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
462 BlockInfoList
*block_list
, *info
;
463 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
464 const char *device
= qdict_get_try_str(qdict
, "device");
465 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
466 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
467 bool printed
= false;
469 /* Print BlockBackend information */
471 block_list
= qmp_query_block(NULL
);
476 for (info
= block_list
; info
; info
= info
->next
) {
477 if (device
&& strcmp(device
, info
->value
->device
)) {
481 if (info
!= block_list
) {
482 monitor_printf(mon
, "\n");
485 print_block_info(mon
, info
->value
, info
->value
->has_inserted
486 ? info
->value
->inserted
: NULL
,
491 qapi_free_BlockInfoList(block_list
);
493 if ((!device
&& !nodes
) || printed
) {
497 /* Print node information */
498 blockdev_list
= qmp_query_named_block_nodes(NULL
);
499 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
500 assert(blockdev
->value
->has_node_name
);
501 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
505 if (blockdev
!= blockdev_list
) {
506 monitor_printf(mon
, "\n");
509 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
511 qapi_free_BlockDeviceInfoList(blockdev_list
);
514 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
516 BlockStatsList
*stats_list
, *stats
;
518 stats_list
= qmp_query_blockstats(false, false, NULL
);
520 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
521 if (!stats
->value
->has_device
) {
525 monitor_printf(mon
, "%s:", stats
->value
->device
);
526 monitor_printf(mon
, " rd_bytes=%" PRId64
528 " rd_operations=%" PRId64
529 " wr_operations=%" PRId64
530 " flush_operations=%" PRId64
531 " wr_total_time_ns=%" PRId64
532 " rd_total_time_ns=%" PRId64
533 " flush_total_time_ns=%" PRId64
534 " rd_merged=%" PRId64
535 " wr_merged=%" PRId64
536 " idle_time_ns=%" PRId64
538 stats
->value
->stats
->rd_bytes
,
539 stats
->value
->stats
->wr_bytes
,
540 stats
->value
->stats
->rd_operations
,
541 stats
->value
->stats
->wr_operations
,
542 stats
->value
->stats
->flush_operations
,
543 stats
->value
->stats
->wr_total_time_ns
,
544 stats
->value
->stats
->rd_total_time_ns
,
545 stats
->value
->stats
->flush_total_time_ns
,
546 stats
->value
->stats
->rd_merged
,
547 stats
->value
->stats
->wr_merged
,
548 stats
->value
->stats
->idle_time_ns
);
551 qapi_free_BlockStatsList(stats_list
);
554 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
558 VncClientInfoList
*client
;
560 info
= qmp_query_vnc(&err
);
562 error_report_err(err
);
566 if (!info
->enabled
) {
567 monitor_printf(mon
, "Server: disabled\n");
571 monitor_printf(mon
, "Server:\n");
572 if (info
->has_host
&& info
->has_service
) {
573 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
575 if (info
->has_auth
) {
576 monitor_printf(mon
, " auth: %s\n", info
->auth
);
579 if (!info
->has_clients
|| info
->clients
== NULL
) {
580 monitor_printf(mon
, "Client: none\n");
582 for (client
= info
->clients
; client
; client
= client
->next
) {
583 monitor_printf(mon
, "Client:\n");
584 monitor_printf(mon
, " address: %s:%s\n",
586 client
->value
->service
);
587 monitor_printf(mon
, " x509_dname: %s\n",
588 client
->value
->x509_dname
?
589 client
->value
->x509_dname
: "none");
590 monitor_printf(mon
, " username: %s\n",
591 client
->value
->has_sasl_username
?
592 client
->value
->sasl_username
: "none");
597 qapi_free_VncInfo(info
);
601 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
603 SpiceChannelList
*chan
;
605 const char *channel_name
;
606 const char * const channel_names
[] = {
607 [SPICE_CHANNEL_MAIN
] = "main",
608 [SPICE_CHANNEL_DISPLAY
] = "display",
609 [SPICE_CHANNEL_INPUTS
] = "inputs",
610 [SPICE_CHANNEL_CURSOR
] = "cursor",
611 [SPICE_CHANNEL_PLAYBACK
] = "playback",
612 [SPICE_CHANNEL_RECORD
] = "record",
613 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
614 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
615 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
616 [SPICE_CHANNEL_PORT
] = "port",
618 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
619 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
620 * as quick fix for build failures with older versions. */
621 [SPICE_CHANNEL_WEBDAV
] = "webdav",
625 info
= qmp_query_spice(NULL
);
627 if (!info
->enabled
) {
628 monitor_printf(mon
, "Server: disabled\n");
632 monitor_printf(mon
, "Server:\n");
633 if (info
->has_port
) {
634 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
635 info
->host
, info
->port
);
637 if (info
->has_tls_port
) {
638 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
639 info
->host
, info
->tls_port
);
641 monitor_printf(mon
, " migrated: %s\n",
642 info
->migrated
? "true" : "false");
643 monitor_printf(mon
, " auth: %s\n", info
->auth
);
644 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
645 monitor_printf(mon
, " mouse-mode: %s\n",
646 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
648 if (!info
->has_channels
|| info
->channels
== NULL
) {
649 monitor_printf(mon
, "Channels: none\n");
651 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
652 monitor_printf(mon
, "Channel:\n");
653 monitor_printf(mon
, " address: %s:%s%s\n",
654 chan
->value
->host
, chan
->value
->port
,
655 chan
->value
->tls
? " [tls]" : "");
656 monitor_printf(mon
, " session: %" PRId64
"\n",
657 chan
->value
->connection_id
);
658 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
659 chan
->value
->channel_type
, chan
->value
->channel_id
);
661 channel_name
= "unknown";
662 if (chan
->value
->channel_type
> 0 &&
663 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
664 channel_names
[chan
->value
->channel_type
]) {
665 channel_name
= channel_names
[chan
->value
->channel_type
];
668 monitor_printf(mon
, " channel name: %s\n", channel_name
);
673 qapi_free_SpiceInfo(info
);
677 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
682 info
= qmp_query_balloon(&err
);
684 error_report_err(err
);
688 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
690 qapi_free_BalloonInfo(info
);
693 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
695 PciMemoryRegionList
*region
;
697 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
698 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
699 dev
->slot
, dev
->function
);
700 monitor_printf(mon
, " ");
702 if (dev
->class_info
->has_desc
) {
703 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
705 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
708 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
709 dev
->id
->vendor
, dev
->id
->device
);
712 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
715 if (dev
->has_pci_bridge
) {
716 monitor_printf(mon
, " BUS %" PRId64
".\n",
717 dev
->pci_bridge
->bus
->number
);
718 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
719 dev
->pci_bridge
->bus
->secondary
);
720 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
721 dev
->pci_bridge
->bus
->subordinate
);
723 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
724 dev
->pci_bridge
->bus
->io_range
->base
,
725 dev
->pci_bridge
->bus
->io_range
->limit
);
728 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
729 dev
->pci_bridge
->bus
->memory_range
->base
,
730 dev
->pci_bridge
->bus
->memory_range
->limit
);
732 monitor_printf(mon
, " prefetchable memory range "
733 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
734 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
735 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
738 for (region
= dev
->regions
; region
; region
= region
->next
) {
741 addr
= region
->value
->address
;
742 size
= region
->value
->size
;
744 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
746 if (!strcmp(region
->value
->type
, "io")) {
747 monitor_printf(mon
, "I/O at 0x%04" PRIx64
748 " [0x%04" PRIx64
"].\n",
749 addr
, addr
+ size
- 1);
751 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
752 " [0x%08" PRIx64
"].\n",
753 region
->value
->mem_type_64
? 64 : 32,
754 region
->value
->prefetch
? " prefetchable" : "",
755 addr
, addr
+ size
- 1);
759 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
761 if (dev
->has_pci_bridge
) {
762 if (dev
->pci_bridge
->has_devices
) {
763 PciDeviceInfoList
*cdev
;
764 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
765 hmp_info_pci_device(mon
, cdev
->value
);
771 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
773 PciInfoList
*info_list
, *info
;
776 info_list
= qmp_query_pci(&err
);
778 monitor_printf(mon
, "PCI devices not supported\n");
783 for (info
= info_list
; info
; info
= info
->next
) {
784 PciDeviceInfoList
*dev
;
786 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
787 hmp_info_pci_device(mon
, dev
->value
);
791 qapi_free_PciInfoList(info_list
);
794 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
796 BlockJobInfoList
*list
;
799 list
= qmp_query_block_jobs(&err
);
803 monitor_printf(mon
, "No active jobs\n");
808 if (strcmp(list
->value
->type
, "stream") == 0) {
809 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
810 " of %" PRId64
" bytes, speed limit %" PRId64
817 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
818 " of %" PRId64
" bytes, speed limit %" PRId64
829 qapi_free_BlockJobInfoList(list
);
832 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
834 TPMInfoList
*info_list
, *info
;
837 TPMPassthroughOptions
*tpo
;
839 info_list
= qmp_query_tpm(&err
);
841 monitor_printf(mon
, "TPM device not supported\n");
847 monitor_printf(mon
, "TPM device:\n");
850 for (info
= info_list
; info
; info
= info
->next
) {
851 TPMInfo
*ti
= info
->value
;
852 monitor_printf(mon
, " tpm%d: model=%s\n",
853 c
, TpmModel_lookup
[ti
->model
]);
855 monitor_printf(mon
, " \\ %s: type=%s",
856 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
858 switch (ti
->options
->type
) {
859 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
860 tpo
= ti
->options
->u
.passthrough
;
861 monitor_printf(mon
, "%s%s%s%s",
862 tpo
->has_path
? ",path=" : "",
863 tpo
->has_path
? tpo
->path
: "",
864 tpo
->has_cancel_path
? ",cancel-path=" : "",
865 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
867 case TPM_TYPE_OPTIONS_KIND__MAX
:
870 monitor_printf(mon
, "\n");
873 qapi_free_TPMInfoList(info_list
);
876 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
878 monitor_suspend(mon
);
882 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
887 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
889 qmp_system_reset(NULL
);
892 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
894 qmp_system_powerdown(NULL
);
897 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
901 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
902 use it are converted to the QAPI */
903 cpu_index
= qdict_get_int(qdict
, "index");
904 if (monitor_set_cpu(cpu_index
) < 0) {
905 monitor_printf(mon
, "invalid CPU index\n");
909 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
911 uint32_t size
= qdict_get_int(qdict
, "size");
912 const char *filename
= qdict_get_str(qdict
, "filename");
913 uint64_t addr
= qdict_get_int(qdict
, "val");
916 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
917 hmp_handle_error(mon
, &err
);
920 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
922 uint32_t size
= qdict_get_int(qdict
, "size");
923 const char *filename
= qdict_get_str(qdict
, "filename");
924 uint64_t addr
= qdict_get_int(qdict
, "val");
927 qmp_pmemsave(addr
, size
, filename
, &err
);
928 hmp_handle_error(mon
, &err
);
931 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
933 const char *chardev
= qdict_get_str(qdict
, "device");
934 const char *data
= qdict_get_str(qdict
, "data");
937 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
939 hmp_handle_error(mon
, &err
);
942 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
944 uint32_t size
= qdict_get_int(qdict
, "size");
945 const char *chardev
= qdict_get_str(qdict
, "device");
950 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
952 error_report_err(err
);
956 for (i
= 0; data
[i
]; i
++) {
957 unsigned char ch
= data
[i
];
960 monitor_printf(mon
, "\\\\");
961 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
962 monitor_printf(mon
, "\\u%04X", ch
);
964 monitor_printf(mon
, "%c", ch
);
968 monitor_printf(mon
, "\n");
972 static void hmp_cont_cb(void *opaque
, int err
)
979 static bool key_is_missing(const BlockInfo
*bdev
)
981 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
984 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
986 BlockInfoList
*bdev_list
, *bdev
;
989 bdev_list
= qmp_query_block(NULL
);
990 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
991 if (key_is_missing(bdev
->value
)) {
992 monitor_read_block_device_key(mon
, bdev
->value
->device
,
999 hmp_handle_error(mon
, &err
);
1002 qapi_free_BlockInfoList(bdev_list
);
1005 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1007 qmp_system_wakeup(NULL
);
1010 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1014 qmp_inject_nmi(&err
);
1015 hmp_handle_error(mon
, &err
);
1018 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1020 const char *name
= qdict_get_str(qdict
, "name");
1021 bool up
= qdict_get_bool(qdict
, "up");
1024 qmp_set_link(name
, up
, &err
);
1025 hmp_handle_error(mon
, &err
);
1028 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1030 const char *device
= qdict_get_str(qdict
, "device");
1031 const char *password
= qdict_get_str(qdict
, "password");
1034 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1035 hmp_handle_error(mon
, &err
);
1038 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1040 int64_t value
= qdict_get_int(qdict
, "value");
1043 qmp_balloon(value
, &err
);
1045 error_report_err(err
);
1049 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1051 const char *device
= qdict_get_str(qdict
, "device");
1052 int64_t size
= qdict_get_int(qdict
, "size");
1055 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1056 hmp_handle_error(mon
, &err
);
1059 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1061 const char *device
= qdict_get_str(qdict
, "device");
1062 const char *filename
= qdict_get_str(qdict
, "target");
1063 const char *format
= qdict_get_try_str(qdict
, "format");
1064 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1065 bool full
= qdict_get_try_bool(qdict
, "full", false);
1066 enum NewImageMode mode
;
1070 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1071 hmp_handle_error(mon
, &err
);
1076 mode
= NEW_IMAGE_MODE_EXISTING
;
1078 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1081 qmp_drive_mirror(device
, filename
, !!format
, format
,
1082 false, NULL
, false, NULL
,
1083 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1084 true, mode
, false, 0, false, 0, false, 0,
1085 false, 0, false, 0, false, true, &err
);
1086 hmp_handle_error(mon
, &err
);
1089 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1091 const char *device
= qdict_get_str(qdict
, "device");
1092 const char *filename
= qdict_get_str(qdict
, "target");
1093 const char *format
= qdict_get_try_str(qdict
, "format");
1094 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1095 bool full
= qdict_get_try_bool(qdict
, "full", false);
1096 enum NewImageMode mode
;
1100 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1101 hmp_handle_error(mon
, &err
);
1106 mode
= NEW_IMAGE_MODE_EXISTING
;
1108 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1111 qmp_drive_backup(device
, filename
, !!format
, format
,
1112 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1113 true, mode
, false, 0, false, NULL
,
1114 false, 0, false, 0, &err
);
1115 hmp_handle_error(mon
, &err
);
1118 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1120 const char *device
= qdict_get_str(qdict
, "device");
1121 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1122 const char *format
= qdict_get_try_str(qdict
, "format");
1123 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1124 enum NewImageMode mode
;
1128 /* In the future, if 'snapshot-file' is not specified, the snapshot
1129 will be taken internally. Today it's actually required. */
1130 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1131 hmp_handle_error(mon
, &err
);
1135 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1136 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1137 filename
, false, NULL
,
1140 hmp_handle_error(mon
, &err
);
1143 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1145 const char *device
= qdict_get_str(qdict
, "device");
1146 const char *name
= qdict_get_str(qdict
, "name");
1149 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1150 hmp_handle_error(mon
, &err
);
1153 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1155 const char *device
= qdict_get_str(qdict
, "device");
1156 const char *name
= qdict_get_str(qdict
, "name");
1157 const char *id
= qdict_get_try_str(qdict
, "id");
1160 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1162 hmp_handle_error(mon
, &err
);
1165 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1167 qmp_migrate_cancel(NULL
);
1170 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1173 const char *uri
= qdict_get_str(qdict
, "uri");
1175 qmp_migrate_incoming(uri
, &err
);
1177 hmp_handle_error(mon
, &err
);
1180 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1182 double value
= qdict_get_double(qdict
, "value");
1183 qmp_migrate_set_downtime(value
, NULL
);
1186 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1188 int64_t value
= qdict_get_int(qdict
, "value");
1191 qmp_migrate_set_cache_size(value
, &err
);
1193 error_report_err(err
);
1198 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1200 int64_t value
= qdict_get_int(qdict
, "value");
1201 qmp_migrate_set_speed(value
, NULL
);
1204 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1206 const char *cap
= qdict_get_str(qdict
, "capability");
1207 bool state
= qdict_get_bool(qdict
, "state");
1209 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1212 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1213 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1214 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1215 caps
->value
->capability
= i
;
1216 caps
->value
->state
= state
;
1218 qmp_migrate_set_capabilities(caps
, &err
);
1223 if (i
== MIGRATION_CAPABILITY__MAX
) {
1224 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1227 qapi_free_MigrationCapabilityStatusList(caps
);
1230 error_report_err(err
);
1234 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1236 const char *param
= qdict_get_str(qdict
, "parameter");
1237 int value
= qdict_get_int(qdict
, "value");
1239 bool has_compress_level
= false;
1240 bool has_compress_threads
= false;
1241 bool has_decompress_threads
= false;
1242 bool has_x_cpu_throttle_initial
= false;
1243 bool has_x_cpu_throttle_increment
= false;
1246 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1247 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1249 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1250 has_compress_level
= true;
1252 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1253 has_compress_threads
= true;
1255 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1256 has_decompress_threads
= true;
1258 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
:
1259 has_x_cpu_throttle_initial
= true;
1261 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
:
1262 has_x_cpu_throttle_increment
= true;
1265 qmp_migrate_set_parameters(has_compress_level
, value
,
1266 has_compress_threads
, value
,
1267 has_decompress_threads
, value
,
1268 has_x_cpu_throttle_initial
, value
,
1269 has_x_cpu_throttle_increment
, value
,
1275 if (i
== MIGRATION_PARAMETER__MAX
) {
1276 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1280 error_report_err(err
);
1284 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1287 const char *protocol
= qdict_get_str(qdict
, "protocol");
1288 const char *hostname
= qdict_get_str(qdict
, "hostname");
1289 bool has_port
= qdict_haskey(qdict
, "port");
1290 int port
= qdict_get_try_int(qdict
, "port", -1);
1291 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1292 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1293 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1295 qmp_client_migrate_info(protocol
, hostname
,
1296 has_port
, port
, has_tls_port
, tls_port
,
1297 !!cert_subject
, cert_subject
, &err
);
1298 hmp_handle_error(mon
, &err
);
1301 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1304 qmp_migrate_start_postcopy(&err
);
1305 hmp_handle_error(mon
, &err
);
1308 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1310 const char *protocol
= qdict_get_str(qdict
, "protocol");
1311 const char *password
= qdict_get_str(qdict
, "password");
1312 const char *connected
= qdict_get_try_str(qdict
, "connected");
1315 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1316 hmp_handle_error(mon
, &err
);
1319 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1321 const char *protocol
= qdict_get_str(qdict
, "protocol");
1322 const char *whenstr
= qdict_get_str(qdict
, "time");
1325 qmp_expire_password(protocol
, whenstr
, &err
);
1326 hmp_handle_error(mon
, &err
);
1329 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1331 bool force
= qdict_get_try_bool(qdict
, "force", false);
1332 const char *device
= qdict_get_str(qdict
, "device");
1335 qmp_eject(device
, true, force
, &err
);
1336 hmp_handle_error(mon
, &err
);
1339 static void hmp_change_read_arg(void *opaque
, const char *password
,
1340 void *readline_opaque
)
1342 qmp_change_vnc_password(password
, NULL
);
1343 monitor_read_command(opaque
, 1);
1346 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1348 const char *device
= qdict_get_str(qdict
, "device");
1349 const char *target
= qdict_get_str(qdict
, "target");
1350 const char *arg
= qdict_get_try_str(qdict
, "arg");
1351 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1352 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1355 if (strcmp(device
, "vnc") == 0) {
1358 "Parameter 'read-only-mode' is invalid for VNC\n");
1361 if (strcmp(target
, "passwd") == 0 ||
1362 strcmp(target
, "password") == 0) {
1364 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1368 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1372 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1373 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1374 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1376 hmp_handle_error(mon
, &err
);
1381 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1382 !!read_only
, read_only_mode
, &err
);
1384 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1386 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1391 hmp_handle_error(mon
, &err
);
1394 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1398 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1399 qdict_get_int(qdict
, "bps"),
1400 qdict_get_int(qdict
, "bps_rd"),
1401 qdict_get_int(qdict
, "bps_wr"),
1402 qdict_get_int(qdict
, "iops"),
1403 qdict_get_int(qdict
, "iops_rd"),
1404 qdict_get_int(qdict
, "iops_wr"),
1405 false, /* no burst max via HMP */
1417 false, /* no burst length via HMP */
1429 false, /* No default I/O size */
1433 hmp_handle_error(mon
, &err
);
1436 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1438 Error
*error
= NULL
;
1439 const char *device
= qdict_get_str(qdict
, "device");
1440 const char *base
= qdict_get_try_str(qdict
, "base");
1441 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1443 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1444 qdict_haskey(qdict
, "speed"), speed
,
1445 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1447 hmp_handle_error(mon
, &error
);
1450 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1452 Error
*error
= NULL
;
1453 const char *device
= qdict_get_str(qdict
, "device");
1454 int64_t value
= qdict_get_int(qdict
, "speed");
1456 qmp_block_job_set_speed(device
, value
, &error
);
1458 hmp_handle_error(mon
, &error
);
1461 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1463 Error
*error
= NULL
;
1464 const char *device
= qdict_get_str(qdict
, "device");
1465 bool force
= qdict_get_try_bool(qdict
, "force", false);
1467 qmp_block_job_cancel(device
, true, force
, &error
);
1469 hmp_handle_error(mon
, &error
);
1472 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1474 Error
*error
= NULL
;
1475 const char *device
= qdict_get_str(qdict
, "device");
1477 qmp_block_job_pause(device
, &error
);
1479 hmp_handle_error(mon
, &error
);
1482 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1484 Error
*error
= NULL
;
1485 const char *device
= qdict_get_str(qdict
, "device");
1487 qmp_block_job_resume(device
, &error
);
1489 hmp_handle_error(mon
, &error
);
1492 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1494 Error
*error
= NULL
;
1495 const char *device
= qdict_get_str(qdict
, "device");
1497 qmp_block_job_complete(device
, &error
);
1499 hmp_handle_error(mon
, &error
);
1502 typedef struct HMPMigrationStatus
1506 bool is_block_migration
;
1507 } HMPMigrationStatus
;
1509 static void hmp_migrate_status_cb(void *opaque
)
1511 HMPMigrationStatus
*status
= opaque
;
1512 MigrationInfo
*info
;
1514 info
= qmp_query_migrate(NULL
);
1515 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1516 info
->status
== MIGRATION_STATUS_SETUP
) {
1517 if (info
->has_disk
) {
1520 if (info
->disk
->remaining
) {
1521 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1526 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1527 monitor_flush(status
->mon
);
1530 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1532 if (status
->is_block_migration
) {
1533 monitor_printf(status
->mon
, "\n");
1535 monitor_resume(status
->mon
);
1536 timer_del(status
->timer
);
1540 qapi_free_MigrationInfo(info
);
1543 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1545 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1546 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1547 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1548 const char *uri
= qdict_get_str(qdict
, "uri");
1551 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1553 error_report_err(err
);
1558 HMPMigrationStatus
*status
;
1560 if (monitor_suspend(mon
) < 0) {
1561 monitor_printf(mon
, "terminal does not allow synchronous "
1562 "migration, continuing detached\n");
1566 status
= g_malloc0(sizeof(*status
));
1568 status
->is_block_migration
= blk
|| inc
;
1569 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1571 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1575 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1579 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1580 hmp_handle_error(mon
, &err
);
1583 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1585 const char *id
= qdict_get_str(qdict
, "id");
1588 qmp_device_del(id
, &err
);
1589 hmp_handle_error(mon
, &err
);
1592 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1595 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1596 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1597 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1598 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1599 const char *file
= qdict_get_str(qdict
, "filename");
1600 bool has_begin
= qdict_haskey(qdict
, "begin");
1601 bool has_length
= qdict_haskey(qdict
, "length");
1604 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1607 if (zlib
+ lzo
+ snappy
> 1) {
1608 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1609 hmp_handle_error(mon
, &err
);
1614 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1618 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1622 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1626 begin
= qdict_get_int(qdict
, "begin");
1629 length
= qdict_get_int(qdict
, "length");
1632 prot
= g_strconcat("file:", file
, NULL
);
1634 qmp_dump_guest_memory(paging
, prot
, has_begin
, begin
, has_length
, length
,
1635 true, dump_format
, &err
);
1636 hmp_handle_error(mon
, &err
);
1640 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1645 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1650 netdev_add(opts
, &err
);
1652 qemu_opts_del(opts
);
1656 hmp_handle_error(mon
, &err
);
1659 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1661 const char *id
= qdict_get_str(qdict
, "id");
1664 qmp_netdev_del(id
, &err
);
1665 hmp_handle_error(mon
, &err
);
1668 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1675 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1677 hmp_handle_error(mon
, &err
);
1681 ov
= opts_visitor_new(opts
);
1682 obj
= user_creatable_add(qdict
, opts_get_visitor(ov
), &err
);
1683 opts_visitor_cleanup(ov
);
1684 qemu_opts_del(opts
);
1687 hmp_handle_error(mon
, &err
);
1694 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1696 const char *fdname
= qdict_get_str(qdict
, "fdname");
1699 qmp_getfd(fdname
, &err
);
1700 hmp_handle_error(mon
, &err
);
1703 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1705 const char *fdname
= qdict_get_str(qdict
, "fdname");
1708 qmp_closefd(fdname
, &err
);
1709 hmp_handle_error(mon
, &err
);
1712 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1714 const char *keys
= qdict_get_str(qdict
, "keys");
1715 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1716 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1717 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1723 separator
= strchr(keys
, '-');
1724 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1726 /* Be compatible with old interface, convert user inputted "<" */
1727 if (keys
[0] == '<' && keyname_len
== 1) {
1732 keylist
= g_malloc0(sizeof(*keylist
));
1733 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1739 tmp
->next
= keylist
;
1743 if (strstart(keys
, "0x", NULL
)) {
1745 int value
= strtoul(keys
, &endp
, 0);
1746 assert(endp
<= keys
+ keyname_len
);
1747 if (endp
!= keys
+ keyname_len
) {
1750 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1751 keylist
->value
->u
.number
= value
;
1753 int idx
= index_from_key(keys
, keyname_len
);
1754 if (idx
== Q_KEY_CODE__MAX
) {
1757 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1758 keylist
->value
->u
.qcode
= idx
;
1764 keys
= separator
+ 1;
1767 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1768 hmp_handle_error(mon
, &err
);
1771 qapi_free_KeyValueList(head
);
1775 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1779 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1781 const char *filename
= qdict_get_str(qdict
, "filename");
1784 qmp_screendump(filename
, &err
);
1785 hmp_handle_error(mon
, &err
);
1788 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1790 const char *uri
= qdict_get_str(qdict
, "uri");
1791 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1792 bool all
= qdict_get_try_bool(qdict
, "all", false);
1793 Error
*local_err
= NULL
;
1794 BlockInfoList
*block_list
, *info
;
1795 SocketAddress
*addr
;
1797 if (writable
&& !all
) {
1798 error_setg(&local_err
, "-w only valid together with -a");
1802 /* First check if the address is valid and start the server. */
1803 addr
= socket_parse(uri
, &local_err
);
1804 if (local_err
!= NULL
) {
1808 qmp_nbd_server_start(addr
, false, NULL
, &local_err
);
1809 qapi_free_SocketAddress(addr
);
1810 if (local_err
!= NULL
) {
1818 /* Then try adding all block devices. If one fails, close all and
1821 block_list
= qmp_query_block(NULL
);
1823 for (info
= block_list
; info
; info
= info
->next
) {
1824 if (!info
->value
->has_inserted
) {
1828 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1830 if (local_err
!= NULL
) {
1831 qmp_nbd_server_stop(NULL
);
1836 qapi_free_BlockInfoList(block_list
);
1839 hmp_handle_error(mon
, &local_err
);
1842 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1844 const char *device
= qdict_get_str(qdict
, "device");
1845 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1846 Error
*local_err
= NULL
;
1848 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1850 if (local_err
!= NULL
) {
1851 hmp_handle_error(mon
, &local_err
);
1855 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1859 qmp_nbd_server_stop(&err
);
1860 hmp_handle_error(mon
, &err
);
1863 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1868 cpuid
= qdict_get_int(qdict
, "id");
1869 qmp_cpu_add(cpuid
, &err
);
1870 hmp_handle_error(mon
, &err
);
1873 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1875 const char *args
= qdict_get_str(qdict
, "args");
1879 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1881 error_setg(&err
, "Parsing chardev args failed");
1883 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1885 hmp_handle_error(mon
, &err
);
1888 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1890 Error
*local_err
= NULL
;
1892 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1893 hmp_handle_error(mon
, &local_err
);
1896 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1899 const char* device
= qdict_get_str(qdict
, "device");
1900 const char* command
= qdict_get_str(qdict
, "command");
1903 blk
= blk_by_name(device
);
1905 qemuio_command(blk
, command
);
1907 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1908 "Device '%s' not found", device
);
1911 hmp_handle_error(mon
, &err
);
1914 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1916 const char *id
= qdict_get_str(qdict
, "id");
1919 user_creatable_del(id
, &err
);
1920 hmp_handle_error(mon
, &err
);
1923 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1926 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1927 MemdevList
*m
= memdev_list
;
1928 StringOutputVisitor
*ov
;
1934 ov
= string_output_visitor_new(false);
1935 visit_type_uint16List(string_output_get_visitor(ov
), NULL
,
1936 &m
->value
->host_nodes
, NULL
);
1937 monitor_printf(mon
, "memory backend: %d\n", i
);
1938 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1939 monitor_printf(mon
, " merge: %s\n",
1940 m
->value
->merge
? "true" : "false");
1941 monitor_printf(mon
, " dump: %s\n",
1942 m
->value
->dump
? "true" : "false");
1943 monitor_printf(mon
, " prealloc: %s\n",
1944 m
->value
->prealloc
? "true" : "false");
1945 monitor_printf(mon
, " policy: %s\n",
1946 HostMemPolicy_lookup
[m
->value
->policy
]);
1947 str
= string_output_get_string(ov
);
1948 monitor_printf(mon
, " host nodes: %s\n", str
);
1951 string_output_visitor_cleanup(ov
);
1956 monitor_printf(mon
, "\n");
1958 qapi_free_MemdevList(memdev_list
);
1961 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1964 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1965 MemoryDeviceInfoList
*info
;
1966 MemoryDeviceInfo
*value
;
1967 PCDIMMDeviceInfo
*di
;
1969 for (info
= info_list
; info
; info
= info
->next
) {
1970 value
= info
->value
;
1973 switch (value
->type
) {
1974 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1977 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1978 MemoryDeviceInfoKind_lookup
[value
->type
],
1979 di
->id
? di
->id
: "");
1980 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1981 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1982 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1983 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
1984 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
1985 monitor_printf(mon
, " hotplugged: %s\n",
1986 di
->hotplugged
? "true" : "false");
1987 monitor_printf(mon
, " hotpluggable: %s\n",
1988 di
->hotpluggable
? "true" : "false");
1996 qapi_free_MemoryDeviceInfoList(info_list
);
1999 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2001 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2002 IOThreadInfoList
*info
;
2004 for (info
= info_list
; info
; info
= info
->next
) {
2005 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2006 info
->value
->id
, info
->value
->thread_id
);
2009 qapi_free_IOThreadInfoList(info_list
);
2012 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2014 const char *path
= qdict_get_try_str(qdict
, "path");
2015 ObjectPropertyInfoList
*list
;
2019 monitor_printf(mon
, "/\n");
2023 list
= qmp_qom_list(path
, &err
);
2025 ObjectPropertyInfoList
*start
= list
;
2026 while (list
!= NULL
) {
2027 ObjectPropertyInfo
*value
= list
->value
;
2029 monitor_printf(mon
, "%s (%s)\n",
2030 value
->name
, value
->type
);
2033 qapi_free_ObjectPropertyInfoList(start
);
2035 hmp_handle_error(mon
, &err
);
2038 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2040 const char *path
= qdict_get_str(qdict
, "path");
2041 const char *property
= qdict_get_str(qdict
, "property");
2042 const char *value
= qdict_get_str(qdict
, "value");
2044 bool ambiguous
= false;
2047 obj
= object_resolve_path(path
, &ambiguous
);
2049 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2050 "Device '%s' not found", path
);
2053 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2055 object_property_parse(obj
, value
, property
, &err
);
2057 hmp_handle_error(mon
, &err
);
2060 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2062 const char *name
= qdict_get_str(qdict
, "name");
2063 RockerSwitch
*rocker
;
2066 rocker
= qmp_query_rocker(name
, &err
);
2068 hmp_handle_error(mon
, &err
);
2072 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2073 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2074 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2076 qapi_free_RockerSwitch(rocker
);
2079 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2081 RockerPortList
*list
, *port
;
2082 const char *name
= qdict_get_str(qdict
, "name");
2085 list
= qmp_query_rocker_ports(name
, &err
);
2087 hmp_handle_error(mon
, &err
);
2091 monitor_printf(mon
, " ena/ speed/ auto\n");
2092 monitor_printf(mon
, " port link duplex neg?\n");
2094 for (port
= list
; port
; port
= port
->next
) {
2095 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2097 port
->value
->enabled
? port
->value
->link_up
?
2098 "up" : "down" : "!ena",
2099 port
->value
->speed
== 10000 ? "10G" : "??",
2100 port
->value
->duplex
? "FD" : "HD",
2101 port
->value
->autoneg
? "Yes" : "No");
2104 qapi_free_RockerPortList(list
);
2107 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2109 RockerOfDpaFlowList
*list
, *info
;
2110 const char *name
= qdict_get_str(qdict
, "name");
2111 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2114 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2116 hmp_handle_error(mon
, &err
);
2120 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2122 for (info
= list
; info
; info
= info
->next
) {
2123 RockerOfDpaFlow
*flow
= info
->value
;
2124 RockerOfDpaFlowKey
*key
= flow
->key
;
2125 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2126 RockerOfDpaFlowAction
*action
= flow
->action
;
2129 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2130 key
->priority
, key
->tbl_id
, flow
->hits
);
2132 monitor_printf(mon
, "%-4d %-3d ",
2133 key
->priority
, key
->tbl_id
);
2136 if (key
->has_in_pport
) {
2137 monitor_printf(mon
, " pport %d", key
->in_pport
);
2138 if (mask
->has_in_pport
) {
2139 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2143 if (key
->has_vlan_id
) {
2144 monitor_printf(mon
, " vlan %d",
2145 key
->vlan_id
& VLAN_VID_MASK
);
2146 if (mask
->has_vlan_id
) {
2147 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2151 if (key
->has_tunnel_id
) {
2152 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2153 if (mask
->has_tunnel_id
) {
2154 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2158 if (key
->has_eth_type
) {
2159 switch (key
->eth_type
) {
2161 monitor_printf(mon
, " ARP");
2164 monitor_printf(mon
, " IP");
2167 monitor_printf(mon
, " IPv6");
2170 monitor_printf(mon
, " LACP");
2173 monitor_printf(mon
, " LLDP");
2176 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2181 if (key
->has_eth_src
) {
2182 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2183 (mask
->has_eth_src
) &&
2184 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2185 monitor_printf(mon
, " src <any mcast/bcast>");
2186 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2187 (mask
->has_eth_src
) &&
2188 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2189 monitor_printf(mon
, " src <any ucast>");
2191 monitor_printf(mon
, " src %s", key
->eth_src
);
2192 if (mask
->has_eth_src
) {
2193 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2198 if (key
->has_eth_dst
) {
2199 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2200 (mask
->has_eth_dst
) &&
2201 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2202 monitor_printf(mon
, " dst <any mcast/bcast>");
2203 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2204 (mask
->has_eth_dst
) &&
2205 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2206 monitor_printf(mon
, " dst <any ucast>");
2208 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2209 if (mask
->has_eth_dst
) {
2210 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2215 if (key
->has_ip_proto
) {
2216 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2217 if (mask
->has_ip_proto
) {
2218 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2222 if (key
->has_ip_tos
) {
2223 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2224 if (mask
->has_ip_tos
) {
2225 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2229 if (key
->has_ip_dst
) {
2230 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2233 if (action
->has_goto_tbl
|| action
->has_group_id
||
2234 action
->has_new_vlan_id
) {
2235 monitor_printf(mon
, " -->");
2238 if (action
->has_new_vlan_id
) {
2239 monitor_printf(mon
, " apply new vlan %d",
2240 ntohs(action
->new_vlan_id
));
2243 if (action
->has_group_id
) {
2244 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2247 if (action
->has_goto_tbl
) {
2248 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2251 monitor_printf(mon
, "\n");
2254 qapi_free_RockerOfDpaFlowList(list
);
2257 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2259 RockerOfDpaGroupList
*list
, *g
;
2260 const char *name
= qdict_get_str(qdict
, "name");
2261 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2265 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2267 hmp_handle_error(mon
, &err
);
2271 monitor_printf(mon
, "id (decode) --> buckets\n");
2273 for (g
= list
; g
; g
= g
->next
) {
2274 RockerOfDpaGroup
*group
= g
->value
;
2276 monitor_printf(mon
, "0x%08x", group
->id
);
2278 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2279 group
->type
== 1 ? "L2 rewrite" :
2280 group
->type
== 2 ? "L3 unicast" :
2281 group
->type
== 3 ? "L2 multicast" :
2282 group
->type
== 4 ? "L2 flood" :
2283 group
->type
== 5 ? "L3 interface" :
2284 group
->type
== 6 ? "L3 multicast" :
2285 group
->type
== 7 ? "L3 ECMP" :
2286 group
->type
== 8 ? "L2 overlay" :
2289 if (group
->has_vlan_id
) {
2290 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2293 if (group
->has_pport
) {
2294 monitor_printf(mon
, " pport %d", group
->pport
);
2297 if (group
->has_index
) {
2298 monitor_printf(mon
, " index %d", group
->index
);
2301 monitor_printf(mon
, ") -->");
2303 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2305 monitor_printf(mon
, " set vlan %d",
2306 group
->set_vlan_id
& VLAN_VID_MASK
);
2309 if (group
->has_set_eth_src
) {
2312 monitor_printf(mon
, " set");
2314 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2317 if (group
->has_set_eth_dst
) {
2320 monitor_printf(mon
, " set");
2322 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2327 if (group
->has_ttl_check
&& group
->ttl_check
) {
2328 monitor_printf(mon
, " check TTL");
2331 if (group
->has_group_id
&& group
->group_id
) {
2332 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2335 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2336 monitor_printf(mon
, " pop vlan");
2339 if (group
->has_out_pport
) {
2340 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2343 if (group
->has_group_ids
) {
2344 struct uint32List
*id
;
2346 monitor_printf(mon
, " groups [");
2347 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2348 monitor_printf(mon
, "0x%08x", id
->value
);
2350 monitor_printf(mon
, ",");
2353 monitor_printf(mon
, "]");
2356 monitor_printf(mon
, "\n");
2359 qapi_free_RockerOfDpaGroupList(list
);