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 "ui/console.h"
34 #include "block/qapi.h"
38 #include <spice/enums.h>
41 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
45 error_report_err(*errp
);
49 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
53 info
= qmp_query_name(NULL
);
55 monitor_printf(mon
, "%s\n", info
->name
);
57 qapi_free_NameInfo(info
);
60 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
64 info
= qmp_query_version(NULL
);
66 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
67 info
->qemu
->major
, info
->qemu
->minor
, info
->qemu
->micro
,
70 qapi_free_VersionInfo(info
);
73 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
77 info
= qmp_query_kvm(NULL
);
78 monitor_printf(mon
, "kvm support: ");
80 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
82 monitor_printf(mon
, "not compiled\n");
85 qapi_free_KvmInfo(info
);
88 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
92 info
= qmp_query_status(NULL
);
94 monitor_printf(mon
, "VM status: %s%s",
95 info
->running
? "running" : "paused",
96 info
->singlestep
? " (single step mode)" : "");
98 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
99 monitor_printf(mon
, " (%s)", RunState_lookup
[info
->status
]);
102 monitor_printf(mon
, "\n");
104 qapi_free_StatusInfo(info
);
107 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
111 info
= qmp_query_uuid(NULL
);
112 monitor_printf(mon
, "%s\n", info
->UUID
);
113 qapi_free_UuidInfo(info
);
116 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
118 ChardevInfoList
*char_info
, *info
;
120 char_info
= qmp_query_chardev(NULL
);
121 for (info
= char_info
; info
; info
= info
->next
) {
122 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
123 info
->value
->filename
);
126 qapi_free_ChardevInfoList(char_info
);
129 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
131 MouseInfoList
*mice_list
, *mouse
;
133 mice_list
= qmp_query_mice(NULL
);
135 monitor_printf(mon
, "No mouse devices connected\n");
139 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
140 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
141 mouse
->value
->current
? '*' : ' ',
142 mouse
->value
->index
, mouse
->value
->name
,
143 mouse
->value
->absolute
? " (absolute)" : "");
146 qapi_free_MouseInfoList(mice_list
);
149 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
152 MigrationCapabilityStatusList
*caps
, *cap
;
154 info
= qmp_query_migrate(NULL
);
155 caps
= qmp_query_migrate_capabilities(NULL
);
157 /* do not display parameters during setup */
158 if (info
->has_status
&& caps
) {
159 monitor_printf(mon
, "capabilities: ");
160 for (cap
= caps
; cap
; cap
= cap
->next
) {
161 monitor_printf(mon
, "%s: %s ",
162 MigrationCapability_lookup
[cap
->value
->capability
],
163 cap
->value
->state
? "on" : "off");
165 monitor_printf(mon
, "\n");
168 if (info
->has_status
) {
169 monitor_printf(mon
, "Migration status: %s\n",
170 MigrationStatus_lookup
[info
->status
]);
171 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
173 if (info
->has_expected_downtime
) {
174 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
175 info
->expected_downtime
);
177 if (info
->has_downtime
) {
178 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
181 if (info
->has_setup_time
) {
182 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
188 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
189 info
->ram
->transferred
>> 10);
190 monitor_printf(mon
, "throughput: %0.2f mbps\n",
192 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
193 info
->ram
->remaining
>> 10);
194 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
195 info
->ram
->total
>> 10);
196 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
197 info
->ram
->duplicate
);
198 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
200 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
202 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
203 info
->ram
->normal_bytes
>> 10);
204 monitor_printf(mon
, "dirty sync count: %" PRIu64
"\n",
205 info
->ram
->dirty_sync_count
);
206 if (info
->ram
->dirty_pages_rate
) {
207 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
208 info
->ram
->dirty_pages_rate
);
212 if (info
->has_disk
) {
213 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
214 info
->disk
->transferred
>> 10);
215 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
216 info
->disk
->remaining
>> 10);
217 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
218 info
->disk
->total
>> 10);
221 if (info
->has_xbzrle_cache
) {
222 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
223 info
->xbzrle_cache
->cache_size
);
224 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
225 info
->xbzrle_cache
->bytes
>> 10);
226 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
227 info
->xbzrle_cache
->pages
);
228 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
229 info
->xbzrle_cache
->cache_miss
);
230 monitor_printf(mon
, "xbzrle cache miss rate: %0.2f\n",
231 info
->xbzrle_cache
->cache_miss_rate
);
232 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
233 info
->xbzrle_cache
->overflow
);
236 if (info
->has_x_cpu_throttle_percentage
) {
237 monitor_printf(mon
, "cpu throttle percentage: %" PRIu64
"\n",
238 info
->x_cpu_throttle_percentage
);
241 qapi_free_MigrationInfo(info
);
242 qapi_free_MigrationCapabilityStatusList(caps
);
245 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
247 MigrationCapabilityStatusList
*caps
, *cap
;
249 caps
= qmp_query_migrate_capabilities(NULL
);
252 monitor_printf(mon
, "capabilities: ");
253 for (cap
= caps
; cap
; cap
= cap
->next
) {
254 monitor_printf(mon
, "%s: %s ",
255 MigrationCapability_lookup
[cap
->value
->capability
],
256 cap
->value
->state
? "on" : "off");
258 monitor_printf(mon
, "\n");
261 qapi_free_MigrationCapabilityStatusList(caps
);
264 void hmp_info_migrate_parameters(Monitor
*mon
, const QDict
*qdict
)
266 MigrationParameters
*params
;
268 params
= qmp_query_migrate_parameters(NULL
);
271 monitor_printf(mon
, "parameters:");
272 monitor_printf(mon
, " %s: %" PRId64
,
273 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_LEVEL
],
274 params
->compress_level
);
275 monitor_printf(mon
, " %s: %" PRId64
,
276 MigrationParameter_lookup
[MIGRATION_PARAMETER_COMPRESS_THREADS
],
277 params
->compress_threads
);
278 monitor_printf(mon
, " %s: %" PRId64
,
279 MigrationParameter_lookup
[MIGRATION_PARAMETER_DECOMPRESS_THREADS
],
280 params
->decompress_threads
);
281 monitor_printf(mon
, " %s: %" PRId64
,
282 MigrationParameter_lookup
[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
],
283 params
->x_cpu_throttle_initial
);
284 monitor_printf(mon
, " %s: %" PRId64
,
285 MigrationParameter_lookup
[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
],
286 params
->x_cpu_throttle_increment
);
287 monitor_printf(mon
, "\n");
290 qapi_free_MigrationParameters(params
);
293 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
295 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
296 qmp_query_migrate_cache_size(NULL
) >> 10);
299 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
301 CpuInfoList
*cpu_list
, *cpu
;
303 cpu_list
= qmp_query_cpus(NULL
);
305 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
308 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
312 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
, cpu
->value
->CPU
);
314 switch (cpu
->value
->arch
) {
315 case CPU_INFO_ARCH_X86
:
316 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->u
.x86
->pc
);
318 case CPU_INFO_ARCH_PPC
:
319 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->u
.ppc
->nip
);
321 case CPU_INFO_ARCH_SPARC
:
322 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->u
.sparc
->pc
);
323 monitor_printf(mon
, " npc=0x%016" PRIx64
, cpu
->value
->u
.sparc
->npc
);
325 case CPU_INFO_ARCH_MIPS
:
326 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.mips
->PC
);
328 case CPU_INFO_ARCH_TRICORE
:
329 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.tricore
->PC
);
335 if (cpu
->value
->halted
) {
336 monitor_printf(mon
, " (halted)");
339 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
342 qapi_free_CpuInfoList(cpu_list
);
345 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
346 BlockDeviceInfo
*inserted
, bool verbose
)
348 ImageInfo
*image_info
;
350 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
353 monitor_printf(mon
, "%s", info
->device
);
354 if (inserted
&& inserted
->has_node_name
) {
355 monitor_printf(mon
, " (%s)", inserted
->node_name
);
359 monitor_printf(mon
, "%s",
360 inserted
->has_node_name
361 ? inserted
->node_name
366 monitor_printf(mon
, ": %s (%s%s%s)\n",
369 inserted
->ro
? ", read-only" : "",
370 inserted
->encrypted
? ", encrypted" : "");
372 monitor_printf(mon
, ": [not inserted]\n");
376 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
377 monitor_printf(mon
, " I/O status: %s\n",
378 BlockDeviceIoStatus_lookup
[info
->io_status
]);
381 if (info
->removable
) {
382 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
383 info
->locked
? "" : "not ",
384 info
->tray_open
? "open" : "closed");
393 monitor_printf(mon
, " Cache mode: %s%s%s\n",
394 inserted
->cache
->writeback
? "writeback" : "writethrough",
395 inserted
->cache
->direct
? ", direct" : "",
396 inserted
->cache
->no_flush
? ", ignore flushes" : "");
398 if (inserted
->has_backing_file
) {
401 "(chain depth: %" PRId64
")\n",
402 inserted
->backing_file
,
403 inserted
->backing_file_depth
);
406 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
407 monitor_printf(mon
, " Detect zeroes: %s\n",
408 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
411 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
412 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
414 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
415 " bps_rd=%" PRId64
" bps_wr=%" PRId64
417 " bps_rd_max=%" PRId64
418 " bps_wr_max=%" PRId64
419 " iops=%" PRId64
" iops_rd=%" PRId64
422 " iops_rd_max=%" PRId64
423 " iops_wr_max=%" PRId64
424 " iops_size=%" PRId64
430 inserted
->bps_rd_max
,
431 inserted
->bps_wr_max
,
436 inserted
->iops_rd_max
,
437 inserted
->iops_wr_max
,
443 monitor_printf(mon
, "\nImages:\n");
444 image_info
= inserted
->image
;
446 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
448 if (image_info
->has_backing_image
) {
449 image_info
= image_info
->backing_image
;
457 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
459 BlockInfoList
*block_list
, *info
;
460 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
461 const char *device
= qdict_get_try_str(qdict
, "device");
462 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
463 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
464 bool printed
= false;
466 /* Print BlockBackend information */
468 block_list
= qmp_query_block(NULL
);
473 for (info
= block_list
; info
; info
= info
->next
) {
474 if (device
&& strcmp(device
, info
->value
->device
)) {
478 if (info
!= block_list
) {
479 monitor_printf(mon
, "\n");
482 print_block_info(mon
, info
->value
, info
->value
->has_inserted
483 ? info
->value
->inserted
: NULL
,
488 qapi_free_BlockInfoList(block_list
);
490 if ((!device
&& !nodes
) || printed
) {
494 /* Print node information */
495 blockdev_list
= qmp_query_named_block_nodes(NULL
);
496 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
497 assert(blockdev
->value
->has_node_name
);
498 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
502 if (blockdev
!= blockdev_list
) {
503 monitor_printf(mon
, "\n");
506 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
508 qapi_free_BlockDeviceInfoList(blockdev_list
);
511 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
513 BlockStatsList
*stats_list
, *stats
;
515 stats_list
= qmp_query_blockstats(false, false, NULL
);
517 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
518 if (!stats
->value
->has_device
) {
522 monitor_printf(mon
, "%s:", stats
->value
->device
);
523 monitor_printf(mon
, " rd_bytes=%" PRId64
525 " rd_operations=%" PRId64
526 " wr_operations=%" PRId64
527 " flush_operations=%" PRId64
528 " wr_total_time_ns=%" PRId64
529 " rd_total_time_ns=%" PRId64
530 " flush_total_time_ns=%" PRId64
531 " rd_merged=%" PRId64
532 " wr_merged=%" PRId64
533 " idle_time_ns=%" PRId64
535 stats
->value
->stats
->rd_bytes
,
536 stats
->value
->stats
->wr_bytes
,
537 stats
->value
->stats
->rd_operations
,
538 stats
->value
->stats
->wr_operations
,
539 stats
->value
->stats
->flush_operations
,
540 stats
->value
->stats
->wr_total_time_ns
,
541 stats
->value
->stats
->rd_total_time_ns
,
542 stats
->value
->stats
->flush_total_time_ns
,
543 stats
->value
->stats
->rd_merged
,
544 stats
->value
->stats
->wr_merged
,
545 stats
->value
->stats
->idle_time_ns
);
548 qapi_free_BlockStatsList(stats_list
);
551 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
555 VncClientInfoList
*client
;
557 info
= qmp_query_vnc(&err
);
559 error_report_err(err
);
563 if (!info
->enabled
) {
564 monitor_printf(mon
, "Server: disabled\n");
568 monitor_printf(mon
, "Server:\n");
569 if (info
->has_host
&& info
->has_service
) {
570 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
572 if (info
->has_auth
) {
573 monitor_printf(mon
, " auth: %s\n", info
->auth
);
576 if (!info
->has_clients
|| info
->clients
== NULL
) {
577 monitor_printf(mon
, "Client: none\n");
579 for (client
= info
->clients
; client
; client
= client
->next
) {
580 monitor_printf(mon
, "Client:\n");
581 monitor_printf(mon
, " address: %s:%s\n",
583 client
->value
->service
);
584 monitor_printf(mon
, " x509_dname: %s\n",
585 client
->value
->x509_dname
?
586 client
->value
->x509_dname
: "none");
587 monitor_printf(mon
, " username: %s\n",
588 client
->value
->has_sasl_username
?
589 client
->value
->sasl_username
: "none");
594 qapi_free_VncInfo(info
);
598 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
600 SpiceChannelList
*chan
;
602 const char *channel_name
;
603 const char * const channel_names
[] = {
604 [SPICE_CHANNEL_MAIN
] = "main",
605 [SPICE_CHANNEL_DISPLAY
] = "display",
606 [SPICE_CHANNEL_INPUTS
] = "inputs",
607 [SPICE_CHANNEL_CURSOR
] = "cursor",
608 [SPICE_CHANNEL_PLAYBACK
] = "playback",
609 [SPICE_CHANNEL_RECORD
] = "record",
610 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
611 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
612 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
613 [SPICE_CHANNEL_PORT
] = "port",
615 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
616 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
617 * as quick fix for build failures with older versions. */
618 [SPICE_CHANNEL_WEBDAV
] = "webdav",
622 info
= qmp_query_spice(NULL
);
624 if (!info
->enabled
) {
625 monitor_printf(mon
, "Server: disabled\n");
629 monitor_printf(mon
, "Server:\n");
630 if (info
->has_port
) {
631 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
632 info
->host
, info
->port
);
634 if (info
->has_tls_port
) {
635 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
636 info
->host
, info
->tls_port
);
638 monitor_printf(mon
, " migrated: %s\n",
639 info
->migrated
? "true" : "false");
640 monitor_printf(mon
, " auth: %s\n", info
->auth
);
641 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
642 monitor_printf(mon
, " mouse-mode: %s\n",
643 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
645 if (!info
->has_channels
|| info
->channels
== NULL
) {
646 monitor_printf(mon
, "Channels: none\n");
648 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
649 monitor_printf(mon
, "Channel:\n");
650 monitor_printf(mon
, " address: %s:%s%s\n",
651 chan
->value
->host
, chan
->value
->port
,
652 chan
->value
->tls
? " [tls]" : "");
653 monitor_printf(mon
, " session: %" PRId64
"\n",
654 chan
->value
->connection_id
);
655 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
656 chan
->value
->channel_type
, chan
->value
->channel_id
);
658 channel_name
= "unknown";
659 if (chan
->value
->channel_type
> 0 &&
660 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
661 channel_names
[chan
->value
->channel_type
]) {
662 channel_name
= channel_names
[chan
->value
->channel_type
];
665 monitor_printf(mon
, " channel name: %s\n", channel_name
);
670 qapi_free_SpiceInfo(info
);
674 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
679 info
= qmp_query_balloon(&err
);
681 error_report_err(err
);
685 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
687 qapi_free_BalloonInfo(info
);
690 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
692 PciMemoryRegionList
*region
;
694 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
695 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
696 dev
->slot
, dev
->function
);
697 monitor_printf(mon
, " ");
699 if (dev
->class_info
->has_desc
) {
700 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
702 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
705 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
706 dev
->id
->vendor
, dev
->id
->device
);
709 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
712 if (dev
->has_pci_bridge
) {
713 monitor_printf(mon
, " BUS %" PRId64
".\n",
714 dev
->pci_bridge
->bus
->number
);
715 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
716 dev
->pci_bridge
->bus
->secondary
);
717 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
718 dev
->pci_bridge
->bus
->subordinate
);
720 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
721 dev
->pci_bridge
->bus
->io_range
->base
,
722 dev
->pci_bridge
->bus
->io_range
->limit
);
725 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
726 dev
->pci_bridge
->bus
->memory_range
->base
,
727 dev
->pci_bridge
->bus
->memory_range
->limit
);
729 monitor_printf(mon
, " prefetchable memory range "
730 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
731 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
732 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
735 for (region
= dev
->regions
; region
; region
= region
->next
) {
738 addr
= region
->value
->address
;
739 size
= region
->value
->size
;
741 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
743 if (!strcmp(region
->value
->type
, "io")) {
744 monitor_printf(mon
, "I/O at 0x%04" PRIx64
745 " [0x%04" PRIx64
"].\n",
746 addr
, addr
+ size
- 1);
748 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
749 " [0x%08" PRIx64
"].\n",
750 region
->value
->mem_type_64
? 64 : 32,
751 region
->value
->prefetch
? " prefetchable" : "",
752 addr
, addr
+ size
- 1);
756 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
758 if (dev
->has_pci_bridge
) {
759 if (dev
->pci_bridge
->has_devices
) {
760 PciDeviceInfoList
*cdev
;
761 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
762 hmp_info_pci_device(mon
, cdev
->value
);
768 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
770 PciInfoList
*info_list
, *info
;
773 info_list
= qmp_query_pci(&err
);
775 monitor_printf(mon
, "PCI devices not supported\n");
780 for (info
= info_list
; info
; info
= info
->next
) {
781 PciDeviceInfoList
*dev
;
783 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
784 hmp_info_pci_device(mon
, dev
->value
);
788 qapi_free_PciInfoList(info_list
);
791 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
793 BlockJobInfoList
*list
;
796 list
= qmp_query_block_jobs(&err
);
800 monitor_printf(mon
, "No active jobs\n");
805 if (strcmp(list
->value
->type
, "stream") == 0) {
806 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
807 " of %" PRId64
" bytes, speed limit %" PRId64
814 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
815 " of %" PRId64
" bytes, speed limit %" PRId64
826 qapi_free_BlockJobInfoList(list
);
829 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
831 TPMInfoList
*info_list
, *info
;
834 TPMPassthroughOptions
*tpo
;
836 info_list
= qmp_query_tpm(&err
);
838 monitor_printf(mon
, "TPM device not supported\n");
844 monitor_printf(mon
, "TPM device:\n");
847 for (info
= info_list
; info
; info
= info
->next
) {
848 TPMInfo
*ti
= info
->value
;
849 monitor_printf(mon
, " tpm%d: model=%s\n",
850 c
, TpmModel_lookup
[ti
->model
]);
852 monitor_printf(mon
, " \\ %s: type=%s",
853 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
855 switch (ti
->options
->type
) {
856 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
857 tpo
= ti
->options
->u
.passthrough
;
858 monitor_printf(mon
, "%s%s%s%s",
859 tpo
->has_path
? ",path=" : "",
860 tpo
->has_path
? tpo
->path
: "",
861 tpo
->has_cancel_path
? ",cancel-path=" : "",
862 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
864 case TPM_TYPE_OPTIONS_KIND__MAX
:
867 monitor_printf(mon
, "\n");
870 qapi_free_TPMInfoList(info_list
);
873 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
875 monitor_suspend(mon
);
879 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
884 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
886 qmp_system_reset(NULL
);
889 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
891 qmp_system_powerdown(NULL
);
894 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
898 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
899 use it are converted to the QAPI */
900 cpu_index
= qdict_get_int(qdict
, "index");
901 if (monitor_set_cpu(cpu_index
) < 0) {
902 monitor_printf(mon
, "invalid CPU index\n");
906 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
908 uint32_t size
= qdict_get_int(qdict
, "size");
909 const char *filename
= qdict_get_str(qdict
, "filename");
910 uint64_t addr
= qdict_get_int(qdict
, "val");
913 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
914 hmp_handle_error(mon
, &err
);
917 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
919 uint32_t size
= qdict_get_int(qdict
, "size");
920 const char *filename
= qdict_get_str(qdict
, "filename");
921 uint64_t addr
= qdict_get_int(qdict
, "val");
924 qmp_pmemsave(addr
, size
, filename
, &err
);
925 hmp_handle_error(mon
, &err
);
928 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
930 const char *chardev
= qdict_get_str(qdict
, "device");
931 const char *data
= qdict_get_str(qdict
, "data");
934 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
936 hmp_handle_error(mon
, &err
);
939 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
941 uint32_t size
= qdict_get_int(qdict
, "size");
942 const char *chardev
= qdict_get_str(qdict
, "device");
947 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
949 error_report_err(err
);
953 for (i
= 0; data
[i
]; i
++) {
954 unsigned char ch
= data
[i
];
957 monitor_printf(mon
, "\\\\");
958 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
959 monitor_printf(mon
, "\\u%04X", ch
);
961 monitor_printf(mon
, "%c", ch
);
965 monitor_printf(mon
, "\n");
969 static void hmp_cont_cb(void *opaque
, int err
)
976 static bool key_is_missing(const BlockInfo
*bdev
)
978 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
981 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
983 BlockInfoList
*bdev_list
, *bdev
;
986 bdev_list
= qmp_query_block(NULL
);
987 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
988 if (key_is_missing(bdev
->value
)) {
989 monitor_read_block_device_key(mon
, bdev
->value
->device
,
996 hmp_handle_error(mon
, &err
);
999 qapi_free_BlockInfoList(bdev_list
);
1002 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1004 qmp_system_wakeup(NULL
);
1007 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1011 qmp_inject_nmi(&err
);
1012 hmp_handle_error(mon
, &err
);
1015 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1017 const char *name
= qdict_get_str(qdict
, "name");
1018 bool up
= qdict_get_bool(qdict
, "up");
1021 qmp_set_link(name
, up
, &err
);
1022 hmp_handle_error(mon
, &err
);
1025 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1027 const char *device
= qdict_get_str(qdict
, "device");
1028 const char *password
= qdict_get_str(qdict
, "password");
1031 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1032 hmp_handle_error(mon
, &err
);
1035 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1037 int64_t value
= qdict_get_int(qdict
, "value");
1040 qmp_balloon(value
, &err
);
1042 error_report_err(err
);
1046 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1048 const char *device
= qdict_get_str(qdict
, "device");
1049 int64_t size
= qdict_get_int(qdict
, "size");
1052 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1053 hmp_handle_error(mon
, &err
);
1056 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1058 const char *device
= qdict_get_str(qdict
, "device");
1059 const char *filename
= qdict_get_str(qdict
, "target");
1060 const char *format
= qdict_get_try_str(qdict
, "format");
1061 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1062 bool full
= qdict_get_try_bool(qdict
, "full", false);
1063 enum NewImageMode mode
;
1067 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1068 hmp_handle_error(mon
, &err
);
1073 mode
= NEW_IMAGE_MODE_EXISTING
;
1075 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1078 qmp_drive_mirror(device
, filename
, !!format
, format
,
1079 false, NULL
, false, NULL
,
1080 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1081 true, mode
, false, 0, false, 0, false, 0,
1082 false, 0, false, 0, false, true, &err
);
1083 hmp_handle_error(mon
, &err
);
1086 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1088 const char *device
= qdict_get_str(qdict
, "device");
1089 const char *filename
= qdict_get_str(qdict
, "target");
1090 const char *format
= qdict_get_try_str(qdict
, "format");
1091 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1092 bool full
= qdict_get_try_bool(qdict
, "full", false);
1093 enum NewImageMode mode
;
1097 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1098 hmp_handle_error(mon
, &err
);
1103 mode
= NEW_IMAGE_MODE_EXISTING
;
1105 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1108 qmp_drive_backup(device
, filename
, !!format
, format
,
1109 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1110 true, mode
, false, 0, false, NULL
,
1111 false, 0, false, 0, &err
);
1112 hmp_handle_error(mon
, &err
);
1115 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1117 const char *device
= qdict_get_str(qdict
, "device");
1118 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1119 const char *format
= qdict_get_try_str(qdict
, "format");
1120 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1121 enum NewImageMode mode
;
1125 /* In the future, if 'snapshot-file' is not specified, the snapshot
1126 will be taken internally. Today it's actually required. */
1127 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1128 hmp_handle_error(mon
, &err
);
1132 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1133 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1134 filename
, false, NULL
,
1137 hmp_handle_error(mon
, &err
);
1140 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1142 const char *device
= qdict_get_str(qdict
, "device");
1143 const char *name
= qdict_get_str(qdict
, "name");
1146 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1147 hmp_handle_error(mon
, &err
);
1150 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1152 const char *device
= qdict_get_str(qdict
, "device");
1153 const char *name
= qdict_get_str(qdict
, "name");
1154 const char *id
= qdict_get_try_str(qdict
, "id");
1157 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1159 hmp_handle_error(mon
, &err
);
1162 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1164 qmp_migrate_cancel(NULL
);
1167 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1170 const char *uri
= qdict_get_str(qdict
, "uri");
1172 qmp_migrate_incoming(uri
, &err
);
1174 hmp_handle_error(mon
, &err
);
1177 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1179 double value
= qdict_get_double(qdict
, "value");
1180 qmp_migrate_set_downtime(value
, NULL
);
1183 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1185 int64_t value
= qdict_get_int(qdict
, "value");
1188 qmp_migrate_set_cache_size(value
, &err
);
1190 error_report_err(err
);
1195 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1197 int64_t value
= qdict_get_int(qdict
, "value");
1198 qmp_migrate_set_speed(value
, NULL
);
1201 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1203 const char *cap
= qdict_get_str(qdict
, "capability");
1204 bool state
= qdict_get_bool(qdict
, "state");
1206 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1209 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1210 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1211 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1212 caps
->value
->capability
= i
;
1213 caps
->value
->state
= state
;
1215 qmp_migrate_set_capabilities(caps
, &err
);
1220 if (i
== MIGRATION_CAPABILITY__MAX
) {
1221 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1224 qapi_free_MigrationCapabilityStatusList(caps
);
1227 error_report_err(err
);
1231 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1233 const char *param
= qdict_get_str(qdict
, "parameter");
1234 int value
= qdict_get_int(qdict
, "value");
1236 bool has_compress_level
= false;
1237 bool has_compress_threads
= false;
1238 bool has_decompress_threads
= false;
1239 bool has_x_cpu_throttle_initial
= false;
1240 bool has_x_cpu_throttle_increment
= false;
1243 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1244 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1246 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1247 has_compress_level
= true;
1249 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1250 has_compress_threads
= true;
1252 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1253 has_decompress_threads
= true;
1255 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
:
1256 has_x_cpu_throttle_initial
= true;
1258 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
:
1259 has_x_cpu_throttle_increment
= true;
1262 qmp_migrate_set_parameters(has_compress_level
, value
,
1263 has_compress_threads
, value
,
1264 has_decompress_threads
, value
,
1265 has_x_cpu_throttle_initial
, value
,
1266 has_x_cpu_throttle_increment
, value
,
1272 if (i
== MIGRATION_PARAMETER__MAX
) {
1273 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1277 error_report_err(err
);
1281 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1284 const char *protocol
= qdict_get_str(qdict
, "protocol");
1285 const char *hostname
= qdict_get_str(qdict
, "hostname");
1286 bool has_port
= qdict_haskey(qdict
, "port");
1287 int port
= qdict_get_try_int(qdict
, "port", -1);
1288 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1289 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1290 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1292 qmp_client_migrate_info(protocol
, hostname
,
1293 has_port
, port
, has_tls_port
, tls_port
,
1294 !!cert_subject
, cert_subject
, &err
);
1295 hmp_handle_error(mon
, &err
);
1298 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1301 qmp_migrate_start_postcopy(&err
);
1302 hmp_handle_error(mon
, &err
);
1305 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1307 const char *protocol
= qdict_get_str(qdict
, "protocol");
1308 const char *password
= qdict_get_str(qdict
, "password");
1309 const char *connected
= qdict_get_try_str(qdict
, "connected");
1312 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1313 hmp_handle_error(mon
, &err
);
1316 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1318 const char *protocol
= qdict_get_str(qdict
, "protocol");
1319 const char *whenstr
= qdict_get_str(qdict
, "time");
1322 qmp_expire_password(protocol
, whenstr
, &err
);
1323 hmp_handle_error(mon
, &err
);
1326 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1328 bool force
= qdict_get_try_bool(qdict
, "force", false);
1329 const char *device
= qdict_get_str(qdict
, "device");
1332 qmp_eject(device
, true, force
, &err
);
1333 hmp_handle_error(mon
, &err
);
1336 static void hmp_change_read_arg(void *opaque
, const char *password
,
1337 void *readline_opaque
)
1339 qmp_change_vnc_password(password
, NULL
);
1340 monitor_read_command(opaque
, 1);
1343 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1345 const char *device
= qdict_get_str(qdict
, "device");
1346 const char *target
= qdict_get_str(qdict
, "target");
1347 const char *arg
= qdict_get_try_str(qdict
, "arg");
1348 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1349 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1352 if (strcmp(device
, "vnc") == 0) {
1355 "Parameter 'read-only-mode' is invalid for VNC\n");
1358 if (strcmp(target
, "passwd") == 0 ||
1359 strcmp(target
, "password") == 0) {
1361 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1365 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1369 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1370 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1371 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1373 hmp_handle_error(mon
, &err
);
1378 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1379 !!read_only
, read_only_mode
, &err
);
1381 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1383 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1388 hmp_handle_error(mon
, &err
);
1391 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1395 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1396 qdict_get_int(qdict
, "bps"),
1397 qdict_get_int(qdict
, "bps_rd"),
1398 qdict_get_int(qdict
, "bps_wr"),
1399 qdict_get_int(qdict
, "iops"),
1400 qdict_get_int(qdict
, "iops_rd"),
1401 qdict_get_int(qdict
, "iops_wr"),
1402 false, /* no burst max via HMP */
1414 false, /* No default I/O size */
1418 hmp_handle_error(mon
, &err
);
1421 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1423 Error
*error
= NULL
;
1424 const char *device
= qdict_get_str(qdict
, "device");
1425 const char *base
= qdict_get_try_str(qdict
, "base");
1426 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1428 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1429 qdict_haskey(qdict
, "speed"), speed
,
1430 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1432 hmp_handle_error(mon
, &error
);
1435 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1437 Error
*error
= NULL
;
1438 const char *device
= qdict_get_str(qdict
, "device");
1439 int64_t value
= qdict_get_int(qdict
, "speed");
1441 qmp_block_job_set_speed(device
, value
, &error
);
1443 hmp_handle_error(mon
, &error
);
1446 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1448 Error
*error
= NULL
;
1449 const char *device
= qdict_get_str(qdict
, "device");
1450 bool force
= qdict_get_try_bool(qdict
, "force", false);
1452 qmp_block_job_cancel(device
, true, force
, &error
);
1454 hmp_handle_error(mon
, &error
);
1457 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1459 Error
*error
= NULL
;
1460 const char *device
= qdict_get_str(qdict
, "device");
1462 qmp_block_job_pause(device
, &error
);
1464 hmp_handle_error(mon
, &error
);
1467 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1469 Error
*error
= NULL
;
1470 const char *device
= qdict_get_str(qdict
, "device");
1472 qmp_block_job_resume(device
, &error
);
1474 hmp_handle_error(mon
, &error
);
1477 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1479 Error
*error
= NULL
;
1480 const char *device
= qdict_get_str(qdict
, "device");
1482 qmp_block_job_complete(device
, &error
);
1484 hmp_handle_error(mon
, &error
);
1487 typedef struct HMPMigrationStatus
1491 bool is_block_migration
;
1492 } HMPMigrationStatus
;
1494 static void hmp_migrate_status_cb(void *opaque
)
1496 HMPMigrationStatus
*status
= opaque
;
1497 MigrationInfo
*info
;
1499 info
= qmp_query_migrate(NULL
);
1500 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1501 info
->status
== MIGRATION_STATUS_SETUP
) {
1502 if (info
->has_disk
) {
1505 if (info
->disk
->remaining
) {
1506 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1511 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1512 monitor_flush(status
->mon
);
1515 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1517 if (status
->is_block_migration
) {
1518 monitor_printf(status
->mon
, "\n");
1520 monitor_resume(status
->mon
);
1521 timer_del(status
->timer
);
1525 qapi_free_MigrationInfo(info
);
1528 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1530 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1531 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1532 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1533 const char *uri
= qdict_get_str(qdict
, "uri");
1536 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1538 error_report_err(err
);
1543 HMPMigrationStatus
*status
;
1545 if (monitor_suspend(mon
) < 0) {
1546 monitor_printf(mon
, "terminal does not allow synchronous "
1547 "migration, continuing detached\n");
1551 status
= g_malloc0(sizeof(*status
));
1553 status
->is_block_migration
= blk
|| inc
;
1554 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1556 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1560 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1564 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1565 hmp_handle_error(mon
, &err
);
1568 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1570 const char *id
= qdict_get_str(qdict
, "id");
1573 qmp_device_del(id
, &err
);
1574 hmp_handle_error(mon
, &err
);
1577 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1580 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1581 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1582 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1583 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1584 const char *file
= qdict_get_str(qdict
, "filename");
1585 bool has_begin
= qdict_haskey(qdict
, "begin");
1586 bool has_length
= qdict_haskey(qdict
, "length");
1589 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1592 if (zlib
+ lzo
+ snappy
> 1) {
1593 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1594 hmp_handle_error(mon
, &err
);
1599 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1603 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1607 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1611 begin
= qdict_get_int(qdict
, "begin");
1614 length
= qdict_get_int(qdict
, "length");
1617 prot
= g_strconcat("file:", file
, NULL
);
1619 qmp_dump_guest_memory(paging
, prot
, has_begin
, begin
, has_length
, length
,
1620 true, dump_format
, &err
);
1621 hmp_handle_error(mon
, &err
);
1625 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1630 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1635 netdev_add(opts
, &err
);
1637 qemu_opts_del(opts
);
1641 hmp_handle_error(mon
, &err
);
1644 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1646 const char *id
= qdict_get_str(qdict
, "id");
1649 qmp_netdev_del(id
, &err
);
1650 hmp_handle_error(mon
, &err
);
1653 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1656 Error
*err_end
= NULL
;
1664 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1669 ov
= opts_visitor_new(opts
);
1670 pdict
= qdict_clone_shallow(qdict
);
1672 visit_start_struct(opts_get_visitor(ov
), &dummy
, NULL
, NULL
, 0, &err
);
1677 qdict_del(pdict
, "qom-type");
1678 visit_type_str(opts_get_visitor(ov
), &type
, "qom-type", &err
);
1683 qdict_del(pdict
, "id");
1684 visit_type_str(opts_get_visitor(ov
), &id
, "id", &err
);
1689 object_add(type
, id
, pdict
, opts_get_visitor(ov
), &err
);
1692 visit_end_struct(opts_get_visitor(ov
), &err_end
);
1693 if (!err
&& err_end
) {
1694 qmp_object_del(id
, NULL
);
1696 error_propagate(&err
, err_end
);
1698 opts_visitor_cleanup(ov
);
1701 qemu_opts_del(opts
);
1707 hmp_handle_error(mon
, &err
);
1710 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1712 const char *fdname
= qdict_get_str(qdict
, "fdname");
1715 qmp_getfd(fdname
, &err
);
1716 hmp_handle_error(mon
, &err
);
1719 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1721 const char *fdname
= qdict_get_str(qdict
, "fdname");
1724 qmp_closefd(fdname
, &err
);
1725 hmp_handle_error(mon
, &err
);
1728 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1730 const char *keys
= qdict_get_str(qdict
, "keys");
1731 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1732 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1733 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1739 separator
= strchr(keys
, '-');
1740 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1742 /* Be compatible with old interface, convert user inputted "<" */
1743 if (keys
[0] == '<' && keyname_len
== 1) {
1748 keylist
= g_malloc0(sizeof(*keylist
));
1749 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1755 tmp
->next
= keylist
;
1759 if (strstart(keys
, "0x", NULL
)) {
1761 int value
= strtoul(keys
, &endp
, 0);
1762 assert(endp
<= keys
+ keyname_len
);
1763 if (endp
!= keys
+ keyname_len
) {
1766 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1767 keylist
->value
->u
.number
= value
;
1769 int idx
= index_from_key(keys
, keyname_len
);
1770 if (idx
== Q_KEY_CODE__MAX
) {
1773 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1774 keylist
->value
->u
.qcode
= idx
;
1780 keys
= separator
+ 1;
1783 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1784 hmp_handle_error(mon
, &err
);
1787 qapi_free_KeyValueList(head
);
1791 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1795 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1797 const char *filename
= qdict_get_str(qdict
, "filename");
1800 qmp_screendump(filename
, &err
);
1801 hmp_handle_error(mon
, &err
);
1804 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1806 const char *uri
= qdict_get_str(qdict
, "uri");
1807 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1808 bool all
= qdict_get_try_bool(qdict
, "all", false);
1809 Error
*local_err
= NULL
;
1810 BlockInfoList
*block_list
, *info
;
1811 SocketAddress
*addr
;
1813 if (writable
&& !all
) {
1814 error_setg(&local_err
, "-w only valid together with -a");
1818 /* First check if the address is valid and start the server. */
1819 addr
= socket_parse(uri
, &local_err
);
1820 if (local_err
!= NULL
) {
1824 qmp_nbd_server_start(addr
, &local_err
);
1825 qapi_free_SocketAddress(addr
);
1826 if (local_err
!= NULL
) {
1834 /* Then try adding all block devices. If one fails, close all and
1837 block_list
= qmp_query_block(NULL
);
1839 for (info
= block_list
; info
; info
= info
->next
) {
1840 if (!info
->value
->has_inserted
) {
1844 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1846 if (local_err
!= NULL
) {
1847 qmp_nbd_server_stop(NULL
);
1852 qapi_free_BlockInfoList(block_list
);
1855 hmp_handle_error(mon
, &local_err
);
1858 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1860 const char *device
= qdict_get_str(qdict
, "device");
1861 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1862 Error
*local_err
= NULL
;
1864 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1866 if (local_err
!= NULL
) {
1867 hmp_handle_error(mon
, &local_err
);
1871 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1875 qmp_nbd_server_stop(&err
);
1876 hmp_handle_error(mon
, &err
);
1879 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1884 cpuid
= qdict_get_int(qdict
, "id");
1885 qmp_cpu_add(cpuid
, &err
);
1886 hmp_handle_error(mon
, &err
);
1889 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1891 const char *args
= qdict_get_str(qdict
, "args");
1895 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1897 error_setg(&err
, "Parsing chardev args failed");
1899 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1901 hmp_handle_error(mon
, &err
);
1904 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1906 Error
*local_err
= NULL
;
1908 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1909 hmp_handle_error(mon
, &local_err
);
1912 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1915 const char* device
= qdict_get_str(qdict
, "device");
1916 const char* command
= qdict_get_str(qdict
, "command");
1919 blk
= blk_by_name(device
);
1921 qemuio_command(blk
, command
);
1923 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1924 "Device '%s' not found", device
);
1927 hmp_handle_error(mon
, &err
);
1930 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1932 const char *id
= qdict_get_str(qdict
, "id");
1935 qmp_object_del(id
, &err
);
1936 hmp_handle_error(mon
, &err
);
1939 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1942 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1943 MemdevList
*m
= memdev_list
;
1944 StringOutputVisitor
*ov
;
1950 ov
= string_output_visitor_new(false);
1951 visit_type_uint16List(string_output_get_visitor(ov
),
1952 &m
->value
->host_nodes
, NULL
, NULL
);
1953 monitor_printf(mon
, "memory backend: %d\n", i
);
1954 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1955 monitor_printf(mon
, " merge: %s\n",
1956 m
->value
->merge
? "true" : "false");
1957 monitor_printf(mon
, " dump: %s\n",
1958 m
->value
->dump
? "true" : "false");
1959 monitor_printf(mon
, " prealloc: %s\n",
1960 m
->value
->prealloc
? "true" : "false");
1961 monitor_printf(mon
, " policy: %s\n",
1962 HostMemPolicy_lookup
[m
->value
->policy
]);
1963 str
= string_output_get_string(ov
);
1964 monitor_printf(mon
, " host nodes: %s\n", str
);
1967 string_output_visitor_cleanup(ov
);
1972 monitor_printf(mon
, "\n");
1974 qapi_free_MemdevList(memdev_list
);
1977 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1980 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1981 MemoryDeviceInfoList
*info
;
1982 MemoryDeviceInfo
*value
;
1983 PCDIMMDeviceInfo
*di
;
1985 for (info
= info_list
; info
; info
= info
->next
) {
1986 value
= info
->value
;
1989 switch (value
->type
) {
1990 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1993 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1994 MemoryDeviceInfoKind_lookup
[value
->type
],
1995 di
->id
? di
->id
: "");
1996 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1997 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
1998 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
1999 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2000 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2001 monitor_printf(mon
, " hotplugged: %s\n",
2002 di
->hotplugged
? "true" : "false");
2003 monitor_printf(mon
, " hotpluggable: %s\n",
2004 di
->hotpluggable
? "true" : "false");
2012 qapi_free_MemoryDeviceInfoList(info_list
);
2015 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2017 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2018 IOThreadInfoList
*info
;
2020 for (info
= info_list
; info
; info
= info
->next
) {
2021 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2022 info
->value
->id
, info
->value
->thread_id
);
2025 qapi_free_IOThreadInfoList(info_list
);
2028 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2030 const char *path
= qdict_get_try_str(qdict
, "path");
2031 ObjectPropertyInfoList
*list
;
2035 monitor_printf(mon
, "/\n");
2039 list
= qmp_qom_list(path
, &err
);
2041 ObjectPropertyInfoList
*start
= list
;
2042 while (list
!= NULL
) {
2043 ObjectPropertyInfo
*value
= list
->value
;
2045 monitor_printf(mon
, "%s (%s)\n",
2046 value
->name
, value
->type
);
2049 qapi_free_ObjectPropertyInfoList(start
);
2051 hmp_handle_error(mon
, &err
);
2054 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2056 const char *path
= qdict_get_str(qdict
, "path");
2057 const char *property
= qdict_get_str(qdict
, "property");
2058 const char *value
= qdict_get_str(qdict
, "value");
2060 bool ambiguous
= false;
2063 obj
= object_resolve_path(path
, &ambiguous
);
2065 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2066 "Device '%s' not found", path
);
2069 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2071 object_property_parse(obj
, value
, property
, &err
);
2073 hmp_handle_error(mon
, &err
);
2076 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2078 const char *name
= qdict_get_str(qdict
, "name");
2079 RockerSwitch
*rocker
;
2082 rocker
= qmp_query_rocker(name
, &err
);
2084 hmp_handle_error(mon
, &err
);
2088 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2089 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2090 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2092 qapi_free_RockerSwitch(rocker
);
2095 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2097 RockerPortList
*list
, *port
;
2098 const char *name
= qdict_get_str(qdict
, "name");
2101 list
= qmp_query_rocker_ports(name
, &err
);
2103 hmp_handle_error(mon
, &err
);
2107 monitor_printf(mon
, " ena/ speed/ auto\n");
2108 monitor_printf(mon
, " port link duplex neg?\n");
2110 for (port
= list
; port
; port
= port
->next
) {
2111 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2113 port
->value
->enabled
? port
->value
->link_up
?
2114 "up" : "down" : "!ena",
2115 port
->value
->speed
== 10000 ? "10G" : "??",
2116 port
->value
->duplex
? "FD" : "HD",
2117 port
->value
->autoneg
? "Yes" : "No");
2120 qapi_free_RockerPortList(list
);
2123 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2125 RockerOfDpaFlowList
*list
, *info
;
2126 const char *name
= qdict_get_str(qdict
, "name");
2127 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2130 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2132 hmp_handle_error(mon
, &err
);
2136 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2138 for (info
= list
; info
; info
= info
->next
) {
2139 RockerOfDpaFlow
*flow
= info
->value
;
2140 RockerOfDpaFlowKey
*key
= flow
->key
;
2141 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2142 RockerOfDpaFlowAction
*action
= flow
->action
;
2145 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2146 key
->priority
, key
->tbl_id
, flow
->hits
);
2148 monitor_printf(mon
, "%-4d %-3d ",
2149 key
->priority
, key
->tbl_id
);
2152 if (key
->has_in_pport
) {
2153 monitor_printf(mon
, " pport %d", key
->in_pport
);
2154 if (mask
->has_in_pport
) {
2155 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2159 if (key
->has_vlan_id
) {
2160 monitor_printf(mon
, " vlan %d",
2161 key
->vlan_id
& VLAN_VID_MASK
);
2162 if (mask
->has_vlan_id
) {
2163 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2167 if (key
->has_tunnel_id
) {
2168 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2169 if (mask
->has_tunnel_id
) {
2170 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2174 if (key
->has_eth_type
) {
2175 switch (key
->eth_type
) {
2177 monitor_printf(mon
, " ARP");
2180 monitor_printf(mon
, " IP");
2183 monitor_printf(mon
, " IPv6");
2186 monitor_printf(mon
, " LACP");
2189 monitor_printf(mon
, " LLDP");
2192 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2197 if (key
->has_eth_src
) {
2198 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2199 (mask
->has_eth_src
) &&
2200 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2201 monitor_printf(mon
, " src <any mcast/bcast>");
2202 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2203 (mask
->has_eth_src
) &&
2204 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2205 monitor_printf(mon
, " src <any ucast>");
2207 monitor_printf(mon
, " src %s", key
->eth_src
);
2208 if (mask
->has_eth_src
) {
2209 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2214 if (key
->has_eth_dst
) {
2215 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2216 (mask
->has_eth_dst
) &&
2217 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2218 monitor_printf(mon
, " dst <any mcast/bcast>");
2219 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2220 (mask
->has_eth_dst
) &&
2221 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2222 monitor_printf(mon
, " dst <any ucast>");
2224 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2225 if (mask
->has_eth_dst
) {
2226 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2231 if (key
->has_ip_proto
) {
2232 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2233 if (mask
->has_ip_proto
) {
2234 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2238 if (key
->has_ip_tos
) {
2239 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2240 if (mask
->has_ip_tos
) {
2241 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2245 if (key
->has_ip_dst
) {
2246 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2249 if (action
->has_goto_tbl
|| action
->has_group_id
||
2250 action
->has_new_vlan_id
) {
2251 monitor_printf(mon
, " -->");
2254 if (action
->has_new_vlan_id
) {
2255 monitor_printf(mon
, " apply new vlan %d",
2256 ntohs(action
->new_vlan_id
));
2259 if (action
->has_group_id
) {
2260 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2263 if (action
->has_goto_tbl
) {
2264 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2267 monitor_printf(mon
, "\n");
2270 qapi_free_RockerOfDpaFlowList(list
);
2273 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2275 RockerOfDpaGroupList
*list
, *g
;
2276 const char *name
= qdict_get_str(qdict
, "name");
2277 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2281 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2283 hmp_handle_error(mon
, &err
);
2287 monitor_printf(mon
, "id (decode) --> buckets\n");
2289 for (g
= list
; g
; g
= g
->next
) {
2290 RockerOfDpaGroup
*group
= g
->value
;
2292 monitor_printf(mon
, "0x%08x", group
->id
);
2294 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2295 group
->type
== 1 ? "L2 rewrite" :
2296 group
->type
== 2 ? "L3 unicast" :
2297 group
->type
== 3 ? "L2 multicast" :
2298 group
->type
== 4 ? "L2 flood" :
2299 group
->type
== 5 ? "L3 interface" :
2300 group
->type
== 6 ? "L3 multicast" :
2301 group
->type
== 7 ? "L3 ECMP" :
2302 group
->type
== 8 ? "L2 overlay" :
2305 if (group
->has_vlan_id
) {
2306 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2309 if (group
->has_pport
) {
2310 monitor_printf(mon
, " pport %d", group
->pport
);
2313 if (group
->has_index
) {
2314 monitor_printf(mon
, " index %d", group
->index
);
2317 monitor_printf(mon
, ") -->");
2319 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2321 monitor_printf(mon
, " set vlan %d",
2322 group
->set_vlan_id
& VLAN_VID_MASK
);
2325 if (group
->has_set_eth_src
) {
2328 monitor_printf(mon
, " set");
2330 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2333 if (group
->has_set_eth_dst
) {
2336 monitor_printf(mon
, " set");
2338 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2343 if (group
->has_ttl_check
&& group
->ttl_check
) {
2344 monitor_printf(mon
, " check TTL");
2347 if (group
->has_group_id
&& group
->group_id
) {
2348 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2351 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2352 monitor_printf(mon
, " pop vlan");
2355 if (group
->has_out_pport
) {
2356 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2359 if (group
->has_group_ids
) {
2360 struct uint32List
*id
;
2362 monitor_printf(mon
, " groups [");
2363 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2364 monitor_printf(mon
, "0x%08x", id
->value
);
2366 monitor_printf(mon
, ",");
2369 monitor_printf(mon
, "]");
2372 monitor_printf(mon
, "\n");
2375 qapi_free_RockerOfDpaGroupList(list
);