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 if (cpu
->value
->has_pc
) {
315 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->pc
);
317 if (cpu
->value
->has_nip
) {
318 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->nip
);
320 if (cpu
->value
->has_npc
) {
321 monitor_printf(mon
, " npc=0x%016" PRIx64
, cpu
->value
->npc
);
323 if (cpu
->value
->has_PC
) {
324 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->PC
);
327 if (cpu
->value
->halted
) {
328 monitor_printf(mon
, " (halted)");
331 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
334 qapi_free_CpuInfoList(cpu_list
);
337 static void print_block_info(Monitor
*mon
, BlockInfo
*info
,
338 BlockDeviceInfo
*inserted
, bool verbose
)
340 ImageInfo
*image_info
;
342 assert(!info
|| !info
->has_inserted
|| info
->inserted
== inserted
);
345 monitor_printf(mon
, "%s", info
->device
);
346 if (inserted
&& inserted
->has_node_name
) {
347 monitor_printf(mon
, " (%s)", inserted
->node_name
);
351 monitor_printf(mon
, "%s",
352 inserted
->has_node_name
353 ? inserted
->node_name
358 monitor_printf(mon
, ": %s (%s%s%s)\n",
361 inserted
->ro
? ", read-only" : "",
362 inserted
->encrypted
? ", encrypted" : "");
364 monitor_printf(mon
, ": [not inserted]\n");
368 if (info
->has_io_status
&& info
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
369 monitor_printf(mon
, " I/O status: %s\n",
370 BlockDeviceIoStatus_lookup
[info
->io_status
]);
373 if (info
->removable
) {
374 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
375 info
->locked
? "" : "not ",
376 info
->tray_open
? "open" : "closed");
385 monitor_printf(mon
, " Cache mode: %s%s%s\n",
386 inserted
->cache
->writeback
? "writeback" : "writethrough",
387 inserted
->cache
->direct
? ", direct" : "",
388 inserted
->cache
->no_flush
? ", ignore flushes" : "");
390 if (inserted
->has_backing_file
) {
393 "(chain depth: %" PRId64
")\n",
394 inserted
->backing_file
,
395 inserted
->backing_file_depth
);
398 if (inserted
->detect_zeroes
!= BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF
) {
399 monitor_printf(mon
, " Detect zeroes: %s\n",
400 BlockdevDetectZeroesOptions_lookup
[inserted
->detect_zeroes
]);
403 if (inserted
->bps
|| inserted
->bps_rd
|| inserted
->bps_wr
||
404 inserted
->iops
|| inserted
->iops_rd
|| inserted
->iops_wr
)
406 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
407 " bps_rd=%" PRId64
" bps_wr=%" PRId64
409 " bps_rd_max=%" PRId64
410 " bps_wr_max=%" PRId64
411 " iops=%" PRId64
" iops_rd=%" PRId64
414 " iops_rd_max=%" PRId64
415 " iops_wr_max=%" PRId64
416 " iops_size=%" PRId64
422 inserted
->bps_rd_max
,
423 inserted
->bps_wr_max
,
428 inserted
->iops_rd_max
,
429 inserted
->iops_wr_max
,
435 monitor_printf(mon
, "\nImages:\n");
436 image_info
= inserted
->image
;
438 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
440 if (image_info
->has_backing_image
) {
441 image_info
= image_info
->backing_image
;
449 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
451 BlockInfoList
*block_list
, *info
;
452 BlockDeviceInfoList
*blockdev_list
, *blockdev
;
453 const char *device
= qdict_get_try_str(qdict
, "device");
454 bool verbose
= qdict_get_try_bool(qdict
, "verbose", false);
455 bool nodes
= qdict_get_try_bool(qdict
, "nodes", false);
456 bool printed
= false;
458 /* Print BlockBackend information */
460 block_list
= qmp_query_block(NULL
);
465 for (info
= block_list
; info
; info
= info
->next
) {
466 if (device
&& strcmp(device
, info
->value
->device
)) {
470 if (info
!= block_list
) {
471 monitor_printf(mon
, "\n");
474 print_block_info(mon
, info
->value
, info
->value
->has_inserted
475 ? info
->value
->inserted
: NULL
,
480 qapi_free_BlockInfoList(block_list
);
482 if ((!device
&& !nodes
) || printed
) {
486 /* Print node information */
487 blockdev_list
= qmp_query_named_block_nodes(NULL
);
488 for (blockdev
= blockdev_list
; blockdev
; blockdev
= blockdev
->next
) {
489 assert(blockdev
->value
->has_node_name
);
490 if (device
&& strcmp(device
, blockdev
->value
->node_name
)) {
494 if (blockdev
!= blockdev_list
) {
495 monitor_printf(mon
, "\n");
498 print_block_info(mon
, NULL
, blockdev
->value
, verbose
);
500 qapi_free_BlockDeviceInfoList(blockdev_list
);
503 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
505 BlockStatsList
*stats_list
, *stats
;
507 stats_list
= qmp_query_blockstats(false, false, NULL
);
509 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
510 if (!stats
->value
->has_device
) {
514 monitor_printf(mon
, "%s:", stats
->value
->device
);
515 monitor_printf(mon
, " rd_bytes=%" PRId64
517 " rd_operations=%" PRId64
518 " wr_operations=%" PRId64
519 " flush_operations=%" PRId64
520 " wr_total_time_ns=%" PRId64
521 " rd_total_time_ns=%" PRId64
522 " flush_total_time_ns=%" PRId64
523 " rd_merged=%" PRId64
524 " wr_merged=%" PRId64
525 " idle_time_ns=%" PRId64
527 stats
->value
->stats
->rd_bytes
,
528 stats
->value
->stats
->wr_bytes
,
529 stats
->value
->stats
->rd_operations
,
530 stats
->value
->stats
->wr_operations
,
531 stats
->value
->stats
->flush_operations
,
532 stats
->value
->stats
->wr_total_time_ns
,
533 stats
->value
->stats
->rd_total_time_ns
,
534 stats
->value
->stats
->flush_total_time_ns
,
535 stats
->value
->stats
->rd_merged
,
536 stats
->value
->stats
->wr_merged
,
537 stats
->value
->stats
->idle_time_ns
);
540 qapi_free_BlockStatsList(stats_list
);
543 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
547 VncClientInfoList
*client
;
549 info
= qmp_query_vnc(&err
);
551 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
556 if (!info
->enabled
) {
557 monitor_printf(mon
, "Server: disabled\n");
561 monitor_printf(mon
, "Server:\n");
562 if (info
->has_host
&& info
->has_service
) {
563 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
565 if (info
->has_auth
) {
566 monitor_printf(mon
, " auth: %s\n", info
->auth
);
569 if (!info
->has_clients
|| info
->clients
== NULL
) {
570 monitor_printf(mon
, "Client: none\n");
572 for (client
= info
->clients
; client
; client
= client
->next
) {
573 monitor_printf(mon
, "Client:\n");
574 monitor_printf(mon
, " address: %s:%s\n",
576 client
->value
->service
);
577 monitor_printf(mon
, " x509_dname: %s\n",
578 client
->value
->x509_dname
?
579 client
->value
->x509_dname
: "none");
580 monitor_printf(mon
, " username: %s\n",
581 client
->value
->has_sasl_username
?
582 client
->value
->sasl_username
: "none");
587 qapi_free_VncInfo(info
);
591 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
593 SpiceChannelList
*chan
;
595 const char *channel_name
;
596 const char * const channel_names
[] = {
597 [SPICE_CHANNEL_MAIN
] = "main",
598 [SPICE_CHANNEL_DISPLAY
] = "display",
599 [SPICE_CHANNEL_INPUTS
] = "inputs",
600 [SPICE_CHANNEL_CURSOR
] = "cursor",
601 [SPICE_CHANNEL_PLAYBACK
] = "playback",
602 [SPICE_CHANNEL_RECORD
] = "record",
603 [SPICE_CHANNEL_TUNNEL
] = "tunnel",
604 [SPICE_CHANNEL_SMARTCARD
] = "smartcard",
605 [SPICE_CHANNEL_USBREDIR
] = "usbredir",
606 [SPICE_CHANNEL_PORT
] = "port",
608 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
609 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
610 * as quick fix for build failures with older versions. */
611 [SPICE_CHANNEL_WEBDAV
] = "webdav",
615 info
= qmp_query_spice(NULL
);
617 if (!info
->enabled
) {
618 monitor_printf(mon
, "Server: disabled\n");
622 monitor_printf(mon
, "Server:\n");
623 if (info
->has_port
) {
624 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
625 info
->host
, info
->port
);
627 if (info
->has_tls_port
) {
628 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
629 info
->host
, info
->tls_port
);
631 monitor_printf(mon
, " migrated: %s\n",
632 info
->migrated
? "true" : "false");
633 monitor_printf(mon
, " auth: %s\n", info
->auth
);
634 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
635 monitor_printf(mon
, " mouse-mode: %s\n",
636 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
638 if (!info
->has_channels
|| info
->channels
== NULL
) {
639 monitor_printf(mon
, "Channels: none\n");
641 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
642 monitor_printf(mon
, "Channel:\n");
643 monitor_printf(mon
, " address: %s:%s%s\n",
644 chan
->value
->host
, chan
->value
->port
,
645 chan
->value
->tls
? " [tls]" : "");
646 monitor_printf(mon
, " session: %" PRId64
"\n",
647 chan
->value
->connection_id
);
648 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
649 chan
->value
->channel_type
, chan
->value
->channel_id
);
651 channel_name
= "unknown";
652 if (chan
->value
->channel_type
> 0 &&
653 chan
->value
->channel_type
< ARRAY_SIZE(channel_names
) &&
654 channel_names
[chan
->value
->channel_type
]) {
655 channel_name
= channel_names
[chan
->value
->channel_type
];
658 monitor_printf(mon
, " channel name: %s\n", channel_name
);
663 qapi_free_SpiceInfo(info
);
667 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
672 info
= qmp_query_balloon(&err
);
674 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
679 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
681 qapi_free_BalloonInfo(info
);
684 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
686 PciMemoryRegionList
*region
;
688 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
689 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
690 dev
->slot
, dev
->function
);
691 monitor_printf(mon
, " ");
693 if (dev
->class_info
->has_desc
) {
694 monitor_printf(mon
, "%s", dev
->class_info
->desc
);
696 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
->q_class
);
699 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
700 dev
->id
->vendor
, dev
->id
->device
);
703 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
706 if (dev
->has_pci_bridge
) {
707 monitor_printf(mon
, " BUS %" PRId64
".\n",
708 dev
->pci_bridge
->bus
->number
);
709 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
710 dev
->pci_bridge
->bus
->secondary
);
711 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
712 dev
->pci_bridge
->bus
->subordinate
);
714 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
715 dev
->pci_bridge
->bus
->io_range
->base
,
716 dev
->pci_bridge
->bus
->io_range
->limit
);
719 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
720 dev
->pci_bridge
->bus
->memory_range
->base
,
721 dev
->pci_bridge
->bus
->memory_range
->limit
);
723 monitor_printf(mon
, " prefetchable memory range "
724 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
725 dev
->pci_bridge
->bus
->prefetchable_range
->base
,
726 dev
->pci_bridge
->bus
->prefetchable_range
->limit
);
729 for (region
= dev
->regions
; region
; region
= region
->next
) {
732 addr
= region
->value
->address
;
733 size
= region
->value
->size
;
735 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
737 if (!strcmp(region
->value
->type
, "io")) {
738 monitor_printf(mon
, "I/O at 0x%04" PRIx64
739 " [0x%04" PRIx64
"].\n",
740 addr
, addr
+ size
- 1);
742 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
743 " [0x%08" PRIx64
"].\n",
744 region
->value
->mem_type_64
? 64 : 32,
745 region
->value
->prefetch
? " prefetchable" : "",
746 addr
, addr
+ size
- 1);
750 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
752 if (dev
->has_pci_bridge
) {
753 if (dev
->pci_bridge
->has_devices
) {
754 PciDeviceInfoList
*cdev
;
755 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
756 hmp_info_pci_device(mon
, cdev
->value
);
762 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
764 PciInfoList
*info_list
, *info
;
767 info_list
= qmp_query_pci(&err
);
769 monitor_printf(mon
, "PCI devices not supported\n");
774 for (info
= info_list
; info
; info
= info
->next
) {
775 PciDeviceInfoList
*dev
;
777 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
778 hmp_info_pci_device(mon
, dev
->value
);
782 qapi_free_PciInfoList(info_list
);
785 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
787 BlockJobInfoList
*list
;
790 list
= qmp_query_block_jobs(&err
);
794 monitor_printf(mon
, "No active jobs\n");
799 if (strcmp(list
->value
->type
, "stream") == 0) {
800 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
801 " of %" PRId64
" bytes, speed limit %" PRId64
808 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
809 " of %" PRId64
" bytes, speed limit %" PRId64
820 qapi_free_BlockJobInfoList(list
);
823 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
825 TPMInfoList
*info_list
, *info
;
828 TPMPassthroughOptions
*tpo
;
830 info_list
= qmp_query_tpm(&err
);
832 monitor_printf(mon
, "TPM device not supported\n");
838 monitor_printf(mon
, "TPM device:\n");
841 for (info
= info_list
; info
; info
= info
->next
) {
842 TPMInfo
*ti
= info
->value
;
843 monitor_printf(mon
, " tpm%d: model=%s\n",
844 c
, TpmModel_lookup
[ti
->model
]);
846 monitor_printf(mon
, " \\ %s: type=%s",
847 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->type
]);
849 switch (ti
->options
->type
) {
850 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
851 tpo
= ti
->options
->u
.passthrough
;
852 monitor_printf(mon
, "%s%s%s%s",
853 tpo
->has_path
? ",path=" : "",
854 tpo
->has_path
? tpo
->path
: "",
855 tpo
->has_cancel_path
? ",cancel-path=" : "",
856 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
858 case TPM_TYPE_OPTIONS_KIND_MAX
:
861 monitor_printf(mon
, "\n");
864 qapi_free_TPMInfoList(info_list
);
867 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
869 monitor_suspend(mon
);
873 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
878 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
880 qmp_system_reset(NULL
);
883 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
885 qmp_system_powerdown(NULL
);
888 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
892 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
893 use it are converted to the QAPI */
894 cpu_index
= qdict_get_int(qdict
, "index");
895 if (monitor_set_cpu(cpu_index
) < 0) {
896 monitor_printf(mon
, "invalid CPU index\n");
900 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
902 uint32_t size
= qdict_get_int(qdict
, "size");
903 const char *filename
= qdict_get_str(qdict
, "filename");
904 uint64_t addr
= qdict_get_int(qdict
, "val");
907 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &err
);
908 hmp_handle_error(mon
, &err
);
911 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
913 uint32_t size
= qdict_get_int(qdict
, "size");
914 const char *filename
= qdict_get_str(qdict
, "filename");
915 uint64_t addr
= qdict_get_int(qdict
, "val");
918 qmp_pmemsave(addr
, size
, filename
, &err
);
919 hmp_handle_error(mon
, &err
);
922 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
924 const char *chardev
= qdict_get_str(qdict
, "device");
925 const char *data
= qdict_get_str(qdict
, "data");
928 qmp_ringbuf_write(chardev
, data
, false, 0, &err
);
930 hmp_handle_error(mon
, &err
);
933 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
935 uint32_t size
= qdict_get_int(qdict
, "size");
936 const char *chardev
= qdict_get_str(qdict
, "device");
941 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &err
);
943 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
948 for (i
= 0; data
[i
]; i
++) {
949 unsigned char ch
= data
[i
];
952 monitor_printf(mon
, "\\\\");
953 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
954 monitor_printf(mon
, "\\u%04X", ch
);
956 monitor_printf(mon
, "%c", ch
);
960 monitor_printf(mon
, "\n");
964 static void hmp_cont_cb(void *opaque
, int err
)
971 static bool key_is_missing(const BlockInfo
*bdev
)
973 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
976 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
978 BlockInfoList
*bdev_list
, *bdev
;
981 bdev_list
= qmp_query_block(NULL
);
982 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
983 if (key_is_missing(bdev
->value
)) {
984 monitor_read_block_device_key(mon
, bdev
->value
->device
,
991 hmp_handle_error(mon
, &err
);
994 qapi_free_BlockInfoList(bdev_list
);
997 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
999 qmp_system_wakeup(NULL
);
1002 void hmp_nmi(Monitor
*mon
, const QDict
*qdict
)
1006 qmp_inject_nmi(&err
);
1007 hmp_handle_error(mon
, &err
);
1010 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
1012 const char *name
= qdict_get_str(qdict
, "name");
1013 bool up
= qdict_get_bool(qdict
, "up");
1016 qmp_set_link(name
, up
, &err
);
1017 hmp_handle_error(mon
, &err
);
1020 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
1022 const char *device
= qdict_get_str(qdict
, "device");
1023 const char *password
= qdict_get_str(qdict
, "password");
1026 qmp_block_passwd(true, device
, false, NULL
, password
, &err
);
1027 hmp_handle_error(mon
, &err
);
1030 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
1032 int64_t value
= qdict_get_int(qdict
, "value");
1035 qmp_balloon(value
, &err
);
1037 monitor_printf(mon
, "balloon: %s\n", error_get_pretty(err
));
1042 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
1044 const char *device
= qdict_get_str(qdict
, "device");
1045 int64_t size
= qdict_get_int(qdict
, "size");
1048 qmp_block_resize(true, device
, false, NULL
, size
, &err
);
1049 hmp_handle_error(mon
, &err
);
1052 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
1054 const char *device
= qdict_get_str(qdict
, "device");
1055 const char *filename
= qdict_get_str(qdict
, "target");
1056 const char *format
= qdict_get_try_str(qdict
, "format");
1057 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1058 bool full
= qdict_get_try_bool(qdict
, "full", false);
1059 enum NewImageMode mode
;
1063 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1064 hmp_handle_error(mon
, &err
);
1069 mode
= NEW_IMAGE_MODE_EXISTING
;
1071 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1074 qmp_drive_mirror(device
, filename
, !!format
, format
,
1075 false, NULL
, false, NULL
,
1076 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1077 true, mode
, false, 0, false, 0, false, 0,
1078 false, 0, false, 0, false, true, &err
);
1079 hmp_handle_error(mon
, &err
);
1082 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
1084 const char *device
= qdict_get_str(qdict
, "device");
1085 const char *filename
= qdict_get_str(qdict
, "target");
1086 const char *format
= qdict_get_try_str(qdict
, "format");
1087 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1088 bool full
= qdict_get_try_bool(qdict
, "full", false);
1089 enum NewImageMode mode
;
1093 error_setg(&err
, QERR_MISSING_PARAMETER
, "target");
1094 hmp_handle_error(mon
, &err
);
1099 mode
= NEW_IMAGE_MODE_EXISTING
;
1101 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1104 qmp_drive_backup(device
, filename
, !!format
, format
,
1105 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
1106 true, mode
, false, 0, false, NULL
,
1107 false, 0, false, 0, &err
);
1108 hmp_handle_error(mon
, &err
);
1111 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
1113 const char *device
= qdict_get_str(qdict
, "device");
1114 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
1115 const char *format
= qdict_get_try_str(qdict
, "format");
1116 bool reuse
= qdict_get_try_bool(qdict
, "reuse", false);
1117 enum NewImageMode mode
;
1121 /* In the future, if 'snapshot-file' is not specified, the snapshot
1122 will be taken internally. Today it's actually required. */
1123 error_setg(&err
, QERR_MISSING_PARAMETER
, "snapshot-file");
1124 hmp_handle_error(mon
, &err
);
1128 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
1129 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
1130 filename
, false, NULL
,
1133 hmp_handle_error(mon
, &err
);
1136 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1138 const char *device
= qdict_get_str(qdict
, "device");
1139 const char *name
= qdict_get_str(qdict
, "name");
1142 qmp_blockdev_snapshot_internal_sync(device
, name
, &err
);
1143 hmp_handle_error(mon
, &err
);
1146 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
1148 const char *device
= qdict_get_str(qdict
, "device");
1149 const char *name
= qdict_get_str(qdict
, "name");
1150 const char *id
= qdict_get_try_str(qdict
, "id");
1153 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1155 hmp_handle_error(mon
, &err
);
1158 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1160 qmp_migrate_cancel(NULL
);
1163 void hmp_migrate_incoming(Monitor
*mon
, const QDict
*qdict
)
1166 const char *uri
= qdict_get_str(qdict
, "uri");
1168 qmp_migrate_incoming(uri
, &err
);
1170 hmp_handle_error(mon
, &err
);
1173 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1175 double value
= qdict_get_double(qdict
, "value");
1176 qmp_migrate_set_downtime(value
, NULL
);
1179 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1181 int64_t value
= qdict_get_int(qdict
, "value");
1184 qmp_migrate_set_cache_size(value
, &err
);
1186 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
1192 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1194 int64_t value
= qdict_get_int(qdict
, "value");
1195 qmp_migrate_set_speed(value
, NULL
);
1198 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1200 const char *cap
= qdict_get_str(qdict
, "capability");
1201 bool state
= qdict_get_bool(qdict
, "state");
1203 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1206 for (i
= 0; i
< MIGRATION_CAPABILITY_MAX
; i
++) {
1207 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1208 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1209 caps
->value
->capability
= i
;
1210 caps
->value
->state
= state
;
1212 qmp_migrate_set_capabilities(caps
, &err
);
1217 if (i
== MIGRATION_CAPABILITY_MAX
) {
1218 error_setg(&err
, QERR_INVALID_PARAMETER
, cap
);
1221 qapi_free_MigrationCapabilityStatusList(caps
);
1224 monitor_printf(mon
, "migrate_set_capability: %s\n",
1225 error_get_pretty(err
));
1230 void hmp_migrate_set_parameter(Monitor
*mon
, const QDict
*qdict
)
1232 const char *param
= qdict_get_str(qdict
, "parameter");
1233 int value
= qdict_get_int(qdict
, "value");
1235 bool has_compress_level
= false;
1236 bool has_compress_threads
= false;
1237 bool has_decompress_threads
= false;
1238 bool has_x_cpu_throttle_initial
= false;
1239 bool has_x_cpu_throttle_increment
= false;
1242 for (i
= 0; i
< MIGRATION_PARAMETER_MAX
; i
++) {
1243 if (strcmp(param
, MigrationParameter_lookup
[i
]) == 0) {
1245 case MIGRATION_PARAMETER_COMPRESS_LEVEL
:
1246 has_compress_level
= true;
1248 case MIGRATION_PARAMETER_COMPRESS_THREADS
:
1249 has_compress_threads
= true;
1251 case MIGRATION_PARAMETER_DECOMPRESS_THREADS
:
1252 has_decompress_threads
= true;
1254 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL
:
1255 has_x_cpu_throttle_initial
= true;
1257 case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT
:
1258 has_x_cpu_throttle_increment
= true;
1261 qmp_migrate_set_parameters(has_compress_level
, value
,
1262 has_compress_threads
, value
,
1263 has_decompress_threads
, value
,
1264 has_x_cpu_throttle_initial
, value
,
1265 has_x_cpu_throttle_increment
, value
,
1271 if (i
== MIGRATION_PARAMETER_MAX
) {
1272 error_setg(&err
, QERR_INVALID_PARAMETER
, param
);
1276 monitor_printf(mon
, "migrate_set_parameter: %s\n",
1277 error_get_pretty(err
));
1282 void hmp_client_migrate_info(Monitor
*mon
, const QDict
*qdict
)
1285 const char *protocol
= qdict_get_str(qdict
, "protocol");
1286 const char *hostname
= qdict_get_str(qdict
, "hostname");
1287 bool has_port
= qdict_haskey(qdict
, "port");
1288 int port
= qdict_get_try_int(qdict
, "port", -1);
1289 bool has_tls_port
= qdict_haskey(qdict
, "tls-port");
1290 int tls_port
= qdict_get_try_int(qdict
, "tls-port", -1);
1291 const char *cert_subject
= qdict_get_try_str(qdict
, "cert-subject");
1293 qmp_client_migrate_info(protocol
, hostname
,
1294 has_port
, port
, has_tls_port
, tls_port
,
1295 !!cert_subject
, cert_subject
, &err
);
1296 hmp_handle_error(mon
, &err
);
1299 void hmp_migrate_start_postcopy(Monitor
*mon
, const QDict
*qdict
)
1302 qmp_migrate_start_postcopy(&err
);
1303 hmp_handle_error(mon
, &err
);
1306 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1308 const char *protocol
= qdict_get_str(qdict
, "protocol");
1309 const char *password
= qdict_get_str(qdict
, "password");
1310 const char *connected
= qdict_get_try_str(qdict
, "connected");
1313 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1314 hmp_handle_error(mon
, &err
);
1317 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1319 const char *protocol
= qdict_get_str(qdict
, "protocol");
1320 const char *whenstr
= qdict_get_str(qdict
, "time");
1323 qmp_expire_password(protocol
, whenstr
, &err
);
1324 hmp_handle_error(mon
, &err
);
1327 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1329 bool force
= qdict_get_try_bool(qdict
, "force", false);
1330 const char *device
= qdict_get_str(qdict
, "device");
1333 qmp_eject(device
, true, force
, &err
);
1334 hmp_handle_error(mon
, &err
);
1337 static void hmp_change_read_arg(void *opaque
, const char *password
,
1338 void *readline_opaque
)
1340 qmp_change_vnc_password(password
, NULL
);
1341 monitor_read_command(opaque
, 1);
1344 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1346 const char *device
= qdict_get_str(qdict
, "device");
1347 const char *target
= qdict_get_str(qdict
, "target");
1348 const char *arg
= qdict_get_try_str(qdict
, "arg");
1349 const char *read_only
= qdict_get_try_str(qdict
, "read-only-mode");
1350 BlockdevChangeReadOnlyMode read_only_mode
= 0;
1353 if (strcmp(device
, "vnc") == 0) {
1356 "Parameter 'read-only-mode' is invalid for VNC\n");
1359 if (strcmp(target
, "passwd") == 0 ||
1360 strcmp(target
, "password") == 0) {
1362 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1366 qmp_change("vnc", target
, !!arg
, arg
, &err
);
1370 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup
,
1371 read_only
, BLOCKDEV_CHANGE_READ_ONLY_MODE_MAX
,
1372 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN
, &err
);
1374 hmp_handle_error(mon
, &err
);
1379 qmp_blockdev_change_medium(device
, target
, !!arg
, arg
,
1380 !!read_only
, read_only_mode
, &err
);
1382 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1384 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1389 hmp_handle_error(mon
, &err
);
1392 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1396 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1397 qdict_get_int(qdict
, "bps"),
1398 qdict_get_int(qdict
, "bps_rd"),
1399 qdict_get_int(qdict
, "bps_wr"),
1400 qdict_get_int(qdict
, "iops"),
1401 qdict_get_int(qdict
, "iops_rd"),
1402 qdict_get_int(qdict
, "iops_wr"),
1403 false, /* no burst max via HMP */
1415 false, /* No default I/O size */
1419 hmp_handle_error(mon
, &err
);
1422 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1424 Error
*error
= NULL
;
1425 const char *device
= qdict_get_str(qdict
, "device");
1426 const char *base
= qdict_get_try_str(qdict
, "base");
1427 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1429 qmp_block_stream(device
, base
!= NULL
, base
, false, NULL
,
1430 qdict_haskey(qdict
, "speed"), speed
,
1431 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1433 hmp_handle_error(mon
, &error
);
1436 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1438 Error
*error
= NULL
;
1439 const char *device
= qdict_get_str(qdict
, "device");
1440 int64_t value
= qdict_get_int(qdict
, "speed");
1442 qmp_block_job_set_speed(device
, value
, &error
);
1444 hmp_handle_error(mon
, &error
);
1447 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1449 Error
*error
= NULL
;
1450 const char *device
= qdict_get_str(qdict
, "device");
1451 bool force
= qdict_get_try_bool(qdict
, "force", false);
1453 qmp_block_job_cancel(device
, true, force
, &error
);
1455 hmp_handle_error(mon
, &error
);
1458 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1460 Error
*error
= NULL
;
1461 const char *device
= qdict_get_str(qdict
, "device");
1463 qmp_block_job_pause(device
, &error
);
1465 hmp_handle_error(mon
, &error
);
1468 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1470 Error
*error
= NULL
;
1471 const char *device
= qdict_get_str(qdict
, "device");
1473 qmp_block_job_resume(device
, &error
);
1475 hmp_handle_error(mon
, &error
);
1478 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1480 Error
*error
= NULL
;
1481 const char *device
= qdict_get_str(qdict
, "device");
1483 qmp_block_job_complete(device
, &error
);
1485 hmp_handle_error(mon
, &error
);
1488 typedef struct HMPMigrationStatus
1492 bool is_block_migration
;
1493 } HMPMigrationStatus
;
1495 static void hmp_migrate_status_cb(void *opaque
)
1497 HMPMigrationStatus
*status
= opaque
;
1498 MigrationInfo
*info
;
1500 info
= qmp_query_migrate(NULL
);
1501 if (!info
->has_status
|| info
->status
== MIGRATION_STATUS_ACTIVE
||
1502 info
->status
== MIGRATION_STATUS_SETUP
) {
1503 if (info
->has_disk
) {
1506 if (info
->disk
->remaining
) {
1507 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1512 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1513 monitor_flush(status
->mon
);
1516 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1518 if (status
->is_block_migration
) {
1519 monitor_printf(status
->mon
, "\n");
1521 monitor_resume(status
->mon
);
1522 timer_del(status
->timer
);
1526 qapi_free_MigrationInfo(info
);
1529 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1531 bool detach
= qdict_get_try_bool(qdict
, "detach", false);
1532 bool blk
= qdict_get_try_bool(qdict
, "blk", false);
1533 bool inc
= qdict_get_try_bool(qdict
, "inc", false);
1534 const char *uri
= qdict_get_str(qdict
, "uri");
1537 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1539 monitor_printf(mon
, "migrate: %s\n", error_get_pretty(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
);
1674 visit_start_struct(opts_get_visitor(ov
), &dummy
, NULL
, NULL
, 0, &err
);
1679 qdict_del(pdict
, "qom-type");
1680 visit_type_str(opts_get_visitor(ov
), &type
, "qom-type", &err
);
1685 qdict_del(pdict
, "id");
1686 visit_type_str(opts_get_visitor(ov
), &id
, "id", &err
);
1691 object_add(type
, id
, pdict
, opts_get_visitor(ov
), &err
);
1694 visit_end_struct(opts_get_visitor(ov
), &err_end
);
1695 if (!err
&& err_end
) {
1696 qmp_object_del(id
, NULL
);
1698 error_propagate(&err
, err_end
);
1700 opts_visitor_cleanup(ov
);
1703 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);
1737 char keyname_buf
[16];
1742 separator
= strchr(keys
, '-');
1743 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1744 pstrcpy(keyname_buf
, sizeof(keyname_buf
), keys
);
1746 /* Be compatible with old interface, convert user inputted "<" */
1747 if (!strncmp(keyname_buf
, "<", 1) && keyname_len
== 1) {
1748 pstrcpy(keyname_buf
, sizeof(keyname_buf
), "less");
1751 keyname_buf
[keyname_len
] = 0;
1753 keylist
= g_malloc0(sizeof(*keylist
));
1754 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1760 tmp
->next
= keylist
;
1764 if (strstart(keyname_buf
, "0x", NULL
)) {
1766 int value
= strtoul(keyname_buf
, &endp
, 0);
1767 if (*endp
!= '\0') {
1770 keylist
->value
->type
= KEY_VALUE_KIND_NUMBER
;
1771 keylist
->value
->u
.number
= value
;
1773 int idx
= index_from_key(keyname_buf
);
1774 if (idx
== Q_KEY_CODE_MAX
) {
1777 keylist
->value
->type
= KEY_VALUE_KIND_QCODE
;
1778 keylist
->value
->u
.qcode
= idx
;
1784 keys
= separator
+ 1;
1787 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1788 hmp_handle_error(mon
, &err
);
1791 qapi_free_KeyValueList(head
);
1795 monitor_printf(mon
, "invalid parameter: %s\n", keyname_buf
);
1799 void hmp_screendump(Monitor
*mon
, const QDict
*qdict
)
1801 const char *filename
= qdict_get_str(qdict
, "filename");
1804 qmp_screendump(filename
, &err
);
1805 hmp_handle_error(mon
, &err
);
1808 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1810 const char *uri
= qdict_get_str(qdict
, "uri");
1811 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1812 bool all
= qdict_get_try_bool(qdict
, "all", false);
1813 Error
*local_err
= NULL
;
1814 BlockInfoList
*block_list
, *info
;
1815 SocketAddress
*addr
;
1817 if (writable
&& !all
) {
1818 error_setg(&local_err
, "-w only valid together with -a");
1822 /* First check if the address is valid and start the server. */
1823 addr
= socket_parse(uri
, &local_err
);
1824 if (local_err
!= NULL
) {
1828 qmp_nbd_server_start(addr
, &local_err
);
1829 qapi_free_SocketAddress(addr
);
1830 if (local_err
!= NULL
) {
1838 /* Then try adding all block devices. If one fails, close all and
1841 block_list
= qmp_query_block(NULL
);
1843 for (info
= block_list
; info
; info
= info
->next
) {
1844 if (!info
->value
->has_inserted
) {
1848 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1850 if (local_err
!= NULL
) {
1851 qmp_nbd_server_stop(NULL
);
1856 qapi_free_BlockInfoList(block_list
);
1859 hmp_handle_error(mon
, &local_err
);
1862 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1864 const char *device
= qdict_get_str(qdict
, "device");
1865 bool writable
= qdict_get_try_bool(qdict
, "writable", false);
1866 Error
*local_err
= NULL
;
1868 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1870 if (local_err
!= NULL
) {
1871 hmp_handle_error(mon
, &local_err
);
1875 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1879 qmp_nbd_server_stop(&err
);
1880 hmp_handle_error(mon
, &err
);
1883 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1888 cpuid
= qdict_get_int(qdict
, "id");
1889 qmp_cpu_add(cpuid
, &err
);
1890 hmp_handle_error(mon
, &err
);
1893 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1895 const char *args
= qdict_get_str(qdict
, "args");
1899 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"), args
, true);
1901 error_setg(&err
, "Parsing chardev args failed");
1903 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1905 hmp_handle_error(mon
, &err
);
1908 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1910 Error
*local_err
= NULL
;
1912 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1913 hmp_handle_error(mon
, &local_err
);
1916 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1919 const char* device
= qdict_get_str(qdict
, "device");
1920 const char* command
= qdict_get_str(qdict
, "command");
1923 blk
= blk_by_name(device
);
1925 qemuio_command(blk
, command
);
1927 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
1928 "Device '%s' not found", device
);
1931 hmp_handle_error(mon
, &err
);
1934 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1936 const char *id
= qdict_get_str(qdict
, "id");
1939 qmp_object_del(id
, &err
);
1940 hmp_handle_error(mon
, &err
);
1943 void hmp_info_memdev(Monitor
*mon
, const QDict
*qdict
)
1946 MemdevList
*memdev_list
= qmp_query_memdev(&err
);
1947 MemdevList
*m
= memdev_list
;
1948 StringOutputVisitor
*ov
;
1954 ov
= string_output_visitor_new(false);
1955 visit_type_uint16List(string_output_get_visitor(ov
),
1956 &m
->value
->host_nodes
, NULL
, NULL
);
1957 monitor_printf(mon
, "memory backend: %d\n", i
);
1958 monitor_printf(mon
, " size: %" PRId64
"\n", m
->value
->size
);
1959 monitor_printf(mon
, " merge: %s\n",
1960 m
->value
->merge
? "true" : "false");
1961 monitor_printf(mon
, " dump: %s\n",
1962 m
->value
->dump
? "true" : "false");
1963 monitor_printf(mon
, " prealloc: %s\n",
1964 m
->value
->prealloc
? "true" : "false");
1965 monitor_printf(mon
, " policy: %s\n",
1966 HostMemPolicy_lookup
[m
->value
->policy
]);
1967 str
= string_output_get_string(ov
);
1968 monitor_printf(mon
, " host nodes: %s\n", str
);
1971 string_output_visitor_cleanup(ov
);
1976 monitor_printf(mon
, "\n");
1978 qapi_free_MemdevList(memdev_list
);
1981 void hmp_info_memory_devices(Monitor
*mon
, const QDict
*qdict
)
1984 MemoryDeviceInfoList
*info_list
= qmp_query_memory_devices(&err
);
1985 MemoryDeviceInfoList
*info
;
1986 MemoryDeviceInfo
*value
;
1987 PCDIMMDeviceInfo
*di
;
1989 for (info
= info_list
; info
; info
= info
->next
) {
1990 value
= info
->value
;
1993 switch (value
->type
) {
1994 case MEMORY_DEVICE_INFO_KIND_DIMM
:
1997 monitor_printf(mon
, "Memory device [%s]: \"%s\"\n",
1998 MemoryDeviceInfoKind_lookup
[value
->type
],
1999 di
->id
? di
->id
: "");
2000 monitor_printf(mon
, " addr: 0x%" PRIx64
"\n", di
->addr
);
2001 monitor_printf(mon
, " slot: %" PRId64
"\n", di
->slot
);
2002 monitor_printf(mon
, " node: %" PRId64
"\n", di
->node
);
2003 monitor_printf(mon
, " size: %" PRIu64
"\n", di
->size
);
2004 monitor_printf(mon
, " memdev: %s\n", di
->memdev
);
2005 monitor_printf(mon
, " hotplugged: %s\n",
2006 di
->hotplugged
? "true" : "false");
2007 monitor_printf(mon
, " hotpluggable: %s\n",
2008 di
->hotpluggable
? "true" : "false");
2016 qapi_free_MemoryDeviceInfoList(info_list
);
2019 void hmp_info_iothreads(Monitor
*mon
, const QDict
*qdict
)
2021 IOThreadInfoList
*info_list
= qmp_query_iothreads(NULL
);
2022 IOThreadInfoList
*info
;
2024 for (info
= info_list
; info
; info
= info
->next
) {
2025 monitor_printf(mon
, "%s: thread_id=%" PRId64
"\n",
2026 info
->value
->id
, info
->value
->thread_id
);
2029 qapi_free_IOThreadInfoList(info_list
);
2032 void hmp_qom_list(Monitor
*mon
, const QDict
*qdict
)
2034 const char *path
= qdict_get_try_str(qdict
, "path");
2035 ObjectPropertyInfoList
*list
;
2039 monitor_printf(mon
, "/\n");
2043 list
= qmp_qom_list(path
, &err
);
2045 ObjectPropertyInfoList
*start
= list
;
2046 while (list
!= NULL
) {
2047 ObjectPropertyInfo
*value
= list
->value
;
2049 monitor_printf(mon
, "%s (%s)\n",
2050 value
->name
, value
->type
);
2053 qapi_free_ObjectPropertyInfoList(start
);
2055 hmp_handle_error(mon
, &err
);
2058 void hmp_qom_set(Monitor
*mon
, const QDict
*qdict
)
2060 const char *path
= qdict_get_str(qdict
, "path");
2061 const char *property
= qdict_get_str(qdict
, "property");
2062 const char *value
= qdict_get_str(qdict
, "value");
2064 bool ambiguous
= false;
2067 obj
= object_resolve_path(path
, &ambiguous
);
2069 error_set(&err
, ERROR_CLASS_DEVICE_NOT_FOUND
,
2070 "Device '%s' not found", path
);
2073 monitor_printf(mon
, "Warning: Path '%s' is ambiguous\n", path
);
2075 object_property_parse(obj
, value
, property
, &err
);
2077 hmp_handle_error(mon
, &err
);
2080 void hmp_rocker(Monitor
*mon
, const QDict
*qdict
)
2082 const char *name
= qdict_get_str(qdict
, "name");
2083 RockerSwitch
*rocker
;
2086 rocker
= qmp_query_rocker(name
, &errp
);
2088 hmp_handle_error(mon
, &errp
);
2092 monitor_printf(mon
, "name: %s\n", rocker
->name
);
2093 monitor_printf(mon
, "id: 0x%" PRIx64
"\n", rocker
->id
);
2094 monitor_printf(mon
, "ports: %d\n", rocker
->ports
);
2096 qapi_free_RockerSwitch(rocker
);
2099 void hmp_rocker_ports(Monitor
*mon
, const QDict
*qdict
)
2101 RockerPortList
*list
, *port
;
2102 const char *name
= qdict_get_str(qdict
, "name");
2105 list
= qmp_query_rocker_ports(name
, &errp
);
2107 hmp_handle_error(mon
, &errp
);
2111 monitor_printf(mon
, " ena/ speed/ auto\n");
2112 monitor_printf(mon
, " port link duplex neg?\n");
2114 for (port
= list
; port
; port
= port
->next
) {
2115 monitor_printf(mon
, "%10s %-4s %-3s %2s %-3s\n",
2117 port
->value
->enabled
? port
->value
->link_up
?
2118 "up" : "down" : "!ena",
2119 port
->value
->speed
== 10000 ? "10G" : "??",
2120 port
->value
->duplex
? "FD" : "HD",
2121 port
->value
->autoneg
? "Yes" : "No");
2124 qapi_free_RockerPortList(list
);
2127 void hmp_rocker_of_dpa_flows(Monitor
*mon
, const QDict
*qdict
)
2129 RockerOfDpaFlowList
*list
, *info
;
2130 const char *name
= qdict_get_str(qdict
, "name");
2131 uint32_t tbl_id
= qdict_get_try_int(qdict
, "tbl_id", -1);
2134 list
= qmp_query_rocker_of_dpa_flows(name
, tbl_id
!= -1, tbl_id
, &errp
);
2136 hmp_handle_error(mon
, &errp
);
2140 monitor_printf(mon
, "prio tbl hits key(mask) --> actions\n");
2142 for (info
= list
; info
; info
= info
->next
) {
2143 RockerOfDpaFlow
*flow
= info
->value
;
2144 RockerOfDpaFlowKey
*key
= flow
->key
;
2145 RockerOfDpaFlowMask
*mask
= flow
->mask
;
2146 RockerOfDpaFlowAction
*action
= flow
->action
;
2149 monitor_printf(mon
, "%-4d %-3d %-4" PRIu64
,
2150 key
->priority
, key
->tbl_id
, flow
->hits
);
2152 monitor_printf(mon
, "%-4d %-3d ",
2153 key
->priority
, key
->tbl_id
);
2156 if (key
->has_in_pport
) {
2157 monitor_printf(mon
, " pport %d", key
->in_pport
);
2158 if (mask
->has_in_pport
) {
2159 monitor_printf(mon
, "(0x%x)", mask
->in_pport
);
2163 if (key
->has_vlan_id
) {
2164 monitor_printf(mon
, " vlan %d",
2165 key
->vlan_id
& VLAN_VID_MASK
);
2166 if (mask
->has_vlan_id
) {
2167 monitor_printf(mon
, "(0x%x)", mask
->vlan_id
);
2171 if (key
->has_tunnel_id
) {
2172 monitor_printf(mon
, " tunnel %d", key
->tunnel_id
);
2173 if (mask
->has_tunnel_id
) {
2174 monitor_printf(mon
, "(0x%x)", mask
->tunnel_id
);
2178 if (key
->has_eth_type
) {
2179 switch (key
->eth_type
) {
2181 monitor_printf(mon
, " ARP");
2184 monitor_printf(mon
, " IP");
2187 monitor_printf(mon
, " IPv6");
2190 monitor_printf(mon
, " LACP");
2193 monitor_printf(mon
, " LLDP");
2196 monitor_printf(mon
, " eth type 0x%04x", key
->eth_type
);
2201 if (key
->has_eth_src
) {
2202 if ((strcmp(key
->eth_src
, "01:00:00:00:00:00") == 0) &&
2203 (mask
->has_eth_src
) &&
2204 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2205 monitor_printf(mon
, " src <any mcast/bcast>");
2206 } else if ((strcmp(key
->eth_src
, "00:00:00:00:00:00") == 0) &&
2207 (mask
->has_eth_src
) &&
2208 (strcmp(mask
->eth_src
, "01:00:00:00:00:00") == 0)) {
2209 monitor_printf(mon
, " src <any ucast>");
2211 monitor_printf(mon
, " src %s", key
->eth_src
);
2212 if (mask
->has_eth_src
) {
2213 monitor_printf(mon
, "(%s)", mask
->eth_src
);
2218 if (key
->has_eth_dst
) {
2219 if ((strcmp(key
->eth_dst
, "01:00:00:00:00:00") == 0) &&
2220 (mask
->has_eth_dst
) &&
2221 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2222 monitor_printf(mon
, " dst <any mcast/bcast>");
2223 } else if ((strcmp(key
->eth_dst
, "00:00:00:00:00:00") == 0) &&
2224 (mask
->has_eth_dst
) &&
2225 (strcmp(mask
->eth_dst
, "01:00:00:00:00:00") == 0)) {
2226 monitor_printf(mon
, " dst <any ucast>");
2228 monitor_printf(mon
, " dst %s", key
->eth_dst
);
2229 if (mask
->has_eth_dst
) {
2230 monitor_printf(mon
, "(%s)", mask
->eth_dst
);
2235 if (key
->has_ip_proto
) {
2236 monitor_printf(mon
, " proto %d", key
->ip_proto
);
2237 if (mask
->has_ip_proto
) {
2238 monitor_printf(mon
, "(0x%x)", mask
->ip_proto
);
2242 if (key
->has_ip_tos
) {
2243 monitor_printf(mon
, " TOS %d", key
->ip_tos
);
2244 if (mask
->has_ip_tos
) {
2245 monitor_printf(mon
, "(0x%x)", mask
->ip_tos
);
2249 if (key
->has_ip_dst
) {
2250 monitor_printf(mon
, " dst %s", key
->ip_dst
);
2253 if (action
->has_goto_tbl
|| action
->has_group_id
||
2254 action
->has_new_vlan_id
) {
2255 monitor_printf(mon
, " -->");
2258 if (action
->has_new_vlan_id
) {
2259 monitor_printf(mon
, " apply new vlan %d",
2260 ntohs(action
->new_vlan_id
));
2263 if (action
->has_group_id
) {
2264 monitor_printf(mon
, " write group 0x%08x", action
->group_id
);
2267 if (action
->has_goto_tbl
) {
2268 monitor_printf(mon
, " goto tbl %d", action
->goto_tbl
);
2271 monitor_printf(mon
, "\n");
2274 qapi_free_RockerOfDpaFlowList(list
);
2277 void hmp_rocker_of_dpa_groups(Monitor
*mon
, const QDict
*qdict
)
2279 RockerOfDpaGroupList
*list
, *g
;
2280 const char *name
= qdict_get_str(qdict
, "name");
2281 uint8_t type
= qdict_get_try_int(qdict
, "type", 9);
2285 list
= qmp_query_rocker_of_dpa_groups(name
, type
!= 9, type
, &errp
);
2287 hmp_handle_error(mon
, &errp
);
2291 monitor_printf(mon
, "id (decode) --> buckets\n");
2293 for (g
= list
; g
; g
= g
->next
) {
2294 RockerOfDpaGroup
*group
= g
->value
;
2296 monitor_printf(mon
, "0x%08x", group
->id
);
2298 monitor_printf(mon
, " (type %s", group
->type
== 0 ? "L2 interface" :
2299 group
->type
== 1 ? "L2 rewrite" :
2300 group
->type
== 2 ? "L3 unicast" :
2301 group
->type
== 3 ? "L2 multicast" :
2302 group
->type
== 4 ? "L2 flood" :
2303 group
->type
== 5 ? "L3 interface" :
2304 group
->type
== 6 ? "L3 multicast" :
2305 group
->type
== 7 ? "L3 ECMP" :
2306 group
->type
== 8 ? "L2 overlay" :
2309 if (group
->has_vlan_id
) {
2310 monitor_printf(mon
, " vlan %d", group
->vlan_id
);
2313 if (group
->has_pport
) {
2314 monitor_printf(mon
, " pport %d", group
->pport
);
2317 if (group
->has_index
) {
2318 monitor_printf(mon
, " index %d", group
->index
);
2321 monitor_printf(mon
, ") -->");
2323 if (group
->has_set_vlan_id
&& group
->set_vlan_id
) {
2325 monitor_printf(mon
, " set vlan %d",
2326 group
->set_vlan_id
& VLAN_VID_MASK
);
2329 if (group
->has_set_eth_src
) {
2332 monitor_printf(mon
, " set");
2334 monitor_printf(mon
, " src %s", group
->set_eth_src
);
2337 if (group
->has_set_eth_dst
) {
2340 monitor_printf(mon
, " set");
2342 monitor_printf(mon
, " dst %s", group
->set_eth_dst
);
2347 if (group
->has_ttl_check
&& group
->ttl_check
) {
2348 monitor_printf(mon
, " check TTL");
2351 if (group
->has_group_id
&& group
->group_id
) {
2352 monitor_printf(mon
, " group id 0x%08x", group
->group_id
);
2355 if (group
->has_pop_vlan
&& group
->pop_vlan
) {
2356 monitor_printf(mon
, " pop vlan");
2359 if (group
->has_out_pport
) {
2360 monitor_printf(mon
, " out pport %d", group
->out_pport
);
2363 if (group
->has_group_ids
) {
2364 struct uint32List
*id
;
2366 monitor_printf(mon
, " groups [");
2367 for (id
= group
->group_ids
; id
; id
= id
->next
) {
2368 monitor_printf(mon
, "0x%08x", id
->value
);
2370 monitor_printf(mon
, ",");
2373 monitor_printf(mon
, "]");
2376 monitor_printf(mon
, "\n");
2379 qapi_free_RockerOfDpaGroupList(list
);