2 * Human Monitor Interface
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
16 #include "qemu/osdep.h"
20 #include "sysemu/char.h"
21 #include "sysemu/block-backend.h"
22 #include "qemu/option.h"
23 #include "qemu/timer.h"
24 #include "qmp-commands.h"
25 #include "qemu/sockets.h"
26 #include "monitor/monitor.h"
27 #include "monitor/qdev.h"
28 #include "qapi/opts-visitor.h"
29 #include "qapi/qmp/qerror.h"
30 #include "qapi/string-output-visitor.h"
31 #include "qapi/util.h"
32 #include "qapi-visit.h"
33 #include "qom/object_interfaces.h"
34 #include "ui/console.h"
35 #include "block/qapi.h"
37 #include "qemu/cutils.h"
38 #include "qemu/error-report.h"
39 #include "hw/intc/intc.h"
42 #include <spice/enums.h>
45 static void hmp_handle_error(Monitor *mon, Error **errp)
49 error_report_err(*errp);
53 void hmp_info_name(Monitor *mon, const QDict *qdict)
57 info = qmp_query_name(NULL);
59 monitor_printf(mon, "%s\n", info->name);
61 qapi_free_NameInfo(info);
64 void hmp_info_version(Monitor *mon, const QDict *qdict)
68 info = qmp_query_version(NULL);
70 monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
71 info->qemu->major, info->qemu->minor, info->qemu->micro,
74 qapi_free_VersionInfo(info);
77 void hmp_info_kvm(Monitor *mon, const QDict *qdict)
81 info = qmp_query_kvm(NULL);
82 monitor_printf(mon, "kvm support: ");
84 monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
86 monitor_printf(mon, "not compiled\n");
89 qapi_free_KvmInfo(info);
92 void hmp_info_status(Monitor *mon, const QDict *qdict)
96 info = qmp_query_status(NULL);
98 monitor_printf(mon, "VM status: %s%s",
99 info->running ? "running" : "paused",
100 info->singlestep ? " (single step mode)" : "");
102 if (!info->running && info->status != RUN_STATE_PAUSED) {
103 monitor_printf(mon, " (%s)", RunState_lookup[info->status]);
106 monitor_printf(mon, "\n");
108 qapi_free_StatusInfo(info);
111 void hmp_info_uuid(Monitor *mon, const QDict *qdict)
115 info = qmp_query_uuid(NULL);
116 monitor_printf(mon, "%s\n", info->UUID);
117 qapi_free_UuidInfo(info);
120 void hmp_info_chardev(Monitor *mon, const QDict *qdict)
122 ChardevInfoList *char_info, *info;
124 char_info = qmp_query_chardev(NULL);
125 for (info = char_info; info; info = info->next) {
126 monitor_printf(mon, "%s: filename=%s\n", info->value->label,
127 info->value->filename);
130 qapi_free_ChardevInfoList(char_info);
133 void hmp_info_mice(Monitor *mon, const QDict *qdict)
135 MouseInfoList *mice_list, *mouse;
137 mice_list = qmp_query_mice(NULL);
139 monitor_printf(mon, "No mouse devices connected\n");
143 for (mouse = mice_list; mouse; mouse = mouse->next) {
144 monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n",
145 mouse->value->current ? '*' : ' ',
146 mouse->value->index, mouse->value->name,
147 mouse->value->absolute ? " (absolute)" : "");
150 qapi_free_MouseInfoList(mice_list);
153 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
156 MigrationCapabilityStatusList *caps, *cap;
158 info = qmp_query_migrate(NULL);
159 caps = qmp_query_migrate_capabilities(NULL);
161 /* do not display parameters during setup */
162 if (info->has_status && caps) {
163 monitor_printf(mon, "capabilities: ");
164 for (cap = caps; cap; cap = cap->next) {
165 monitor_printf(mon, "%s: %s ",
166 MigrationCapability_lookup[cap->value->capability],
167 cap->value->state ? "on" : "off");
169 monitor_printf(mon, "\n");
172 if (info->has_status) {
173 monitor_printf(mon, "Migration status: %s",
174 MigrationStatus_lookup[info->status]);
175 if (info->status == MIGRATION_STATUS_FAILED &&
176 info->has_error_desc) {
177 monitor_printf(mon, " (%s)\n", info->error_desc);
179 monitor_printf(mon, "\n");
182 monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
184 if (info->has_expected_downtime) {
185 monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n",
186 info->expected_downtime);
188 if (info->has_downtime) {
189 monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
192 if (info->has_setup_time) {
193 monitor_printf(mon, "setup: %" PRIu64 " milliseconds\n",
199 monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n",
200 info->ram->transferred >> 10);
201 monitor_printf(mon, "throughput: %0.2f mbps\n",
203 monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n",
204 info->ram->remaining >> 10);
205 monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n",
206 info->ram->total >> 10);
207 monitor_printf(mon, "duplicate: %" PRIu64 " pages\n",
208 info->ram->duplicate);
209 monitor_printf(mon, "skipped: %" PRIu64 " pages\n",
211 monitor_printf(mon, "normal: %" PRIu64 " pages\n",
213 monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n",
214 info->ram->normal_bytes >> 10);
215 monitor_printf(mon, "dirty sync count: %" PRIu64 "\n",
216 info->ram->dirty_sync_count);
217 if (info->ram->dirty_pages_rate) {
218 monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n",
219 info->ram->dirty_pages_rate);
221 if (info->ram->postcopy_requests) {
222 monitor_printf(mon, "postcopy request count: %" PRIu64 "\n",
223 info->ram->postcopy_requests);
227 if (info->has_disk) {
228 monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n",
229 info->disk->transferred >> 10);
230 monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n",
231 info->disk->remaining >> 10);
232 monitor_printf(mon, "total disk: %" PRIu64 " kbytes\n",
233 info->disk->total >> 10);
236 if (info->has_xbzrle_cache) {
237 monitor_printf(mon, "cache size: %" PRIu64 " bytes\n",
238 info->xbzrle_cache->cache_size);
239 monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n",
240 info->xbzrle_cache->bytes >> 10);
241 monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n",
242 info->xbzrle_cache->pages);
243 monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
244 info->xbzrle_cache->cache_miss);
245 monitor_printf(mon, "xbzrle cache miss rate: %0.2f\n",
246 info->xbzrle_cache->cache_miss_rate);
247 monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n",
248 info->xbzrle_cache->overflow);
251 if (info->has_cpu_throttle_percentage) {
252 monitor_printf(mon, "cpu throttle percentage: %" PRIu64 "\n",
253 info->cpu_throttle_percentage);
256 qapi_free_MigrationInfo(info);
257 qapi_free_MigrationCapabilityStatusList(caps);
260 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)
262 MigrationCapabilityStatusList *caps, *cap;
264 caps = qmp_query_migrate_capabilities(NULL);
267 monitor_printf(mon, "capabilities: ");
268 for (cap = caps; cap; cap = cap->next) {
269 monitor_printf(mon, "%s: %s ",
270 MigrationCapability_lookup[cap->value->capability],
271 cap->value->state ? "on" : "off");
273 monitor_printf(mon, "\n");
276 qapi_free_MigrationCapabilityStatusList(caps);
279 void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
281 MigrationParameters *params;
283 params = qmp_query_migrate_parameters(NULL);
286 monitor_printf(mon, "parameters:");
287 assert(params->has_compress_level);
288 monitor_printf(mon, " %s: %" PRId64,
289 MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL],
290 params->compress_level);
291 assert(params->has_compress_threads);
292 monitor_printf(mon, " %s: %" PRId64,
293 MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS],
294 params->compress_threads);
295 assert(params->has_decompress_threads);
296 monitor_printf(mon, " %s: %" PRId64,
297 MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS],
298 params->decompress_threads);
299 assert(params->has_cpu_throttle_initial);
300 monitor_printf(mon, " %s: %" PRId64,
301 MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL],
302 params->cpu_throttle_initial);
303 assert(params->has_cpu_throttle_increment);
304 monitor_printf(mon, " %s: %" PRId64,
305 MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT],
306 params->cpu_throttle_increment);
307 monitor_printf(mon, " %s: '%s'",
308 MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_CREDS],
309 params->has_tls_creds ? params->tls_creds : "");
310 monitor_printf(mon, " %s: '%s'",
311 MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME],
312 params->has_tls_hostname ? params->tls_hostname : "");
313 monitor_printf(mon, "\n");
316 qapi_free_MigrationParameters(params);
319 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict)
321 monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n",
322 qmp_query_migrate_cache_size(NULL) >> 10);
325 void hmp_info_cpus(Monitor *mon, const QDict *qdict)
327 CpuInfoList *cpu_list, *cpu;
329 cpu_list = qmp_query_cpus(NULL);
331 for (cpu = cpu_list; cpu; cpu = cpu->next) {
334 if (cpu->value->CPU == monitor_get_cpu_index()) {
338 monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CPU);
340 switch (cpu->value->arch) {
341 case CPU_INFO_ARCH_X86:
342 monitor_printf(mon, " pc=0x%016" PRIx64, cpu->value->u.x86.pc);
344 case CPU_INFO_ARCH_PPC:
345 monitor_printf(mon, " nip=0x%016" PRIx64, cpu->value->u.ppc.nip);
347 case CPU_INFO_ARCH_SPARC:
348 monitor_printf(mon, " pc=0x%016" PRIx64,
349 cpu->value->u.q_sparc.pc);
350 monitor_printf(mon, " npc=0x%016" PRIx64,
351 cpu->value->u.q_sparc.npc);
353 case CPU_INFO_ARCH_MIPS:
354 monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.q_mips.PC);
356 case CPU_INFO_ARCH_TRICORE:
357 monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore.PC);
363 if (cpu->value->halted) {
364 monitor_printf(mon, " (halted)");
367 monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
370 qapi_free_CpuInfoList(cpu_list);
373 static void print_block_info(Monitor *mon, BlockInfo *info,
374 BlockDeviceInfo *inserted, bool verbose)
376 ImageInfo *image_info;
378 assert(!info || !info->has_inserted || info->inserted == inserted);
381 monitor_printf(mon, "%s", info->device);
382 if (inserted && inserted->has_node_name) {
383 monitor_printf(mon, " (%s)", inserted->node_name);
387 monitor_printf(mon, "%s",
388 inserted->has_node_name
389 ? inserted->node_name
394 monitor_printf(mon, ": %s (%s%s%s)\n",
397 inserted->ro ? ", read-only" : "",
398 inserted->encrypted ? ", encrypted" : "");
400 monitor_printf(mon, ": [not inserted]\n");
404 if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
405 monitor_printf(mon, " I/O status: %s\n",
406 BlockDeviceIoStatus_lookup[info->io_status]);
409 if (info->removable) {
410 monitor_printf(mon, " Removable device: %slocked, tray %s\n",
411 info->locked ? "" : "not ",
412 info->tray_open ? "open" : "closed");
421 monitor_printf(mon, " Cache mode: %s%s%s\n",
422 inserted->cache->writeback ? "writeback" : "writethrough",
423 inserted->cache->direct ? ", direct" : "",
424 inserted->cache->no_flush ? ", ignore flushes" : "");
426 if (inserted->has_backing_file) {
429 "(chain depth: %" PRId64 ")\n",
430 inserted->backing_file,
431 inserted->backing_file_depth);
434 if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
435 monitor_printf(mon, " Detect zeroes: %s\n",
436 BlockdevDetectZeroesOptions_lookup[inserted->detect_zeroes]);
439 if (inserted->bps || inserted->bps_rd || inserted->bps_wr ||
440 inserted->iops || inserted->iops_rd || inserted->iops_wr)
442 monitor_printf(mon, " I/O throttling: bps=%" PRId64
443 " bps_rd=%" PRId64 " bps_wr=%" PRId64
445 " bps_rd_max=%" PRId64
446 " bps_wr_max=%" PRId64
447 " iops=%" PRId64 " iops_rd=%" PRId64
450 " iops_rd_max=%" PRId64
451 " iops_wr_max=%" PRId64
452 " iops_size=%" PRId64
458 inserted->bps_rd_max,
459 inserted->bps_wr_max,
464 inserted->iops_rd_max,
465 inserted->iops_wr_max,
471 monitor_printf(mon, "\nImages:\n");
472 image_info = inserted->image;
474 bdrv_image_info_dump((fprintf_function)monitor_printf,
476 if (image_info->has_backing_image) {
477 image_info = image_info->backing_image;
485 void hmp_info_block(Monitor *mon, const QDict *qdict)
487 BlockInfoList *block_list, *info;
488 BlockDeviceInfoList *blockdev_list, *blockdev;
489 const char *device = qdict_get_try_str(qdict, "device");
490 bool verbose = qdict_get_try_bool(qdict, "verbose", false);
491 bool nodes = qdict_get_try_bool(qdict, "nodes", false);
492 bool printed = false;
494 /* Print BlockBackend information */
496 block_list = qmp_query_block(NULL);
501 for (info = block_list; info; info = info->next) {
502 if (device && strcmp(device, info->value->device)) {
506 if (info != block_list) {
507 monitor_printf(mon, "\n");
510 print_block_info(mon, info->value, info->value->has_inserted
511 ? info->value->inserted : NULL,
516 qapi_free_BlockInfoList(block_list);
518 if ((!device && !nodes) || printed) {
522 /* Print node information */
523 blockdev_list = qmp_query_named_block_nodes(NULL);
524 for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
525 assert(blockdev->value->has_node_name);
526 if (device && strcmp(device, blockdev->value->node_name)) {
530 if (blockdev != blockdev_list) {
531 monitor_printf(mon, "\n");
534 print_block_info(mon, NULL, blockdev->value, verbose);
536 qapi_free_BlockDeviceInfoList(blockdev_list);
539 void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
541 BlockStatsList *stats_list, *stats;
543 stats_list = qmp_query_blockstats(false, false, NULL);
545 for (stats = stats_list; stats; stats = stats->next) {
546 if (!stats->value->has_device) {
550 monitor_printf(mon, "%s:", stats->value->device);
551 monitor_printf(mon, " rd_bytes=%" PRId64
553 " rd_operations=%" PRId64
554 " wr_operations=%" PRId64
555 " flush_operations=%" PRId64
556 " wr_total_time_ns=%" PRId64
557 " rd_total_time_ns=%" PRId64
558 " flush_total_time_ns=%" PRId64
559 " rd_merged=%" PRId64
560 " wr_merged=%" PRId64
561 " idle_time_ns=%" PRId64
563 stats->value->stats->rd_bytes,
564 stats->value->stats->wr_bytes,
565 stats->value->stats->rd_operations,
566 stats->value->stats->wr_operations,
567 stats->value->stats->flush_operations,
568 stats->value->stats->wr_total_time_ns,
569 stats->value->stats->rd_total_time_ns,
570 stats->value->stats->flush_total_time_ns,
571 stats->value->stats->rd_merged,
572 stats->value->stats->wr_merged,
573 stats->value->stats->idle_time_ns);
576 qapi_free_BlockStatsList(stats_list);
579 void hmp_info_vnc(Monitor *mon, const QDict *qdict)
583 VncClientInfoList *client;
585 info = qmp_query_vnc(&err);
587 error_report_err(err);
591 if (!info->enabled) {
592 monitor_printf(mon, "Server: disabled\n");
596 monitor_printf(mon, "Server:\n");
597 if (info->has_host && info->has_service) {
598 monitor_printf(mon, " address: %s:%s\n", info->host, info->service);
600 if (info->has_auth) {
601 monitor_printf(mon, " auth: %s\n", info->auth);
604 if (!info->has_clients || info->clients == NULL) {
605 monitor_printf(mon, "Client: none\n");
607 for (client = info->clients; client; client = client->next) {
608 monitor_printf(mon, "Client:\n");
609 monitor_printf(mon, " address: %s:%s\n",
611 client->value->service);
612 monitor_printf(mon, " x509_dname: %s\n",
613 client->value->x509_dname ?
614 client->value->x509_dname : "none");
615 monitor_printf(mon, " username: %s\n",
616 client->value->has_sasl_username ?
617 client->value->sasl_username : "none");
622 qapi_free_VncInfo(info);
626 void hmp_info_spice(Monitor *mon, const QDict *qdict)
628 SpiceChannelList *chan;
630 const char *channel_name;
631 const char * const channel_names[] = {
632 [SPICE_CHANNEL_MAIN] = "main",
633 [SPICE_CHANNEL_DISPLAY] = "display",
634 [SPICE_CHANNEL_INPUTS] = "inputs",
635 [SPICE_CHANNEL_CURSOR] = "cursor",
636 [SPICE_CHANNEL_PLAYBACK] = "playback",
637 [SPICE_CHANNEL_RECORD] = "record",
638 [SPICE_CHANNEL_TUNNEL] = "tunnel",
639 [SPICE_CHANNEL_SMARTCARD] = "smartcard",
640 [SPICE_CHANNEL_USBREDIR] = "usbredir",
641 [SPICE_CHANNEL_PORT] = "port",
643 /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
644 * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
645 * as quick fix for build failures with older versions. */
646 [SPICE_CHANNEL_WEBDAV] = "webdav",
650 info = qmp_query_spice(NULL);
652 if (!info->enabled) {
653 monitor_printf(mon, "Server: disabled\n");
657 monitor_printf(mon, "Server:\n");
658 if (info->has_port) {
659 monitor_printf(mon, " address: %s:%" PRId64 "\n",
660 info->host, info->port);
662 if (info->has_tls_port) {
663 monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n",
664 info->host, info->tls_port);
666 monitor_printf(mon, " migrated: %s\n",
667 info->migrated ? "true" : "false");
668 monitor_printf(mon, " auth: %s\n", info->auth);
669 monitor_printf(mon, " compiled: %s\n", info->compiled_version);
670 monitor_printf(mon, " mouse-mode: %s\n",
671 SpiceQueryMouseMode_lookup[info->mouse_mode]);
673 if (!info->has_channels || info->channels == NULL) {
674 monitor_printf(mon, "Channels: none\n");
676 for (chan = info->channels; chan; chan = chan->next) {
677 monitor_printf(mon, "Channel:\n");
678 monitor_printf(mon, " address: %s:%s%s\n",
679 chan->value->host, chan->value->port,
680 chan->value->tls ? " [tls]" : "");
681 monitor_printf(mon, " session: %" PRId64 "\n",
682 chan->value->connection_id);
683 monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n",
684 chan->value->channel_type, chan->value->channel_id);
686 channel_name = "unknown";
687 if (chan->value->channel_type > 0 &&
688 chan->value->channel_type < ARRAY_SIZE(channel_names) &&
689 channel_names[chan->value->channel_type]) {
690 channel_name = channel_names[chan->value->channel_type];
693 monitor_printf(mon, " channel name: %s\n", channel_name);
698 qapi_free_SpiceInfo(info);
702 void hmp_info_balloon(Monitor *mon, const QDict *qdict)
707 info = qmp_query_balloon(&err);
709 error_report_err(err);
713 monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
715 qapi_free_BalloonInfo(info);
718 static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
720 PciMemoryRegionList *region;
722 monitor_printf(mon, " Bus %2" PRId64 ", ", dev->bus);
723 monitor_printf(mon, "device %3" PRId64 ", function %" PRId64 ":\n",
724 dev->slot, dev->function);
725 monitor_printf(mon, " ");
727 if (dev->class_info->has_desc) {
728 monitor_printf(mon, "%s", dev->class_info->desc);
730 monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class);
733 monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n",
734 dev->id->vendor, dev->id->device);
737 monitor_printf(mon, " IRQ %" PRId64 ".\n", dev->irq);
740 if (dev->has_pci_bridge) {
741 monitor_printf(mon, " BUS %" PRId64 ".\n",
742 dev->pci_bridge->bus->number);
743 monitor_printf(mon, " secondary bus %" PRId64 ".\n",
744 dev->pci_bridge->bus->secondary);
745 monitor_printf(mon, " subordinate bus %" PRId64 ".\n",
746 dev->pci_bridge->bus->subordinate);
748 monitor_printf(mon, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n",
749 dev->pci_bridge->bus->io_range->base,
750 dev->pci_bridge->bus->io_range->limit);
753 " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n",
754 dev->pci_bridge->bus->memory_range->base,
755 dev->pci_bridge->bus->memory_range->limit);
757 monitor_printf(mon, " prefetchable memory range "
758 "[0x%08"PRIx64", 0x%08"PRIx64"]\n",
759 dev->pci_bridge->bus->prefetchable_range->base,
760 dev->pci_bridge->bus->prefetchable_range->limit);
763 for (region = dev->regions; region; region = region->next) {
766 addr = region->value->address;
767 size = region->value->size;
769 monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar);
771 if (!strcmp(region->value->type, "io")) {
772 monitor_printf(mon, "I/O at 0x%04" PRIx64
773 " [0x%04" PRIx64 "].\n",
774 addr, addr + size - 1);
776 monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64
777 " [0x%08" PRIx64 "].\n",
778 region->value->mem_type_64 ? 64 : 32,
779 region->value->prefetch ? " prefetchable" : "",
780 addr, addr + size - 1);
784 monitor_printf(mon, " id \"%s\"\n", dev->qdev_id);
786 if (dev->has_pci_bridge) {
787 if (dev->pci_bridge->has_devices) {
788 PciDeviceInfoList *cdev;
789 for (cdev = dev->pci_bridge->devices; cdev; cdev = cdev->next) {
790 hmp_info_pci_device(mon, cdev->value);
796 static int hmp_info_irq_foreach(Object *obj, void *opaque)
798 InterruptStatsProvider *intc;
799 InterruptStatsProviderClass *k;
800 Monitor *mon = opaque;
802 if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
803 intc = INTERRUPT_STATS_PROVIDER(obj);
804 k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
805 uint64_t *irq_counts;
806 unsigned int nb_irqs, i;
807 if (k->get_statistics &&
808 k->get_statistics(intc, &irq_counts, &nb_irqs)) {
810 monitor_printf(mon, "IRQ statistics for %s:\n",
811 object_get_typename(obj));
812 for (i = 0; i < nb_irqs; i++) {
813 if (irq_counts[i] > 0) {
814 monitor_printf(mon, "%2d: %" PRId64 "\n", i,
820 monitor_printf(mon, "IRQ statistics not available for %s.\n",
821 object_get_typename(obj));
828 void hmp_info_irq(Monitor *mon, const QDict *qdict)
830 object_child_foreach_recursive(object_get_root(),
831 hmp_info_irq_foreach, mon);
834 static int hmp_info_pic_foreach(Object *obj, void *opaque)
836 InterruptStatsProvider *intc;
837 InterruptStatsProviderClass *k;
838 Monitor *mon = opaque;
840 if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
841 intc = INTERRUPT_STATS_PROVIDER(obj);
842 k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
844 k->print_info(intc, mon);
846 monitor_printf(mon, "Interrupt controller information not available for %s.\n",
847 object_get_typename(obj));
854 void hmp_info_pic(Monitor *mon, const QDict *qdict)
856 object_child_foreach_recursive(object_get_root(),
857 hmp_info_pic_foreach, mon);
860 void hmp_info_pci(Monitor *mon, const QDict *qdict)
862 PciInfoList *info_list, *info;
865 info_list = qmp_query_pci(&err);
867 monitor_printf(mon, "PCI devices not supported\n");
872 for (info = info_list; info; info = info->next) {
873 PciDeviceInfoList *dev;
875 for (dev = info->value->devices; dev; dev = dev->next) {
876 hmp_info_pci_device(mon, dev->value);
880 qapi_free_PciInfoList(info_list);
883 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
885 BlockJobInfoList *list;
888 list = qmp_query_block_jobs(&err);
892 monitor_printf(mon, "No active jobs\n");
897 if (strcmp(list->value->type, "stream") == 0) {
898 monitor_printf(mon, "Streaming device %s: Completed %" PRId64
899 " of %" PRId64 " bytes, speed limit %" PRId64
906 monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
907 " of %" PRId64 " bytes, speed limit %" PRId64
918 qapi_free_BlockJobInfoList(list);
921 void hmp_info_tpm(Monitor *mon, const QDict *qdict)
923 TPMInfoList *info_list, *info;
926 TPMPassthroughOptions *tpo;
928 info_list = qmp_query_tpm(&err);
930 monitor_printf(mon, "TPM device not supported\n");
936 monitor_printf(mon, "TPM device:\n");
939 for (info = info_list; info; info = info->next) {
940 TPMInfo *ti = info->value;
941 monitor_printf(mon, " tpm%d: model=%s\n",
942 c, TpmModel_lookup[ti->model]);
944 monitor_printf(mon, " \\ %s: type=%s",
945 ti->id, TpmTypeOptionsKind_lookup[ti->options->type]);
947 switch (ti->options->type) {
948 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:
949 tpo = ti->options->u.passthrough.data;
950 monitor_printf(mon, "%s%s%s%s",
951 tpo->has_path ? ",path=" : "",
952 tpo->has_path ? tpo->path : "",
953 tpo->has_cancel_path ? ",cancel-path=" : "",
954 tpo->has_cancel_path ? tpo->cancel_path : "");
956 case TPM_TYPE_OPTIONS_KIND__MAX:
959 monitor_printf(mon, "\n");
962 qapi_free_TPMInfoList(info_list);
965 void hmp_quit(Monitor *mon, const QDict *qdict)
967 monitor_suspend(mon);
971 void hmp_stop(Monitor *mon, const QDict *qdict)
976 void hmp_system_reset(Monitor *mon, const QDict *qdict)
978 qmp_system_reset(NULL);
981 void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
983 qmp_system_powerdown(NULL);
986 void hmp_cpu(Monitor *mon, const QDict *qdict)
990 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
991 use it are converted to the QAPI */
992 cpu_index = qdict_get_int(qdict, "index");
993 if (monitor_set_cpu(cpu_index) < 0) {
994 monitor_printf(mon, "invalid CPU index\n");
998 void hmp_memsave(Monitor *mon, const QDict *qdict)
1000 uint32_t size = qdict_get_int(qdict, "size");
1001 const char *filename = qdict_get_str(qdict, "filename");
1002 uint64_t addr = qdict_get_int(qdict, "val");
1005 qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &err);
1006 hmp_handle_error(mon, &err);
1009 void hmp_pmemsave(Monitor *mon, const QDict *qdict)
1011 uint32_t size = qdict_get_int(qdict, "size");
1012 const char *filename = qdict_get_str(qdict, "filename");
1013 uint64_t addr = qdict_get_int(qdict, "val");
1016 qmp_pmemsave(addr, size, filename, &err);
1017 hmp_handle_error(mon, &err);
1020 void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
1022 const char *chardev = qdict_get_str(qdict, "device");
1023 const char *data = qdict_get_str(qdict, "data");
1026 qmp_ringbuf_write(chardev, data, false, 0, &err);
1028 hmp_handle_error(mon, &err);
1031 void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
1033 uint32_t size = qdict_get_int(qdict, "size");
1034 const char *chardev = qdict_get_str(qdict, "device");
1039 data = qmp_ringbuf_read(chardev, size, false, 0, &err);
1041 error_report_err(err);
1045 for (i = 0; data[i]; i++) {
1046 unsigned char ch = data[i];
1049 monitor_printf(mon, "\\\\");
1050 } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) {
1051 monitor_printf(mon, "\\u%04X", ch);
1053 monitor_printf(mon, "%c", ch);
1057 monitor_printf(mon, "\n");
1061 static void hmp_cont_cb(void *opaque, int err)
1068 static bool key_is_missing(const BlockInfo *bdev)
1070 return (bdev->inserted && bdev->inserted->encryption_key_missing);
1073 void hmp_cont(Monitor *mon, const QDict *qdict)
1075 BlockInfoList *bdev_list, *bdev;
1078 bdev_list = qmp_query_block(NULL);
1079 for (bdev = bdev_list; bdev; bdev = bdev->next) {
1080 if (key_is_missing(bdev->value)) {
1081 monitor_read_block_device_key(mon, bdev->value->device,
1088 hmp_handle_error(mon, &err);
1091 qapi_free_BlockInfoList(bdev_list);
1094 void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
1096 qmp_system_wakeup(NULL);
1099 void hmp_nmi(Monitor *mon, const QDict *qdict)
1103 qmp_inject_nmi(&err);
1104 hmp_handle_error(mon, &err);
1107 void hmp_set_link(Monitor *mon, const QDict *qdict)
1109 const char *name = qdict_get_str(qdict, "name");
1110 bool up = qdict_get_bool(qdict, "up");
1113 qmp_set_link(name, up, &err);
1114 hmp_handle_error(mon, &err);
1117 void hmp_block_passwd(Monitor *mon, const QDict *qdict)
1119 const char *device = qdict_get_str(qdict, "device");
1120 const char *password = qdict_get_str(qdict, "password");
1123 qmp_block_passwd(true, device, false, NULL, password, &err);
1124 hmp_handle_error(mon, &err);
1127 void hmp_balloon(Monitor *mon, const QDict *qdict)
1129 int64_t value = qdict_get_int(qdict, "value");
1132 qmp_balloon(value, &err);
1134 error_report_err(err);
1138 void hmp_block_resize(Monitor *mon, const QDict *qdict)
1140 const char *device = qdict_get_str(qdict, "device");
1141 int64_t size = qdict_get_int(qdict, "size");
1144 qmp_block_resize(true, device, false, NULL, size, &err);
1145 hmp_handle_error(mon, &err);
1148 void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
1150 const char *filename = qdict_get_str(qdict, "target");
1151 const char *format = qdict_get_try_str(qdict, "format");
1152 bool reuse = qdict_get_try_bool(qdict, "reuse", false);
1153 bool full = qdict_get_try_bool(qdict, "full", false);
1155 DriveMirror mirror = {
1156 .device = (char *)qdict_get_str(qdict, "device"),
1157 .target = (char *)filename,
1158 .has_format = !!format,
1159 .format = (char *)format,
1160 .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
1162 .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
1167 error_setg(&err, QERR_MISSING_PARAMETER, "target");
1168 hmp_handle_error(mon, &err);
1171 qmp_drive_mirror(&mirror, &err);
1172 hmp_handle_error(mon, &err);
1175 void hmp_drive_backup(Monitor *mon, const QDict *qdict)
1177 const char *device = qdict_get_str(qdict, "device");
1178 const char *filename = qdict_get_str(qdict, "target");
1179 const char *format = qdict_get_try_str(qdict, "format");
1180 bool reuse = qdict_get_try_bool(qdict, "reuse", false);
1181 bool full = qdict_get_try_bool(qdict, "full", false);
1182 bool compress = qdict_get_try_bool(qdict, "compress", false);
1184 DriveBackup backup = {
1185 .device = (char *)device,
1186 .target = (char *)filename,
1187 .has_format = !!format,
1188 .format = (char *)format,
1189 .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
1191 .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
1192 .has_compress = !!compress,
1193 .compress = compress,
1197 error_setg(&err, QERR_MISSING_PARAMETER, "target");
1198 hmp_handle_error(mon, &err);
1202 qmp_drive_backup(&backup, &err);
1203 hmp_handle_error(mon, &err);
1206 void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
1208 const char *device = qdict_get_str(qdict, "device");
1209 const char *filename = qdict_get_try_str(qdict, "snapshot-file");
1210 const char *format = qdict_get_try_str(qdict, "format");
1211 bool reuse = qdict_get_try_bool(qdict, "reuse", false);
1212 enum NewImageMode mode;
1216 /* In the future, if 'snapshot-file' is not specified, the snapshot
1217 will be taken internally. Today it's actually required. */
1218 error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
1219 hmp_handle_error(mon, &err);
1223 mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
1224 qmp_blockdev_snapshot_sync(true, device, false, NULL,
1225 filename, false, NULL,
1228 hmp_handle_error(mon, &err);
1231 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
1233 const char *device = qdict_get_str(qdict, "device");
1234 const char *name = qdict_get_str(qdict, "name");
1237 qmp_blockdev_snapshot_internal_sync(device, name, &err);
1238 hmp_handle_error(mon, &err);
1241 void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
1243 const char *device = qdict_get_str(qdict, "device");
1244 const char *name = qdict_get_str(qdict, "name");
1245 const char *id = qdict_get_try_str(qdict, "id");
1248 qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
1250 hmp_handle_error(mon, &err);
1253 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
1255 qmp_migrate_cancel(NULL);
1258 void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
1261 const char *uri = qdict_get_str(qdict, "uri");
1263 qmp_migrate_incoming(uri, &err);
1265 hmp_handle_error(mon, &err);
1268 void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
1270 double value = qdict_get_double(qdict, "value");
1271 qmp_migrate_set_downtime(value, NULL);
1274 void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict)
1276 int64_t value = qdict_get_int(qdict, "value");
1279 qmp_migrate_set_cache_size(value, &err);
1281 error_report_err(err);
1286 void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict)
1288 int64_t value = qdict_get_int(qdict, "value");
1289 qmp_migrate_set_speed(value, NULL);
1292 void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
1294 const char *cap = qdict_get_str(qdict, "capability");
1295 bool state = qdict_get_bool(qdict, "state");
1297 MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
1300 for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
1301 if (strcmp(cap, MigrationCapability_lookup[i]) == 0) {
1302 caps->value = g_malloc0(sizeof(*caps->value));
1303 caps->value->capability = i;
1304 caps->value->state = state;
1306 qmp_migrate_set_capabilities(caps, &err);
1311 if (i == MIGRATION_CAPABILITY__MAX) {
1312 error_setg(&err, QERR_INVALID_PARAMETER, cap);
1315 qapi_free_MigrationCapabilityStatusList(caps);
1318 error_report_err(err);
1322 void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
1324 const char *param = qdict_get_str(qdict, "parameter");
1325 const char *valuestr = qdict_get_str(qdict, "value");
1328 bool has_compress_level = false;
1329 bool has_compress_threads = false;
1330 bool has_decompress_threads = false;
1331 bool has_cpu_throttle_initial = false;
1332 bool has_cpu_throttle_increment = false;
1333 bool has_tls_creds = false;
1334 bool has_tls_hostname = false;
1335 bool use_int_value = false;
1338 for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
1339 if (strcmp(param, MigrationParameter_lookup[i]) == 0) {
1341 case MIGRATION_PARAMETER_COMPRESS_LEVEL:
1342 has_compress_level = true;
1343 use_int_value = true;
1345 case MIGRATION_PARAMETER_COMPRESS_THREADS:
1346 has_compress_threads = true;
1347 use_int_value = true;
1349 case MIGRATION_PARAMETER_DECOMPRESS_THREADS:
1350 has_decompress_threads = true;
1351 use_int_value = true;
1353 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL:
1354 has_cpu_throttle_initial = true;
1355 use_int_value = true;
1357 case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT:
1358 has_cpu_throttle_increment = true;
1359 use_int_value = true;
1361 case MIGRATION_PARAMETER_TLS_CREDS:
1362 has_tls_creds = true;
1364 case MIGRATION_PARAMETER_TLS_HOSTNAME:
1365 has_tls_hostname = true;
1369 if (use_int_value) {
1370 if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) {
1371 error_setg(&err, "Unable to parse '%s' as an int",
1377 qmp_migrate_set_parameters(has_compress_level, valueint,
1378 has_compress_threads, valueint,
1379 has_decompress_threads, valueint,
1380 has_cpu_throttle_initial, valueint,
1381 has_cpu_throttle_increment, valueint,
1382 has_tls_creds, valuestr,
1383 has_tls_hostname, valuestr,
1389 if (i == MIGRATION_PARAMETER__MAX) {
1390 error_setg(&err, QERR_INVALID_PARAMETER, param);
1395 error_report_err(err);
1399 void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
1402 const char *protocol = qdict_get_str(qdict, "protocol");
1403 const char *hostname = qdict_get_str(qdict, "hostname");
1404 bool has_port = qdict_haskey(qdict, "port");
1405 int port = qdict_get_try_int(qdict, "port", -1);
1406 bool has_tls_port = qdict_haskey(qdict, "tls-port");
1407 int tls_port = qdict_get_try_int(qdict, "tls-port", -1);
1408 const char *cert_subject = qdict_get_try_str(qdict, "cert-subject");
1410 qmp_client_migrate_info(protocol, hostname,
1411 has_port, port, has_tls_port, tls_port,
1412 !!cert_subject, cert_subject, &err);
1413 hmp_handle_error(mon, &err);
1416 void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict)
1419 qmp_migrate_start_postcopy(&err);
1420 hmp_handle_error(mon, &err);
1423 void hmp_set_password(Monitor *mon, const QDict *qdict)
1425 const char *protocol = qdict_get_str(qdict, "protocol");
1426 const char *password = qdict_get_str(qdict, "password");
1427 const char *connected = qdict_get_try_str(qdict, "connected");
1430 qmp_set_password(protocol, password, !!connected, connected, &err);
1431 hmp_handle_error(mon, &err);
1434 void hmp_expire_password(Monitor *mon, const QDict *qdict)
1436 const char *protocol = qdict_get_str(qdict, "protocol");
1437 const char *whenstr = qdict_get_str(qdict, "time");
1440 qmp_expire_password(protocol, whenstr, &err);
1441 hmp_handle_error(mon, &err);
1444 void hmp_eject(Monitor *mon, const QDict *qdict)
1446 bool force = qdict_get_try_bool(qdict, "force", false);
1447 const char *device = qdict_get_str(qdict, "device");
1450 qmp_eject(true, device, false, NULL, true, force, &err);
1451 hmp_handle_error(mon, &err);
1454 static void hmp_change_read_arg(void *opaque, const char *password,
1455 void *readline_opaque)
1457 qmp_change_vnc_password(password, NULL);
1458 monitor_read_command(opaque, 1);
1461 void hmp_change(Monitor *mon, const QDict *qdict)
1463 const char *device = qdict_get_str(qdict, "device");
1464 const char *target = qdict_get_str(qdict, "target");
1465 const char *arg = qdict_get_try_str(qdict, "arg");
1466 const char *read_only = qdict_get_try_str(qdict, "read-only-mode");
1467 BlockdevChangeReadOnlyMode read_only_mode = 0;
1470 if (strcmp(device, "vnc") == 0) {
1473 "Parameter 'read-only-mode' is invalid for VNC\n");
1476 if (strcmp(target, "passwd") == 0 ||
1477 strcmp(target, "password") == 0) {
1479 monitor_read_password(mon, hmp_change_read_arg, NULL);
1483 qmp_change("vnc", target, !!arg, arg, &err);
1487 qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup,
1488 read_only, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX,
1489 BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
1491 hmp_handle_error(mon, &err);
1496 qmp_blockdev_change_medium(true, device, false, NULL, target,
1497 !!arg, arg, !!read_only, read_only_mode,
1500 error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) {
1502 monitor_read_block_device_key(mon, device, NULL, NULL);
1507 hmp_handle_error(mon, &err);
1510 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
1513 BlockIOThrottle throttle = {
1514 .device = (char *) qdict_get_str(qdict, "device"),
1515 .bps = qdict_get_int(qdict, "bps"),
1516 .bps_rd = qdict_get_int(qdict, "bps_rd"),
1517 .bps_wr = qdict_get_int(qdict, "bps_wr"),
1518 .iops = qdict_get_int(qdict, "iops"),
1519 .iops_rd = qdict_get_int(qdict, "iops_rd"),
1520 .iops_wr = qdict_get_int(qdict, "iops_wr"),
1523 qmp_block_set_io_throttle(&throttle, &err);
1524 hmp_handle_error(mon, &err);
1527 void hmp_block_stream(Monitor *mon, const QDict *qdict)
1529 Error *error = NULL;
1530 const char *device = qdict_get_str(qdict, "device");
1531 const char *base = qdict_get_try_str(qdict, "base");
1532 int64_t speed = qdict_get_try_int(qdict, "speed", 0);
1534 qmp_block_stream(false, NULL, device, base != NULL, base, false, NULL,
1535 qdict_haskey(qdict, "speed"), speed,
1536 true, BLOCKDEV_ON_ERROR_REPORT, &error);
1538 hmp_handle_error(mon, &error);
1541 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
1543 Error *error = NULL;
1544 const char *device = qdict_get_str(qdict, "device");
1545 int64_t value = qdict_get_int(qdict, "speed");
1547 qmp_block_job_set_speed(device, value, &error);
1549 hmp_handle_error(mon, &error);
1552 void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
1554 Error *error = NULL;
1555 const char *device = qdict_get_str(qdict, "device");
1556 bool force = qdict_get_try_bool(qdict, "force", false);
1558 qmp_block_job_cancel(device, true, force, &error);
1560 hmp_handle_error(mon, &error);
1563 void hmp_block_job_pause(Monitor *mon, const QDict *qdict)
1565 Error *error = NULL;
1566 const char *device = qdict_get_str(qdict, "device");
1568 qmp_block_job_pause(device, &error);
1570 hmp_handle_error(mon, &error);
1573 void hmp_block_job_resume(Monitor *mon, const QDict *qdict)
1575 Error *error = NULL;
1576 const char *device = qdict_get_str(qdict, "device");
1578 qmp_block_job_resume(device, &error);
1580 hmp_handle_error(mon, &error);
1583 void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
1585 Error *error = NULL;
1586 const char *device = qdict_get_str(qdict, "device");
1588 qmp_block_job_complete(device, &error);
1590 hmp_handle_error(mon, &error);
1593 typedef struct HMPMigrationStatus
1597 bool is_block_migration;
1598 } HMPMigrationStatus;
1600 static void hmp_migrate_status_cb(void *opaque)
1602 HMPMigrationStatus *status = opaque;
1603 MigrationInfo *info;
1605 info = qmp_query_migrate(NULL);
1606 if (!info->has_status || info->status == MIGRATION_STATUS_ACTIVE ||
1607 info->status == MIGRATION_STATUS_SETUP) {
1608 if (info->has_disk) {
1611 if (info->disk->remaining) {
1612 progress = info->disk->transferred * 100 / info->disk->total;
1617 monitor_printf(status->mon, "Completed %d %%\r", progress);
1618 monitor_flush(status->mon);
1621 timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000);
1623 if (status->is_block_migration) {
1624 monitor_printf(status->mon, "\n");
1626 if (info->has_error_desc) {
1627 error_report("%s", info->error_desc);
1629 monitor_resume(status->mon);
1630 timer_del(status->timer);
1634 qapi_free_MigrationInfo(info);
1637 void hmp_migrate(Monitor *mon, const QDict *qdict)
1639 bool detach = qdict_get_try_bool(qdict, "detach", false);
1640 bool blk = qdict_get_try_bool(qdict, "blk", false);
1641 bool inc = qdict_get_try_bool(qdict, "inc", false);
1642 const char *uri = qdict_get_str(qdict, "uri");
1645 qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err);
1647 error_report_err(err);
1652 HMPMigrationStatus *status;
1654 if (monitor_suspend(mon) < 0) {
1655 monitor_printf(mon, "terminal does not allow synchronous "
1656 "migration, continuing detached\n");
1660 status = g_malloc0(sizeof(*status));
1662 status->is_block_migration = blk || inc;
1663 status->timer = timer_new_ms(QEMU_CLOCK_REALTIME, hmp_migrate_status_cb,
1665 timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
1669 void hmp_device_add(Monitor *mon, const QDict *qdict)
1673 qmp_device_add((QDict *)qdict, NULL, &err);
1674 hmp_handle_error(mon, &err);
1677 void hmp_device_del(Monitor *mon, const QDict *qdict)
1679 const char *id = qdict_get_str(qdict, "id");
1682 qmp_device_del(id, &err);
1683 hmp_handle_error(mon, &err);
1686 void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
1689 bool paging = qdict_get_try_bool(qdict, "paging", false);
1690 bool zlib = qdict_get_try_bool(qdict, "zlib", false);
1691 bool lzo = qdict_get_try_bool(qdict, "lzo", false);
1692 bool snappy = qdict_get_try_bool(qdict, "snappy", false);
1693 const char *file = qdict_get_str(qdict, "filename");
1694 bool has_begin = qdict_haskey(qdict, "begin");
1695 bool has_length = qdict_haskey(qdict, "length");
1696 bool has_detach = qdict_haskey(qdict, "detach");
1699 bool detach = false;
1700 enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
1703 if (zlib + lzo + snappy > 1) {
1704 error_setg(&err, "only one of '-z|-l|-s' can be set");
1705 hmp_handle_error(mon, &err);
1710 dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
1714 dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
1718 dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
1722 begin = qdict_get_int(qdict, "begin");
1725 length = qdict_get_int(qdict, "length");
1728 detach = qdict_get_bool(qdict, "detach");
1731 prot = g_strconcat("file:", file, NULL);
1733 qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
1734 has_length, length, true, dump_format, &err);
1735 hmp_handle_error(mon, &err);
1739 void hmp_netdev_add(Monitor *mon, const QDict *qdict)
1744 opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
1749 netdev_add(opts, &err);
1751 qemu_opts_del(opts);
1755 hmp_handle_error(mon, &err);
1758 void hmp_netdev_del(Monitor *mon, const QDict *qdict)
1760 const char *id = qdict_get_str(qdict, "id");
1763 qmp_netdev_del(id, &err);
1764 hmp_handle_error(mon, &err);
1767 void hmp_object_add(Monitor *mon, const QDict *qdict)
1774 opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
1776 hmp_handle_error(mon, &err);
1780 v = opts_visitor_new(opts);
1781 obj = user_creatable_add(qdict, v, &err);
1783 qemu_opts_del(opts);
1786 hmp_handle_error(mon, &err);
1793 void hmp_getfd(Monitor *mon, const QDict *qdict)
1795 const char *fdname = qdict_get_str(qdict, "fdname");
1798 qmp_getfd(fdname, &err);
1799 hmp_handle_error(mon, &err);
1802 void hmp_closefd(Monitor *mon, const QDict *qdict)
1804 const char *fdname = qdict_get_str(qdict, "fdname");
1807 qmp_closefd(fdname, &err);
1808 hmp_handle_error(mon, &err);
1811 void hmp_sendkey(Monitor *mon, const QDict *qdict)
1813 const char *keys = qdict_get_str(qdict, "keys");
1814 KeyValueList *keylist, *head = NULL, *tmp = NULL;
1815 int has_hold_time = qdict_haskey(qdict, "hold-time");
1816 int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
1822 separator = strchr(keys, '-');
1823 keyname_len = separator ? separator - keys : strlen(keys);
1825 /* Be compatible with old interface, convert user inputted "<" */
1826 if (keys[0] == '<' && keyname_len == 1) {
1831 keylist = g_malloc0(sizeof(*keylist));
1832 keylist->value = g_malloc0(sizeof(*keylist->value));
1838 tmp->next = keylist;
1842 if (strstart(keys, "0x", NULL)) {
1844 int value = strtoul(keys, &endp, 0);
1845 assert(endp <= keys + keyname_len);
1846 if (endp != keys + keyname_len) {
1849 keylist->value->type = KEY_VALUE_KIND_NUMBER;
1850 keylist->value->u.number.data = value;
1852 int idx = index_from_key(keys, keyname_len);
1853 if (idx == Q_KEY_CODE__MAX) {
1856 keylist->value->type = KEY_VALUE_KIND_QCODE;
1857 keylist->value->u.qcode.data = idx;
1863 keys = separator + 1;
1866 qmp_send_key(head, has_hold_time, hold_time, &err);
1867 hmp_handle_error(mon, &err);
1870 qapi_free_KeyValueList(head);
1874 monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys);
1878 void hmp_screendump(Monitor *mon, const QDict *qdict)
1880 const char *filename = qdict_get_str(qdict, "filename");
1883 qmp_screendump(filename, &err);
1884 hmp_handle_error(mon, &err);
1887 void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
1889 const char *uri = qdict_get_str(qdict, "uri");
1890 bool writable = qdict_get_try_bool(qdict, "writable", false);
1891 bool all = qdict_get_try_bool(qdict, "all", false);
1892 Error *local_err = NULL;
1893 BlockInfoList *block_list, *info;
1894 SocketAddress *addr;
1896 if (writable && !all) {
1897 error_setg(&local_err, "-w only valid together with -a");
1901 /* First check if the address is valid and start the server. */
1902 addr = socket_parse(uri, &local_err);
1903 if (local_err != NULL) {
1907 qmp_nbd_server_start(addr, false, NULL, &local_err);
1908 qapi_free_SocketAddress(addr);
1909 if (local_err != NULL) {
1917 /* Then try adding all block devices. If one fails, close all and
1920 block_list = qmp_query_block(NULL);
1922 for (info = block_list; info; info = info->next) {
1923 if (!info->value->has_inserted) {
1927 qmp_nbd_server_add(info->value->device, true, writable, &local_err);
1929 if (local_err != NULL) {
1930 qmp_nbd_server_stop(NULL);
1935 qapi_free_BlockInfoList(block_list);
1938 hmp_handle_error(mon, &local_err);
1941 void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
1943 const char *device = qdict_get_str(qdict, "device");
1944 bool writable = qdict_get_try_bool(qdict, "writable", false);
1945 Error *local_err = NULL;
1947 qmp_nbd_server_add(device, true, writable, &local_err);
1949 if (local_err != NULL) {
1950 hmp_handle_error(mon, &local_err);
1954 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
1958 qmp_nbd_server_stop(&err);
1959 hmp_handle_error(mon, &err);
1962 void hmp_cpu_add(Monitor *mon, const QDict *qdict)
1967 cpuid = qdict_get_int(qdict, "id");
1968 qmp_cpu_add(cpuid, &err);
1969 hmp_handle_error(mon, &err);
1972 void hmp_chardev_add(Monitor *mon, const QDict *qdict)
1974 const char *args = qdict_get_str(qdict, "args");
1978 opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true);
1980 error_setg(&err, "Parsing chardev args failed");
1982 qemu_chr_new_from_opts(opts, NULL, &err);
1983 qemu_opts_del(opts);
1985 hmp_handle_error(mon, &err);
1988 void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
1990 Error *local_err = NULL;
1992 qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
1993 hmp_handle_error(mon, &local_err);
1996 void hmp_qemu_io(Monitor *mon, const QDict *qdict)
1999 BlockBackend *local_blk = NULL;
2000 AioContext *aio_context;
2001 const char* device = qdict_get_str(qdict, "device");
2002 const char* command = qdict_get_str(qdict, "command");
2005 blk = blk_by_name(device);
2007 BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
2009 blk = local_blk = blk_new();
2010 blk_insert_bs(blk, bs);
2016 aio_context = blk_get_aio_context(blk);
2017 aio_context_acquire(aio_context);
2019 qemuio_command(blk, command);
2021 aio_context_release(aio_context);
2024 blk_unref(local_blk);
2025 hmp_handle_error(mon, &err);
2028 void hmp_object_del(Monitor *mon, const QDict *qdict)
2030 const char *id = qdict_get_str(qdict, "id");
2033 user_creatable_del(id, &err);
2034 hmp_handle_error(mon, &err);
2037 void hmp_info_memdev(Monitor *mon, const QDict *qdict)
2040 MemdevList *memdev_list = qmp_query_memdev(&err);
2041 MemdevList *m = memdev_list;
2048 v = string_output_visitor_new(false, &str);
2049 visit_type_uint16List(v, NULL, &m->value->host_nodes, NULL);
2050 monitor_printf(mon, "memory backend: %d\n", i);
2051 monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
2052 monitor_printf(mon, " merge: %s\n",
2053 m->value->merge ? "true" : "false");
2054 monitor_printf(mon, " dump: %s\n",
2055 m->value->dump ? "true" : "false");
2056 monitor_printf(mon, " prealloc: %s\n",
2057 m->value->prealloc ? "true" : "false");
2058 monitor_printf(mon, " policy: %s\n",
2059 HostMemPolicy_lookup[m->value->policy]);
2060 visit_complete(v, &str);
2061 monitor_printf(mon, " host nodes: %s\n", str);
2069 monitor_printf(mon, "\n");
2071 qapi_free_MemdevList(memdev_list);
2074 void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
2077 MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
2078 MemoryDeviceInfoList *info;
2079 MemoryDeviceInfo *value;
2080 PCDIMMDeviceInfo *di;
2082 for (info = info_list; info; info = info->next) {
2083 value = info->value;
2086 switch (value->type) {
2087 case MEMORY_DEVICE_INFO_KIND_DIMM:
2088 di = value->u.dimm.data;
2090 monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
2091 MemoryDeviceInfoKind_lookup[value->type],
2092 di->id ? di->id : "");
2093 monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
2094 monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
2095 monitor_printf(mon, " node: %" PRId64 "\n", di->node);
2096 monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
2097 monitor_printf(mon, " memdev: %s\n", di->memdev);
2098 monitor_printf(mon, " hotplugged: %s\n",
2099 di->hotplugged ? "true" : "false");
2100 monitor_printf(mon, " hotpluggable: %s\n",
2101 di->hotpluggable ? "true" : "false");
2109 qapi_free_MemoryDeviceInfoList(info_list);
2112 void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
2114 IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
2115 IOThreadInfoList *info;
2117 for (info = info_list; info; info = info->next) {
2118 monitor_printf(mon, "%s: thread_id=%" PRId64 "\n",
2119 info->value->id, info->value->thread_id);
2122 qapi_free_IOThreadInfoList(info_list);
2125 void hmp_qom_list(Monitor *mon, const QDict *qdict)
2127 const char *path = qdict_get_try_str(qdict, "path");
2128 ObjectPropertyInfoList *list;
2132 monitor_printf(mon, "/\n");
2136 list = qmp_qom_list(path, &err);
2138 ObjectPropertyInfoList *start = list;
2139 while (list != NULL) {
2140 ObjectPropertyInfo *value = list->value;
2142 monitor_printf(mon, "%s (%s)\n",
2143 value->name, value->type);
2146 qapi_free_ObjectPropertyInfoList(start);
2148 hmp_handle_error(mon, &err);
2151 void hmp_qom_set(Monitor *mon, const QDict *qdict)
2153 const char *path = qdict_get_str(qdict, "path");
2154 const char *property = qdict_get_str(qdict, "property");
2155 const char *value = qdict_get_str(qdict, "value");
2157 bool ambiguous = false;
2160 obj = object_resolve_path(path, &ambiguous);
2162 error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
2163 "Device '%s' not found", path);
2166 monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);
2168 object_property_parse(obj, value, property, &err);
2170 hmp_handle_error(mon, &err);
2173 void hmp_rocker(Monitor *mon, const QDict *qdict)
2175 const char *name = qdict_get_str(qdict, "name");
2176 RockerSwitch *rocker;
2179 rocker = qmp_query_rocker(name, &err);
2181 hmp_handle_error(mon, &err);
2185 monitor_printf(mon, "name: %s\n", rocker->name);
2186 monitor_printf(mon, "id: 0x%" PRIx64 "\n", rocker->id);
2187 monitor_printf(mon, "ports: %d\n", rocker->ports);
2189 qapi_free_RockerSwitch(rocker);
2192 void hmp_rocker_ports(Monitor *mon, const QDict *qdict)
2194 RockerPortList *list, *port;
2195 const char *name = qdict_get_str(qdict, "name");
2198 list = qmp_query_rocker_ports(name, &err);
2200 hmp_handle_error(mon, &err);
2204 monitor_printf(mon, " ena/ speed/ auto\n");
2205 monitor_printf(mon, " port link duplex neg?\n");
2207 for (port = list; port; port = port->next) {
2208 monitor_printf(mon, "%10s %-4s %-3s %2s %-3s\n",
2210 port->value->enabled ? port->value->link_up ?
2211 "up" : "down" : "!ena",
2212 port->value->speed == 10000 ? "10G" : "??",
2213 port->value->duplex ? "FD" : "HD",
2214 port->value->autoneg ? "Yes" : "No");
2217 qapi_free_RockerPortList(list);
2220 void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict)
2222 RockerOfDpaFlowList *list, *info;
2223 const char *name = qdict_get_str(qdict, "name");
2224 uint32_t tbl_id = qdict_get_try_int(qdict, "tbl_id", -1);
2227 list = qmp_query_rocker_of_dpa_flows(name, tbl_id != -1, tbl_id, &err);
2229 hmp_handle_error(mon, &err);
2233 monitor_printf(mon, "prio tbl hits key(mask) --> actions\n");
2235 for (info = list; info; info = info->next) {
2236 RockerOfDpaFlow *flow = info->value;
2237 RockerOfDpaFlowKey *key = flow->key;
2238 RockerOfDpaFlowMask *mask = flow->mask;
2239 RockerOfDpaFlowAction *action = flow->action;
2242 monitor_printf(mon, "%-4d %-3d %-4" PRIu64,
2243 key->priority, key->tbl_id, flow->hits);
2245 monitor_printf(mon, "%-4d %-3d ",
2246 key->priority, key->tbl_id);
2249 if (key->has_in_pport) {
2250 monitor_printf(mon, " pport %d", key->in_pport);
2251 if (mask->has_in_pport) {
2252 monitor_printf(mon, "(0x%x)", mask->in_pport);
2256 if (key->has_vlan_id) {
2257 monitor_printf(mon, " vlan %d",
2258 key->vlan_id & VLAN_VID_MASK);
2259 if (mask->has_vlan_id) {
2260 monitor_printf(mon, "(0x%x)", mask->vlan_id);
2264 if (key->has_tunnel_id) {
2265 monitor_printf(mon, " tunnel %d", key->tunnel_id);
2266 if (mask->has_tunnel_id) {
2267 monitor_printf(mon, "(0x%x)", mask->tunnel_id);
2271 if (key->has_eth_type) {
2272 switch (key->eth_type) {
2274 monitor_printf(mon, " ARP");
2277 monitor_printf(mon, " IP");
2280 monitor_printf(mon, " IPv6");
2283 monitor_printf(mon, " LACP");
2286 monitor_printf(mon, " LLDP");
2289 monitor_printf(mon, " eth type 0x%04x", key->eth_type);
2294 if (key->has_eth_src) {
2295 if ((strcmp(key->eth_src, "01:00:00:00:00:00") == 0) &&
2296 (mask->has_eth_src) &&
2297 (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) {
2298 monitor_printf(mon, " src <any mcast/bcast>");
2299 } else if ((strcmp(key->eth_src, "00:00:00:00:00:00") == 0) &&
2300 (mask->has_eth_src) &&
2301 (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) {
2302 monitor_printf(mon, " src <any ucast>");
2304 monitor_printf(mon, " src %s", key->eth_src);
2305 if (mask->has_eth_src) {
2306 monitor_printf(mon, "(%s)", mask->eth_src);
2311 if (key->has_eth_dst) {
2312 if ((strcmp(key->eth_dst, "01:00:00:00:00:00") == 0) &&
2313 (mask->has_eth_dst) &&
2314 (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) {
2315 monitor_printf(mon, " dst <any mcast/bcast>");
2316 } else if ((strcmp(key->eth_dst, "00:00:00:00:00:00") == 0) &&
2317 (mask->has_eth_dst) &&
2318 (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) {
2319 monitor_printf(mon, " dst <any ucast>");
2321 monitor_printf(mon, " dst %s", key->eth_dst);
2322 if (mask->has_eth_dst) {
2323 monitor_printf(mon, "(%s)", mask->eth_dst);
2328 if (key->has_ip_proto) {
2329 monitor_printf(mon, " proto %d", key->ip_proto);
2330 if (mask->has_ip_proto) {
2331 monitor_printf(mon, "(0x%x)", mask->ip_proto);
2335 if (key->has_ip_tos) {
2336 monitor_printf(mon, " TOS %d", key->ip_tos);
2337 if (mask->has_ip_tos) {
2338 monitor_printf(mon, "(0x%x)", mask->ip_tos);
2342 if (key->has_ip_dst) {
2343 monitor_printf(mon, " dst %s", key->ip_dst);
2346 if (action->has_goto_tbl || action->has_group_id ||
2347 action->has_new_vlan_id) {
2348 monitor_printf(mon, " -->");
2351 if (action->has_new_vlan_id) {
2352 monitor_printf(mon, " apply new vlan %d",
2353 ntohs(action->new_vlan_id));
2356 if (action->has_group_id) {
2357 monitor_printf(mon, " write group 0x%08x", action->group_id);
2360 if (action->has_goto_tbl) {
2361 monitor_printf(mon, " goto tbl %d", action->goto_tbl);
2364 monitor_printf(mon, "\n");
2367 qapi_free_RockerOfDpaFlowList(list);
2370 void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
2372 RockerOfDpaGroupList *list, *g;
2373 const char *name = qdict_get_str(qdict, "name");
2374 uint8_t type = qdict_get_try_int(qdict, "type", 9);
2378 list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err);
2380 hmp_handle_error(mon, &err);
2384 monitor_printf(mon, "id (decode) --> buckets\n");
2386 for (g = list; g; g = g->next) {
2387 RockerOfDpaGroup *group = g->value;
2389 monitor_printf(mon, "0x%08x", group->id);
2391 monitor_printf(mon, " (type %s", group->type == 0 ? "L2 interface" :
2392 group->type == 1 ? "L2 rewrite" :
2393 group->type == 2 ? "L3 unicast" :
2394 group->type == 3 ? "L2 multicast" :
2395 group->type == 4 ? "L2 flood" :
2396 group->type == 5 ? "L3 interface" :
2397 group->type == 6 ? "L3 multicast" :
2398 group->type == 7 ? "L3 ECMP" :
2399 group->type == 8 ? "L2 overlay" :
2402 if (group->has_vlan_id) {
2403 monitor_printf(mon, " vlan %d", group->vlan_id);
2406 if (group->has_pport) {
2407 monitor_printf(mon, " pport %d", group->pport);
2410 if (group->has_index) {
2411 monitor_printf(mon, " index %d", group->index);
2414 monitor_printf(mon, ") -->");
2416 if (group->has_set_vlan_id && group->set_vlan_id) {
2418 monitor_printf(mon, " set vlan %d",
2419 group->set_vlan_id & VLAN_VID_MASK);
2422 if (group->has_set_eth_src) {
2425 monitor_printf(mon, " set");
2427 monitor_printf(mon, " src %s", group->set_eth_src);
2430 if (group->has_set_eth_dst) {
2433 monitor_printf(mon, " set");
2435 monitor_printf(mon, " dst %s", group->set_eth_dst);
2440 if (group->has_ttl_check && group->ttl_check) {
2441 monitor_printf(mon, " check TTL");
2444 if (group->has_group_id && group->group_id) {
2445 monitor_printf(mon, " group id 0x%08x", group->group_id);
2448 if (group->has_pop_vlan && group->pop_vlan) {
2449 monitor_printf(mon, " pop vlan");
2452 if (group->has_out_pport) {
2453 monitor_printf(mon, " out pport %d", group->out_pport);
2456 if (group->has_group_ids) {
2457 struct uint32List *id;
2459 monitor_printf(mon, " groups [");
2460 for (id = group->group_ids; id; id = id->next) {
2461 monitor_printf(mon, "0x%08x", id->value);
2463 monitor_printf(mon, ",");
2466 monitor_printf(mon, "]");
2469 monitor_printf(mon, "\n");
2472 qapi_free_RockerOfDpaGroupList(list);
2475 void hmp_info_dump(Monitor *mon, const QDict *qdict)
2477 DumpQueryResult *result = qmp_query_dump(NULL);
2479 assert(result && result->status < DUMP_STATUS__MAX);
2480 monitor_printf(mon, "Status: %s\n", DumpStatus_lookup[result->status]);
2482 if (result->status == DUMP_STATUS_ACTIVE) {
2484 assert(result->total != 0);
2485 percent = 100.0 * result->completed / result->total;
2486 monitor_printf(mon, "Finished: %.2f %%\n", percent);
2489 qapi_free_DumpQueryResult(result);
2492 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
2495 HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err);
2496 HotpluggableCPUList *saved = l;
2497 CpuInstanceProperties *c;
2500 hmp_handle_error(mon, &err);
2504 monitor_printf(mon, "Hotpluggable CPUs:\n");
2506 monitor_printf(mon, " type: \"%s\"\n", l->value->type);
2507 monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n",
2508 l->value->vcpus_count);
2509 if (l->value->has_qom_path) {
2510 monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path);
2513 c = l->value->props;
2514 monitor_printf(mon, " CPUInstance Properties:\n");
2515 if (c->has_node_id) {
2516 monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id);
2518 if (c->has_socket_id) {
2519 monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
2521 if (c->has_core_id) {
2522 monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
2524 if (c->has_thread_id) {
2525 monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id);
2531 qapi_free_HotpluggableCPUList(saved);