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.
19 #include "sysemu/char.h"
20 #include "sysemu/block-backend.h"
21 #include "qemu/option.h"
22 #include "qemu/timer.h"
23 #include "qmp-commands.h"
24 #include "qemu/sockets.h"
25 #include "monitor/monitor.h"
26 #include "monitor/qdev.h"
27 #include "qapi/opts-visitor.h"
28 #include "qapi/qmp/qerror.h"
29 #include "qapi/string-output-visitor.h"
30 #include "qapi/util.h"
31 #include "qapi-visit.h"
32 #include "ui/console.h"
33 #include "block/qapi.h"
37 #include <spice/enums.h>
40 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
44 monitor_printf(mon
, "%s\n", error_get_pretty(*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 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
564 if (!info
->enabled
) {
565 monitor_printf(mon
, "Server: disabled\n");
569 monitor_printf(mon
, "Server:\n");
570 if (info
->has_host
&& info
->has_service
) {
571 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
573 if (info
->has_auth
) {
574 monitor_printf(mon
, " auth: %s\n", info
->auth
);
577 if (!info
->has_clients
|| info
->clients
== NULL
) {
578 monitor_printf(mon
, "Client: none\n");
580 for (client
= info
->clients
; client
; client
= client
->next
) {
581 monitor_printf(mon
, "Client:\n");
582 monitor_printf(mon
, " address: %s:%s\n",
584 client
->value
->service
);
585 monitor_printf(mon
, " x509_dname: %s\n",
586 client
->value
->x509_dname
?
587 client
->value
->x509_dname
: "none");
588 monitor_printf(mon
, " username: %s\n",
589 client
->value
->has_sasl_username
?
590 client
->value
->sasl_username
: "none");
595 qapi_free_VncInfo(info
);
599 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
601 SpiceChannelList
*chan
;
603 const char *channel_name
;
604 const char * const channel_names
[] = {
605 [SPICE_CHANNEL_MAIN
] = "main",
606 [SPICE_CHANNEL_DISPLAY
] = "display",
607 [SPICE_CHANNEL_INPUTS
] = "inputs",
608 [SPICE_CHANNEL_CURSOR
] = "cursor",
609 [SPICE_CHANNEL_PLAYBACK
] = "playback",
610 [SPICE_CHANNEL_RECORD
] = "record",
611 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
612 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
613 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
614 [SPICE_CHANNEL_PORT
] = "port",
616 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
617 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
618 * as quick fix for build failures with older versions. */
619 [SPICE_CHANNEL_WEBDAV
] = "webdav",
623 info
= qmp_query_spice(NULL
);
625 if (!info
->enabled
) {
626 monitor_printf(mon
, "Server: disabled\n");
630 monitor_printf(mon
, "Server:\n");
631 if (info
->has_port
) {
632 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
633 info
->host
, info
->port
);
635 if (info
->has_tls_port
) {
636 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
637 info
->host
, info
->tls_port
);
639 monitor_printf(mon
, " migrated: %s\n",
640 info
->migrated
? "true" : "false");
641 monitor_printf(mon
, " auth: %s\n", info
->auth
);
642 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
643 monitor_printf(mon
, " mouse-mode: %s\n",
644 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
646 if (!info
->has_channels
|| info
->channels
== NULL
) {
647 monitor_printf(mon
, "Channels: none\n");
649 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
650 monitor_printf(mon
, "Channel:\n");
651 monitor_printf(mon
, " address: %s:%s%s\n",
652 chan
->value
->host
, chan
->value
->port
,
653 chan
->value
->tls
? " [tls]" : "");
654 monitor_printf(mon
, " session: %" PRId64
"\n",
655 chan
->value
->connection_id
);
656 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
657 chan
->value
->channel_type
, chan
->value
->channel_id
);
659 channel_name
= "unknown";
660 if (chan
->value
->channel_type
> 0 &&
661 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
662 channel_names
[chan
->value
->channel_type
]) {
663 channel_name
= channel_names
[chan
->value
->channel_type
];
666 monitor_printf(mon
, " channel name: %s\n", channel_name
);
671 qapi_free_SpiceInfo(info
);
675 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
680 info
= qmp_query_balloon(&err
);
682 monitor_printf(mon
, "%s\n", error_get_pretty(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 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
956 for (i
= 0; data
[i
]; i
++) {
957 unsigned char ch
= data
[i
];
960 monitor_printf(mon
, "\\\\");
961 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
962 monitor_printf(mon
, "\\u%04X", ch
);
964 monitor_printf(mon
, "%c", ch
);
968 monitor_printf(mon
, "\n");
972 static void hmp_cont_cb(void *opaque
, int err
)
979 static bool key_is_missing(const BlockInfo
*bdev
)
981 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
984 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
986 BlockInfoList
*bdev_list
, *bdev
;
989 bdev_list
= qmp_query_block(NULL
);
990 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
991 if (key_is_missing(bdev
->value
)) {
992 monitor_read_block_device_key(mon
, bdev
->value
->device
,
999 hmp_handle_error(mon
, &err
);
1002 qapi_free_BlockInfoList(bdev_list
);
1005 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
1007 qmp_system_wakeup(NULL
);
1010 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1014 qmp_inject_nmi(&err
);
1015 hmp_handle_error(mon
, &err
);
1018 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1020 const char *name
= qdict_get_str(qdict
, "name");
1021 bool up
= qdict_get_bool(qdict
, "up");
1024 qmp_set_link(name
, up
, &err
);
1025 hmp_handle_error(mon
, &err
);
1028 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1030 const char *device
= qdict_get_str(qdict
, "device");
1031 const char *password
= qdict_get_str(qdict
, "password");
1034 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1035 hmp_handle_error(mon
, &err
);
1038 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1040 int64_t value
= qdict_get_int(qdict
, "value");
1043 qmp_balloon(value
, &err
);
1045 monitor_printf(mon
, "balloon: %s\n", error_get_pretty(err
));
1050 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1052 const char *device
= qdict_get_str(qdict
, "device");
1053 int64_t size
= qdict_get_int(qdict
, "size");
1056 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1057 hmp_handle_error(mon
, &err
);
1060 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1062 const char *device
= qdict_get_str(qdict
, "device");
1063 const char *filename
= qdict_get_str(qdict
, "target");
1064 const char *format
= qdict_get_try_str(qdict
, "format");
1065 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1066 bool full
= qdict_get_try_bool(qdict
, "full", false);
1067 enum NewImageMode mode
;
1071 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1072 hmp_handle_error(mon
, &err
);
1077 mode
= NEW_IMAGE_MODE_EXISTING
;
1079 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1082 qmp_drive_mirror(device
, filename
, !!format
, format
,
1083 false, NULL
, false, NULL
,
1084 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1085 true, mode
, false, 0, false, 0, false, 0,
1086 false, 0, false, 0, false, true, &err
);
1087 hmp_handle_error(mon
, &err
);
1090 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1092 const char *device
= qdict_get_str(qdict
, "device");
1093 const char *filename
= qdict_get_str(qdict
, "target");
1094 const char *format
= qdict_get_try_str(qdict
, "format");
1095 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1096 bool full
= qdict_get_try_bool(qdict
, "full", false);
1097 enum NewImageMode mode
;
1101 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1102 hmp_handle_error(mon
, &err
);
1107 mode
= NEW_IMAGE_MODE_EXISTING
;
1109 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1112 qmp_drive_backup(device
, filename
, !!format
, format
,
1113 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1114 true, mode
, false, 0, false, NULL
,
1115 false, 0, false, 0, &err
);
1116 hmp_handle_error(mon
, &err
);
1119 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1121 const char *device
= qdict_get_str(qdict
, "device");
1122 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1123 const char *format
= qdict_get_try_str(qdict
, "format");
1124 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1125 enum NewImageMode mode
;
1129 /* In the future, if 'snapshot-file' is not specified, the snapshot
1130 will be taken internally. Today it's actually required. */
1131 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1132 hmp_handle_error(mon
, &err
);
1136 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1137 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1138 filename
, false, NULL
,
1141 hmp_handle_error(mon
, &err
);
1144 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1146 const char *device
= qdict_get_str(qdict
, "device");
1147 const char *name
= qdict_get_str(qdict
, "name");
1150 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1151 hmp_handle_error(mon
, &err
);
1154 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1156 const char *device
= qdict_get_str(qdict
, "device");
1157 const char *name
= qdict_get_str(qdict
, "name");
1158 const char *id
= qdict_get_try_str(qdict
, "id");
1161 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1163 hmp_handle_error(mon
, &err
);
1166 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1168 qmp_migrate_cancel(NULL
);
1171 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1174 const char *uri
= qdict_get_str(qdict
, "uri");
1176 qmp_migrate_incoming(uri
, &err
);
1178 hmp_handle_error(mon
, &err
);
1181 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1183 double value
= qdict_get_double(qdict
, "value");
1184 qmp_migrate_set_downtime(value
, NULL
);
1187 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1189 int64_t value
= qdict_get_int(qdict
, "value");
1192 qmp_migrate_set_cache_size(value
, &err
);
1194 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
1200 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1202 int64_t value
= qdict_get_int(qdict
, "value");
1203 qmp_migrate_set_speed(value
, NULL
);
1206 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1208 const char *cap
= qdict_get_str(qdict
, "capability");
1209 bool state
= qdict_get_bool(qdict
, "state");
1211 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1214 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
1215 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1216 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1217 caps
->value
->capability
= i
;
1218 caps
->value
->state
= state
;
1220 qmp_migrate_set_capabilities(caps
, &err
);
1225 if (i
== MIGRATION_CAPABILITY__MAX
) {
1226 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1229 qapi_free_MigrationCapabilityStatusList(caps
);
1232 monitor_printf(mon
, "migrate_set_capability: %s\n",
1233 error_get_pretty(err
));
1238 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1240 const char *param
= qdict_get_str(qdict
, "parameter");
1241 int value
= qdict_get_int(qdict
, "value");
1243 bool has_compress_level
= false;
1244 bool has_compress_threads
= false;
1245 bool has_decompress_threads
= false;
1246 bool has_x_cpu_throttle_initial
= false;
1247 bool has_x_cpu_throttle_increment
= false;
1250 for (i
= 0; i
< MIGRATION_PARAMETER__MAX
; i
++) {
1251 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1253 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1254 has_compress_level
= true;
1256 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1257 has_compress_threads
= true;
1259 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1260 has_decompress_threads
= true;
1262 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
:
1263 has_x_cpu_throttle_initial
= true;
1265 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
:
1266 has_x_cpu_throttle_increment
= true;
1269 qmp_migrate_set_parameters(has_compress_level
, value
,
1270 has_compress_threads
, value
,
1271 has_decompress_threads
, value
,
1272 has_x_cpu_throttle_initial
, value
,
1273 has_x_cpu_throttle_increment
, value
,
1279 if (i
== MIGRATION_PARAMETER__MAX
) {
1280 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1284 monitor_printf(mon
, "migrate_set_parameter: %s\n",
1285 error_get_pretty(err
));
1290 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1293 const char *protocol
= qdict_get_str(qdict
, "protocol");
1294 const char *hostname
= qdict_get_str(qdict
, "hostname");
1295 bool has_port
= qdict_haskey(qdict
, "port");
1296 int port
= qdict_get_try_int(qdict
, "port", -1);
1297 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1298 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1299 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1301 qmp_client_migrate_info(protocol
, hostname
,
1302 has_port
, port
, has_tls_port
, tls_port
,
1303 !!cert_subject
, cert_subject
, &err
);
1304 hmp_handle_error(mon
, &err
);
1307 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1310 qmp_migrate_start_postcopy(&err
);
1311 hmp_handle_error(mon
, &err
);
1314 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1316 const char *protocol
= qdict_get_str(qdict
, "protocol");
1317 const char *password
= qdict_get_str(qdict
, "password");
1318 const char *connected
= qdict_get_try_str(qdict
, "connected");
1321 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1322 hmp_handle_error(mon
, &err
);
1325 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1327 const char *protocol
= qdict_get_str(qdict
, "protocol");
1328 const char *whenstr
= qdict_get_str(qdict
, "time");
1331 qmp_expire_password(protocol
, whenstr
, &err
);
1332 hmp_handle_error(mon
, &err
);
1335 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1337 bool force
= qdict_get_try_bool(qdict
, "force", false);
1338 const char *device
= qdict_get_str(qdict
, "device");
1341 qmp_eject(device
, true, force
, &err
);
1342 hmp_handle_error(mon
, &err
);
1345 static void hmp_change_read_arg(void *opaque
, const char *password
,
1346 void *readline_opaque
)
1348 qmp_change_vnc_password(password
, NULL
);
1349 monitor_read_command(opaque
, 1);
1352 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1354 const char *device
= qdict_get_str(qdict
, "device");
1355 const char *target
= qdict_get_str(qdict
, "target");
1356 const char *arg
= qdict_get_try_str(qdict
, "arg");
1357 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1358 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1361 if (strcmp(device
, "vnc") == 0) {
1364 "Parameter 'read-only-mode' is invalid for VNC\n");
1367 if (strcmp(target
, "passwd") == 0 ||
1368 strcmp(target
, "password") == 0) {
1370 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1374 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1378 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1379 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX
,
1380 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1382 hmp_handle_error(mon
, &err
);
1387 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1388 !!read_only
, read_only_mode
, &err
);
1390 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1392 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1397 hmp_handle_error(mon
, &err
);
1400 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1404 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1405 qdict_get_int(qdict
, "bps"),
1406 qdict_get_int(qdict
, "bps_rd"),
1407 qdict_get_int(qdict
, "bps_wr"),
1408 qdict_get_int(qdict
, "iops"),
1409 qdict_get_int(qdict
, "iops_rd"),
1410 qdict_get_int(qdict
, "iops_wr"),
1411 false, /* no burst max via HMP */
1423 false, /* No default I/O size */
1427 hmp_handle_error(mon
, &err
);
1430 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1432 Error
*error
= NULL
;
1433 const char *device
= qdict_get_str(qdict
, "device");
1434 const char *base
= qdict_get_try_str(qdict
, "base");
1435 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1437 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1438 qdict_haskey(qdict
, "speed"), speed
,
1439 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1441 hmp_handle_error(mon
, &error
);
1444 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1446 Error
*error
= NULL
;
1447 const char *device
= qdict_get_str(qdict
, "device");
1448 int64_t value
= qdict_get_int(qdict
, "speed");
1450 qmp_block_job_set_speed(device
, value
, &error
);
1452 hmp_handle_error(mon
, &error
);
1455 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1457 Error
*error
= NULL
;
1458 const char *device
= qdict_get_str(qdict
, "device");
1459 bool force
= qdict_get_try_bool(qdict
, "force", false);
1461 qmp_block_job_cancel(device
, true, force
, &error
);
1463 hmp_handle_error(mon
, &error
);
1466 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1468 Error
*error
= NULL
;
1469 const char *device
= qdict_get_str(qdict
, "device");
1471 qmp_block_job_pause(device
, &error
);
1473 hmp_handle_error(mon
, &error
);
1476 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1478 Error
*error
= NULL
;
1479 const char *device
= qdict_get_str(qdict
, "device");
1481 qmp_block_job_resume(device
, &error
);
1483 hmp_handle_error(mon
, &error
);
1486 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1488 Error
*error
= NULL
;
1489 const char *device
= qdict_get_str(qdict
, "device");
1491 qmp_block_job_complete(device
, &error
);
1493 hmp_handle_error(mon
, &error
);
1496 typedef struct HMPMigrationStatus
1500 bool is_block_migration
;
1501 } HMPMigrationStatus
;
1503 static void hmp_migrate_status_cb(void *opaque
)
1505 HMPMigrationStatus
*status
= opaque
;
1506 MigrationInfo
*info
;
1508 info
= qmp_query_migrate(NULL
);
1509 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1510 info
->status
== MIGRATION_STATUS_SETUP
) {
1511 if (info
->has_disk
) {
1514 if (info
->disk
->remaining
) {
1515 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1520 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1521 monitor_flush(status
->mon
);
1524 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1526 if (status
->is_block_migration
) {
1527 monitor_printf(status
->mon
, "\n");
1529 monitor_resume(status
->mon
);
1530 timer_del(status
->timer
);
1534 qapi_free_MigrationInfo(info
);
1537 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1539 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1540 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1541 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1542 const char *uri
= qdict_get_str(qdict
, "uri");
1545 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1547 monitor_printf(mon
, "migrate: %s\n", error_get_pretty(err
));
1553 HMPMigrationStatus
*status
;
1555 if (monitor_suspend(mon
) < 0) {
1556 monitor_printf(mon
, "terminal does not allow synchronous "
1557 "migration, continuing detached\n");
1561 status
= g_malloc0(sizeof(*status
));
1563 status
->is_block_migration
= blk
|| inc
;
1564 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1566 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1570 void hmp_device_add(Monitor
*mon
, const QDict
*qdict
)
1574 qmp_device_add((QDict
*)qdict
, NULL
, &err
);
1575 hmp_handle_error(mon
, &err
);
1578 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1580 const char *id
= qdict_get_str(qdict
, "id");
1583 qmp_device_del(id
, &err
);
1584 hmp_handle_error(mon
, &err
);
1587 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1590 bool paging
= qdict_get_try_bool(qdict
, "paging", false);
1591 bool zlib
= qdict_get_try_bool(qdict
, "zlib", false);
1592 bool lzo
= qdict_get_try_bool(qdict
, "lzo", false);
1593 bool snappy
= qdict_get_try_bool(qdict
, "snappy", false);
1594 const char *file
= qdict_get_str(qdict
, "filename");
1595 bool has_begin
= qdict_haskey(qdict
, "begin");
1596 bool has_length
= qdict_haskey(qdict
, "length");
1599 enum DumpGuestMemoryFormat dump_format
= DUMP_GUEST_MEMORY_FORMAT_ELF
;
1602 if (zlib
+ lzo
+ snappy
> 1) {
1603 error_setg(&err
, "only one of '-z|-l|-s' can be set");
1604 hmp_handle_error(mon
, &err
);
1609 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB
;
1613 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO
;
1617 dump_format
= DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY
;
1621 begin
= qdict_get_int(qdict
, "begin");
1624 length
= qdict_get_int(qdict
, "length");
1627 prot
= g_strconcat("file:", file
, NULL
);
1629 qmp_dump_guest_memory(paging
, prot
, has_begin
, begin
, has_length
, length
,
1630 true, dump_format
, &err
);
1631 hmp_handle_error(mon
, &err
);
1635 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1640 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1645 netdev_add(opts
, &err
);
1647 qemu_opts_del(opts
);
1651 hmp_handle_error(mon
, &err
);
1654 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1656 const char *id
= qdict_get_str(qdict
, "id");
1659 qmp_netdev_del(id
, &err
);
1660 hmp_handle_error(mon
, &err
);
1663 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1666 Error
*err_end
= NULL
;
1674 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1679 ov
= opts_visitor_new(opts
);
1680 pdict
= qdict_clone_shallow(qdict
);
1682 visit_start_struct(opts_get_visitor(ov
), &dummy
, NULL
, NULL
, 0, &err
);
1687 qdict_del(pdict
, "qom-type");
1688 visit_type_str(opts_get_visitor(ov
), &type
, "qom-type", &err
);
1693 qdict_del(pdict
, "id");
1694 visit_type_str(opts_get_visitor(ov
), &id
, "id", &err
);
1699 object_add(type
, id
, pdict
, opts_get_visitor(ov
), &err
);
1702 visit_end_struct(opts_get_visitor(ov
), &err_end
);
1703 if (!err
&& err_end
) {
1704 qmp_object_del(id
, NULL
);
1706 error_propagate(&err
, err_end
);
1708 opts_visitor_cleanup(ov
);
1711 qemu_opts_del(opts
);
1717 hmp_handle_error(mon
, &err
);
1720 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1722 const char *fdname
= qdict_get_str(qdict
, "fdname");
1725 qmp_getfd(fdname
, &err
);
1726 hmp_handle_error(mon
, &err
);
1729 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1731 const char *fdname
= qdict_get_str(qdict
, "fdname");
1734 qmp_closefd(fdname
, &err
);
1735 hmp_handle_error(mon
, &err
);
1738 void hmp_sendkey(Monitor
*mon
, const QDict
*qdict
)
1740 const char *keys
= qdict_get_str(qdict
, "keys");
1741 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1742 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1743 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1745 char keyname_buf
[16];
1750 separator
= strchr(keys
, '-');
1751 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1752 pstrcpy(keyname_buf
, sizeof(keyname_buf
), keys
);
1754 /* Be compatible with old interface, convert user inputted "<" */
1755 if (!strncmp(keyname_buf
, "<", 1) && keyname_len
== 1) {
1756 pstrcpy(keyname_buf
, sizeof(keyname_buf
), "less");
1759 keyname_buf
[keyname_len
] = 0;
1761 keylist
= g_malloc0(sizeof(*keylist
));
1762 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1768 tmp
->next
= keylist
;
1772 if (strstart(keyname_buf
, "0x", NULL
)) {
1774 int value
= strtoul(keyname_buf
, &endp
, 0);
1775 if (*endp
!= '\0') {
1778 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1779 keylist
->value
->u
.number
= value
;
1781 int idx
= index_from_key(keyname_buf
);
1782 if (idx
== Q_KEY_CODE__MAX
) {
1785 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1786 keylist
->value
->u
.qcode
= idx
;
1792 keys
= separator
+ 1;
1795 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1796 hmp_handle_error(mon
, &err
);
1799 qapi_free_KeyValueList(head
);
1803 monitor_printf(mon
, "invalid parameter: %s\n", keyname_buf
);
1807 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1809 const char *filename
= qdict_get_str(qdict
, "filename");
1812 qmp_screendump(filename
, &err
);
1813 hmp_handle_error(mon
, &err
);
1816 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1818 const char *uri
= qdict_get_str(qdict
, "uri");
1819 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1820 bool all
= qdict_get_try_bool(qdict
, "all", false);
1821 Error
*local_err
= NULL
;
1822 BlockInfoList
*block_list
, *info
;
1823 SocketAddress
*addr
;
1825 if (writable
&& !all
) {
1826 error_setg(&local_err
, "-w only valid together with -a");
1830 /* First check if the address is valid and start the server. */
1831 addr
= socket_parse(uri
, &local_err
);
1832 if (local_err
!= NULL
) {
1836 qmp_nbd_server_start(addr
, &local_err
);
1837 qapi_free_SocketAddress(addr
);
1838 if (local_err
!= NULL
) {
1846 /* Then try adding all block devices. If one fails, close all and
1849 block_list
= qmp_query_block(NULL
);
1851 for (info
= block_list
; info
; info
= info
->next
) {
1852 if (!info
->value
->has_inserted
) {
1856 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1858 if (local_err
!= NULL
) {
1859 qmp_nbd_server_stop(NULL
);
1864 qapi_free_BlockInfoList(block_list
);
1867 hmp_handle_error(mon
, &local_err
);
1870 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1872 const char *device
= qdict_get_str(qdict
, "device");
1873 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1874 Error
*local_err
= NULL
;
1876 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1878 if (local_err
!= NULL
) {
1879 hmp_handle_error(mon
, &local_err
);
1883 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1887 qmp_nbd_server_stop(&err
);
1888 hmp_handle_error(mon
, &err
);
1891 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1896 cpuid
= qdict_get_int(qdict
, "id");
1897 qmp_cpu_add(cpuid
, &err
);
1898 hmp_handle_error(mon
, &err
);
1901 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1903 const char *args
= qdict_get_str(qdict
, "args");
1907 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1909 error_setg(&err
, "Parsing chardev args failed");
1911 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1913 hmp_handle_error(mon
, &err
);
1916 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1918 Error
*local_err
= NULL
;
1920 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1921 hmp_handle_error(mon
, &local_err
);
1924 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1927 const char* device
= qdict_get_str(qdict
, "device");
1928 const char* command
= qdict_get_str(qdict
, "command");
1931 blk
= blk_by_name(device
);
1933 qemuio_command(blk
, command
);
1935 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1936 "Device '%s' not found", device
);
1939 hmp_handle_error(mon
, &err
);
1942 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1944 const char *id
= qdict_get_str(qdict
, "id");
1947 qmp_object_del(id
, &err
);
1948 hmp_handle_error(mon
, &err
);
1951 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1954 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1955 MemdevList
*m
= memdev_list
;
1956 StringOutputVisitor
*ov
;
1962 ov
= string_output_visitor_new(false);
1963 visit_type_uint16List(string_output_get_visitor(ov
),
1964 &m
->value
->host_nodes
, NULL
, NULL
);
1965 monitor_printf(mon
, "memory backend: %d\n", i
);
1966 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1967 monitor_printf(mon
, " merge: %s\n",
1968 m
->value
->merge
? "true" : "false");
1969 monitor_printf(mon
, " dump: %s\n",
1970 m
->value
->dump
? "true" : "false");
1971 monitor_printf(mon
, " prealloc: %s\n",
1972 m
->value
->prealloc
? "true" : "false");
1973 monitor_printf(mon
, " policy: %s\n",
1974 HostMemPolicy_lookup
[m
->value
->policy
]);
1975 str
= string_output_get_string(ov
);
1976 monitor_printf(mon
, " host nodes: %s\n", str
);
1979 string_output_visitor_cleanup(ov
);
1984 monitor_printf(mon
, "\n");
1986 qapi_free_MemdevList(memdev_list
);
1989 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1992 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1993 MemoryDeviceInfoList
*info
;
1994 MemoryDeviceInfo
*value
;
1995 PCDIMMDeviceInfo
*di
;
1997 for (info
= info_list
; info
; info
= info
->next
) {
1998 value
= info
->value
;
2001 switch (value
->type
) {
2002 case MEMORY_DEVICE_INFO_KIND_DIMM
:
2005 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
2006 MemoryDeviceInfoKind_lookup
[value
->type
],
2007 di
->id
? di
->id
: "");
2008 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2009 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2010 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2011 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2012 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2013 monitor_printf(mon
, " hotplugged: %s\n",
2014 di
->hotplugged
? "true" : "false");
2015 monitor_printf(mon
, " hotpluggable: %s\n",
2016 di
->hotpluggable
? "true" : "false");
2024 qapi_free_MemoryDeviceInfoList(info_list
);
2027 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2029 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2030 IOThreadInfoList
*info
;
2032 for (info
= info_list
; info
; info
= info
->next
) {
2033 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2034 info
->value
->id
, info
->value
->thread_id
);
2037 qapi_free_IOThreadInfoList(info_list
);
2040 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2042 const char *path
= qdict_get_try_str(qdict
, "path");
2043 ObjectPropertyInfoList
*list
;
2047 monitor_printf(mon
, "/\n");
2051 list
= qmp_qom_list(path
, &err
);
2053 ObjectPropertyInfoList
*start
= list
;
2054 while (list
!= NULL
) {
2055 ObjectPropertyInfo
*value
= list
->value
;
2057 monitor_printf(mon
, "%s (%s)\n",
2058 value
->name
, value
->type
);
2061 qapi_free_ObjectPropertyInfoList(start
);
2063 hmp_handle_error(mon
, &err
);
2066 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2068 const char *path
= qdict_get_str(qdict
, "path");
2069 const char *property
= qdict_get_str(qdict
, "property");
2070 const char *value
= qdict_get_str(qdict
, "value");
2072 bool ambiguous
= false;
2075 obj
= object_resolve_path(path
, &ambiguous
);
2077 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2078 "Device '%s' not found", path
);
2081 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2083 object_property_parse(obj
, value
, property
, &err
);
2085 hmp_handle_error(mon
, &err
);
2088 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2090 const char *name
= qdict_get_str(qdict
, "name");
2091 RockerSwitch
*rocker
;
2094 rocker
= qmp_query_rocker(name
, &errp
);
2096 hmp_handle_error(mon
, &errp
);
2100 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2101 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2102 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2104 qapi_free_RockerSwitch(rocker
);
2107 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2109 RockerPortList
*list
, *port
;
2110 const char *name
= qdict_get_str(qdict
, "name");
2113 list
= qmp_query_rocker_ports(name
, &errp
);
2115 hmp_handle_error(mon
, &errp
);
2119 monitor_printf(mon
, " ena/ speed/ auto\n");
2120 monitor_printf(mon
, " port link duplex neg?\n");
2122 for (port
= list
; port
; port
= port
->next
) {
2123 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2125 port
->value
->enabled
? port
->value
->link_up
?
2126 "up" : "down" : "!ena",
2127 port
->value
->speed
== 10000 ? "10G" : "??",
2128 port
->value
->duplex
? "FD" : "HD",
2129 port
->value
->autoneg
? "Yes" : "No");
2132 qapi_free_RockerPortList(list
);
2135 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2137 RockerOfDpaFlowList
*list
, *info
;
2138 const char *name
= qdict_get_str(qdict
, "name");
2139 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2142 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &errp
);
2144 hmp_handle_error(mon
, &errp
);
2148 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2150 for (info
= list
; info
; info
= info
->next
) {
2151 RockerOfDpaFlow
*flow
= info
->value
;
2152 RockerOfDpaFlowKey
*key
= flow
->key
;
2153 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2154 RockerOfDpaFlowAction
*action
= flow
->action
;
2157 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2158 key
->priority
, key
->tbl_id
, flow
->hits
);
2160 monitor_printf(mon
, "%-4d %-3d ",
2161 key
->priority
, key
->tbl_id
);
2164 if (key
->has_in_pport
) {
2165 monitor_printf(mon
, " pport %d", key
->in_pport
);
2166 if (mask
->has_in_pport
) {
2167 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2171 if (key
->has_vlan_id
) {
2172 monitor_printf(mon
, " vlan %d",
2173 key
->vlan_id
& VLAN_VID_MASK
);
2174 if (mask
->has_vlan_id
) {
2175 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2179 if (key
->has_tunnel_id
) {
2180 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2181 if (mask
->has_tunnel_id
) {
2182 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2186 if (key
->has_eth_type
) {
2187 switch (key
->eth_type
) {
2189 monitor_printf(mon
, " ARP");
2192 monitor_printf(mon
, " IP");
2195 monitor_printf(mon
, " IPv6");
2198 monitor_printf(mon
, " LACP");
2201 monitor_printf(mon
, " LLDP");
2204 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2209 if (key
->has_eth_src
) {
2210 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2211 (mask
->has_eth_src
) &&
2212 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2213 monitor_printf(mon
, " src <any mcast/bcast>");
2214 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2215 (mask
->has_eth_src
) &&
2216 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2217 monitor_printf(mon
, " src <any ucast>");
2219 monitor_printf(mon
, " src %s", key
->eth_src
);
2220 if (mask
->has_eth_src
) {
2221 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2226 if (key
->has_eth_dst
) {
2227 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2228 (mask
->has_eth_dst
) &&
2229 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2230 monitor_printf(mon
, " dst <any mcast/bcast>");
2231 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2232 (mask
->has_eth_dst
) &&
2233 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2234 monitor_printf(mon
, " dst <any ucast>");
2236 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2237 if (mask
->has_eth_dst
) {
2238 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2243 if (key
->has_ip_proto
) {
2244 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2245 if (mask
->has_ip_proto
) {
2246 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2250 if (key
->has_ip_tos
) {
2251 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2252 if (mask
->has_ip_tos
) {
2253 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2257 if (key
->has_ip_dst
) {
2258 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2261 if (action
->has_goto_tbl
|| action
->has_group_id
||
2262 action
->has_new_vlan_id
) {
2263 monitor_printf(mon
, " -->");
2266 if (action
->has_new_vlan_id
) {
2267 monitor_printf(mon
, " apply new vlan %d",
2268 ntohs(action
->new_vlan_id
));
2271 if (action
->has_group_id
) {
2272 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2275 if (action
->has_goto_tbl
) {
2276 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2279 monitor_printf(mon
, "\n");
2282 qapi_free_RockerOfDpaFlowList(list
);
2285 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2287 RockerOfDpaGroupList
*list
, *g
;
2288 const char *name
= qdict_get_str(qdict
, "name");
2289 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2293 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &errp
);
2295 hmp_handle_error(mon
, &errp
);
2299 monitor_printf(mon
, "id (decode) --> buckets\n");
2301 for (g
= list
; g
; g
= g
->next
) {
2302 RockerOfDpaGroup
*group
= g
->value
;
2304 monitor_printf(mon
, "0x%08x", group
->id
);
2306 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2307 group
->type
== 1 ? "L2 rewrite" :
2308 group
->type
== 2 ? "L3 unicast" :
2309 group
->type
== 3 ? "L2 multicast" :
2310 group
->type
== 4 ? "L2 flood" :
2311 group
->type
== 5 ? "L3 interface" :
2312 group
->type
== 6 ? "L3 multicast" :
2313 group
->type
== 7 ? "L3 ECMP" :
2314 group
->type
== 8 ? "L2 overlay" :
2317 if (group
->has_vlan_id
) {
2318 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2321 if (group
->has_pport
) {
2322 monitor_printf(mon
, " pport %d", group
->pport
);
2325 if (group
->has_index
) {
2326 monitor_printf(mon
, " index %d", group
->index
);
2329 monitor_printf(mon
, ") -->");
2331 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2333 monitor_printf(mon
, " set vlan %d",
2334 group
->set_vlan_id
& VLAN_VID_MASK
);
2337 if (group
->has_set_eth_src
) {
2340 monitor_printf(mon
, " set");
2342 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2345 if (group
->has_set_eth_dst
) {
2348 monitor_printf(mon
, " set");
2350 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2355 if (group
->has_ttl_check
&& group
->ttl_check
) {
2356 monitor_printf(mon
, " check TTL");
2359 if (group
->has_group_id
&& group
->group_id
) {
2360 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2363 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2364 monitor_printf(mon
, " pop vlan");
2367 if (group
->has_out_pport
) {
2368 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2371 if (group
->has_group_ids
) {
2372 struct uint32List
*id
;
2374 monitor_printf(mon
, " groups [");
2375 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2376 monitor_printf(mon
, "0x%08x", id
->value
);
2378 monitor_printf(mon
, ",");
2381 monitor_printf(mon
, "]");
2384 monitor_printf(mon
, "\n");
2387 qapi_free_RockerOfDpaGroupList(list
);