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
,
323 cpu
->value
->u
.q_sparc
->pc
);
324 monitor_printf(mon
, " npc=0x%016" PRIx64
,
325 cpu
->value
->u
.q_sparc
->npc
);
327 case CPU_INFO_ARCH_MIPS
:
328 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.q_mips
->PC
);
330 case CPU_INFO_ARCH_TRICORE
:
331 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->u
.tricore
->PC
);
337 if (cpu
->value
->halted
) {
338 monitor_printf(mon
, " (halted)");
341 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
344 qapi_free_CpuInfoList(cpu_list
);
347 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
348 BlockDeviceInfo
*inserted
, bool verbose
)
350 ImageInfo
*image_info
;
352 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
355 monitor_printf(mon
, "%s", info
->device
);
356 if (inserted
&& inserted
->has_node_name
) {
357 monitor_printf(mon
, " (%s)", inserted
->node_name
);
361 monitor_printf(mon
, "%s",
362 inserted
->has_node_name
363 ? inserted
->node_name
368 monitor_printf(mon
, ": %s (%s%s%s)\n",
371 inserted
->ro
? ", read-only" : "",
372 inserted
->encrypted
? ", encrypted" : "");
374 monitor_printf(mon
, ": [not inserted]\n");
378 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
379 monitor_printf(mon
, " I/O status: %s\n",
380 BlockDeviceIoStatus_lookup
[info
->io_status
]);
383 if (info
->removable
) {
384 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
385 info
->locked
? "" : "not ",
386 info
->tray_open
? "open" : "closed");
395 monitor_printf(mon
, " Cache mode: %s%s%s\n",
396 inserted
->cache
->writeback
? "writeback" : "writethrough",
397 inserted
->cache
->direct
? ", direct" : "",
398 inserted
->cache
->no_flush
? ", ignore flushes" : "");
400 if (inserted
->has_backing_file
) {
403 "(chain depth: %" PRId64
")\n",
404 inserted
->backing_file
,
405 inserted
->backing_file_depth
);
408 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
409 monitor_printf(mon
, " Detect zeroes: %s\n",
410 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
413 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
414 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
416 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
417 " bps_rd=%" PRId64
" bps_wr=%" PRId64
419 " bps_rd_max=%" PRId64
420 " bps_wr_max=%" PRId64
421 " iops=%" PRId64
" iops_rd=%" PRId64
424 " iops_rd_max=%" PRId64
425 " iops_wr_max=%" PRId64
426 " iops_size=%" PRId64
432 inserted
->bps_rd_max
,
433 inserted
->bps_wr_max
,
438 inserted
->iops_rd_max
,
439 inserted
->iops_wr_max
,
445 monitor_printf(mon
, "\nImages:\n");
446 image_info
= inserted
->image
;
448 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
450 if (image_info
->has_backing_image
) {
451 image_info
= image_info
->backing_image
;
459 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
461 BlockInfoList
*block_list
, *info
;
462 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
463 const char *device
= qdict_get_try_str(qdict
, "device");
464 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
465 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
466 bool printed
= false;
468 /* Print BlockBackend information */
470 block_list
= qmp_query_block(NULL
);
475 for (info
= block_list
; info
; info
= info
->next
) {
476 if (device
&& strcmp(device
, info
->value
->device
)) {
480 if (info
!= block_list
) {
481 monitor_printf(mon
, "\n");
484 print_block_info(mon
, info
->value
, info
->value
->has_inserted
485 ? info
->value
->inserted
: NULL
,
490 qapi_free_BlockInfoList(block_list
);
492 if ((!device
&& !nodes
) || printed
) {
496 /* Print node information */
497 blockdev_list
= qmp_query_named_block_nodes(NULL
);
498 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
499 assert(blockdev
->value
->has_node_name
);
500 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
504 if (blockdev
!= blockdev_list
) {
505 monitor_printf(mon
, "\n");
508 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
510 qapi_free_BlockDeviceInfoList(blockdev_list
);
513 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
515 BlockStatsList
*stats_list
, *stats
;
517 stats_list
= qmp_query_blockstats(false, false, NULL
);
519 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
520 if (!stats
->value
->has_device
) {
524 monitor_printf(mon
, "%s:", stats
->value
->device
);
525 monitor_printf(mon
, " rd_bytes=%" PRId64
527 " rd_operations=%" PRId64
528 " wr_operations=%" PRId64
529 " flush_operations=%" PRId64
530 " wr_total_time_ns=%" PRId64
531 " rd_total_time_ns=%" PRId64
532 " flush_total_time_ns=%" PRId64
533 " rd_merged=%" PRId64
534 " wr_merged=%" PRId64
535 " idle_time_ns=%" PRId64
537 stats
->value
->stats
->rd_bytes
,
538 stats
->value
->stats
->wr_bytes
,
539 stats
->value
->stats
->rd_operations
,
540 stats
->value
->stats
->wr_operations
,
541 stats
->value
->stats
->flush_operations
,
542 stats
->value
->stats
->wr_total_time_ns
,
543 stats
->value
->stats
->rd_total_time_ns
,
544 stats
->value
->stats
->flush_total_time_ns
,
545 stats
->value
->stats
->rd_merged
,
546 stats
->value
->stats
->wr_merged
,
547 stats
->value
->stats
->idle_time_ns
);
550 qapi_free_BlockStatsList(stats_list
);
553 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
557 VncClientInfoList
*client
;
559 info
= qmp_query_vnc(&err
);
561 error_report_err(err
);
565 if (!info
->enabled
) {
566 monitor_printf(mon
, "Server: disabled\n");
570 monitor_printf(mon
, "Server:\n");
571 if (info
->has_host
&& info
->has_service
) {
572 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
574 if (info
->has_auth
) {
575 monitor_printf(mon
, " auth: %s\n", info
->auth
);
578 if (!info
->has_clients
|| info
->clients
== NULL
) {
579 monitor_printf(mon
, "Client: none\n");
581 for (client
= info
->clients
; client
; client
= client
->next
) {
582 monitor_printf(mon
, "Client:\n");
583 monitor_printf(mon
, " address: %s:%s\n",
585 client
->value
->service
);
586 monitor_printf(mon
, " x509_dname: %s\n",
587 client
->value
->x509_dname
?
588 client
->value
->x509_dname
: "none");
589 monitor_printf(mon
, " username: %s\n",
590 client
->value
->has_sasl_username
?
591 client
->value
->sasl_username
: "none");
596 qapi_free_VncInfo(info
);
600 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
602 SpiceChannelList
*chan
;
604 const char *channel_name
;
605 const char * const channel_names
[] = {
606 [SPICE_CHANNEL_MAIN
] = "main",
607 [SPICE_CHANNEL_DISPLAY
] = "display",
608 [SPICE_CHANNEL_INPUTS
] = "inputs",
609 [SPICE_CHANNEL_CURSOR
] = "cursor",
610 [SPICE_CHANNEL_PLAYBACK
] = "playback",
611 [SPICE_CHANNEL_RECORD
] = "record",
612 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
613 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
614 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
615 [SPICE_CHANNEL_PORT
] = "port",
617 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
618 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
619 * as quick fix for build failures with older versions. */
620 [SPICE_CHANNEL_WEBDAV
] = "webdav",
624 info
= qmp_query_spice(NULL
);
626 if (!info
->enabled
) {
627 monitor_printf(mon
, "Server: disabled\n");
631 monitor_printf(mon
, "Server:\n");
632 if (info
->has_port
) {
633 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
634 info
->host
, info
->port
);
636 if (info
->has_tls_port
) {
637 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
638 info
->host
, info
->tls_port
);
640 monitor_printf(mon
, " migrated: %s\n",
641 info
->migrated
? "true" : "false");
642 monitor_printf(mon
, " auth: %s\n", info
->auth
);
643 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
644 monitor_printf(mon
, " mouse-mode: %s\n",
645 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
647 if (!info
->has_channels
|| info
->channels
== NULL
) {
648 monitor_printf(mon
, "Channels: none\n");
650 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
651 monitor_printf(mon
, "Channel:\n");
652 monitor_printf(mon
, " address: %s:%s%s\n",
653 chan
->value
->host
, chan
->value
->port
,
654 chan
->value
->tls
? " [tls]" : "");
655 monitor_printf(mon
, " session: %" PRId64
"\n",
656 chan
->value
->connection_id
);
657 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
658 chan
->value
->channel_type
, chan
->value
->channel_id
);
660 channel_name
= "unknown";
661 if (chan
->value
->channel_type
> 0 &&
662 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
663 channel_names
[chan
->value
->channel_type
]) {
664 channel_name
= channel_names
[chan
->value
->channel_type
];
667 monitor_printf(mon
, " channel name: %s\n", channel_name
);
672 qapi_free_SpiceInfo(info
);
676 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
681 info
= qmp_query_balloon(&err
);
683 error_report_err(err
);
687 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
689 qapi_free_BalloonInfo(info
);
692 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
694 PciMemoryRegionList
*region
;
696 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
697 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
698 dev
->slot
, dev
->function
);
699 monitor_printf(mon
, " ");
701 if (dev
->class_info
->has_desc
) {
702 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
704 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
707 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
708 dev
->id
->vendor
, dev
->id
->device
);
711 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
714 if (dev
->has_pci_bridge
) {
715 monitor_printf(mon
, " BUS %" PRId64
".\n",
716 dev
->pci_bridge
->bus
->number
);
717 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
718 dev
->pci_bridge
->bus
->secondary
);
719 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
720 dev
->pci_bridge
->bus
->subordinate
);
722 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
723 dev
->pci_bridge
->bus
->io_range
->base
,
724 dev
->pci_bridge
->bus
->io_range
->limit
);
727 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
728 dev
->pci_bridge
->bus
->memory_range
->base
,
729 dev
->pci_bridge
->bus
->memory_range
->limit
);
731 monitor_printf(mon
, " prefetchable memory range "
732 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
733 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
734 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
737 for (region
= dev
->regions
; region
; region
= region
->next
) {
740 addr
= region
->value
->address
;
741 size
= region
->value
->size
;
743 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
745 if (!strcmp(region
->value
->type
, "io")) {
746 monitor_printf(mon
, "I/O at 0x%04" PRIx64
747 " [0x%04" PRIx64
"].\n",
748 addr
, addr
+ size
- 1);
750 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
751 " [0x%08" PRIx64
"].\n",
752 region
->value
->mem_type_64
? 64 : 32,
753 region
->value
->prefetch
? " prefetchable" : "",
754 addr
, addr
+ size
- 1);
758 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
760 if (dev
->has_pci_bridge
) {
761 if (dev
->pci_bridge
->has_devices
) {
762 PciDeviceInfoList
*cdev
;
763 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
764 hmp_info_pci_device(mon
, cdev
->value
);
770 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
772 PciInfoList
*info_list
, *info
;
775 info_list
= qmp_query_pci(&err
);
777 monitor_printf(mon
, "PCI devices not supported\n");
782 for (info
= info_list
; info
; info
= info
->next
) {
783 PciDeviceInfoList
*dev
;
785 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
786 hmp_info_pci_device(mon
, dev
->value
);
790 qapi_free_PciInfoList(info_list
);
793 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
795 BlockJobInfoList
*list
;
798 list
= qmp_query_block_jobs(&err
);
802 monitor_printf(mon
, "No active jobs\n");
807 if (strcmp(list
->value
->type
, "stream") == 0) {
808 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
809 " of %" PRId64
" bytes, speed limit %" PRId64
816 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
817 " of %" PRId64
" bytes, speed limit %" PRId64
828 qapi_free_BlockJobInfoList(list
);
831 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
833 TPMInfoList
*info_list
, *info
;
836 TPMPassthroughOptions
*tpo
;
838 info_list
= qmp_query_tpm(&err
);
840 monitor_printf(mon
, "TPM device not supported\n");
846 monitor_printf(mon
, "TPM device:\n");
849 for (info
= info_list
; info
; info
= info
->next
) {
850 TPMInfo
*ti
= info
->value
;
851 monitor_printf(mon
, " tpm%d: model=%s\n",
852 c
, TpmModel_lookup
[ti
->model
]);
854 monitor_printf(mon
, " \\ %s: type=%s",
855 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
857 switch (ti
->options
->type
) {
858 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
859 tpo
= ti
->options
->u
.passthrough
;
860 monitor_printf(mon
, "%s%s%s%s",
861 tpo
->has_path
? ",path=" : "",
862 tpo
->has_path
? tpo
->path
: "",
863 tpo
->has_cancel_path
? ",cancel-path=" : "",
864 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
866 case TPM_TYPE_OPTIONS_KIND__MAX
:
869 monitor_printf(mon
, "\n");
872 qapi_free_TPMInfoList(info_list
);
875 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
877 monitor_suspend(mon
);
881 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
886 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
888 qmp_system_reset(NULL
);
891 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
893 qmp_system_powerdown(NULL
);
896 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
900 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
901 use it are converted to the QAPI */
902 cpu_index
= qdict_get_int(qdict
, "index");
903 if (monitor_set_cpu(cpu_index
) < 0) {
904 monitor_printf(mon
, "invalid CPU index\n");
908 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
910 uint32_t size
= qdict_get_int(qdict
, "size");
911 const char *filename
= qdict_get_str(qdict
, "filename");
912 uint64_t addr
= qdict_get_int(qdict
, "val");
915 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
916 hmp_handle_error(mon
, &err
);
919 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
921 uint32_t size
= qdict_get_int(qdict
, "size");
922 const char *filename
= qdict_get_str(qdict
, "filename");
923 uint64_t addr
= qdict_get_int(qdict
, "val");
926 qmp_pmemsave(addr
, size
, filename
, &err
);
927 hmp_handle_error(mon
, &err
);
930 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
932 const char *chardev
= qdict_get_str(qdict
, "device");
933 const char *data
= qdict_get_str(qdict
, "data");
936 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
938 hmp_handle_error(mon
, &err
);
941 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
943 uint32_t size
= qdict_get_int(qdict
, "size");
944 const char *chardev
= qdict_get_str(qdict
, "device");
949 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
951 error_report_err(err
);
955 for (i
= 0; data
[i
]; i
++) {
956 unsigned char ch
= data
[i
];
959 monitor_printf(mon
, "\\\\");
960 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
961 monitor_printf(mon
, "\\u%04X", ch
);
963 monitor_printf(mon
, "%c", ch
);
967 monitor_printf(mon
, "\n");
971 static void hmp_cont_cb(void *opaque
, int err
)
978 static bool key_is_missing(const BlockInfo
*bdev
)
980 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
983 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
985 BlockInfoList
*bdev_list
, *bdev
;
988 bdev_list
= qmp_query_block(NULL
);
989 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
990 if (key_is_missing(bdev
->value
)) {
991 monitor_read_block_device_key(mon
, bdev
->value
->device
,
998 hmp_handle_error(mon
, &err
);
1001 qapi_free_BlockInfoList(bdev_list
);
1004 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1006 qmp_system_wakeup(NULL
);
1009 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1013 qmp_inject_nmi(&err
);
1014 hmp_handle_error(mon
, &err
);
1017 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1019 const char *name
= qdict_get_str(qdict
, "name");
1020 bool up
= qdict_get_bool(qdict
, "up");
1023 qmp_set_link(name
, up
, &err
);
1024 hmp_handle_error(mon
, &err
);
1027 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1029 const char *device
= qdict_get_str(qdict
, "device");
1030 const char *password
= qdict_get_str(qdict
, "password");
1033 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1034 hmp_handle_error(mon
, &err
);
1037 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1039 int64_t value
= qdict_get_int(qdict
, "value");
1042 qmp_balloon(value
, &err
);
1044 error_report_err(err
);
1048 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1050 const char *device
= qdict_get_str(qdict
, "device");
1051 int64_t size
= qdict_get_int(qdict
, "size");
1054 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1055 hmp_handle_error(mon
, &err
);
1058 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1060 const char *device
= qdict_get_str(qdict
, "device");
1061 const char *filename
= qdict_get_str(qdict
, "target");
1062 const char *format
= qdict_get_try_str(qdict
, "format");
1063 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1064 bool full
= qdict_get_try_bool(qdict
, "full", false);
1065 enum NewImageMode mode
;
1069 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1070 hmp_handle_error(mon
, &err
);
1075 mode
= NEW_IMAGE_MODE_EXISTING
;
1077 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1080 qmp_drive_mirror(device
, filename
, !!format
, format
,
1081 false, NULL
, false, NULL
,
1082 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1083 true, mode
, false, 0, false, 0, false, 0,
1084 false, 0, false, 0, false, true, &err
);
1085 hmp_handle_error(mon
, &err
);
1088 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1090 const char *device
= qdict_get_str(qdict
, "device");
1091 const char *filename
= qdict_get_str(qdict
, "target");
1092 const char *format
= qdict_get_try_str(qdict
, "format");
1093 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1094 bool full
= qdict_get_try_bool(qdict
, "full", false);
1095 enum NewImageMode mode
;
1099 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1100 hmp_handle_error(mon
, &err
);
1105 mode
= NEW_IMAGE_MODE_EXISTING
;
1107 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1110 qmp_drive_backup(device
, filename
, !!format
, format
,
1111 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1112 true, mode
, false, 0, false, NULL
,
1113 false, 0, false, 0, &err
);
1114 hmp_handle_error(mon
, &err
);
1117 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1119 const char *device
= qdict_get_str(qdict
, "device");
1120 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1121 const char *format
= qdict_get_try_str(qdict
, "format");
1122 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1123 enum NewImageMode mode
;
1127 /* In the future, if 'snapshot-file' is not specified, the snapshot
1128 will be taken internally. Today it's actually required. */
1129 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1130 hmp_handle_error(mon
, &err
);
1134 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1135 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1136 filename
, false, NULL
,
1139 hmp_handle_error(mon
, &err
);
1142 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1144 const char *device
= qdict_get_str(qdict
, "device");
1145 const char *name
= qdict_get_str(qdict
, "name");
1148 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1149 hmp_handle_error(mon
, &err
);
1152 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1154 const char *device
= qdict_get_str(qdict
, "device");
1155 const char *name
= qdict_get_str(qdict
, "name");
1156 const char *id
= qdict_get_try_str(qdict
, "id");
1159 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1161 hmp_handle_error(mon
, &err
);
1164 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1166 qmp_migrate_cancel(NULL
);
1169 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1172 const char *uri
= qdict_get_str(qdict
, "uri");
1174 qmp_migrate_incoming(uri
, &err
);
1176 hmp_handle_error(mon
, &err
);
1179 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1181 double value
= qdict_get_double(qdict
, "value");
1182 qmp_migrate_set_downtime(value
, NULL
);
1185 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1187 int64_t value
= qdict_get_int(qdict
, "value");
1190 qmp_migrate_set_cache_size(value
, &err
);
1192 error_report_err(err
);
1197 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1199 int64_t value
= qdict_get_int(qdict
, "value");
1200 qmp_migrate_set_speed(value
, NULL
);
1203 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1205 const char *cap
= qdict_get_str(qdict
, "capability");
1206 bool state
= qdict_get_bool(qdict
, "state");
1208 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1211 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1212 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1213 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1214 caps
->value
->capability
= i
;
1215 caps
->value
->state
= state
;
1217 qmp_migrate_set_capabilities(caps
, &err
);
1222 if (i
== MIGRATION_CAPABILITY__MAX
) {
1223 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1226 qapi_free_MigrationCapabilityStatusList(caps
);
1229 error_report_err(err
);
1233 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1235 const char *param
= qdict_get_str(qdict
, "parameter");
1236 int value
= qdict_get_int(qdict
, "value");
1238 bool has_compress_level
= false;
1239 bool has_compress_threads
= false;
1240 bool has_decompress_threads
= false;
1241 bool has_x_cpu_throttle_initial
= false;
1242 bool has_x_cpu_throttle_increment
= false;
1245 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1246 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1248 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1249 has_compress_level
= true;
1251 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1252 has_compress_threads
= true;
1254 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1255 has_decompress_threads
= true;
1257 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
:
1258 has_x_cpu_throttle_initial
= true;
1260 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
:
1261 has_x_cpu_throttle_increment
= true;
1264 qmp_migrate_set_parameters(has_compress_level
, value
,
1265 has_compress_threads
, value
,
1266 has_decompress_threads
, value
,
1267 has_x_cpu_throttle_initial
, value
,
1268 has_x_cpu_throttle_increment
, value
,
1274 if (i
== MIGRATION_PARAMETER__MAX
) {
1275 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1279 error_report_err(err
);
1283 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1286 const char *protocol
= qdict_get_str(qdict
, "protocol");
1287 const char *hostname
= qdict_get_str(qdict
, "hostname");
1288 bool has_port
= qdict_haskey(qdict
, "port");
1289 int port
= qdict_get_try_int(qdict
, "port", -1);
1290 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1291 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1292 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1294 qmp_client_migrate_info(protocol
, hostname
,
1295 has_port
, port
, has_tls_port
, tls_port
,
1296 !!cert_subject
, cert_subject
, &err
);
1297 hmp_handle_error(mon
, &err
);
1300 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1303 qmp_migrate_start_postcopy(&err
);
1304 hmp_handle_error(mon
, &err
);
1307 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1309 const char *protocol
= qdict_get_str(qdict
, "protocol");
1310 const char *password
= qdict_get_str(qdict
, "password");
1311 const char *connected
= qdict_get_try_str(qdict
, "connected");
1314 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1315 hmp_handle_error(mon
, &err
);
1318 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1320 const char *protocol
= qdict_get_str(qdict
, "protocol");
1321 const char *whenstr
= qdict_get_str(qdict
, "time");
1324 qmp_expire_password(protocol
, whenstr
, &err
);
1325 hmp_handle_error(mon
, &err
);
1328 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1330 bool force
= qdict_get_try_bool(qdict
, "force", false);
1331 const char *device
= qdict_get_str(qdict
, "device");
1334 qmp_eject(device
, true, force
, &err
);
1335 hmp_handle_error(mon
, &err
);
1338 static void hmp_change_read_arg(void *opaque
, const char *password
,
1339 void *readline_opaque
)
1341 qmp_change_vnc_password(password
, NULL
);
1342 monitor_read_command(opaque
, 1);
1345 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1347 const char *device
= qdict_get_str(qdict
, "device");
1348 const char *target
= qdict_get_str(qdict
, "target");
1349 const char *arg
= qdict_get_try_str(qdict
, "arg");
1350 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1351 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1354 if (strcmp(device
, "vnc") == 0) {
1357 "Parameter 'read-only-mode' is invalid for VNC\n");
1360 if (strcmp(target
, "passwd") == 0 ||
1361 strcmp(target
, "password") == 0) {
1363 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1367 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1371 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1372 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1373 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1375 hmp_handle_error(mon
, &err
);
1380 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1381 !!read_only
, read_only_mode
, &err
);
1383 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1385 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1390 hmp_handle_error(mon
, &err
);
1393 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1397 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1398 qdict_get_int(qdict
, "bps"),
1399 qdict_get_int(qdict
, "bps_rd"),
1400 qdict_get_int(qdict
, "bps_wr"),
1401 qdict_get_int(qdict
, "iops"),
1402 qdict_get_int(qdict
, "iops_rd"),
1403 qdict_get_int(qdict
, "iops_wr"),
1404 false, /* no burst max via HMP */
1416 false, /* No default I/O size */
1420 hmp_handle_error(mon
, &err
);
1423 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1425 Error
*error
= NULL
;
1426 const char *device
= qdict_get_str(qdict
, "device");
1427 const char *base
= qdict_get_try_str(qdict
, "base");
1428 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1430 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1431 qdict_haskey(qdict
, "speed"), speed
,
1432 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1434 hmp_handle_error(mon
, &error
);
1437 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1439 Error
*error
= NULL
;
1440 const char *device
= qdict_get_str(qdict
, "device");
1441 int64_t value
= qdict_get_int(qdict
, "speed");
1443 qmp_block_job_set_speed(device
, value
, &error
);
1445 hmp_handle_error(mon
, &error
);
1448 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1450 Error
*error
= NULL
;
1451 const char *device
= qdict_get_str(qdict
, "device");
1452 bool force
= qdict_get_try_bool(qdict
, "force", false);
1454 qmp_block_job_cancel(device
, true, force
, &error
);
1456 hmp_handle_error(mon
, &error
);
1459 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1461 Error
*error
= NULL
;
1462 const char *device
= qdict_get_str(qdict
, "device");
1464 qmp_block_job_pause(device
, &error
);
1466 hmp_handle_error(mon
, &error
);
1469 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1471 Error
*error
= NULL
;
1472 const char *device
= qdict_get_str(qdict
, "device");
1474 qmp_block_job_resume(device
, &error
);
1476 hmp_handle_error(mon
, &error
);
1479 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1481 Error
*error
= NULL
;
1482 const char *device
= qdict_get_str(qdict
, "device");
1484 qmp_block_job_complete(device
, &error
);
1486 hmp_handle_error(mon
, &error
);
1489 typedef struct HMPMigrationStatus
1493 bool is_block_migration
;
1494 } HMPMigrationStatus
;
1496 static void hmp_migrate_status_cb(void *opaque
)
1498 HMPMigrationStatus
*status
= opaque
;
1499 MigrationInfo
*info
;
1501 info
= qmp_query_migrate(NULL
);
1502 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1503 info
->status
== MIGRATION_STATUS_SETUP
) {
1504 if (info
->has_disk
) {
1507 if (info
->disk
->remaining
) {
1508 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1513 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1514 monitor_flush(status
->mon
);
1517 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1519 if (status
->is_block_migration
) {
1520 monitor_printf(status
->mon
, "\n");
1522 monitor_resume(status
->mon
);
1523 timer_del(status
->timer
);
1527 qapi_free_MigrationInfo(info
);
1530 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1532 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1533 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1534 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1535 const char *uri
= qdict_get_str(qdict
, "uri");
1538 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1540 error_report_err(err
);
1545 HMPMigrationStatus
*status
;
1547 if (monitor_suspend(mon
) < 0) {
1548 monitor_printf(mon
, "terminal does not allow synchronous "
1549 "migration, continuing detached\n");
1553 status
= g_malloc0(sizeof(*status
));
1555 status
->is_block_migration
= blk
|| inc
;
1556 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1558 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1562 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1566 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1567 hmp_handle_error(mon
, &err
);
1570 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1572 const char *id
= qdict_get_str(qdict
, "id");
1575 qmp_device_del(id
, &err
);
1576 hmp_handle_error(mon
, &err
);
1579 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1582 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1583 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1584 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1585 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1586 const char *file
= qdict_get_str(qdict
, "filename");
1587 bool has_begin
= qdict_haskey(qdict
, "begin");
1588 bool has_length
= qdict_haskey(qdict
, "length");
1591 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1594 if (zlib
+ lzo
+ snappy
> 1) {
1595 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1596 hmp_handle_error(mon
, &err
);
1601 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1605 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1609 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1613 begin
= qdict_get_int(qdict
, "begin");
1616 length
= qdict_get_int(qdict
, "length");
1619 prot
= g_strconcat("file:", file
, NULL
);
1621 qmp_dump_guest_memory(paging
, prot
, has_begin
, begin
, has_length
, length
,
1622 true, dump_format
, &err
);
1623 hmp_handle_error(mon
, &err
);
1627 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1632 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1637 netdev_add(opts
, &err
);
1639 qemu_opts_del(opts
);
1643 hmp_handle_error(mon
, &err
);
1646 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1648 const char *id
= qdict_get_str(qdict
, "id");
1651 qmp_netdev_del(id
, &err
);
1652 hmp_handle_error(mon
, &err
);
1655 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1658 Error
*err_end
= NULL
;
1666 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1671 ov
= opts_visitor_new(opts
);
1672 pdict
= qdict_clone_shallow(qdict
);
1673 v
= opts_get_visitor(ov
);
1675 visit_start_struct(v
, NULL
, NULL
, 0, &err
);
1680 qdict_del(pdict
, "qom-type");
1681 visit_type_str(v
, "qom-type", &type
, &err
);
1686 qdict_del(pdict
, "id");
1687 visit_type_str(v
, "id", &id
, &err
);
1692 object_add(type
, id
, pdict
, v
, &err
);
1695 visit_end_struct(v
, &err_end
);
1696 if (!err
&& err_end
) {
1697 qmp_object_del(id
, NULL
);
1699 error_propagate(&err
, err_end
);
1701 opts_visitor_cleanup(ov
);
1704 qemu_opts_del(opts
);
1709 hmp_handle_error(mon
, &err
);
1712 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1714 const char *fdname
= qdict_get_str(qdict
, "fdname");
1717 qmp_getfd(fdname
, &err
);
1718 hmp_handle_error(mon
, &err
);
1721 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1723 const char *fdname
= qdict_get_str(qdict
, "fdname");
1726 qmp_closefd(fdname
, &err
);
1727 hmp_handle_error(mon
, &err
);
1730 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1732 const char *keys
= qdict_get_str(qdict
, "keys");
1733 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1734 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1735 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1741 separator
= strchr(keys
, '-');
1742 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1744 /* Be compatible with old interface, convert user inputted "<" */
1745 if (keys
[0] == '<' && keyname_len
== 1) {
1750 keylist
= g_malloc0(sizeof(*keylist
));
1751 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1757 tmp
->next
= keylist
;
1761 if (strstart(keys
, "0x", NULL
)) {
1763 int value
= strtoul(keys
, &endp
, 0);
1764 assert(endp
<= keys
+ keyname_len
);
1765 if (endp
!= keys
+ keyname_len
) {
1768 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1769 keylist
->value
->u
.number
= value
;
1771 int idx
= index_from_key(keys
, keyname_len
);
1772 if (idx
== Q_KEY_CODE__MAX
) {
1775 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1776 keylist
->value
->u
.qcode
= idx
;
1782 keys
= separator
+ 1;
1785 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1786 hmp_handle_error(mon
, &err
);
1789 qapi_free_KeyValueList(head
);
1793 monitor_printf(mon
, "invalid parameter: %.*s\n", keyname_len
, keys
);
1797 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1799 const char *filename
= qdict_get_str(qdict
, "filename");
1802 qmp_screendump(filename
, &err
);
1803 hmp_handle_error(mon
, &err
);
1806 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1808 const char *uri
= qdict_get_str(qdict
, "uri");
1809 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1810 bool all
= qdict_get_try_bool(qdict
, "all", false);
1811 Error
*local_err
= NULL
;
1812 BlockInfoList
*block_list
, *info
;
1813 SocketAddress
*addr
;
1815 if (writable
&& !all
) {
1816 error_setg(&local_err
, "-w only valid together with -a");
1820 /* First check if the address is valid and start the server. */
1821 addr
= socket_parse(uri
, &local_err
);
1822 if (local_err
!= NULL
) {
1826 qmp_nbd_server_start(addr
, &local_err
);
1827 qapi_free_SocketAddress(addr
);
1828 if (local_err
!= NULL
) {
1836 /* Then try adding all block devices. If one fails, close all and
1839 block_list
= qmp_query_block(NULL
);
1841 for (info
= block_list
; info
; info
= info
->next
) {
1842 if (!info
->value
->has_inserted
) {
1846 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1848 if (local_err
!= NULL
) {
1849 qmp_nbd_server_stop(NULL
);
1854 qapi_free_BlockInfoList(block_list
);
1857 hmp_handle_error(mon
, &local_err
);
1860 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1862 const char *device
= qdict_get_str(qdict
, "device");
1863 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1864 Error
*local_err
= NULL
;
1866 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1868 if (local_err
!= NULL
) {
1869 hmp_handle_error(mon
, &local_err
);
1873 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1877 qmp_nbd_server_stop(&err
);
1878 hmp_handle_error(mon
, &err
);
1881 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1886 cpuid
= qdict_get_int(qdict
, "id");
1887 qmp_cpu_add(cpuid
, &err
);
1888 hmp_handle_error(mon
, &err
);
1891 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1893 const char *args
= qdict_get_str(qdict
, "args");
1897 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1899 error_setg(&err
, "Parsing chardev args failed");
1901 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1903 hmp_handle_error(mon
, &err
);
1906 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1908 Error
*local_err
= NULL
;
1910 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1911 hmp_handle_error(mon
, &local_err
);
1914 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1917 const char* device
= qdict_get_str(qdict
, "device");
1918 const char* command
= qdict_get_str(qdict
, "command");
1921 blk
= blk_by_name(device
);
1923 qemuio_command(blk
, command
);
1925 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1926 "Device '%s' not found", device
);
1929 hmp_handle_error(mon
, &err
);
1932 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1934 const char *id
= qdict_get_str(qdict
, "id");
1937 qmp_object_del(id
, &err
);
1938 hmp_handle_error(mon
, &err
);
1941 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1944 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1945 MemdevList
*m
= memdev_list
;
1946 StringOutputVisitor
*ov
;
1952 ov
= string_output_visitor_new(false);
1953 visit_type_uint16List(string_output_get_visitor(ov
), NULL
,
1954 &m
->value
->host_nodes
, NULL
);
1955 monitor_printf(mon
, "memory backend: %d\n", i
);
1956 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1957 monitor_printf(mon
, " merge: %s\n",
1958 m
->value
->merge
? "true" : "false");
1959 monitor_printf(mon
, " dump: %s\n",
1960 m
->value
->dump
? "true" : "false");
1961 monitor_printf(mon
, " prealloc: %s\n",
1962 m
->value
->prealloc
? "true" : "false");
1963 monitor_printf(mon
, " policy: %s\n",
1964 HostMemPolicy_lookup
[m
->value
->policy
]);
1965 str
= string_output_get_string(ov
);
1966 monitor_printf(mon
, " host nodes: %s\n", str
);
1969 string_output_visitor_cleanup(ov
);
1974 monitor_printf(mon
, "\n");
1976 qapi_free_MemdevList(memdev_list
);
1979 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1982 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1983 MemoryDeviceInfoList
*info
;
1984 MemoryDeviceInfo
*value
;
1985 PCDIMMDeviceInfo
*di
;
1987 for (info
= info_list
; info
; info
= info
->next
) {
1988 value
= info
->value
;
1991 switch (value
->type
) {
1992 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1995 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1996 MemoryDeviceInfoKind_lookup
[value
->type
],
1997 di
->id
? di
->id
: "");
1998 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
1999 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2000 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2001 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2002 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2003 monitor_printf(mon
, " hotplugged: %s\n",
2004 di
->hotplugged
? "true" : "false");
2005 monitor_printf(mon
, " hotpluggable: %s\n",
2006 di
->hotpluggable
? "true" : "false");
2014 qapi_free_MemoryDeviceInfoList(info_list
);
2017 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2019 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2020 IOThreadInfoList
*info
;
2022 for (info
= info_list
; info
; info
= info
->next
) {
2023 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2024 info
->value
->id
, info
->value
->thread_id
);
2027 qapi_free_IOThreadInfoList(info_list
);
2030 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2032 const char *path
= qdict_get_try_str(qdict
, "path");
2033 ObjectPropertyInfoList
*list
;
2037 monitor_printf(mon
, "/\n");
2041 list
= qmp_qom_list(path
, &err
);
2043 ObjectPropertyInfoList
*start
= list
;
2044 while (list
!= NULL
) {
2045 ObjectPropertyInfo
*value
= list
->value
;
2047 monitor_printf(mon
, "%s (%s)\n",
2048 value
->name
, value
->type
);
2051 qapi_free_ObjectPropertyInfoList(start
);
2053 hmp_handle_error(mon
, &err
);
2056 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2058 const char *path
= qdict_get_str(qdict
, "path");
2059 const char *property
= qdict_get_str(qdict
, "property");
2060 const char *value
= qdict_get_str(qdict
, "value");
2062 bool ambiguous
= false;
2065 obj
= object_resolve_path(path
, &ambiguous
);
2067 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2068 "Device '%s' not found", path
);
2071 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2073 object_property_parse(obj
, value
, property
, &err
);
2075 hmp_handle_error(mon
, &err
);
2078 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2080 const char *name
= qdict_get_str(qdict
, "name");
2081 RockerSwitch
*rocker
;
2084 rocker
= qmp_query_rocker(name
, &err
);
2086 hmp_handle_error(mon
, &err
);
2090 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2091 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2092 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2094 qapi_free_RockerSwitch(rocker
);
2097 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2099 RockerPortList
*list
, *port
;
2100 const char *name
= qdict_get_str(qdict
, "name");
2103 list
= qmp_query_rocker_ports(name
, &err
);
2105 hmp_handle_error(mon
, &err
);
2109 monitor_printf(mon
, " ena/ speed/ auto\n");
2110 monitor_printf(mon
, " port link duplex neg?\n");
2112 for (port
= list
; port
; port
= port
->next
) {
2113 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2115 port
->value
->enabled
? port
->value
->link_up
?
2116 "up" : "down" : "!ena",
2117 port
->value
->speed
== 10000 ? "10G" : "??",
2118 port
->value
->duplex
? "FD" : "HD",
2119 port
->value
->autoneg
? "Yes" : "No");
2122 qapi_free_RockerPortList(list
);
2125 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2127 RockerOfDpaFlowList
*list
, *info
;
2128 const char *name
= qdict_get_str(qdict
, "name");
2129 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2132 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &err
);
2134 hmp_handle_error(mon
, &err
);
2138 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2140 for (info
= list
; info
; info
= info
->next
) {
2141 RockerOfDpaFlow
*flow
= info
->value
;
2142 RockerOfDpaFlowKey
*key
= flow
->key
;
2143 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2144 RockerOfDpaFlowAction
*action
= flow
->action
;
2147 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2148 key
->priority
, key
->tbl_id
, flow
->hits
);
2150 monitor_printf(mon
, "%-4d %-3d ",
2151 key
->priority
, key
->tbl_id
);
2154 if (key
->has_in_pport
) {
2155 monitor_printf(mon
, " pport %d", key
->in_pport
);
2156 if (mask
->has_in_pport
) {
2157 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2161 if (key
->has_vlan_id
) {
2162 monitor_printf(mon
, " vlan %d",
2163 key
->vlan_id
& VLAN_VID_MASK
);
2164 if (mask
->has_vlan_id
) {
2165 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2169 if (key
->has_tunnel_id
) {
2170 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2171 if (mask
->has_tunnel_id
) {
2172 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2176 if (key
->has_eth_type
) {
2177 switch (key
->eth_type
) {
2179 monitor_printf(mon
, " ARP");
2182 monitor_printf(mon
, " IP");
2185 monitor_printf(mon
, " IPv6");
2188 monitor_printf(mon
, " LACP");
2191 monitor_printf(mon
, " LLDP");
2194 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2199 if (key
->has_eth_src
) {
2200 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2201 (mask
->has_eth_src
) &&
2202 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2203 monitor_printf(mon
, " src <any mcast/bcast>");
2204 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2205 (mask
->has_eth_src
) &&
2206 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2207 monitor_printf(mon
, " src <any ucast>");
2209 monitor_printf(mon
, " src %s", key
->eth_src
);
2210 if (mask
->has_eth_src
) {
2211 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2216 if (key
->has_eth_dst
) {
2217 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2218 (mask
->has_eth_dst
) &&
2219 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2220 monitor_printf(mon
, " dst <any mcast/bcast>");
2221 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2222 (mask
->has_eth_dst
) &&
2223 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2224 monitor_printf(mon
, " dst <any ucast>");
2226 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2227 if (mask
->has_eth_dst
) {
2228 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2233 if (key
->has_ip_proto
) {
2234 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2235 if (mask
->has_ip_proto
) {
2236 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2240 if (key
->has_ip_tos
) {
2241 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2242 if (mask
->has_ip_tos
) {
2243 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2247 if (key
->has_ip_dst
) {
2248 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2251 if (action
->has_goto_tbl
|| action
->has_group_id
||
2252 action
->has_new_vlan_id
) {
2253 monitor_printf(mon
, " -->");
2256 if (action
->has_new_vlan_id
) {
2257 monitor_printf(mon
, " apply new vlan %d",
2258 ntohs(action
->new_vlan_id
));
2261 if (action
->has_group_id
) {
2262 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2265 if (action
->has_goto_tbl
) {
2266 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2269 monitor_printf(mon
, "\n");
2272 qapi_free_RockerOfDpaFlowList(list
);
2275 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2277 RockerOfDpaGroupList
*list
, *g
;
2278 const char *name
= qdict_get_str(qdict
, "name");
2279 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2283 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &err
);
2285 hmp_handle_error(mon
, &err
);
2289 monitor_printf(mon
, "id (decode) --> buckets\n");
2291 for (g
= list
; g
; g
= g
->next
) {
2292 RockerOfDpaGroup
*group
= g
->value
;
2294 monitor_printf(mon
, "0x%08x", group
->id
);
2296 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2297 group
->type
== 1 ? "L2 rewrite" :
2298 group
->type
== 2 ? "L3 unicast" :
2299 group
->type
== 3 ? "L2 multicast" :
2300 group
->type
== 4 ? "L2 flood" :
2301 group
->type
== 5 ? "L3 interface" :
2302 group
->type
== 6 ? "L3 multicast" :
2303 group
->type
== 7 ? "L3 ECMP" :
2304 group
->type
== 8 ? "L2 overlay" :
2307 if (group
->has_vlan_id
) {
2308 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2311 if (group
->has_pport
) {
2312 monitor_printf(mon
, " pport %d", group
->pport
);
2315 if (group
->has_index
) {
2316 monitor_printf(mon
, " index %d", group
->index
);
2319 monitor_printf(mon
, ") -->");
2321 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2323 monitor_printf(mon
, " set vlan %d",
2324 group
->set_vlan_id
& VLAN_VID_MASK
);
2327 if (group
->has_set_eth_src
) {
2330 monitor_printf(mon
, " set");
2332 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2335 if (group
->has_set_eth_dst
) {
2338 monitor_printf(mon
, " set");
2340 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2345 if (group
->has_ttl_check
&& group
->ttl_check
) {
2346 monitor_printf(mon
, " check TTL");
2349 if (group
->has_group_id
&& group
->group_id
) {
2350 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2353 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2354 monitor_printf(mon
, " pop vlan");
2357 if (group
->has_out_pport
) {
2358 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2361 if (group
->has_group_ids
) {
2362 struct uint32List
*id
;
2364 monitor_printf(mon
, " groups [");
2365 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2366 monitor_printf(mon
, "0x%08x", id
->value
);
2368 monitor_printf(mon
, ",");
2371 monitor_printf(mon
, "]");
2374 monitor_printf(mon
, "\n");
2377 qapi_free_RockerOfDpaGroupList(list
);