@samitouri / QOSamiQemu / commits / f3900cfb0c

monitor: tighten monitor_printf*()

Rename monitor_printf->monitor_hmp_printf, monitor_vprintf-> monitor_hmp_vprintf, and monitor_printc->monitor_hmp_printc, changing the first parameter from Monitor * to MonitorHMP * to enforce type safety. The implementation is also simplified: monitor_hmp_vprintf now directly calls g_strdup_vprintf + monitor_puts, removing the virtual dispatch via moncls->vprintf. The dev_print() callbacks are temporarily using the MONITOR_HMP(mon) cast, they are fixed in the following commits. Early return in qemu_vprintf() if "hmp" is NULL, relying on monitor_hmp_vprintf() handling NULL case is a bit uncommon. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-37-9227de146347@redhat.com>

Marc-André Lureau committed Aug 28, 2026 at 16:04 UTC f3900cfb0cddd2fcc3b9db20f52f3755e6ed962f
63 files changed +1226 -1328
audio/audio-hmp-cmds.c
+2 -4
@@ -34,14 +34,13 @@ static QLIST_HEAD (capture_list_head, CaptureState) capture_head;
34
35 void hmp_info_capture(MonitorHMP *hmp, const QDict *qdict)
36 {
37 - Monitor *mon = MONITOR(hmp);
37 int i;
38 CaptureState *s;
39
40 warn_report_once("'info capture' is deprecated since v10.2, to be removed");
41
42 for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
44 - monitor_printf(mon, "[%d]: ", i);
43 + monitor_hmp_printf(hmp, "[%d]: ", i);
44 s->ops.info (s->opaque);
45 }
46 }
@@ -66,7 +65,6 @@ void hmp_stopcapture(MonitorHMP *hmp, const QDict *qdict)
65
66 void hmp_wavcapture(MonitorHMP *hmp, const QDict *qdict)
67 {
69 - Monitor *mon = MONITOR(hmp);
68 const char *path = qdict_get_str(qdict, "path");
69 int freq = qdict_get_try_int(qdict, "freq", 44100);
70 int bits = qdict_get_try_int(qdict, "bits", 16);
@@ -86,7 +84,7 @@ void hmp_wavcapture(MonitorHMP *hmp, const QDict *qdict)
84 s = g_malloc0 (sizeof (*s));
85
86 if (wav_start_capture(as, s, path, freq, bits, nchannels)) {
89 - monitor_printf(mon, "Failed to add wave capture\n");
87 + monitor_hmp_printf(hmp, "Failed to add wave capture\n");
88 g_free (s);
89 return;
90 }
backends/cryptodev-hmp-cmds.c
+4 -5
@@ -19,7 +19,6 @@
19
20 void hmp_info_cryptodev(MonitorHMP *hmp, const QDict *qdict)
21 {
22 - Monitor *mon = MONITOR(hmp);
22 QCryptodevInfoList *il;
23 QCryptodevBackendServiceTypeList *sl;
24 QCryptodevBackendClientList *cl;
@@ -41,13 +40,13 @@ void hmp_info_cryptodev(MonitorHMP *hmp, const QDict *qdict)
40 services = tmp_services;
41 }
42 }
44 - monitor_printf(mon, "%s: service=[%s]\n", info->id, services);
43 + monitor_hmp_printf(hmp, "%s: service=[%s]\n", info->id, services);
44
45 for (cl = info->client; cl; cl = cl->next) {
46 QCryptodevBackendClient *client = cl->value;
48 - monitor_printf(mon, " queue %" PRIu32 ": type=%s\n",
49 - client->queue,
50 - QCryptodevBackendType_str(client->type));
47 + monitor_hmp_printf(hmp, " queue %" PRIu32 ": type=%s\n",
48 + client->queue,
49 + QCryptodevBackendType_str(client->type));
50 }
51 }
52
block/monitor/block-hmp-cmds.c
+83 -87
@@ -89,7 +89,6 @@ out:
89
90 void hmp_drive_add(MonitorHMP *hmp, const QDict *qdict)
91 {
92 - Monitor *mon = MONITOR(hmp);
92 Error *err = NULL;
93 DriveInfo *dinfo;
94 QemuOpts *opts;
@@ -119,7 +118,7 @@ void hmp_drive_add(MonitorHMP *hmp, const QDict *qdict)
118
119 switch (dinfo->type) {
120 case IF_NONE:
122 - monitor_printf(mon, "OK\n");
121 + monitor_hmp_printf(hmp, "OK\n");
122 break;
123 default:
124 error_setg(&err, "Can't hot-add drive to type %d", dinfo->type);
@@ -552,9 +551,10 @@ void hmp_qemu_io(MonitorHMP *hmp, const QDict *qdict)
551 hmp_handle_error(hmp, err);
552 }
553
555 -static void print_block_info(Monitor *mon, BlockInfo *info,
554 +static void print_block_info(MonitorHMP *hmp, BlockInfo *info,
555 BlockDeviceInfo *inserted, bool verbose)
556 {
557 + Monitor *mon = MONITOR(hmp);
558 ImageInfo *image_info;
559
560 assert(!info || !info->inserted || info->inserted == inserted);
@@ -562,7 +562,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
562 if (info && *info->device) {
563 monitor_puts(mon, info->device);
564 if (inserted && inserted->node_name) {
565 - monitor_printf(mon, " (%s)", inserted->node_name);
565 + monitor_hmp_printf(hmp, " (%s)", inserted->node_name);
566 }
567 } else {
568 assert(info || inserted);
@@ -573,29 +573,29 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
573 }
574
575 if (inserted) {
576 - monitor_printf(mon, ": %s (%s%s%s%s)\n",
577 - inserted->file,
578 - inserted->drv,
579 - inserted->ro ? ", read-only" : "",
580 - inserted->encrypted ? ", encrypted" : "",
581 - inserted->active ? "" : ", inactive");
576 + monitor_hmp_printf(hmp, ": %s (%s%s%s%s)\n",
577 + inserted->file,
578 + inserted->drv,
579 + inserted->ro ? ", read-only" : "",
580 + inserted->encrypted ? ", encrypted" : "",
581 + inserted->active ? "" : ", inactive");
582 } else {
583 - monitor_printf(mon, ": [not inserted]\n");
583 + monitor_hmp_printf(hmp, ": [not inserted]\n");
584 }
585
586 if (info) {
587 if (info->qdev) {
588 - monitor_printf(mon, " Attached to: %s\n", info->qdev);
588 + monitor_hmp_printf(hmp, " Attached to: %s\n", info->qdev);
589 }
590 if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
591 - monitor_printf(mon, " I/O status: %s\n",
592 - BlockDeviceIoStatus_str(info->io_status));
591 + monitor_hmp_printf(hmp, " I/O status: %s\n",
592 + BlockDeviceIoStatus_str(info->io_status));
593 }
594
595 if (info->removable) {
596 - monitor_printf(mon, " Removable device: %slocked, tray %s\n",
597 - info->locked ? "" : "not ",
598 - info->tray_open ? "open" : "closed");
596 + monitor_hmp_printf(hmp, " Removable device: %slocked, tray %s\n",
597 + info->locked ? "" : "not ",
598 + info->tray_open ? "open" : "closed");
599 }
600 }
601
@@ -604,28 +604,28 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
604 return;
605 }
606
607 - monitor_printf(mon, " Cache mode: %s%s%s\n",
608 - inserted->cache->writeback ? "writeback" : "writethrough",
609 - inserted->cache->direct ? ", direct" : "",
610 - inserted->cache->no_flush ? ", ignore flushes" : "");
607 + monitor_hmp_printf(hmp, " Cache mode: %s%s%s\n",
608 + inserted->cache->writeback ? "writeback" : "writethrough",
609 + inserted->cache->direct ? ", direct" : "",
610 + inserted->cache->no_flush ? ", ignore flushes" : "");
611
612 if (inserted->backing_file) {
613 - monitor_printf(mon,
614 - " Backing file: %s "
615 - "(chain depth: %" PRId64 ")\n",
616 - inserted->backing_file,
617 - inserted->backing_file_depth);
613 + monitor_hmp_printf(hmp,
614 + " Backing file: %s "
615 + "(chain depth: %" PRId64 ")\n",
616 + inserted->backing_file,
617 + inserted->backing_file_depth);
618 }
619
620 if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
621 - monitor_printf(mon, " Detect zeroes: %s\n",
621 + monitor_hmp_printf(hmp, " Detect zeroes: %s\n",
622 BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
623 }
624
625 if (inserted->bps || inserted->bps_rd || inserted->bps_wr ||
626 inserted->iops || inserted->iops_rd || inserted->iops_wr)
627 {
628 - monitor_printf(mon, " I/O throttling: bps=%" PRId64
628 + monitor_hmp_printf(hmp, " I/O throttling: bps=%" PRId64
629 " bps_rd=%" PRId64 " bps_wr=%" PRId64
630 " bps_max=%" PRId64
631 " bps_rd_max=%" PRId64
@@ -654,7 +654,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
654 }
655
656 if (verbose) {
657 - monitor_printf(mon, "\nImages:\n");
657 + monitor_hmp_printf(hmp, "\nImages:\n");
658 image_info = inserted->image;
659 while (1) {
660 bdrv_node_info_dump(qapi_ImageInfo_base(image_info), 0, false);
@@ -669,7 +669,6 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
669
670 void hmp_info_block(MonitorHMP *hmp, const QDict *qdict)
671 {
672 - Monitor *mon = MONITOR(hmp);
672 BlockInfoList *block_list, *info;
673 BlockDeviceInfoList *blockdev_list, *blockdev;
674 const char *device = qdict_get_try_str(qdict, "device");
@@ -690,10 +689,10 @@ void hmp_info_block(MonitorHMP *hmp, const QDict *qdict)
689 }
690
691 if (info != block_list) {
693 - monitor_printf(mon, "\n");
692 + monitor_hmp_printf(hmp, "\n");
693 }
694
696 - print_block_info(mon, info->value, info->value->inserted,
695 + print_block_info(hmp, info->value, info->value->inserted,
696 verbose);
697 printed = true;
698 }
@@ -713,17 +712,16 @@ void hmp_info_block(MonitorHMP *hmp, const QDict *qdict)
712 }
713
714 if (blockdev != blockdev_list) {
716 - monitor_printf(mon, "\n");
715 + monitor_hmp_printf(hmp, "\n");
716 }
717
719 - print_block_info(mon, NULL, blockdev->value, verbose);
718 + print_block_info(hmp, NULL, blockdev->value, verbose);
719 }
720 qapi_free_BlockDeviceInfoList(blockdev_list);
721 }
722
723 void hmp_info_blockstats(MonitorHMP *hmp, const QDict *qdict)
724 {
726 - Monitor *mon = MONITOR(hmp);
725 BlockStatsList *stats_list, *stats;
726
727 stats_list = qmp_query_blockstats(false, false, NULL);
@@ -733,28 +731,28 @@ void hmp_info_blockstats(MonitorHMP *hmp, const QDict *qdict)
731 continue;
732 }
733
736 - monitor_printf(mon, "%s%s: idle_time_ns=%" PRId64 "\n",
737 - stats != stats_list ? "\n" : "",
738 - stats->value->device,
739 - stats->value->stats->idle_time_ns);
740 - monitor_printf(mon, " %24s %16s %24s %10s\n", "bytes",
741 - "operations", "total_time_ns", "merged");
742 - monitor_printf(mon, "Read: %24" PRId64 " %16" PRId64 " %24" PRId64
743 - " %10" PRId64 "\n",
744 - stats->value->stats->rd_bytes,
745 - stats->value->stats->rd_operations,
746 - stats->value->stats->rd_total_time_ns,
747 - stats->value->stats->rd_merged);
748 - monitor_printf(mon, "Write: %24" PRId64 " %16" PRId64 " %24" PRId64
749 - " %10" PRId64 "\n",
750 - stats->value->stats->wr_bytes,
751 - stats->value->stats->wr_operations,
752 - stats->value->stats->wr_total_time_ns,
753 - stats->value->stats->wr_merged);
754 - monitor_printf(mon, "Flush: %24s %16" PRId64 " %24" PRId64 "\n",
755 - "",
756 - stats->value->stats->flush_operations,
757 - stats->value->stats->flush_total_time_ns);
734 + monitor_hmp_printf(hmp, "%s%s: idle_time_ns=%" PRId64 "\n",
735 + stats != stats_list ? "\n" : "",
736 + stats->value->device,
737 + stats->value->stats->idle_time_ns);
738 + monitor_hmp_printf(hmp, " %24s %16s %24s %10s\n", "bytes",
739 + "operations", "total_time_ns", "merged");
740 + monitor_hmp_printf(hmp, "Read: %24" PRId64 " %16" PRId64 " %24" PRId64
741 + " %10" PRId64 "\n",
742 + stats->value->stats->rd_bytes,
743 + stats->value->stats->rd_operations,
744 + stats->value->stats->rd_total_time_ns,
745 + stats->value->stats->rd_merged);
746 + monitor_hmp_printf(hmp, "Write: %24" PRId64 " %16" PRId64 " %24" PRId64
747 + " %10" PRId64 "\n",
748 + stats->value->stats->wr_bytes,
749 + stats->value->stats->wr_operations,
750 + stats->value->stats->wr_total_time_ns,
751 + stats->value->stats->wr_merged);
752 + monitor_hmp_printf(hmp, "Flush: %24s %16" PRId64 " %24" PRId64 "\n",
753 + "",
754 + stats->value->stats->flush_operations,
755 + stats->value->stats->flush_total_time_ns);
756 }
757
758 qapi_free_BlockStatsList(stats_list);
@@ -762,34 +760,33 @@ void hmp_info_blockstats(MonitorHMP *hmp, const QDict *qdict)
760
761 void hmp_info_block_jobs(MonitorHMP *hmp, const QDict *qdict)
762 {
765 - Monitor *mon = MONITOR(hmp);
763 BlockJobInfoList *list;
764
765 list = qmp_query_block_jobs(&error_abort);
766
767 if (!list) {
771 - monitor_printf(mon, "No active jobs\n");
768 + monitor_hmp_printf(hmp, "No active jobs\n");
769 return;
770 }
771
772 while (list) {
773 if (list->value->type == JOB_TYPE_STREAM) {
777 - monitor_printf(mon, "Streaming device %s: Completed %" PRId64
778 - " of %" PRId64 " bytes, speed limit %" PRId64
779 - " bytes/s\n",
780 - list->value->device,
781 - list->value->offset,
782 - list->value->len,
783 - list->value->speed);
774 + monitor_hmp_printf(hmp, "Streaming device %s: Completed %" PRId64
775 + " of %" PRId64 " bytes, speed limit %" PRId64
776 + " bytes/s\n",
777 + list->value->device,
778 + list->value->offset,
779 + list->value->len,
780 + list->value->speed);
781 } else {
785 - monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
786 - " of %" PRId64 " bytes, speed limit %" PRId64
787 - " bytes/s\n",
788 - JobType_str(list->value->type),
789 - list->value->device,
790 - list->value->offset,
791 - list->value->len,
792 - list->value->speed);
782 + monitor_hmp_printf(hmp, "Type %s, device %s: Completed %" PRId64
783 + " of %" PRId64 " bytes, speed limit %" PRId64
784 + " bytes/s\n",
785 + JobType_str(list->value->type),
786 + list->value->device,
787 + list->value->offset,
788 + list->value->len,
789 + list->value->speed);
790 }
791 list = list->next;
792 }
@@ -799,7 +796,6 @@ void hmp_info_block_jobs(MonitorHMP *hmp, const QDict *qdict)
796
797 void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
798 {
802 - Monitor *mon = MONITOR(hmp);
799 BlockDriverState *bs, *bs1;
800 BdrvNextIterator it1;
801 QEMUSnapshotInfo *sn_tab, *sn;
@@ -837,7 +833,7 @@ void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
833 nb_sns = bdrv_snapshot_list(bs, &sn_tab);
834
835 if (nb_sns < 0) {
840 - monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
836 + monitor_hmp_printf(hmp, "bdrv_snapshot_list: error %d\n", nb_sns);
837 return;
838 }
839
@@ -866,7 +862,7 @@ void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
862 }
863
864 if (no_snapshot) {
869 - monitor_printf(mon, "There is no snapshot available.\n");
865 + monitor_hmp_printf(hmp, "There is no snapshot available.\n");
866 return;
867 }
868
@@ -889,11 +885,11 @@ void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
885 }
886 }
887 }
892 - monitor_printf(mon, "List of snapshots present on all disks:\n");
888 + monitor_hmp_printf(hmp, "List of snapshots present on all disks:\n");
889
890 if (total > 0) {
891 bdrv_snapshot_dump(NULL);
896 - monitor_printf(mon, "\n");
892 + monitor_hmp_printf(hmp, "\n");
893 for (i = 0; i < total; i++) {
894 sn = &sn_tab[global_snapshots[i]];
895 /*
@@ -902,24 +898,24 @@ void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
898 */
899 pstrcpy(sn->id_str, sizeof(sn->id_str), "--");
900 bdrv_snapshot_dump(sn);
905 - monitor_printf(mon, "\n");
901 + monitor_hmp_printf(hmp, "\n");
902 }
903 } else {
908 - monitor_printf(mon, "None\n");
904 + monitor_hmp_printf(hmp, "None\n");
905 }
906
907 QTAILQ_FOREACH(image_entry, &image_list, next) {
908 if (QTAILQ_EMPTY(&image_entry->snapshots)) {
909 continue;
910 }
915 - monitor_printf(mon,
916 - "\nList of partial (non-loadable) snapshots on '%s':\n",
917 - image_entry->imagename);
911 + monitor_hmp_printf(hmp,
912 + "\nList of partial (non-loadable) snapshots on '%s':\n",
913 + image_entry->imagename);
914 bdrv_snapshot_dump(NULL);
919 - monitor_printf(mon, "\n");
915 + monitor_hmp_printf(hmp, "\n");
916 QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) {
917 bdrv_snapshot_dump(&snapshot_entry->sn);
922 - monitor_printf(mon, "\n");
918 + monitor_hmp_printf(hmp, "\n");
919 }
920 }
921
@@ -935,7 +931,7 @@ void hmp_info_snapshots(MonitorHMP *hmp, const QDict *qdict)
931 g_free(global_snapshots);
932 }
933
938 -void hmp_change_medium(Monitor *mon, const char *device, const char *target,
934 +void hmp_change_medium(MonitorHMP *hmp, const char *device, const char *target,
935 const char *arg, const char *read_only, bool force,
936 Error **errp)
937 {
chardev/char-hmp-cmds.c
+5 -7
@@ -26,12 +26,11 @@
26
27 void hmp_info_chardev(MonitorHMP *hmp, const QDict *qdict)
28 {
29 - Monitor *mon = MONITOR(hmp);
29 ChardevInfoList *char_info, *info;
30
31 char_info = qmp_query_chardev(NULL);
32 for (info = char_info; info; info = info->next) {
34 - monitor_printf(mon, "%s: filename=%s\n", info->value->label,
33 + monitor_hmp_printf(hmp, "%s: filename=%s\n", info->value->label,
34 info->value->filename);
35 }
36
@@ -51,7 +50,6 @@ void hmp_ringbuf_write(MonitorHMP *hmp, const QDict *qdict)
50
51 void hmp_ringbuf_read(MonitorHMP *hmp, const QDict *qdict)
52 {
54 - Monitor *mon = MONITOR(hmp);
53 uint32_t size = qdict_get_int(qdict, "size");
54 const char *chardev = qdict_get_str(qdict, "device");
55 char *data;
@@ -67,15 +65,15 @@ void hmp_ringbuf_read(MonitorHMP *hmp, const QDict *qdict)
65 unsigned char ch = data[i];
66
67 if (ch == '\\') {
70 - monitor_printf(mon, "\\\\");
68 + monitor_hmp_printf(hmp, "\\\\");
69 } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) {
72 - monitor_printf(mon, "\\u%04X", ch);
70 + monitor_hmp_printf(hmp, "\\u%04X", ch);
71 } else {
74 - monitor_printf(mon, "%c", ch);
72 + monitor_hmp_printf(hmp, "%c", ch);
73 }
74
75 }
78 - monitor_printf(mon, "\n");
76 + monitor_hmp_printf(hmp, "\n");
77 g_free(data);
78 }
79
disas/disas-mon.c
+5 -5
@@ -38,7 +38,7 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,
38 }
39
40 /* Disassembler for the monitor. */
41 -void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc,
41 +void monitor_disas(MonitorHMP *hmp, CPUState *cpu, uint64_t pc,
42 int nb_insn, bool is_physical)
43 {
44 int count, i;
@@ -58,13 +58,13 @@ void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc,
58 s.info.buffer_vma = pc;
59
60 if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) {
61 - monitor_puts(mon, ds->str);
61 + monitor_puts(MONITOR(hmp), ds->str);
62 return;
63 }
64
65 if (!s.info.print_insn) {
66 - monitor_printf(mon, "0x%08" PRIx64
67 - ": Asm output not supported on this arch\n", pc);
66 + monitor_hmp_printf(hmp, "0x%08" PRIx64
67 + ": Asm output not supported on this arch\n", pc);
68 return;
69 }
70
@@ -78,5 +78,5 @@ void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc,
78 pc += count;
79 }
80
81 - monitor_puts(mon, ds->str);
81 + monitor_puts(MONITOR(hmp), ds->str);
82 }
docs/devel/style.rst
+1 -1
@@ -754,7 +754,7 @@ Error handling and reporting
754 Reporting errors to the human user
755 ----------------------------------
756
757 -Do not use printf(), fprintf() or monitor_printf(). Instead, use
757 +Do not use printf(), fprintf() or monitor_hmp_printf(). Instead, use
758 error_report() or error_vreport() from error-report.h. This ensures the
759 error is reported in the right place (current monitor or stderr), and in
760 a uniform format.
docs/devel/writing-monitor-commands.rst
+4 -4
@@ -479,7 +479,7 @@ The HMP command
479
480 Here's the HMP counterpart of the query-option-roms command::
481
482 - void hmp_info_option_roms(Monitor *mon, const QDict *qdict)
482 + void hmp_info_option_roms(MonitorHMP *mon, const QDict *qdict)
483 {
484 Error *err = NULL;
485 OptionRomInfoList *info_list, *tail;
@@ -492,11 +492,11 @@ Here's the HMP counterpart of the query-option-roms command::
492
493 for (tail = info_list; tail; tail = tail->next) {
494 info = tail->value;
495 - monitor_printf(mon, "%s", info->filename);
495 + monitor_hmp_printf(mon, "%s", info->filename);
496 if (info->has_bootindex) {
497 - monitor_printf(mon, " %" PRId64, info->bootindex);
497 + monitor_hmp_printf(mon, " %" PRId64, info->bootindex);
498 }
499 - monitor_printf(mon, "\n");
499 + monitor_hmp_printf(mon, "\n");
500 }
501
502 qapi_free_OptionRomInfoList(info_list);
dump/dump-hmp-cmds.c
+2 -3
@@ -85,17 +85,16 @@ void hmp_dump_guest_memory(MonitorHMP *hmp, const QDict *qdict)
85
86 void hmp_info_dump(MonitorHMP *hmp, const QDict *qdict)
87 {
88 - Monitor *mon = MONITOR(hmp);
88 DumpQueryResult *result = qmp_query_dump(NULL);
89
90 assert(result && result->status < DUMP_STATUS__MAX);
92 - monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status));
91 + monitor_hmp_printf(hmp, "Status: %s\n", DumpStatus_str(result->status));
92
93 if (result->status == DUMP_STATUS_ACTIVE) {
94 float percent = 0;
95 assert(result->total != 0);
96 percent = 100.0 * result->completed / result->total;
98 - monitor_printf(mon, "Finished: %.2f %%\n", percent);
97 + monitor_hmp_printf(hmp, "Finished: %.2f %%\n", percent);
98 }
99
100 qapi_free_DumpQueryResult(result);
hw/char/virtio-serial-bus.c
+5 -5
@@ -838,11 +838,11 @@ static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
838 {
839 VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(qdev);
840
841 - monitor_printf(mon, "%*sport %d, guest %s, host %s, throttle %s\n",
842 - indent, "", port->id,
843 - port->guest_connected ? "on" : "off",
844 - port->host_connected ? "on" : "off",
845 - port->throttled ? "on" : "off");
841 + monitor_hmp_printf(MONITOR_HMP(mon), "%*sport %d, guest %s, host %s, throttle %s\n",
842 + indent, "", port->id,
843 + port->guest_connected ? "on" : "off",
844 + port->host_connected ? "on" : "off",
845 + port->throttled ? "on" : "off");
846 }
847
848 /* This function is only used if a port id is not provided by the user */
hw/core/machine-hmp-cmds.c
+101 -112
@@ -27,7 +27,6 @@
27
28 void hmp_info_cpus(MonitorHMP *hmp, const QDict *qdict)
29 {
30 - Monitor *mon = MONITOR(hmp);
30 CpuInfoFastList *cpu_list, *cpu;
31
32 cpu_list = qmp_query_cpus_fast(NULL);
@@ -40,10 +39,10 @@ void hmp_info_cpus(MonitorHMP *hmp, const QDict *qdict)
39 active = '*';
40 }
41
43 - monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
44 - cpu->value->cpu_index);
45 - monitor_printf(mon, " thread_id=%" PRId64 " model=%s\n",
46 - cpu->value->thread_id, cpu_model);
42 + monitor_hmp_printf(hmp, "%c CPU #%" PRId64 ":", active,
43 + cpu->value->cpu_index);
44 + monitor_hmp_printf(hmp, " thread_id=%" PRId64 " model=%s\n",
45 + cpu->value->thread_id, cpu_model);
46 }
47
48 qapi_free_CpuInfoFastList(cpu_list);
@@ -51,7 +50,6 @@ void hmp_info_cpus(MonitorHMP *hmp, const QDict *qdict)
50
51 void hmp_hotpluggable_cpus(MonitorHMP *hmp, const QDict *qdict)
52 {
54 - Monitor *mon = MONITOR(hmp);
53 Error *err = NULL;
54 HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err);
55 HotpluggableCPUList *saved = l;
@@ -61,45 +59,45 @@ void hmp_hotpluggable_cpus(MonitorHMP *hmp, const QDict *qdict)
59 return;
60 }
61
64 - monitor_printf(mon, "Hotpluggable CPUs:\n");
62 + monitor_hmp_printf(hmp, "Hotpluggable CPUs:\n");
63 while (l) {
66 - monitor_printf(mon, " type: \"%s\"\n", l->value->type);
67 - monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n",
68 - l->value->vcpus_count);
64 + monitor_hmp_printf(hmp, " type: \"%s\"\n", l->value->type);
65 + monitor_hmp_printf(hmp, " vcpus_count: \"%" PRIu64 "\"\n",
66 + l->value->vcpus_count);
67 if (l->value->qom_path) {
70 - monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path);
68 + monitor_hmp_printf(hmp, " qom_path: \"%s\"\n", l->value->qom_path);
69 }
70
71 c = l->value->props;
74 - monitor_printf(mon, " CPUInstance Properties:\n");
72 + monitor_hmp_printf(hmp, " CPUInstance Properties:\n");
73 if (c->has_node_id) {
76 - monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id);
74 + monitor_hmp_printf(hmp, " node-id: \"%" PRIu64 "\"\n", c->node_id);
75 }
76 if (c->has_drawer_id) {
79 - monitor_printf(mon, " drawer-id: \"%" PRIu64 "\"\n", c->drawer_id);
77 + monitor_hmp_printf(hmp, " drawer-id: \"%" PRIu64 "\"\n", c->drawer_id);
78 }
79 if (c->has_book_id) {
82 - monitor_printf(mon, " book-id: \"%" PRIu64 "\"\n", c->book_id);
80 + monitor_hmp_printf(hmp, " book-id: \"%" PRIu64 "\"\n", c->book_id);
81 }
82 if (c->has_socket_id) {
85 - monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
83 + monitor_hmp_printf(hmp, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
84 }
85 if (c->has_die_id) {
88 - monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
86 + monitor_hmp_printf(hmp, " die-id: \"%" PRIu64 "\"\n", c->die_id);
87 }
88 if (c->has_cluster_id) {
91 - monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n",
92 - c->cluster_id);
89 + monitor_hmp_printf(hmp, " cluster-id: \"%" PRIu64 "\"\n",
90 + c->cluster_id);
91 }
92 if (c->has_module_id) {
95 - monitor_printf(mon, " module-id: \"%" PRIu64 "\"\n",
96 - c->module_id);
93 + monitor_hmp_printf(hmp, " module-id: \"%" PRIu64 "\"\n",
94 + c->module_id);
95 }
96 if (c->has_core_id) {
99 - monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
97 + monitor_hmp_printf(hmp, " core-id: \"%" PRIu64 "\"\n", c->core_id);
98 }
99 if (c->has_thread_id) {
102 - monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id);
100 + monitor_hmp_printf(hmp, " thread-id: \"%" PRIu64 "\"\n", c->thread_id);
101 }
102
103 l = l->next;
@@ -110,7 +108,6 @@ void hmp_hotpluggable_cpus(MonitorHMP *hmp, const QDict *qdict)
108
109 void hmp_info_memdev(MonitorHMP *hmp, const QDict *qdict)
110 {
113 - Monitor *mon = MONITOR(hmp);
111 Error *err = NULL;
112 MemdevList *memdev_list = qmp_query_memdev(&err);
113 MemdevList *m = memdev_list;
@@ -120,31 +117,31 @@ void hmp_info_memdev(MonitorHMP *hmp, const QDict *qdict)
117 while (m) {
118 v = string_output_visitor_new(false, &str);
119 visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
123 - monitor_printf(mon, "memory backend: %s\n", m->value->id);
124 - monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
125 - monitor_printf(mon, " merge: %s\n",
126 - m->value->merge ? "true" : "false");
127 - monitor_printf(mon, " dump: %s\n",
128 - m->value->dump ? "true" : "false");
129 - monitor_printf(mon, " prealloc: %s\n",
130 - m->value->prealloc ? "true" : "false");
131 - monitor_printf(mon, " share: %s\n",
132 - m->value->share ? "true" : "false");
120 + monitor_hmp_printf(hmp, "memory backend: %s\n", m->value->id);
121 + monitor_hmp_printf(hmp, " size: %" PRId64 "\n", m->value->size);
122 + monitor_hmp_printf(hmp, " merge: %s\n",
123 + m->value->merge ? "true" : "false");
124 + monitor_hmp_printf(hmp, " dump: %s\n",
125 + m->value->dump ? "true" : "false");
126 + monitor_hmp_printf(hmp, " prealloc: %s\n",
127 + m->value->prealloc ? "true" : "false");
128 + monitor_hmp_printf(hmp, " share: %s\n",
129 + m->value->share ? "true" : "false");
130 if (m->value->has_reserve) {
134 - monitor_printf(mon, " reserve: %s\n",
135 - m->value->reserve ? "true" : "false");
131 + monitor_hmp_printf(hmp, " reserve: %s\n",
132 + m->value->reserve ? "true" : "false");
133 }
137 - monitor_printf(mon, " policy: %s\n",
138 - HostMemPolicy_str(m->value->policy));
134 + monitor_hmp_printf(hmp, " policy: %s\n",
135 + HostMemPolicy_str(m->value->policy));
136 visit_complete(v, &str);
140 - monitor_printf(mon, " host nodes: %s\n", str);
137 + monitor_hmp_printf(hmp, " host nodes: %s\n", str);
138
139 g_free(str);
140 visit_free(v);
141 m = m->next;
142 }
143
147 - monitor_printf(mon, "\n");
144 + monitor_hmp_printf(hmp, "\n");
145
146 qapi_free_MemdevList(memdev_list);
147 hmp_handle_error(hmp, err);
@@ -152,15 +149,14 @@ void hmp_info_memdev(MonitorHMP *hmp, const QDict *qdict)
149
150 void hmp_info_kvm(MonitorHMP *hmp, const QDict *qdict)
151 {
155 - Monitor *mon = MONITOR(hmp);
152 KvmInfo *info;
153
154 info = qmp_query_kvm(NULL);
159 - monitor_printf(mon, "kvm support: ");
155 + monitor_hmp_printf(hmp, "kvm support: ");
156 if (info->present) {
161 - monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
157 + monitor_hmp_printf(hmp, "%s\n", info->enabled ? "enabled" : "disabled");
158 } else {
163 - monitor_printf(mon, "not compiled\n");
159 + monitor_hmp_printf(hmp, "not compiled\n");
160 }
161
162 qapi_free_KvmInfo(info);
@@ -168,7 +164,6 @@ void hmp_info_kvm(MonitorHMP *hmp, const QDict *qdict)
164
165 void hmp_info_accelerators(MonitorHMP *hmp, const QDict *qdict)
166 {
171 - Monitor *mon = MONITOR(hmp);
167 AcceleratorInfo *info;
168 AcceleratorList *accel;
169
@@ -176,9 +171,9 @@ void hmp_info_accelerators(MonitorHMP *hmp, const QDict *qdict)
171 for (accel = info->present; accel; accel = accel->next) {
172 char trail = accel->next ? ' ' : '\n';
173 if (info->enabled == accel->value) {
179 - monitor_printf(mon, "[%s]%c", Accelerator_str(accel->value), trail);
174 + monitor_hmp_printf(hmp, "[%s]%c", Accelerator_str(accel->value), trail);
175 } else {
181 - monitor_printf(mon, "%s%c", Accelerator_str(accel->value), trail);
176 + monitor_hmp_printf(hmp, "%s%c", Accelerator_str(accel->value), trail);
177 }
178 }
179
@@ -187,17 +182,15 @@ void hmp_info_accelerators(MonitorHMP *hmp, const QDict *qdict)
182
183 void hmp_info_uuid(MonitorHMP *hmp, const QDict *qdict)
184 {
190 - Monitor *mon = MONITOR(hmp);
185 UuidInfo *info;
186
187 info = qmp_query_uuid(NULL);
194 - monitor_printf(mon, "%s\n", info->UUID);
188 + monitor_hmp_printf(hmp, "%s\n", info->UUID);
189 qapi_free_UuidInfo(info);
190 }
191
192 void hmp_info_balloon(MonitorHMP *hmp, const QDict *qdict)
193 {
200 - Monitor *mon = MONITOR(hmp);
194 BalloonInfo *info;
195 Error *err = NULL;
196
@@ -206,7 +199,7 @@ void hmp_info_balloon(MonitorHMP *hmp, const QDict *qdict)
199 return;
200 }
201
209 - monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
202 + monitor_hmp_printf(hmp, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
203
204 qapi_free_BalloonInfo(info);
205 }
@@ -223,7 +216,6 @@ void hmp_system_powerdown(MonitorHMP *hmp, const QDict *qdict)
216
217 void hmp_memsave(MonitorHMP *hmp, const QDict *qdict)
218 {
226 - Monitor *mon = MONITOR(hmp);
219 uint32_t size = qdict_get_int(qdict, "size");
220 const char *filename = qdict_get_str(qdict, "filename");
221 uint64_t addr = qdict_get_int(qdict, "val");
@@ -231,7 +223,7 @@ void hmp_memsave(MonitorHMP *hmp, const QDict *qdict)
223 int cpu_index = monitor_hmp_get_cpu_index(hmp);
224
225 if (cpu_index < 0) {
234 - monitor_printf(mon, "No CPU available\n");
226 + monitor_hmp_printf(hmp, "No CPU available\n");
227 return;
228 }
229
@@ -277,7 +269,6 @@ void hmp_balloon(MonitorHMP *hmp, const QDict *qdict)
269
270 void hmp_info_memory_devices(MonitorHMP *hmp, const QDict *qdict)
271 {
280 - Monitor *mon = MONITOR(hmp);
272 Error *err = NULL;
273 MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
274 MemoryDeviceInfoList *info;
@@ -298,76 +289,76 @@ void hmp_info_memory_devices(MonitorHMP *hmp, const QDict *qdict)
289 case MEMORY_DEVICE_INFO_KIND_NVDIMM:
290 di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
291 value->u.dimm.data : value->u.nvdimm.data;
301 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
302 - MemoryDeviceInfoKind_str(value->type),
303 - di->id ? di->id : "");
304 - monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
305 - monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
306 - monitor_printf(mon, " node: %" PRId64 "\n", di->node);
307 - monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
308 - monitor_printf(mon, " memdev: %s\n", di->memdev);
309 - monitor_printf(mon, " hotplugged: %s\n",
310 - di->hotplugged ? "true" : "false");
311 - monitor_printf(mon, " hotpluggable: %s\n",
312 - di->hotpluggable ? "true" : "false");
292 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
293 + MemoryDeviceInfoKind_str(value->type),
294 + di->id ? di->id : "");
295 + monitor_hmp_printf(hmp, " addr: 0x%" PRIx64 "\n", di->addr);
296 + monitor_hmp_printf(hmp, " slot: %" PRId64 "\n", di->slot);
297 + monitor_hmp_printf(hmp, " node: %" PRId64 "\n", di->node);
298 + monitor_hmp_printf(hmp, " size: %" PRIu64 "\n", di->size);
299 + monitor_hmp_printf(hmp, " memdev: %s\n", di->memdev);
300 + monitor_hmp_printf(hmp, " hotplugged: %s\n",
301 + di->hotplugged ? "true" : "false");
302 + monitor_hmp_printf(hmp, " hotpluggable: %s\n",
303 + di->hotpluggable ? "true" : "false");
304 break;
305 case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
306 vpi = value->u.virtio_pmem.data;
316 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
317 - MemoryDeviceInfoKind_str(value->type),
318 - vpi->id ? vpi->id : "");
319 - monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
320 - monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size);
321 - monitor_printf(mon, " memdev: %s\n", vpi->memdev);
307 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
308 + MemoryDeviceInfoKind_str(value->type),
309 + vpi->id ? vpi->id : "");
310 + monitor_hmp_printf(hmp, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
311 + monitor_hmp_printf(hmp, " size: %" PRIu64 "\n", vpi->size);
312 + monitor_hmp_printf(hmp, " memdev: %s\n", vpi->memdev);
313 break;
314 case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM:
315 vmi = value->u.virtio_mem.data;
325 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
326 - MemoryDeviceInfoKind_str(value->type),
327 - vmi->id ? vmi->id : "");
328 - monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vmi->memaddr);
329 - monitor_printf(mon, " node: %" PRId64 "\n", vmi->node);
330 - monitor_printf(mon, " requested-size: %" PRIu64 "\n",
331 - vmi->requested_size);
332 - monitor_printf(mon, " size: %" PRIu64 "\n", vmi->size);
333 - monitor_printf(mon, " max-size: %" PRIu64 "\n", vmi->max_size);
334 - monitor_printf(mon, " block-size: %" PRIu64 "\n",
335 - vmi->block_size);
336 - monitor_printf(mon, " memdev: %s\n", vmi->memdev);
316 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
317 + MemoryDeviceInfoKind_str(value->type),
318 + vmi->id ? vmi->id : "");
319 + monitor_hmp_printf(hmp, " memaddr: 0x%" PRIx64 "\n", vmi->memaddr);
320 + monitor_hmp_printf(hmp, " node: %" PRId64 "\n", vmi->node);
321 + monitor_hmp_printf(hmp, " requested-size: %" PRIu64 "\n",
322 + vmi->requested_size);
323 + monitor_hmp_printf(hmp, " size: %" PRIu64 "\n", vmi->size);
324 + monitor_hmp_printf(hmp, " max-size: %" PRIu64 "\n", vmi->max_size);
325 + monitor_hmp_printf(hmp, " block-size: %" PRIu64 "\n",
326 + vmi->block_size);
327 + monitor_hmp_printf(hmp, " memdev: %s\n", vmi->memdev);
328 break;
329 case MEMORY_DEVICE_INFO_KIND_SGX_EPC:
330 se = value->u.sgx_epc.data;
340 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
341 - MemoryDeviceInfoKind_str(value->type),
342 - se->id ? se->id : "");
343 - monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", se->memaddr);
344 - monitor_printf(mon, " size: %" PRIu64 "\n", se->size);
345 - monitor_printf(mon, " node: %" PRId64 "\n", se->node);
346 - monitor_printf(mon, " memdev: %s\n", se->memdev);
331 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
332 + MemoryDeviceInfoKind_str(value->type),
333 + se->id ? se->id : "");
334 + monitor_hmp_printf(hmp, " memaddr: 0x%" PRIx64 "\n", se->memaddr);
335 + monitor_hmp_printf(hmp, " size: %" PRIu64 "\n", se->size);
336 + monitor_hmp_printf(hmp, " node: %" PRId64 "\n", se->node);
337 + monitor_hmp_printf(hmp, " memdev: %s\n", se->memdev);
338 break;
339 case MEMORY_DEVICE_INFO_KIND_HV_BALLOON:
340 hi = value->u.hv_balloon.data;
350 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
351 - MemoryDeviceInfoKind_str(value->type),
352 - hi->id ? hi->id : "");
341 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
342 + MemoryDeviceInfoKind_str(value->type),
343 + hi->id ? hi->id : "");
344 if (hi->has_memaddr) {
354 - monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n",
355 - hi->memaddr);
345 + monitor_hmp_printf(hmp, " memaddr: 0x%" PRIx64 "\n",
346 + hi->memaddr);
347 }
357 - monitor_printf(mon, " max-size: %" PRIu64 "\n", hi->max_size);
348 + monitor_hmp_printf(hmp, " max-size: %" PRIu64 "\n", hi->max_size);
349 if (hi->memdev) {
359 - monitor_printf(mon, " memdev: %s\n", hi->memdev);
350 + monitor_hmp_printf(hmp, " memdev: %s\n", hi->memdev);
351 }
352 break;
353 case MEMORY_DEVICE_INFO_KIND_SP_MEM:
354 spmi = value->u.sp_mem.data;
364 - monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
365 - MemoryDeviceInfoKind_str(value->type),
366 - spmi->id ? spmi->id : "");
367 - monitor_printf(mon, " addr: 0x%" PRIx64 "\n", spmi->addr);
368 - monitor_printf(mon, " node: %" PRId64 "\n", spmi->node);
369 - monitor_printf(mon, " size: %" PRIu64 "\n", spmi->size);
370 - monitor_printf(mon, " memdev: %s\n", spmi->memdev);
355 + monitor_hmp_printf(hmp, "Memory device [%s]: \"%s\"\n",
356 + MemoryDeviceInfoKind_str(value->type),
357 + spmi->id ? spmi->id : "");
358 + monitor_hmp_printf(hmp, " addr: 0x%" PRIx64 "\n", spmi->addr);
359 + monitor_hmp_printf(hmp, " node: %" PRId64 "\n", spmi->node);
360 + monitor_hmp_printf(hmp, " size: %" PRIu64 "\n", spmi->size);
361 + monitor_hmp_printf(hmp, " memdev: %s\n", spmi->memdev);
362 break;
363 default:
364 g_assert_not_reached();
@@ -381,11 +372,10 @@ void hmp_info_memory_devices(MonitorHMP *hmp, const QDict *qdict)
372
373 void hmp_info_vm_generation_id(MonitorHMP *hmp, const QDict *qdict)
374 {
384 - Monitor *mon = MONITOR(hmp);
375 Error *err = NULL;
376 GuidInfo *info = qmp_query_vm_generation_id(&err);
377 if (info) {
388 - monitor_printf(mon, "%s\n", info->guid);
378 + monitor_hmp_printf(hmp, "%s\n", info->guid);
379 }
380 hmp_handle_error(hmp, err);
381 qapi_free_GuidInfo(info);
@@ -393,16 +383,15 @@ void hmp_info_vm_generation_id(MonitorHMP *hmp, const QDict *qdict)
383
384 void hmp_info_memory_size_summary(MonitorHMP *hmp, const QDict *qdict)
385 {
396 - Monitor *mon = MONITOR(hmp);
386 Error *err = NULL;
387 MemoryInfo *info = qmp_query_memory_size_summary(&err);
388 if (info) {
400 - monitor_printf(mon, "base memory: %" PRIu64 "\n",
401 - info->base_memory);
389 + monitor_hmp_printf(hmp, "base memory: %" PRIu64 "\n",
390 + info->base_memory);
391
392 if (info->has_plugged_memory) {
404 - monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
405 - info->plugged_memory);
393 + monitor_hmp_printf(hmp, "plugged memory: %" PRIu64 "\n",
394 + info->plugged_memory);
395 }
396
397 qapi_free_MemoryInfo(info);
hw/core/sysbus.c
+3 -2
@@ -252,13 +252,14 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp)
252 static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
253 {
254 SysBusDevice *s = SYS_BUS_DEVICE(dev);
255 + MonitorHMP *hmp = MONITOR_HMP(mon);
256 hwaddr size;
257 int i;
258
259 for (i = 0; i < s->num_mmio; i++) {
260 size = memory_region_size(s->mmio[i].memory);
260 - monitor_printf(mon, "%*smmio " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
261 - indent, "", s->mmio[i].addr, size);
261 + monitor_hmp_printf(hmp, "%*smmio " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
262 + indent, "", s->mmio[i].addr, size);
263 }
264 }
265
hw/hexagon/hexagon_tlb.c
+23 -21
@@ -124,30 +124,32 @@ static inline uint64_t hex_tlb_virt_addr(uint64_t entry)
124
125 bool hexagon_tlb_dump_entry(Monitor *mon, uint64_t entry)
126 {
127 + MonitorHMP *hmp = MONITOR_HMP(mon);
128 +
129 if (GET_PTE_V(entry)) {
130 uint64_t PA = hex_tlb_phys_addr(entry);
131 uint64_t VA = hex_tlb_virt_addr(entry);
130 - monitor_printf(mon, "0x%016" PRIx64 ": ", entry);
131 - monitor_printf(mon, "V:%" PRId64 " G:%" PRId64
132 - " A1:%" PRId64 " A0:%" PRId64,
133 - GET_PTE_V(entry),
134 - GET_PTE_G(entry),
135 - GET_PTE_ATR1(entry),
136 - GET_PTE_ATR0(entry));
137 - monitor_printf(mon, " ASID:0x%02" PRIx64 " VA:0x%08" PRIx64,
138 - GET_PTE_ASID(entry), VA);
139 - monitor_printf(mon,
140 - " X:%" PRId64 " W:%" PRId64 " R:%" PRId64
141 - " U:%" PRId64 " C:%" PRId64,
142 - GET_PTE_X(entry),
143 - GET_PTE_W(entry),
144 - GET_PTE_R(entry),
145 - GET_PTE_U(entry),
146 - GET_PTE_C(entry));
147 - monitor_printf(mon, " PA:0x%09" PRIx64 " SZ:%s (0x%" PRIx64 ")",
148 - PA, pgsize_str[hex_tlb_pgsize_type(entry)],
149 - hex_tlb_page_size_bytes(entry));
150 - monitor_printf(mon, "\n");
132 + monitor_hmp_printf(hmp, "0x%016" PRIx64 ": ", entry);
133 + monitor_hmp_printf(hmp, "V:%" PRId64 " G:%" PRId64
134 + " A1:%" PRId64 " A0:%" PRId64,
135 + GET_PTE_V(entry),
136 + GET_PTE_G(entry),
137 + GET_PTE_ATR1(entry),
138 + GET_PTE_ATR0(entry));
139 + monitor_hmp_printf(hmp, " ASID:0x%02" PRIx64 " VA:0x%08" PRIx64,
140 + GET_PTE_ASID(entry), VA);
141 + monitor_hmp_printf(hmp,
142 + " X:%" PRId64 " W:%" PRId64 " R:%" PRId64
143 + " U:%" PRId64 " C:%" PRId64,
144 + GET_PTE_X(entry),
145 + GET_PTE_W(entry),
146 + GET_PTE_R(entry),
147 + GET_PTE_U(entry),
148 + GET_PTE_C(entry));
149 + monitor_hmp_printf(hmp, " PA:0x%09" PRIx64 " SZ:%s (0x%" PRIx64 ")",
150 + PA, pgsize_str[hex_tlb_pgsize_type(entry)],
151 + hex_tlb_page_size_bytes(entry));
152 + monitor_hmp_printf(hmp, "\n");
153 return true;
154 }
155
hw/i386/kvm/xen-stubs.c
+2 -4
@@ -42,12 +42,10 @@ void xen_primary_console_set_be_port(uint16_t port)
42
43 void hmp_xen_event_list(MonitorHMP *hmp, const QDict *qdict)
44 {
45 - Monitor *mon = MONITOR(hmp);
46 - monitor_printf(mon, "XEN emulation is not available in this QEMU\n");
45 + monitor_hmp_printf(hmp, "XEN emulation is not available in this QEMU\n");
46 }
47
48 void hmp_xen_event_inject(MonitorHMP *hmp, const QDict *qdict)
49 {
51 - Monitor *mon = MONITOR(hmp);
52 - monitor_printf(mon, "XEN emulation is not available in this QEMU\n");
50 + monitor_hmp_printf(hmp, "XEN emulation is not available in this QEMU\n");
51 }
hw/i386/kvm/xen_evtchn.c
+9 -12
@@ -2346,7 +2346,6 @@ void qmp_xen_event_inject(uint32_t port, Error **errp)
2346
2347 void hmp_xen_event_list(MonitorHMP *hmp, const QDict *qdict)
2348 {
2349 - Monitor *mon = MONITOR(hmp);
2349 EvtchnInfoList *iter, *info_list;
2350 Error *err = NULL;
2351
@@ -2359,22 +2358,22 @@ void hmp_xen_event_list(MonitorHMP *hmp, const QDict *qdict)
2358 for (iter = info_list; iter; iter = iter->next) {
2359 EvtchnInfo *info = iter->value;
2360
2362 - monitor_printf(mon, "port %4u: vcpu: %d %s", info->port, info->vcpu,
2363 - EvtchnPortType_str(info->type));
2361 + monitor_hmp_printf(hmp, "port %4u: vcpu: %d %s", info->port, info->vcpu,
2362 + EvtchnPortType_str(info->type));
2363 if (info->type != EVTCHN_PORT_TYPE_IPI) {
2365 - monitor_printf(mon, "(");
2364 + monitor_hmp_printf(hmp, "(");
2365 if (info->remote_domain) {
2367 - monitor_printf(mon, "%s:", info->remote_domain);
2366 + monitor_hmp_printf(hmp, "%s:", info->remote_domain);
2367 }
2369 - monitor_printf(mon, "%d)", info->target);
2368 + monitor_hmp_printf(hmp, "%d)", info->target);
2369 }
2370 if (info->pending) {
2372 - monitor_printf(mon, " PENDING");
2371 + monitor_hmp_printf(hmp, " PENDING");
2372 }
2373 if (info->masked) {
2375 - monitor_printf(mon, " MASKED");
2374 + monitor_hmp_printf(hmp, " MASKED");
2375 }
2377 - monitor_printf(mon, "\n");
2376 + monitor_hmp_printf(hmp, "\n");
2377 }
2378
2379 qapi_free_EvtchnInfoList(info_list);
@@ -2382,7 +2381,6 @@ void hmp_xen_event_list(MonitorHMP *hmp, const QDict *qdict)
2381
2382 void hmp_xen_event_inject(MonitorHMP *hmp, const QDict *qdict)
2383 {
2385 - Monitor *mon = MONITOR(hmp);
2384 int port = qdict_get_int(qdict, "port");
2385 Error *err = NULL;
2386
@@ -2390,7 +2388,6 @@ void hmp_xen_event_inject(MonitorHMP *hmp, const QDict *qdict)
2388 if (err) {
2389 hmp_handle_error(hmp, err);
2390 } else {
2393 - monitor_printf(mon, "Delivered port %d\n", port);
2391 + monitor_hmp_printf(hmp, "Delivered port %d\n", port);
2392 }
2393 }
2396 -
hw/i386/sgx-hmp-stub.c
+1 -2
@@ -12,6 +12,5 @@
12
13 void hmp_info_sgx(MonitorHMP *hmp, const QDict *qdict)
14 {
15 - Monitor *mon = MONITOR(hmp);
16 - monitor_printf(mon, "SGX is not available in this QEMU\n");
15 + monitor_hmp_printf(hmp, "SGX is not available in this QEMU\n");
16 }
hw/i386/sgx.c
+14 -15
@@ -236,7 +236,6 @@ SgxInfo *qmp_query_sgx(Error **errp)
236
237 void hmp_info_sgx(MonitorHMP *hmp, const QDict *qdict)
238 {
239 - Monitor *mon = MONITOR(hmp);
239 Error *err = NULL;
240 SgxEpcSectionList *section_list, *section;
241 g_autoptr(SgxInfo) info = qmp_query_sgx(&err);
@@ -246,25 +245,25 @@ void hmp_info_sgx(MonitorHMP *hmp, const QDict *qdict)
245 error_report_err(err);
246 return;
247 }
249 - monitor_printf(mon, "SGX support: %s\n",
250 - info->sgx ? "enabled" : "disabled");
251 - monitor_printf(mon, "SGX1 support: %s\n",
252 - info->sgx1 ? "enabled" : "disabled");
253 - monitor_printf(mon, "SGX2 support: %s\n",
254 - info->sgx2 ? "enabled" : "disabled");
255 - monitor_printf(mon, "FLC support: %s\n",
256 - info->flc ? "enabled" : "disabled");
248 + monitor_hmp_printf(hmp, "SGX support: %s\n",
249 + info->sgx ? "enabled" : "disabled");
250 + monitor_hmp_printf(hmp, "SGX1 support: %s\n",
251 + info->sgx1 ? "enabled" : "disabled");
252 + monitor_hmp_printf(hmp, "SGX2 support: %s\n",
253 + info->sgx2 ? "enabled" : "disabled");
254 + monitor_hmp_printf(hmp, "FLC support: %s\n",
255 + info->flc ? "enabled" : "disabled");
256
257 section_list = info->sections;
258 for (section = section_list; section; section = section->next) {
260 - monitor_printf(mon, "NUMA node #%" PRId64 ": ",
261 - section->value->node);
262 - monitor_printf(mon, "size=%" PRIu64 "\n",
263 - section->value->size);
259 + monitor_hmp_printf(hmp, "NUMA node #%" PRId64 ": ",
260 + section->value->node);
261 + monitor_hmp_printf(hmp, "size=%" PRIu64 "\n",
262 + section->value->size);
263 size += section->value->size;
264 }
266 - monitor_printf(mon, "total size=%" PRIu64 "\n",
267 - size);
265 + monitor_hmp_printf(hmp, "total size=%" PRIu64 "\n",
266 + size);
267 }
268
269 bool check_sgx_support(void)
hw/misc/auxbus.c
+5 -4
@@ -300,10 +300,11 @@ static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent)
300
301 s = AUX_SLAVE(dev);
302
303 - monitor_printf(mon, "%*smemory " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
304 - indent, "",
305 - object_property_get_uint(OBJECT(s->mmio), "addr", NULL),
306 - memory_region_size(s->mmio));
303 + monitor_hmp_printf(MONITOR_HMP(mon),
304 + "%*smemory " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
305 + indent, "",
306 + object_property_get_uint(OBJECT(s->mmio), "addr", NULL),
307 + memory_region_size(s->mmio));
308 }
309
310 void aux_init_mmio(AUXSlave *aux_slave, MemoryRegion *mmio)
hw/misc/mos6522-stub.c
+1 -2
@@ -12,6 +12,5 @@
12
13 void hmp_info_via(MonitorHMP *hmp, const QDict *qdict)
14 {
15 - Monitor *mon = MONITOR(hmp);
16 - monitor_printf(mon, "MOS6522 VIA is not available in this QEMU\n");
15 + monitor_hmp_printf(hmp, "MOS6522 VIA is not available in this QEMU\n");
16 }
hw/net/rocker/rocker-hmp-cmds.c
+71 -75
@@ -22,7 +22,6 @@
22
23 void hmp_rocker(MonitorHMP *hmp, const QDict *qdict)
24 {
25 - Monitor *mon = MONITOR(hmp);
25 const char *name = qdict_get_str(qdict, "name");
26 RockerSwitch *rocker;
27 Error *err = NULL;
@@ -32,16 +31,15 @@ void hmp_rocker(MonitorHMP *hmp, const QDict *qdict)
31 return;
32 }
33
35 - monitor_printf(mon, "name: %s\n", rocker->name);
36 - monitor_printf(mon, "id: 0x%" PRIx64 "\n", rocker->id);
37 - monitor_printf(mon, "ports: %d\n", rocker->ports);
34 + monitor_hmp_printf(hmp, "name: %s\n", rocker->name);
35 + monitor_hmp_printf(hmp, "id: 0x%" PRIx64 "\n", rocker->id);
36 + monitor_hmp_printf(hmp, "ports: %d\n", rocker->ports);
37
38 qapi_free_RockerSwitch(rocker);
39 }
40
41 void hmp_rocker_ports(MonitorHMP *hmp, const QDict *qdict)
42 {
44 - Monitor *mon = MONITOR(hmp);
43 RockerPortList *list, *port;
44 const char *name = qdict_get_str(qdict, "name");
45 Error *err = NULL;
@@ -51,17 +49,17 @@ void hmp_rocker_ports(MonitorHMP *hmp, const QDict *qdict)
49 return;
50 }
51
54 - monitor_printf(mon, " ena/ speed/ auto\n");
55 - monitor_printf(mon, " port link duplex neg?\n");
52 + monitor_hmp_printf(hmp, " ena/ speed/ auto\n");
53 + monitor_hmp_printf(hmp, " port link duplex neg?\n");
54
55 for (port = list; port; port = port->next) {
58 - monitor_printf(mon, "%10s %-4s %-3s %2s %s\n",
59 - port->value->name,
60 - port->value->enabled ? port->value->link_up ?
61 - "up" : "down" : "!ena",
62 - port->value->speed == 10000 ? "10G" : "??",
63 - port->value->duplex ? "FD" : "HD",
64 - port->value->autoneg ? "Yes" : "No");
56 + monitor_hmp_printf(hmp, "%10s %-4s %-3s %2s %s\n",
57 + port->value->name,
58 + port->value->enabled ? port->value->link_up ?
59 + "up" : "down" : "!ena",
60 + port->value->speed == 10000 ? "10G" : "??",
61 + port->value->duplex ? "FD" : "HD",
62 + port->value->autoneg ? "Yes" : "No");
63 }
64
65 qapi_free_RockerPortList(list);
@@ -69,7 +67,6 @@ void hmp_rocker_ports(MonitorHMP *hmp, const QDict *qdict)
67
68 void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
69 {
72 - Monitor *mon = MONITOR(hmp);
70 RockerOfDpaFlowList *list, *info;
71 const char *name = qdict_get_str(qdict, "name");
72 uint32_t tbl_id = qdict_get_try_int(qdict, "tbl_id", -1);
@@ -80,7 +77,7 @@ void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
77 return;
78 }
79
83 - monitor_printf(mon, "prio tbl hits key(mask) --> actions\n");
80 + monitor_hmp_printf(hmp, "prio tbl hits key(mask) --> actions\n");
81
82 for (info = list; info; info = info->next) {
83 RockerOfDpaFlow *flow = info->value;
@@ -89,54 +86,54 @@ void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
86 RockerOfDpaFlowAction *action = flow->action;
87
88 if (flow->hits) {
92 - monitor_printf(mon, "%-4d %-3d %-4" PRIu64,
93 - key->priority, key->tbl_id, flow->hits);
89 + monitor_hmp_printf(hmp, "%-4d %-3d %-4" PRIu64,
90 + key->priority, key->tbl_id, flow->hits);
91 } else {
95 - monitor_printf(mon, "%-4d %-3d ",
96 - key->priority, key->tbl_id);
92 + monitor_hmp_printf(hmp, "%-4d %-3d ",
93 + key->priority, key->tbl_id);
94 }
95
96 if (key->has_in_pport) {
100 - monitor_printf(mon, " pport %d", key->in_pport);
97 + monitor_hmp_printf(hmp, " pport %d", key->in_pport);
98 if (mask->has_in_pport) {
102 - monitor_printf(mon, "(0x%x)", mask->in_pport);
99 + monitor_hmp_printf(hmp, "(0x%x)", mask->in_pport);
100 }
101 }
102
103 if (key->has_vlan_id) {
107 - monitor_printf(mon, " vlan %d",
108 - key->vlan_id & VLAN_VID_MASK);
104 + monitor_hmp_printf(hmp, " vlan %d",
105 + key->vlan_id & VLAN_VID_MASK);
106 if (mask->has_vlan_id) {
110 - monitor_printf(mon, "(0x%x)", mask->vlan_id);
107 + monitor_hmp_printf(hmp, "(0x%x)", mask->vlan_id);
108 }
109 }
110
111 if (key->has_tunnel_id) {
115 - monitor_printf(mon, " tunnel %d", key->tunnel_id);
112 + monitor_hmp_printf(hmp, " tunnel %d", key->tunnel_id);
113 if (mask->has_tunnel_id) {
117 - monitor_printf(mon, "(0x%x)", mask->tunnel_id);
114 + monitor_hmp_printf(hmp, "(0x%x)", mask->tunnel_id);
115 }
116 }
117
118 if (key->has_eth_type) {
119 switch (key->eth_type) {
120 case 0x0806:
124 - monitor_printf(mon, " ARP");
121 + monitor_hmp_printf(hmp, " ARP");
122 break;
123 case 0x0800:
127 - monitor_printf(mon, " IP");
124 + monitor_hmp_printf(hmp, " IP");
125 break;
126 case 0x86dd:
130 - monitor_printf(mon, " IPv6");
127 + monitor_hmp_printf(hmp, " IPv6");
128 break;
129 case 0x8809:
133 - monitor_printf(mon, " LACP");
130 + monitor_hmp_printf(hmp, " LACP");
131 break;
132 case 0x88cc:
136 - monitor_printf(mon, " LLDP");
133 + monitor_hmp_printf(hmp, " LLDP");
134 break;
135 default:
139 - monitor_printf(mon, " eth type 0x%04x", key->eth_type);
136 + monitor_hmp_printf(hmp, " eth type 0x%04x", key->eth_type);
137 break;
138 }
139 }
@@ -145,15 +142,15 @@ void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
142 if ((strcmp(key->eth_src, "01:00:00:00:00:00") == 0) &&
143 mask->eth_src &&
144 (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) {
148 - monitor_printf(mon, " src <any mcast/bcast>");
145 + monitor_hmp_printf(hmp, " src <any mcast/bcast>");
146 } else if ((strcmp(key->eth_src, "00:00:00:00:00:00") == 0) &&
147 mask->eth_src &&
148 (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) {
152 - monitor_printf(mon, " src <any ucast>");
149 + monitor_hmp_printf(hmp, " src <any ucast>");
150 } else {
154 - monitor_printf(mon, " src %s", key->eth_src);
151 + monitor_hmp_printf(hmp, " src %s", key->eth_src);
152 if (mask->eth_src) {
156 - monitor_printf(mon, "(%s)", mask->eth_src);
153 + monitor_hmp_printf(hmp, "(%s)", mask->eth_src);
154 }
155 }
156 }
@@ -162,56 +159,56 @@ void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
159 if ((strcmp(key->eth_dst, "01:00:00:00:00:00") == 0) &&
160 mask->eth_dst &&
161 (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) {
165 - monitor_printf(mon, " dst <any mcast/bcast>");
162 + monitor_hmp_printf(hmp, " dst <any mcast/bcast>");
163 } else if ((strcmp(key->eth_dst, "00:00:00:00:00:00") == 0) &&
164 mask->eth_dst &&
165 (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) {
169 - monitor_printf(mon, " dst <any ucast>");
166 + monitor_hmp_printf(hmp, " dst <any ucast>");
167 } else {
171 - monitor_printf(mon, " dst %s", key->eth_dst);
168 + monitor_hmp_printf(hmp, " dst %s", key->eth_dst);
169 if (mask->eth_dst) {
173 - monitor_printf(mon, "(%s)", mask->eth_dst);
170 + monitor_hmp_printf(hmp, "(%s)", mask->eth_dst);
171 }
172 }
173 }
174
175 if (key->has_ip_proto) {
179 - monitor_printf(mon, " proto %d", key->ip_proto);
176 + monitor_hmp_printf(hmp, " proto %d", key->ip_proto);
177 if (mask->has_ip_proto) {
181 - monitor_printf(mon, "(0x%x)", mask->ip_proto);
178 + monitor_hmp_printf(hmp, "(0x%x)", mask->ip_proto);
179 }
180 }
181
182 if (key->has_ip_tos) {
186 - monitor_printf(mon, " TOS %d", key->ip_tos);
183 + monitor_hmp_printf(hmp, " TOS %d", key->ip_tos);
184 if (mask->has_ip_tos) {
188 - monitor_printf(mon, "(0x%x)", mask->ip_tos);
185 + monitor_hmp_printf(hmp, "(0x%x)", mask->ip_tos);
186 }
187 }
188
189 if (key->ip_dst) {
193 - monitor_printf(mon, " dst %s", key->ip_dst);
190 + monitor_hmp_printf(hmp, " dst %s", key->ip_dst);
191 }
192
193 if (action->has_goto_tbl || action->has_group_id ||
194 action->has_new_vlan_id) {
198 - monitor_printf(mon, " -->");
195 + monitor_hmp_printf(hmp, " -->");
196 }
197
198 if (action->has_new_vlan_id) {
202 - monitor_printf(mon, " apply new vlan %d",
203 - ntohs(action->new_vlan_id));
199 + monitor_hmp_printf(hmp, " apply new vlan %d",
200 + ntohs(action->new_vlan_id));
201 }
202
203 if (action->has_group_id) {
207 - monitor_printf(mon, " write group 0x%08x", action->group_id);
204 + monitor_hmp_printf(hmp, " write group 0x%08x", action->group_id);
205 }
206
207 if (action->has_goto_tbl) {
211 - monitor_printf(mon, " goto tbl %d", action->goto_tbl);
208 + monitor_hmp_printf(hmp, " goto tbl %d", action->goto_tbl);
209 }
210
214 - monitor_printf(mon, "\n");
211 + monitor_hmp_printf(hmp, "\n");
212 }
213
214 qapi_free_RockerOfDpaFlowList(list);
@@ -219,7 +216,6 @@ void hmp_rocker_of_dpa_flows(MonitorHMP *hmp, const QDict *qdict)
216
217 void hmp_rocker_of_dpa_groups(MonitorHMP *hmp, const QDict *qdict)
218 {
222 - Monitor *mon = MONITOR(hmp);
219 RockerOfDpaGroupList *list, *g;
220 const char *name = qdict_get_str(qdict, "name");
221 uint8_t type = qdict_get_try_int(qdict, "type", 9);
@@ -230,15 +226,15 @@ void hmp_rocker_of_dpa_groups(MonitorHMP *hmp, const QDict *qdict)
226 return;
227 }
228
233 - monitor_printf(mon, "id (decode) --> buckets\n");
229 + monitor_hmp_printf(hmp, "id (decode) --> buckets\n");
230
231 for (g = list; g; g = g->next) {
232 RockerOfDpaGroup *group = g->value;
233 bool set = false;
234
239 - monitor_printf(mon, "0x%08x", group->id);
235 + monitor_hmp_printf(hmp, "0x%08x", group->id);
236
241 - monitor_printf(mon, " (type %s", group->type == 0 ? "L2 interface" :
237 + monitor_hmp_printf(hmp, " (type %s", group->type == 0 ? "L2 interface" :
238 group->type == 1 ? "L2 rewrite" :
239 group->type == 2 ? "L3 unicast" :
240 group->type == 3 ? "L2 multicast" :
@@ -250,70 +246,70 @@ void hmp_rocker_of_dpa_groups(MonitorHMP *hmp, const QDict *qdict)
246 "unknown");
247
248 if (group->has_vlan_id) {
253 - monitor_printf(mon, " vlan %d", group->vlan_id);
249 + monitor_hmp_printf(hmp, " vlan %d", group->vlan_id);
250 }
251
252 if (group->has_pport) {
257 - monitor_printf(mon, " pport %d", group->pport);
253 + monitor_hmp_printf(hmp, " pport %d", group->pport);
254 }
255
256 if (group->has_index) {
261 - monitor_printf(mon, " index %d", group->index);
257 + monitor_hmp_printf(hmp, " index %d", group->index);
258 }
259
264 - monitor_printf(mon, ") -->");
260 + monitor_hmp_printf(hmp, ") -->");
261
262 if (group->has_set_vlan_id && group->set_vlan_id) {
263 set = true;
268 - monitor_printf(mon, " set vlan %d",
269 - group->set_vlan_id & VLAN_VID_MASK);
264 + monitor_hmp_printf(hmp, " set vlan %d",
265 + group->set_vlan_id & VLAN_VID_MASK);
266 }
267
268 if (group->set_eth_src) {
269 if (!set) {
270 set = true;
275 - monitor_printf(mon, " set");
271 + monitor_hmp_printf(hmp, " set");
272 }
277 - monitor_printf(mon, " src %s", group->set_eth_src);
273 + monitor_hmp_printf(hmp, " src %s", group->set_eth_src);
274 }
275
276 if (group->set_eth_dst) {
277 if (!set) {
282 - monitor_printf(mon, " set");
278 + monitor_hmp_printf(hmp, " set");
279 }
284 - monitor_printf(mon, " dst %s", group->set_eth_dst);
280 + monitor_hmp_printf(hmp, " dst %s", group->set_eth_dst);
281 }
282
283 if (group->has_ttl_check && group->ttl_check) {
288 - monitor_printf(mon, " check TTL");
284 + monitor_hmp_printf(hmp, " check TTL");
285 }
286
287 if (group->has_group_id && group->group_id) {
292 - monitor_printf(mon, " group id 0x%08x", group->group_id);
288 + monitor_hmp_printf(hmp, " group id 0x%08x", group->group_id);
289 }
290
291 if (group->has_pop_vlan && group->pop_vlan) {
296 - monitor_printf(mon, " pop vlan");
292 + monitor_hmp_printf(hmp, " pop vlan");
293 }
294
295 if (group->has_out_pport) {
300 - monitor_printf(mon, " out pport %d", group->out_pport);
296 + monitor_hmp_printf(hmp, " out pport %d", group->out_pport);
297 }
298
299 if (group->has_group_ids) {
300 struct uint32List *id;
301
306 - monitor_printf(mon, " groups [");
302 + monitor_hmp_printf(hmp, " groups [");
303 for (id = group->group_ids; id; id = id->next) {
308 - monitor_printf(mon, "0x%08x", id->value);
304 + monitor_hmp_printf(hmp, "0x%08x", id->value);
305 if (id->next) {
310 - monitor_printf(mon, ",");
306 + monitor_hmp_printf(hmp, ",");
307 }
308 }
313 - monitor_printf(mon, "]");
309 + monitor_hmp_printf(hmp, "]");
310 }
311
316 - monitor_printf(mon, "\n");
312 + monitor_hmp_printf(hmp, "\n");
313 }
314
315 qapi_free_RockerOfDpaGroupList(list);
hw/pci/pci-hmp-cmds.c
+57 -57
@@ -24,54 +24,55 @@
24 #include "qapi/qapi-commands-pci.h"
25 #include "qemu/cutils.h"
26
27 -static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
27 +static void hmp_info_pci_device(MonitorHMP *hmp, const PciDeviceInfo *dev)
28 {
29 + Monitor *mon = MONITOR(hmp);
30 PciMemoryRegionList *region;
31
31 - monitor_printf(mon, " Bus %2" PRId64 ", ", dev->bus);
32 - monitor_printf(mon, "device %3" PRId64 ", function %" PRId64 ":\n",
33 - dev->slot, dev->function);
34 - monitor_printf(mon, " ");
32 + monitor_hmp_printf(hmp, " Bus %2" PRId64 ", ", dev->bus);
33 + monitor_hmp_printf(hmp, "device %3" PRId64 ", function %" PRId64 ":\n",
34 + dev->slot, dev->function);
35 + monitor_hmp_printf(hmp, " ");
36
37 if (dev->class_info->desc) {
38 monitor_puts(mon, dev->class_info->desc);
39 } else {
39 - monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class);
40 + monitor_hmp_printf(hmp, "Class %04" PRId64, dev->class_info->q_class);
41 }
42
42 - monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n",
43 - dev->id->vendor, dev->id->device);
43 + monitor_hmp_printf(hmp, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n",
44 + dev->id->vendor, dev->id->device);
45 if (dev->id->has_subsystem_vendor && dev->id->has_subsystem) {
45 - monitor_printf(mon, " PCI subsystem %04" PRIx64 ":%04" PRIx64 "\n",
46 - dev->id->subsystem_vendor, dev->id->subsystem);
46 + monitor_hmp_printf(hmp, " PCI subsystem %04" PRIx64 ":%04" PRIx64 "\n",
47 + dev->id->subsystem_vendor, dev->id->subsystem);
48 }
49
50 if (dev->has_irq) {
50 - monitor_printf(mon, " IRQ %" PRId64 ", pin %c\n",
51 - dev->irq, (char)('A' + dev->irq_pin - 1));
51 + monitor_hmp_printf(hmp, " IRQ %" PRId64 ", pin %c\n",
52 + dev->irq, (char)('A' + dev->irq_pin - 1));
53 }
54
55 if (dev->pci_bridge) {
55 - monitor_printf(mon, " BUS %" PRId64 ".\n",
56 - dev->pci_bridge->bus->number);
57 - monitor_printf(mon, " secondary bus %" PRId64 ".\n",
58 - dev->pci_bridge->bus->secondary);
59 - monitor_printf(mon, " subordinate bus %" PRId64 ".\n",
60 - dev->pci_bridge->bus->subordinate);
56 + monitor_hmp_printf(hmp, " BUS %" PRId64 ".\n",
57 + dev->pci_bridge->bus->number);
58 + monitor_hmp_printf(hmp, " secondary bus %" PRId64 ".\n",
59 + dev->pci_bridge->bus->secondary);
60 + monitor_hmp_printf(hmp, " subordinate bus %" PRId64 ".\n",
61 + dev->pci_bridge->bus->subordinate);
62
62 - monitor_printf(mon, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n",
63 - dev->pci_bridge->bus->io_range->base,
64 - dev->pci_bridge->bus->io_range->limit);
63 + monitor_hmp_printf(hmp, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n",
64 + dev->pci_bridge->bus->io_range->base,
65 + dev->pci_bridge->bus->io_range->limit);
66
66 - monitor_printf(mon,
67 - " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n",
68 - dev->pci_bridge->bus->memory_range->base,
69 - dev->pci_bridge->bus->memory_range->limit);
67 + monitor_hmp_printf(hmp,
68 + " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n",
69 + dev->pci_bridge->bus->memory_range->base,
70 + dev->pci_bridge->bus->memory_range->limit);
71
71 - monitor_printf(mon, " prefetchable memory range "
72 - "[0x%08"PRIx64", 0x%08"PRIx64"]\n",
73 - dev->pci_bridge->bus->prefetchable_range->base,
74 - dev->pci_bridge->bus->prefetchable_range->limit);
72 + monitor_hmp_printf(hmp, " prefetchable memory range "
73 + "[0x%08"PRIx64", 0x%08"PRIx64"]\n",
74 + dev->pci_bridge->bus->prefetchable_range->base,
75 + dev->pci_bridge->bus->prefetchable_range->limit);
76 }
77
78 for (region = dev->regions; region; region = region->next) {
@@ -80,38 +81,38 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
81 addr = region->value->address;
82 size = region->value->size;
83
83 - monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar);
84 + monitor_hmp_printf(hmp, " BAR%" PRId64 ": ", region->value->bar);
85
86 if (!strcmp(region->value->type, "io")) {
87 if (addr != PCI_BAR_UNMAPPED) {
87 - monitor_printf(mon, "I/O at 0x%04" PRIx64
88 + monitor_hmp_printf(hmp, "I/O at 0x%04" PRIx64
89 " [0x%04" PRIx64 "]\n",
90 addr, addr + size - 1);
91 } else {
91 - monitor_printf(mon, "I/O (not mapped)\n");
92 + monitor_hmp_printf(hmp, "I/O (not mapped)\n");
93 }
94 } else {
95 if (addr != PCI_BAR_UNMAPPED) {
95 - monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64
96 + monitor_hmp_printf(hmp, "%d bit%s memory at 0x%08" PRIx64
97 " [0x%08" PRIx64 "]\n",
98 region->value->mem_type_64 ? 64 : 32,
99 region->value->prefetch ? " prefetchable" : "",
100 addr, addr + size - 1);
101 } else {
101 - monitor_printf(mon, "%d bit%s memory (not mapped)\n",
102 - region->value->mem_type_64 ? 64 : 32,
103 - region->value->prefetch ? " prefetchable" : "");
102 + monitor_hmp_printf(hmp, "%d bit%s memory (not mapped)\n",
103 + region->value->mem_type_64 ? 64 : 32,
104 + region->value->prefetch ? " prefetchable" : "");
105 }
106 }
107 }
108
108 - monitor_printf(mon, " id \"%s\"\n", dev->qdev_id);
109 + monitor_hmp_printf(hmp, " id \"%s\"\n", dev->qdev_id);
110
111 if (dev->pci_bridge) {
112 if (dev->pci_bridge->has_devices) {
113 PciDeviceInfoList *cdev;
114 for (cdev = dev->pci_bridge->devices; cdev; cdev = cdev->next) {
114 - hmp_info_pci_device(mon, cdev->value);
115 + hmp_info_pci_device(hmp, cdev->value);
116 }
117 }
118 }
@@ -119,7 +120,6 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
120
121 void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict)
122 {
122 - Monitor *mon = MONITOR(hmp);
123 PciInfoList *info_list, *info;
124
125 info_list = qmp_query_pci(&error_abort);
@@ -128,7 +128,7 @@ void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict)
128 PciDeviceInfoList *dev;
129
130 for (dev = info->value->devices; dev; dev = dev->next) {
131 - hmp_info_pci_device(mon, dev->value);
131 + hmp_info_pci_device(hmp, dev->value);
132 }
133 }
134
@@ -137,6 +137,7 @@ void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict)
137
138 void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
139 {
140 + MonitorHMP *hmp = MONITOR_HMP(mon);
141 PCIDevice *d = (PCIDevice *)dev;
142 int class = pci_get_word(d->config + PCI_CLASS_DEVICE);
143 const pci_class_desc *desc = get_class_desc(class);
@@ -150,30 +151,29 @@ void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
151 snprintf(ctxt, sizeof(ctxt), "Class %04x", class);
152 }
153
153 - monitor_printf(mon, "%*sclass %s, addr %02x:%02x.%x, "
154 - "pci id %04x:%04x (sub %04x:%04x)\n",
155 - indent, "", ctxt, pci_dev_bus_num(d),
156 - PCI_SLOT(d->devfn), PCI_FUNC(d->devfn),
157 - pci_get_word(d->config + PCI_VENDOR_ID),
158 - pci_get_word(d->config + PCI_DEVICE_ID),
159 - pci_get_word(d->config + PCI_SUBSYSTEM_VENDOR_ID),
160 - pci_get_word(d->config + PCI_SUBSYSTEM_ID));
154 + monitor_hmp_printf(hmp, "%*sclass %s, addr %02x:%02x.%x, "
155 + "pci id %04x:%04x (sub %04x:%04x)\n",
156 + indent, "", ctxt, pci_dev_bus_num(d),
157 + PCI_SLOT(d->devfn), PCI_FUNC(d->devfn),
158 + pci_get_word(d->config + PCI_VENDOR_ID),
159 + pci_get_word(d->config + PCI_DEVICE_ID),
160 + pci_get_word(d->config + PCI_SUBSYSTEM_VENDOR_ID),
161 + pci_get_word(d->config + PCI_SUBSYSTEM_ID));
162 for (i = 0; i < PCI_NUM_REGIONS; i++) {
163 r = &d->io_regions[i];
164 if (!r->size) {
165 continue;
166 }
166 - monitor_printf(mon, "%*sbar %d: %s at 0x%"FMT_PCIBUS
167 - " [0x%"FMT_PCIBUS"]\n",
168 - indent, "",
169 - i, r->type & PCI_BASE_ADDRESS_SPACE_IO ? "i/o" : "mem",
170 - r->addr, r->addr + r->size - 1);
167 + monitor_hmp_printf(hmp, "%*sbar %d: %s at 0x%"FMT_PCIBUS
168 + " [0x%"FMT_PCIBUS"]\n",
169 + indent, "",
170 + i, r->type & PCI_BASE_ADDRESS_SPACE_IO ? "i/o" : "mem",
171 + r->addr, r->addr + r->size - 1);
172 }
173 }
174
175 void hmp_pcie_aer_inject_error(MonitorHMP *hmp, const QDict *qdict)
176 {
176 - Monitor *mon = MONITOR(hmp);
177 Error *err = NULL;
178 const char *id = qdict_get_str(qdict, "id");
179 const char *error_name;
@@ -242,9 +242,9 @@ void hmp_pcie_aer_inject_error(MonitorHMP *hmp, const QDict *qdict)
242 }
243
244
245 - monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
246 - id, pci_root_bus_path(dev), pci_dev_bus_num(dev),
247 - PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
245 + monitor_hmp_printf(hmp, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
246 + id, pci_root_bus_path(dev), pci_dev_bus_num(dev),
247 + PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
248
249 out:
250 hmp_handle_error(hmp, err);
hw/pci/pci-stub.c
+1 -2
@@ -40,8 +40,7 @@ void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict)
40
41 void hmp_pcie_aer_inject_error(MonitorHMP *hmp, const QDict *qdict)
42 {
43 - Monitor *mon = MONITOR(hmp);
44 - monitor_printf(mon, "PCI devices not supported\n");
43 + monitor_hmp_printf(hmp, "PCI devices not supported\n");
44 }
45
46 /* kvm-all wants this */
hw/s390x/s390-skeys.c
+4 -5
@@ -106,7 +106,6 @@ static void write_keys(FILE *f, uint8_t *keys, uint64_t startgfn,
106
107 void hmp_info_skeys(MonitorHMP *hmp, const QDict *qdict)
108 {
109 - Monitor *mon = MONITOR(hmp);
109 S390SKeysState *ss = s390_get_skeys_device();
110 S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss);
111 uint64_t addr = qdict_get_int(qdict, "addr");
@@ -115,24 +114,24 @@ void hmp_info_skeys(MonitorHMP *hmp, const QDict *qdict)
114
115 /* Quick check to see if guest is using storage keys*/
116 if (!skeyclass->skeys_are_enabled(ss)) {
118 - monitor_printf(mon, "Error: This guest is not using storage keys\n");
117 + monitor_hmp_printf(hmp, "Error: This guest is not using storage keys\n");
118 return;
119 }
120
121 if (!address_space_access_valid(&address_space_memory,
122 addr & TARGET_PAGE_MASK, TARGET_PAGE_SIZE,
123 false, MEMTXATTRS_UNSPECIFIED)) {
125 - monitor_printf(mon, "Error: The given address is not valid\n");
124 + monitor_hmp_printf(hmp, "Error: The given address is not valid\n");
125 return;
126 }
127
128 r = skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
129 if (r < 0) {
131 - monitor_printf(mon, "Error: %s\n", strerror(-r));
130 + monitor_hmp_printf(hmp, "Error: %s\n", strerror(-r));
131 return;
132 }
133
135 - monitor_printf(mon, " key: 0x%X\n", key);
134 + monitor_hmp_printf(hmp, " key: 0x%X\n", key);
135 }
136
137 void hmp_dump_skeys(MonitorHMP *hmp, const QDict *qdict)
hw/s390x/s390-stattrib.c
+9 -11
@@ -61,7 +61,6 @@ void s390_stattrib_init(void)
61
62 void hmp_migrationmode(MonitorHMP *hmp, const QDict *qdict)
63 {
64 - Monitor *mon = MONITOR(hmp);
64 S390StAttribState *sas = s390_get_stattrib_device();
65 S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
66 uint64_t what = qdict_get_int(qdict, "mode");
@@ -70,14 +69,13 @@ void hmp_migrationmode(MonitorHMP *hmp, const QDict *qdict)
69
70 r = sac->set_migrationmode(sas, what, &local_err);
71 if (r < 0) {
73 - monitor_printf(mon, "Error: %s", error_get_pretty(local_err));
72 + monitor_hmp_printf(hmp, "Error: %s", error_get_pretty(local_err));
73 error_free(local_err);
74 }
75 }
76
77 void hmp_info_cmma(MonitorHMP *hmp, const QDict *qdict)
78 {
80 - Monitor *mon = MONITOR(hmp);
79 S390StAttribState *sas = s390_get_stattrib_device();
80 S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
81 uint64_t addr = qdict_get_int(qdict, "addr");
@@ -87,27 +85,27 @@ void hmp_info_cmma(MonitorHMP *hmp, const QDict *qdict)
85
86 vals = g_try_malloc(buflen);
87 if (!vals) {
90 - monitor_printf(mon, "Error: %s\n", strerror(errno));
88 + monitor_hmp_printf(hmp, "Error: %s\n", strerror(errno));
89 return;
90 }
91
92 len = sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, buflen, vals);
93 if (len < 0) {
96 - monitor_printf(mon, "Error: %s", strerror(-len));
94 + monitor_hmp_printf(hmp, "Error: %s", strerror(-len));
95 goto out;
96 }
97
100 - monitor_printf(mon, " CMMA attributes, "
101 - "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n",
102 - addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK);
98 + monitor_hmp_printf(hmp, " CMMA attributes, "
99 + "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n",
100 + addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK);
101 for (cx = 0; cx < len; cx++) {
102 if (cx % 8 == 7) {
105 - monitor_printf(mon, "%02x\n", vals[cx]);
103 + monitor_hmp_printf(hmp, "%02x\n", vals[cx]);
104 } else {
107 - monitor_printf(mon, "%02x", vals[cx]);
105 + monitor_hmp_printf(hmp, "%02x", vals[cx]);
106 }
107 }
110 - monitor_printf(mon, "\n");
108 + monitor_hmp_printf(hmp, "\n");
109
110 out:
111 g_free(vals);
hw/uefi/ovmf-log.c
+2 -3
@@ -258,7 +258,6 @@ FirmwareLog *qmp_query_firmware_log(bool have_max_size, uint64_t max_size,
258
259 void hmp_info_firmware_log(MonitorHMP *hmp, const QDict *qdict)
260 {
261 - Monitor *mon = MONITOR(hmp);
261 g_autofree gchar *log_esc = NULL;
262 g_autofree guchar *log_out = NULL;
263 Error *err = NULL;
@@ -278,10 +277,10 @@ void hmp_info_firmware_log(MonitorHMP *hmp, const QDict *qdict)
277
278 if (log->version) {
279 g_autofree gchar *esc = g_strescape(log->version, NULL);
281 - monitor_printf(mon, "[ firmware version: %s ]\n", esc);
280 + monitor_hmp_printf(hmp, "[ firmware version: %s ]\n", esc);
281 }
282
283 log_out = g_base64_decode(log->log, &log_len);
284 log_esc = g_strescape((gchar *)log_out, "\r\n");
286 - monitor_printf(mon, "%s\n", log_esc);
285 + monitor_hmp_printf(hmp, "%s\n", log_esc);
286 }
hw/usb/bus.c
+6 -5
@@ -546,14 +546,15 @@ static const char *usb_speed(unsigned int speed)
546
547 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
548 {
549 + MonitorHMP *hmp = MONITOR_HMP(mon);
550 USBDevice *dev = USB_DEVICE(qdev);
551 USBBus *bus = usb_bus_from_device(dev);
552
552 - monitor_printf(mon, "%*saddr %d.%d, port %s, speed %s, name %s%s\n",
553 - indent, "", bus->busnr, dev->addr,
554 - dev->port ? dev->port->path : "-",
555 - usb_speed(dev->speed), dev->product_desc,
556 - dev->attached ? ", attached" : "");
553 + monitor_hmp_printf(hmp, "%*saddr %d.%d, port %s, speed %s, name %s%s\n",
554 + indent, "", bus->busnr, dev->addr,
555 + dev->port ? dev->port->path : "-",
556 + usb_speed(dev->speed), dev->product_desc,
557 + dev->attached ? ", attached" : "");
558 }
559
560 static char *usb_get_dev_path(DeviceState *qdev)
hw/usb/host-libusb.c
+10 -11
@@ -1922,7 +1922,6 @@ static void usb_host_auto_check(void *unused)
1922
1923 void hmp_info_usbhost(MonitorHMP *hmp, const QDict *qdict)
1924 {
1925 - Monitor *mon = MONITOR(hmp);
1925 libusb_device **devs = NULL;
1926 struct libusb_device_descriptor ddesc;
1927 char port[16];
@@ -1941,14 +1940,14 @@ void hmp_info_usbhost(MonitorHMP *hmp, const QDict *qdict)
1940 continue;
1941 }
1942 usb_host_get_port(devs[i], port, sizeof(port));
1944 - monitor_printf(mon, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
1945 - libusb_get_bus_number(devs[i]),
1946 - libusb_get_device_address(devs[i]),
1947 - port,
1948 - speed_name[libusb_get_device_speed(devs[i])]);
1949 - monitor_printf(mon, " Class %02x:", ddesc.bDeviceClass);
1950 - monitor_printf(mon, " USB device %04x:%04x",
1951 - ddesc.idVendor, ddesc.idProduct);
1943 + monitor_hmp_printf(hmp, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
1944 + libusb_get_bus_number(devs[i]),
1945 + libusb_get_device_address(devs[i]),
1946 + port,
1947 + speed_name[libusb_get_device_speed(devs[i])]);
1948 + monitor_hmp_printf(hmp, " Class %02x:", ddesc.bDeviceClass);
1949 + monitor_hmp_printf(hmp, " USB device %04x:%04x",
1950 + ddesc.idVendor, ddesc.idProduct);
1951 if (ddesc.iProduct) {
1952 libusb_device_handle *handle;
1953 if (libusb_open(devs[i], &handle) == 0) {
@@ -1957,10 +1956,10 @@ void hmp_info_usbhost(MonitorHMP *hmp, const QDict *qdict)
1956 ddesc.iProduct,
1957 name, sizeof(name));
1958 libusb_close(handle);
1960 - monitor_printf(mon, ", %s", name);
1959 + monitor_hmp_printf(hmp, ", %s", name);
1960 }
1961 }
1963 - monitor_printf(mon, "\n");
1962 + monitor_hmp_printf(hmp, "\n");
1963 }
1964 libusb_free_device_list(devs, 1);
1965 }
hw/virtio/virtio-hmp-cmds.c
+146 -151
@@ -12,77 +12,76 @@
12 #include "qobject/qdict.h"
13
14
15 -static void hmp_virtio_dump_protocols(Monitor *mon,
15 +static void hmp_virtio_dump_protocols(MonitorHMP *hmp,
16 VhostDeviceProtocols *pcol)
17 {
18 strList *pcol_list = pcol->protocols;
19 while (pcol_list) {
20 - monitor_printf(mon, "\t%s", pcol_list->value);
20 + monitor_hmp_printf(hmp, "\t%s", pcol_list->value);
21 pcol_list = pcol_list->next;
22 if (pcol_list != NULL) {
23 - monitor_printf(mon, ",\n");
23 + monitor_hmp_printf(hmp, ",\n");
24 }
25 }
26 - monitor_printf(mon, "\n");
26 + monitor_hmp_printf(hmp, "\n");
27 if (pcol->has_unknown_protocols) {
28 - monitor_printf(mon, " unknown-protocols(0x%016"PRIx64")\n",
29 - pcol->unknown_protocols);
28 + monitor_hmp_printf(hmp, " unknown-protocols(0x%016"PRIx64")\n",
29 + pcol->unknown_protocols);
30 }
31 }
32
33 -static void hmp_virtio_dump_status(Monitor *mon,
33 +static void hmp_virtio_dump_status(MonitorHMP *hmp,
34 VirtioDeviceStatus *status)
35 {
36 strList *status_list = status->statuses;
37 while (status_list) {
38 - monitor_printf(mon, "\t%s", status_list->value);
38 + monitor_hmp_printf(hmp, "\t%s", status_list->value);
39 status_list = status_list->next;
40 if (status_list != NULL) {
41 - monitor_printf(mon, ",\n");
41 + monitor_hmp_printf(hmp, ",\n");
42 }
43 }
44 - monitor_printf(mon, "\n");
44 + monitor_hmp_printf(hmp, "\n");
45 if (status->has_unknown_statuses) {
46 - monitor_printf(mon, " unknown-statuses(0x%016"PRIx32")\n",
47 - status->unknown_statuses);
46 + monitor_hmp_printf(hmp, " unknown-statuses(0x%016"PRIx32")\n",
47 + status->unknown_statuses);
48 }
49 }
50
51 -static void hmp_virtio_dump_features(Monitor *mon,
51 +static void hmp_virtio_dump_features(MonitorHMP *hmp,
52 VirtioDeviceFeatures *features)
53 {
54 strList *transport_list = features->transports;
55 while (transport_list) {
56 - monitor_printf(mon, "\t%s", transport_list->value);
56 + monitor_hmp_printf(hmp, "\t%s", transport_list->value);
57 transport_list = transport_list->next;
58 if (transport_list != NULL) {
59 - monitor_printf(mon, ",\n");
59 + monitor_hmp_printf(hmp, ",\n");
60 }
61 }
62
63 - monitor_printf(mon, "\n");
63 + monitor_hmp_printf(hmp, "\n");
64 strList *list = features->dev_features;
65 if (list) {
66 while (list) {
67 - monitor_printf(mon, "\t%s", list->value);
67 + monitor_hmp_printf(hmp, "\t%s", list->value);
68 list = list->next;
69 if (list != NULL) {
70 - monitor_printf(mon, ",\n");
70 + monitor_hmp_printf(hmp, ",\n");
71 }
72 }
73 - monitor_printf(mon, "\n");
73 + monitor_hmp_printf(hmp, "\n");
74 }
75
76 if (features->has_unknown_dev_features) {
77 - monitor_printf(mon, " unknown-features(0x%016"PRIx64"%016"PRIx64")\n",
78 - features->unknown_dev_features2,
79 - features->unknown_dev_features);
77 + monitor_hmp_printf(hmp, " unknown-features(0x%016"PRIx64"%016"PRIx64")\n",
78 + features->unknown_dev_features2,
79 + features->unknown_dev_features);
80 }
81 }
82
83 void hmp_virtio_query(MonitorHMP *hmp, const QDict *qdict)
84 {
85 - Monitor *mon = MONITOR(hmp);
85 Error *err = NULL;
86 VirtioInfoList *list = qmp_x_query_virtio(&err);
87 VirtioInfoList *node;
@@ -93,14 +92,14 @@ void hmp_virtio_query(MonitorHMP *hmp, const QDict *qdict)
92 }
93
94 if (list == NULL) {
96 - monitor_printf(mon, "No VirtIO devices\n");
95 + monitor_hmp_printf(hmp, "No VirtIO devices\n");
96 return;
97 }
98
99 node = list;
100 while (node) {
102 - monitor_printf(mon, "%s [%s]\n", node->value->path,
103 - node->value->name);
101 + monitor_hmp_printf(hmp, "%s [%s]\n", node->value->path,
102 + node->value->name);
103 node = node->next;
104 }
105 qapi_free_VirtioInfoList(list);
@@ -108,7 +107,6 @@ void hmp_virtio_query(MonitorHMP *hmp, const QDict *qdict)
107
108 void hmp_virtio_status(MonitorHMP *hmp, const QDict *qdict)
109 {
111 - Monitor *mon = MONITOR(hmp);
110 Error *err = NULL;
111 const char *path = qdict_get_try_str(qdict, "path");
112 VirtioStatus *s = qmp_x_query_virtio_status(path, &err);
@@ -118,68 +116,68 @@ void hmp_virtio_status(MonitorHMP *hmp, const QDict *qdict)
116 return;
117 }
118
121 - monitor_printf(mon, "%s:\n", path);
122 - monitor_printf(mon, " device_name: %s %s\n",
123 - s->name, s->vhost_dev ? "(vhost)" : "");
124 - monitor_printf(mon, " device_id: %d\n", s->device_id);
125 - monitor_printf(mon, " vhost_started: %s\n",
126 - s->vhost_started ? "true" : "false");
127 - monitor_printf(mon, " bus_name: %s\n", s->bus_name);
128 - monitor_printf(mon, " broken: %s\n",
129 - s->broken ? "true" : "false");
130 - monitor_printf(mon, " disabled: %s\n",
131 - s->disabled ? "true" : "false");
132 - monitor_printf(mon, " disable_legacy_check: %s\n",
133 - s->disable_legacy_check ? "true" : "false");
134 - monitor_printf(mon, " started: %s\n",
135 - s->started ? "true" : "false");
136 - monitor_printf(mon, " use_started: %s\n",
137 - s->use_started ? "true" : "false");
138 - monitor_printf(mon, " start_on_kick: %s\n",
139 - s->start_on_kick ? "true" : "false");
140 - monitor_printf(mon, " use_guest_notifier_mask: %s\n",
141 - s->use_guest_notifier_mask ? "true" : "false");
142 - monitor_printf(mon, " vm_running: %s\n",
143 - s->vm_running ? "true" : "false");
144 - monitor_printf(mon, " num_vqs: %"PRId64"\n", s->num_vqs);
145 - monitor_printf(mon, " queue_sel: %d\n",
146 - s->queue_sel);
147 - monitor_printf(mon, " isr: %d\n", s->isr);
148 - monitor_printf(mon, " endianness: %s\n",
149 - s->device_endian);
150 - monitor_printf(mon, " status:\n");
151 - hmp_virtio_dump_status(mon, s->status);
152 - monitor_printf(mon, " Guest features:\n");
153 - hmp_virtio_dump_features(mon, s->guest_features);
154 - monitor_printf(mon, " Host features:\n");
155 - hmp_virtio_dump_features(mon, s->host_features);
156 - monitor_printf(mon, " Backend features:\n");
157 - hmp_virtio_dump_features(mon, s->backend_features);
119 + monitor_hmp_printf(hmp, "%s:\n", path);
120 + monitor_hmp_printf(hmp, " device_name: %s %s\n",
121 + s->name, s->vhost_dev ? "(vhost)" : "");
122 + monitor_hmp_printf(hmp, " device_id: %d\n", s->device_id);
123 + monitor_hmp_printf(hmp, " vhost_started: %s\n",
124 + s->vhost_started ? "true" : "false");
125 + monitor_hmp_printf(hmp, " bus_name: %s\n", s->bus_name);
126 + monitor_hmp_printf(hmp, " broken: %s\n",
127 + s->broken ? "true" : "false");
128 + monitor_hmp_printf(hmp, " disabled: %s\n",
129 + s->disabled ? "true" : "false");
130 + monitor_hmp_printf(hmp, " disable_legacy_check: %s\n",
131 + s->disable_legacy_check ? "true" : "false");
132 + monitor_hmp_printf(hmp, " started: %s\n",
133 + s->started ? "true" : "false");
134 + monitor_hmp_printf(hmp, " use_started: %s\n",
135 + s->use_started ? "true" : "false");
136 + monitor_hmp_printf(hmp, " start_on_kick: %s\n",
137 + s->start_on_kick ? "true" : "false");
138 + monitor_hmp_printf(hmp, " use_guest_notifier_mask: %s\n",
139 + s->use_guest_notifier_mask ? "true" : "false");
140 + monitor_hmp_printf(hmp, " vm_running: %s\n",
141 + s->vm_running ? "true" : "false");
142 + monitor_hmp_printf(hmp, " num_vqs: %"PRId64"\n", s->num_vqs);
143 + monitor_hmp_printf(hmp, " queue_sel: %d\n",
144 + s->queue_sel);
145 + monitor_hmp_printf(hmp, " isr: %d\n", s->isr);
146 + monitor_hmp_printf(hmp, " endianness: %s\n",
147 + s->device_endian);
148 + monitor_hmp_printf(hmp, " status:\n");
149 + hmp_virtio_dump_status(hmp, s->status);
150 + monitor_hmp_printf(hmp, " Guest features:\n");
151 + hmp_virtio_dump_features(hmp, s->guest_features);
152 + monitor_hmp_printf(hmp, " Host features:\n");
153 + hmp_virtio_dump_features(hmp, s->host_features);
154 + monitor_hmp_printf(hmp, " Backend features:\n");
155 + hmp_virtio_dump_features(hmp, s->backend_features);
156
157 if (s->vhost_dev) {
160 - monitor_printf(mon, " VHost:\n");
161 - monitor_printf(mon, " nvqs: %d\n",
162 - s->vhost_dev->nvqs);
163 - monitor_printf(mon, " vq_index: %"PRId64"\n",
164 - s->vhost_dev->vq_index);
165 - monitor_printf(mon, " max_queues: %"PRId64"\n",
166 - s->vhost_dev->max_queues);
167 - monitor_printf(mon, " n_mem_sections: %"PRId64"\n",
168 - s->vhost_dev->n_mem_sections);
169 - monitor_printf(mon, " n_tmp_sections: %"PRId64"\n",
170 - s->vhost_dev->n_tmp_sections);
171 - monitor_printf(mon, " backend_cap: %"PRId64"\n",
172 - s->vhost_dev->backend_cap);
173 - monitor_printf(mon, " log_enabled: %s\n",
174 - s->vhost_dev->log_enabled ? "true" : "false");
175 - monitor_printf(mon, " log_size: %"PRId64"\n",
176 - s->vhost_dev->log_size);
177 - monitor_printf(mon, " Features:\n");
178 - hmp_virtio_dump_features(mon, s->vhost_dev->features);
179 - monitor_printf(mon, " Acked features:\n");
180 - hmp_virtio_dump_features(mon, s->vhost_dev->acked_features);
181 - monitor_printf(mon, " Protocol features:\n");
182 - hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features);
158 + monitor_hmp_printf(hmp, " VHost:\n");
159 + monitor_hmp_printf(hmp, " nvqs: %d\n",
160 + s->vhost_dev->nvqs);
161 + monitor_hmp_printf(hmp, " vq_index: %"PRId64"\n",
162 + s->vhost_dev->vq_index);
163 + monitor_hmp_printf(hmp, " max_queues: %"PRId64"\n",
164 + s->vhost_dev->max_queues);
165 + monitor_hmp_printf(hmp, " n_mem_sections: %"PRId64"\n",
166 + s->vhost_dev->n_mem_sections);
167 + monitor_hmp_printf(hmp, " n_tmp_sections: %"PRId64"\n",
168 + s->vhost_dev->n_tmp_sections);
169 + monitor_hmp_printf(hmp, " backend_cap: %"PRId64"\n",
170 + s->vhost_dev->backend_cap);
171 + monitor_hmp_printf(hmp, " log_enabled: %s\n",
172 + s->vhost_dev->log_enabled ? "true" : "false");
173 + monitor_hmp_printf(hmp, " log_size: %"PRId64"\n",
174 + s->vhost_dev->log_size);
175 + monitor_hmp_printf(hmp, " Features:\n");
176 + hmp_virtio_dump_features(hmp, s->vhost_dev->features);
177 + monitor_hmp_printf(hmp, " Acked features:\n");
178 + hmp_virtio_dump_features(hmp, s->vhost_dev->acked_features);
179 + monitor_hmp_printf(hmp, " Protocol features:\n");
180 + hmp_virtio_dump_protocols(hmp, s->vhost_dev->protocol_features);
181 }
182
183 qapi_free_VirtioStatus(s);
@@ -187,7 +185,6 @@ void hmp_virtio_status(MonitorHMP *hmp, const QDict *qdict)
185
186 void hmp_vhost_queue_status(MonitorHMP *hmp, const QDict *qdict)
187 {
190 - Monitor *mon = MONITOR(hmp);
188 Error *err = NULL;
189 const char *path = qdict_get_try_str(qdict, "path");
190 int queue = qdict_get_int(qdict, "queue");
@@ -199,29 +196,28 @@ void hmp_vhost_queue_status(MonitorHMP *hmp, const QDict *qdict)
196 return;
197 }
198
202 - monitor_printf(mon, "%s:\n", path);
203 - monitor_printf(mon, " device_name: %s (vhost)\n",
204 - s->name);
205 - monitor_printf(mon, " kick: %"PRId64"\n", s->kick);
206 - monitor_printf(mon, " call: %"PRId64"\n", s->call);
207 - monitor_printf(mon, " VRing:\n");
208 - monitor_printf(mon, " num: %"PRId64"\n", s->num);
209 - monitor_printf(mon, " desc_phys: 0x%016"PRIx64"\n",
210 - s->desc_phys);
211 - monitor_printf(mon, " desc_size: %"PRId32"\n", s->desc_size);
212 - monitor_printf(mon, " avail_phys: 0x%016"PRIx64"\n",
213 - s->avail_phys);
214 - monitor_printf(mon, " avail_size: %"PRId32"\n", s->avail_size);
215 - monitor_printf(mon, " used_phys: 0x%016"PRIx64"\n",
216 - s->used_phys);
217 - monitor_printf(mon, " used_size: %"PRId32"\n", s->used_size);
199 + monitor_hmp_printf(hmp, "%s:\n", path);
200 + monitor_hmp_printf(hmp, " device_name: %s (vhost)\n",
201 + s->name);
202 + monitor_hmp_printf(hmp, " kick: %"PRId64"\n", s->kick);
203 + monitor_hmp_printf(hmp, " call: %"PRId64"\n", s->call);
204 + monitor_hmp_printf(hmp, " VRing:\n");
205 + monitor_hmp_printf(hmp, " num: %"PRId64"\n", s->num);
206 + monitor_hmp_printf(hmp, " desc_phys: 0x%016"PRIx64"\n",
207 + s->desc_phys);
208 + monitor_hmp_printf(hmp, " desc_size: %"PRId32"\n", s->desc_size);
209 + monitor_hmp_printf(hmp, " avail_phys: 0x%016"PRIx64"\n",
210 + s->avail_phys);
211 + monitor_hmp_printf(hmp, " avail_size: %"PRId32"\n", s->avail_size);
212 + monitor_hmp_printf(hmp, " used_phys: 0x%016"PRIx64"\n",
213 + s->used_phys);
214 + monitor_hmp_printf(hmp, " used_size: %"PRId32"\n", s->used_size);
215
216 qapi_free_VirtVhostQueueStatus(s);
217 }
218
219 void hmp_virtio_queue_status(MonitorHMP *hmp, const QDict *qdict)
220 {
224 - Monitor *mon = MONITOR(hmp);
221 Error *err = NULL;
222 const char *path = qdict_get_try_str(qdict, "path");
223 int queue = qdict_get_int(qdict, "queue");
@@ -232,42 +228,41 @@ void hmp_virtio_queue_status(MonitorHMP *hmp, const QDict *qdict)
228 return;
229 }
230
235 - monitor_printf(mon, "%s:\n", path);
236 - monitor_printf(mon, " device_name: %s\n", s->name);
237 - monitor_printf(mon, " queue_index: %d\n", s->queue_index);
238 - monitor_printf(mon, " inuse: %d\n", s->inuse);
239 - monitor_printf(mon, " used_idx: %d\n", s->used_idx);
240 - monitor_printf(mon, " signalled_used: %d\n",
241 - s->signalled_used);
242 - monitor_printf(mon, " signalled_used_valid: %s\n",
243 - s->signalled_used_valid ? "true" : "false");
231 + monitor_hmp_printf(hmp, "%s:\n", path);
232 + monitor_hmp_printf(hmp, " device_name: %s\n", s->name);
233 + monitor_hmp_printf(hmp, " queue_index: %d\n", s->queue_index);
234 + monitor_hmp_printf(hmp, " inuse: %d\n", s->inuse);
235 + monitor_hmp_printf(hmp, " used_idx: %d\n", s->used_idx);
236 + monitor_hmp_printf(hmp, " signalled_used: %d\n",
237 + s->signalled_used);
238 + monitor_hmp_printf(hmp, " signalled_used_valid: %s\n",
239 + s->signalled_used_valid ? "true" : "false");
240 if (s->has_last_avail_idx) {
245 - monitor_printf(mon, " last_avail_idx: %d\n",
246 - s->last_avail_idx);
241 + monitor_hmp_printf(hmp, " last_avail_idx: %d\n",
242 + s->last_avail_idx);
243 }
244 if (s->has_shadow_avail_idx) {
249 - monitor_printf(mon, " shadow_avail_idx: %d\n",
250 - s->shadow_avail_idx);
245 + monitor_hmp_printf(hmp, " shadow_avail_idx: %d\n",
246 + s->shadow_avail_idx);
247 }
252 - monitor_printf(mon, " VRing:\n");
253 - monitor_printf(mon, " num: %"PRId32"\n", s->vring_num);
254 - monitor_printf(mon, " num_default: %"PRId32"\n",
255 - s->vring_num_default);
256 - monitor_printf(mon, " align: %"PRId32"\n",
257 - s->vring_align);
258 - monitor_printf(mon, " desc: 0x%016"PRIx64"\n",
259 - s->vring_desc);
260 - monitor_printf(mon, " avail: 0x%016"PRIx64"\n",
261 - s->vring_avail);
262 - monitor_printf(mon, " used: 0x%016"PRIx64"\n",
263 - s->vring_used);
248 + monitor_hmp_printf(hmp, " VRing:\n");
249 + monitor_hmp_printf(hmp, " num: %"PRId32"\n", s->vring_num);
250 + monitor_hmp_printf(hmp, " num_default: %"PRId32"\n",
251 + s->vring_num_default);
252 + monitor_hmp_printf(hmp, " align: %"PRId32"\n",
253 + s->vring_align);
254 + monitor_hmp_printf(hmp, " desc: 0x%016"PRIx64"\n",
255 + s->vring_desc);
256 + monitor_hmp_printf(hmp, " avail: 0x%016"PRIx64"\n",
257 + s->vring_avail);
258 + monitor_hmp_printf(hmp, " used: 0x%016"PRIx64"\n",
259 + s->vring_used);
260
261 qapi_free_VirtQueueStatus(s);
262 }
263
264 void hmp_virtio_queue_element(MonitorHMP *hmp, const QDict *qdict)
265 {
270 - Monitor *mon = MONITOR(hmp);
266 Error *err = NULL;
267 const char *path = qdict_get_try_str(qdict, "path");
268 int queue = qdict_get_int(qdict, "queue");
@@ -282,41 +277,41 @@ void hmp_virtio_queue_element(MonitorHMP *hmp, const QDict *qdict)
277 return;
278 }
279
285 - monitor_printf(mon, "%s:\n", path);
286 - monitor_printf(mon, " device_name: %s\n", e->name);
287 - monitor_printf(mon, " index: %d\n", e->index);
288 - monitor_printf(mon, " desc:\n");
289 - monitor_printf(mon, " descs:\n");
280 + monitor_hmp_printf(hmp, "%s:\n", path);
281 + monitor_hmp_printf(hmp, " device_name: %s\n", e->name);
282 + monitor_hmp_printf(hmp, " index: %d\n", e->index);
283 + monitor_hmp_printf(hmp, " desc:\n");
284 + monitor_hmp_printf(hmp, " descs:\n");
285
286 list = e->descs;
287 while (list) {
293 - monitor_printf(mon, " addr 0x%"PRIx64" len %d",
294 - list->value->addr, list->value->len);
288 + monitor_hmp_printf(hmp, " addr 0x%"PRIx64" len %d",
289 + list->value->addr, list->value->len);
290 if (list->value->flags) {
291 strList *flag = list->value->flags;
297 - monitor_printf(mon, " (");
292 + monitor_hmp_printf(hmp, " (");
293 while (flag) {
299 - monitor_printf(mon, "%s", flag->value);
294 + monitor_hmp_printf(hmp, "%s", flag->value);
295 flag = flag->next;
296 if (flag) {
302 - monitor_printf(mon, ", ");
297 + monitor_hmp_printf(hmp, ", ");
298 }
299 }
305 - monitor_printf(mon, ")");
300 + monitor_hmp_printf(hmp, ")");
301 }
302 list = list->next;
303 if (list) {
309 - monitor_printf(mon, ",\n");
304 + monitor_hmp_printf(hmp, ",\n");
305 }
306 }
312 - monitor_printf(mon, "\n");
313 - monitor_printf(mon, " avail:\n");
314 - monitor_printf(mon, " flags: %d\n", e->avail->flags);
315 - monitor_printf(mon, " idx: %d\n", e->avail->idx);
316 - monitor_printf(mon, " ring: %d\n", e->avail->ring);
317 - monitor_printf(mon, " used:\n");
318 - monitor_printf(mon, " flags: %d\n", e->used->flags);
319 - monitor_printf(mon, " idx: %d\n", e->used->idx);
307 + monitor_hmp_printf(hmp, "\n");
308 + monitor_hmp_printf(hmp, " avail:\n");
309 + monitor_hmp_printf(hmp, " flags: %d\n", e->avail->flags);
310 + monitor_hmp_printf(hmp, " idx: %d\n", e->avail->idx);
311 + monitor_hmp_printf(hmp, " ring: %d\n", e->avail->ring);
312 + monitor_hmp_printf(hmp, " used:\n");
313 + monitor_hmp_printf(hmp, " flags: %d\n", e->used->flags);
314 + monitor_hmp_printf(hmp, " idx: %d\n", e->used->idx);
315
316 qapi_free_VirtioQueueElement(e);
317 }
hw/xen/xen-bus.c
+3 -2
@@ -103,10 +103,11 @@ abort:
103
104 static void xen_bus_print_dev(Monitor *mon, DeviceState *dev, int indent)
105 {
106 + MonitorHMP *hmp = MONITOR_HMP(mon);
107 XenDevice *xendev = XEN_DEVICE(dev);
108
108 - monitor_printf(mon, "%*sname = '%s' frontend_id = %u\n",
109 - indent, "", xendev->name, xendev->frontend_id);
109 + monitor_hmp_printf(hmp, "%*sname = '%s' frontend_id = %u\n",
110 + indent, "", xendev->name, xendev->frontend_id);
111 }
112
113 static char *xen_bus_get_dev_path(DeviceState *dev)
include/disas/disas.h
+3 -1
@@ -1,13 +1,15 @@
1 #ifndef QEMU_DISAS_H
2 #define QEMU_DISAS_H
3
4 +#include "monitor/hmp.h"
5 +
6 /* Disassemble this for me please... (debugging). */
7 #ifdef CONFIG_TCG
8 void disas(FILE *out, const void *code, size_t size);
9 void target_disas(FILE *out, CPUState *cpu, const DisasContextBase *db);
10 #endif
11
10 -void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc,
12 +void monitor_disas(MonitorHMP *hmp, CPUState *cpu, uint64_t pc,
13 int nb_insn, bool is_physical);
14
15 #ifdef CONFIG_PLUGIN
include/monitor/hmp.h
+6 -6
@@ -38,10 +38,10 @@ void monitor_new_hmp(const char *id, const char *chardev_id,
38
39 MonitorHMP *monitor_cur_hmp(void);
40
41 -int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
41 +int monitor_hmp_vprintf(MonitorHMP *mon, const char *fmt, va_list ap)
42 G_GNUC_PRINTF(2, 0);
43 -int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
44 -void monitor_printc(Monitor *mon, int ch);
43 +int monitor_hmp_printf(MonitorHMP *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
44 +void monitor_hmp_printc(MonitorHMP *mon, int ch);
45
46 void monitor_hmp_read_command(MonitorHMP *hmp, int show_prompt);
47 int monitor_hmp_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
@@ -58,7 +58,7 @@ CPUState *monitor_hmp_get_cpu(MonitorHMP *hmp);
58 int monitor_hmp_get_cpu_index(MonitorHMP *hmp);
59
60 bool hmp_handle_error(MonitorHMP *hmp, Error *err);
61 -void hmp_help_cmd(Monitor *mon, const char *name);
61 +void hmp_help_cmd(MonitorHMP *hmp, const char *name);
62 strList *hmp_split_at_comma(const char *str);
63
64 void hmp_info_name(MonitorHMP *hmp, const QDict *qdict);
@@ -114,11 +114,11 @@ void hmp_set_password(MonitorHMP *hmp, const QDict *qdict);
114 void hmp_expire_password(MonitorHMP *hmp, const QDict *qdict);
115 void hmp_change(MonitorHMP *hmp, const QDict *qdict);
116 #ifdef CONFIG_VNC
117 -void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
117 +void hmp_change_vnc(MonitorHMP *hmp, const char *device, const char *target,
118 const char *arg, const char *read_only, bool force,
119 Error **errp);
120 #endif
121 -void hmp_change_medium(Monitor *mon, const char *device, const char *target,
121 +void hmp_change_medium(MonitorHMP *hmp, const char *device, const char *target,
122 const char *arg, const char *read_only, bool force,
123 Error **errp);
124 void hmp_migrate(MonitorHMP *hmp, const QDict *qdict);
migration/dirtyrate.c
+23 -25
@@ -858,34 +858,33 @@ struct DirtyRateInfo *qmp_query_dirty_rate(bool has_calc_time_unit,
858
859 void hmp_info_dirty_rate(MonitorHMP *hmp, const QDict *qdict)
860 {
861 - Monitor *mon = MONITOR(hmp);
861 DirtyRateInfo *info = query_dirty_rate_info(TIME_UNIT_SECOND);
862
864 - monitor_printf(mon, "Status: %s\n",
865 - DirtyRateStatus_str(info->status));
866 - monitor_printf(mon, "Start Time: %"PRIi64" (ms)\n",
867 - info->start_time);
863 + monitor_hmp_printf(hmp, "Status: %s\n",
864 + DirtyRateStatus_str(info->status));
865 + monitor_hmp_printf(hmp, "Start Time: %"PRIi64" (ms)\n",
866 + info->start_time);
867 if (info->mode == DIRTY_RATE_MEASURE_MODE_PAGE_SAMPLING) {
869 - monitor_printf(mon, "Sample Pages: %"PRIu64" (per GB)\n",
870 - info->sample_pages);
871 - }
872 - monitor_printf(mon, "Period: %"PRIi64" (sec)\n",
873 - info->calc_time);
874 - monitor_printf(mon, "Mode: %s\n",
875 - DirtyRateMeasureMode_str(info->mode));
876 - monitor_printf(mon, "Dirty rate: ");
868 + monitor_hmp_printf(hmp, "Sample Pages: %"PRIu64" (per GB)\n",
869 + info->sample_pages);
870 + }
871 + monitor_hmp_printf(hmp, "Period: %"PRIi64" (sec)\n",
872 + info->calc_time);
873 + monitor_hmp_printf(hmp, "Mode: %s\n",
874 + DirtyRateMeasureMode_str(info->mode));
875 + monitor_hmp_printf(hmp, "Dirty rate: ");
876 if (info->has_dirty_rate) {
878 - monitor_printf(mon, "%"PRIi64" (MB/s)\n", info->dirty_rate);
877 + monitor_hmp_printf(hmp, "%"PRIi64" (MB/s)\n", info->dirty_rate);
878 if (info->has_vcpu_dirty_rate) {
879 DirtyRateVcpuList *rate, *head = info->vcpu_dirty_rate;
880 for (rate = head; rate != NULL; rate = rate->next) {
882 - monitor_printf(mon, "vcpu[%"PRIi64"], Dirty rate: %"PRIi64
883 - " (MB/s)\n", rate->value->id,
884 - rate->value->dirty_rate);
881 + monitor_hmp_printf(hmp, "vcpu[%"PRIi64"], Dirty rate: %"PRIi64
882 + " (MB/s)\n", rate->value->id,
883 + rate->value->dirty_rate);
884 }
885 }
886 } else {
888 - monitor_printf(mon, "(not ready)\n");
887 + monitor_hmp_printf(hmp, "(not ready)\n");
888 }
889
890 qapi_free_DirtyRateVcpuList(info->vcpu_dirty_rate);
@@ -894,7 +893,6 @@ void hmp_info_dirty_rate(MonitorHMP *hmp, const QDict *qdict)
893
894 void hmp_calc_dirty_rate(MonitorHMP *hmp, const QDict *qdict)
895 {
897 - Monitor *mon = MONITOR(hmp);
896 int64_t sec = qdict_get_try_int(qdict, "second", 0);
897 int64_t sample_pages = qdict_get_try_int(qdict, "sample_pages_per_GB", -1);
898 bool has_sample_pages = (sample_pages != -1);
@@ -904,13 +902,13 @@ void hmp_calc_dirty_rate(MonitorHMP *hmp, const QDict *qdict)
902 Error *err = NULL;
903
904 if (!sec) {
907 - monitor_printf(mon, "Incorrect period length specified!\n");
905 + monitor_hmp_printf(hmp, "Incorrect period length specified!\n");
906 return;
907 }
908
909 if (dirty_ring && dirty_bitmap) {
912 - monitor_printf(mon, "Either dirty ring or dirty bitmap "
913 - "can be specified!\n");
910 + monitor_hmp_printf(hmp, "Either dirty ring or dirty bitmap "
911 + "can be specified!\n");
912 return;
913 }
914
@@ -930,7 +928,7 @@ void hmp_calc_dirty_rate(MonitorHMP *hmp, const QDict *qdict)
928 return;
929 }
930
933 - monitor_printf(mon, "Starting dirty rate measurement with period %"PRIi64
934 - " seconds\n", sec);
935 - monitor_printf(mon, "[Please use 'info dirty_rate' to check results]\n");
931 + monitor_hmp_printf(hmp, "Starting dirty rate measurement with period %"PRIi64
932 + " seconds\n", sec);
933 + monitor_hmp_printf(hmp, "[Please use 'info dirty_rate' to check results]\n");
934 }
migration/migration-hmp-cmds.c
+149 -152
@@ -36,23 +36,23 @@
36 #include "options.h"
37 #include "migration.h"
38
39 -static void migration_global_dump(Monitor *mon)
39 +static void migration_global_dump(MonitorHMP *hmp)
40 {
41 MigrationState *ms = migrate_get_current();
42
43 - monitor_printf(mon, "Globals:\n");
44 - monitor_printf(mon, " store-global-state: %s\n",
45 - ms->store_global_state ? "on" : "off");
46 - monitor_printf(mon, " only-migratable: %s\n",
47 - only_migratable ? "on" : "off");
48 - monitor_printf(mon, " send-configuration: %s\n",
49 - ms->send_configuration ? "on" : "off");
50 - monitor_printf(mon, " send-section-footer: %s\n",
51 - ms->send_section_footer ? "on" : "off");
52 - monitor_printf(mon, " send-switchover-start: %s\n",
53 - ms->send_switchover_start ? "on" : "off");
54 - monitor_printf(mon, " clear-bitmap-shift: %u\n",
55 - ms->clear_bitmap_shift);
43 + monitor_hmp_printf(hmp, "Globals:\n");
44 + monitor_hmp_printf(hmp, " store-global-state: %s\n",
45 + ms->store_global_state ? "on" : "off");
46 + monitor_hmp_printf(hmp, " only-migratable: %s\n",
47 + only_migratable ? "on" : "off");
48 + monitor_hmp_printf(hmp, " send-configuration: %s\n",
49 + ms->send_configuration ? "on" : "off");
50 + monitor_hmp_printf(hmp, " send-section-footer: %s\n",
51 + ms->send_section_footer ? "on" : "off");
52 + monitor_hmp_printf(hmp, " send-switchover-start: %s\n",
53 + ms->send_switchover_start ? "on" : "off");
54 + monitor_hmp_printf(hmp, " clear-bitmap-shift: %u\n",
55 + ms->clear_bitmap_shift);
56 }
57
58 static const gchar *format_time_str(uint64_t us)
@@ -68,11 +68,11 @@ static const gchar *format_time_str(uint64_t us)
68 return g_strdup_printf("%"PRIu64" %s", us, units[index]);
69 }
70
71 -static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info)
71 +static void migration_dump_blocktime(MonitorHMP *hmp, MigrationInfo *info)
72 {
73 if (info->has_postcopy_blocktime) {
74 - monitor_printf(mon, "Postcopy Blocktime (ms): %" PRIu32 "\n",
75 - info->postcopy_blocktime);
74 + monitor_hmp_printf(hmp, "Postcopy Blocktime (ms): %" PRIu32 "\n",
75 + info->postcopy_blocktime);
76 }
77
78 if (info->has_postcopy_vcpu_blocktime) {
@@ -80,25 +80,25 @@ static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info)
80 const char *sep = "";
81 int count = 0;
82
83 - monitor_printf(mon, "Postcopy vCPU Blocktime (ms):\n [");
83 + monitor_hmp_printf(hmp, "Postcopy vCPU Blocktime (ms):\n [");
84
85 while (item) {
86 - monitor_printf(mon, "%s%"PRIu32, sep, item->value);
86 + monitor_hmp_printf(hmp, "%s%"PRIu32, sep, item->value);
87 item = item->next;
88 /* Each line 10 vcpu results, newline if there's more */
89 sep = ((++count % 10 == 0) && item) ? ",\n " : ", ";
90 }
91 - monitor_printf(mon, "]\n");
91 + monitor_hmp_printf(hmp, "]\n");
92 }
93
94 if (info->has_postcopy_latency) {
95 - monitor_printf(mon, "Postcopy Latency (ns): %" PRIu64 "\n",
96 - info->postcopy_latency);
95 + monitor_hmp_printf(hmp, "Postcopy Latency (ns): %" PRIu64 "\n",
96 + info->postcopy_latency);
97 }
98
99 if (info->has_postcopy_non_vcpu_latency) {
100 - monitor_printf(mon, "Postcopy non-vCPU Latency (ns): %" PRIu64 "\n",
101 - info->postcopy_non_vcpu_latency);
100 + monitor_hmp_printf(hmp, "Postcopy non-vCPU Latency (ns): %" PRIu64 "\n",
101 + info->postcopy_non_vcpu_latency);
102 }
103
104 if (info->has_postcopy_vcpu_latency) {
@@ -106,29 +106,29 @@ static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info)
106 const char *sep = "";
107 int count = 0;
108
109 - monitor_printf(mon, "Postcopy vCPU Latencies (ns):\n [");
109 + monitor_hmp_printf(hmp, "Postcopy vCPU Latencies (ns):\n [");
110
111 while (item) {
112 - monitor_printf(mon, "%s%"PRIu64, sep, item->value);
112 + monitor_hmp_printf(hmp, "%s%"PRIu64, sep, item->value);
113 item = item->next;
114 /* Each line 10 vcpu results, newline if there's more */
115 sep = ((++count % 10 == 0) && item) ? ",\n " : ", ";
116 }
117 - monitor_printf(mon, "]\n");
117 + monitor_hmp_printf(hmp, "]\n");
118 }
119
120 if (info->has_postcopy_latency_dist) {
121 uint64List *item = info->postcopy_latency_dist;
122 int count = 0;
123
124 - monitor_printf(mon, "Postcopy Latency Distribution:\n");
124 + monitor_hmp_printf(hmp, "Postcopy Latency Distribution:\n");
125
126 while (item) {
127 g_autofree const gchar *from = format_time_str(1UL << count);
128 g_autofree const gchar *to = format_time_str(1UL << (count + 1));
129
130 - monitor_printf(mon, " [ %8s - %8s ]: %10"PRIu64"\n",
131 - from, to, item->value);
130 + monitor_hmp_printf(hmp, " [ %8s - %8s ]: %10"PRIu64"\n",
131 + from, to, item->value);
132 item = item->next;
133 count++;
134 }
@@ -137,7 +137,6 @@ static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info)
137
138 void hmp_info_migrate(MonitorHMP *hmp, const QDict *qdict)
139 {
140 - Monitor *mon = MONITOR(hmp);
140 bool show_all = qdict_get_try_bool(qdict, "all", false);
141 MigrationInfo *info;
142
@@ -145,59 +144,59 @@ void hmp_info_migrate(MonitorHMP *hmp, const QDict *qdict)
144
145 if (info->blocked_reasons) {
146 strList *reasons = info->blocked_reasons;
148 - monitor_printf(mon, "Outgoing migration blocked:\n");
147 + monitor_hmp_printf(hmp, "Outgoing migration blocked:\n");
148 while (reasons) {
150 - monitor_printf(mon, " %s\n", reasons->value);
149 + monitor_hmp_printf(hmp, " %s\n", reasons->value);
150 reasons = reasons->next;
151 }
152 }
153
154 if (info->has_status) {
156 - monitor_printf(mon, "Status: \t\t%s",
157 - MigrationStatus_str(info->status));
155 + monitor_hmp_printf(hmp, "Status: \t\t%s",
156 + MigrationStatus_str(info->status));
157 if ((info->status == MIGRATION_STATUS_FAILED ||
158 info->status == MIGRATION_STATUS_POSTCOPY_PAUSED) &&
159 info->error_desc) {
161 - monitor_printf(mon, " (%s)\n", info->error_desc);
160 + monitor_hmp_printf(hmp, " (%s)\n", info->error_desc);
161 } else {
163 - monitor_printf(mon, "\n");
162 + monitor_hmp_printf(hmp, "\n");
163 }
164
165 if (info->total_time) {
167 - monitor_printf(mon, "Time (ms): \t\ttotal=%" PRIu64,
168 - info->total_time);
166 + monitor_hmp_printf(hmp, "Time (ms): \t\ttotal=%" PRIu64,
167 + info->total_time);
168 if (info->has_setup_time) {
170 - monitor_printf(mon, ", setup=%" PRIu64,
171 - info->setup_time);
169 + monitor_hmp_printf(hmp, ", setup=%" PRIu64,
170 + info->setup_time);
171 }
172 if (info->has_expected_downtime) {
174 - monitor_printf(mon, ", exp_down=%" PRIu64,
175 - info->expected_downtime);
173 + monitor_hmp_printf(hmp, ", exp_down=%" PRIu64,
174 + info->expected_downtime);
175 }
176 if (info->has_downtime) {
178 - monitor_printf(mon, ", down=%" PRIu64,
179 - info->downtime);
177 + monitor_hmp_printf(hmp, ", down=%" PRIu64,
178 + info->downtime);
179 }
181 - monitor_printf(mon, "\n");
180 + monitor_hmp_printf(hmp, "\n");
181 }
182 }
183
184 if (info->has_remaining) {
185 g_autofree char *remaining = size_to_str(info->remaining);
187 - monitor_printf(mon, "Remaining: \t\t%s\n", remaining);
186 + monitor_hmp_printf(hmp, "Remaining: \t\t%s\n", remaining);
187 }
188
189 if (info->has_socket_address) {
190 SocketAddressList *addr;
191
193 - monitor_printf(mon, "Sockets: [\n");
192 + monitor_hmp_printf(hmp, "Sockets: [\n");
193
194 for (addr = info->socket_address; addr; addr = addr->next) {
195 char *s = socket_uri(addr->value);
197 - monitor_printf(mon, "\t%s\n", s);
196 + monitor_hmp_printf(hmp, "\t%s\n", s);
197 g_free(s);
198 }
200 - monitor_printf(mon, "]\n");
199 + monitor_hmp_printf(hmp, "]\n");
200 }
201
202 if (info->ram) {
@@ -209,219 +208,217 @@ void hmp_info_migrate(MonitorHMP *hmp, const QDict *qdict)
208 g_autofree char *str_multifd = size_to_str(info->ram->multifd_bytes);
209 g_autofree char *str_postcopy = size_to_str(info->ram->postcopy_bytes);
210
212 - monitor_printf(mon, "RAM info:\n");
213 - monitor_printf(mon, " Throughput (Mbps): \t%0.2f\n",
214 - info->ram->mbps);
215 - monitor_printf(mon, " Sizes: \t\tpagesize=%s, total=%s\n",
216 - str_psize, str_total);
217 - monitor_printf(mon, " Transfers: \t\ttransferred=%s, remain=%s\n",
218 - str_transferred, str_remaining);
219 - monitor_printf(mon, " Channels: \t\tprecopy=%s, "
220 - "multifd=%s, postcopy=%s",
221 - str_precopy, str_multifd, str_postcopy);
211 + monitor_hmp_printf(hmp, "RAM info:\n");
212 + monitor_hmp_printf(hmp, " Throughput (Mbps): \t%0.2f\n",
213 + info->ram->mbps);
214 + monitor_hmp_printf(hmp, " Sizes: \t\tpagesize=%s, total=%s\n",
215 + str_psize, str_total);
216 + monitor_hmp_printf(hmp, " Transfers: \t\ttransferred=%s, remain=%s\n",
217 + str_transferred, str_remaining);
218 + monitor_hmp_printf(hmp, " Channels: \t\tprecopy=%s, "
219 + "multifd=%s, postcopy=%s",
220 + str_precopy, str_multifd, str_postcopy);
221
222 if (info->vfio) {
223 g_autofree char *str_vfio = size_to_str(info->vfio->transferred);
224
226 - monitor_printf(mon, ", vfio=%s", str_vfio);
225 + monitor_hmp_printf(hmp, ", vfio=%s", str_vfio);
226 }
228 - monitor_printf(mon, "\n");
227 + monitor_hmp_printf(hmp, "\n");
228
230 - monitor_printf(mon, " Page Types: \tnormal=%" PRIu64
231 - ", zero=%" PRIu64 "\n",
232 - info->ram->normal, info->ram->duplicate);
233 - monitor_printf(mon, " Page Rates (pps): \ttransfer=%" PRIu64,
234 - info->ram->pages_per_second);
229 + monitor_hmp_printf(hmp, " Page Types: \tnormal=%" PRIu64
230 + ", zero=%" PRIu64 "\n",
231 + info->ram->normal, info->ram->duplicate);
232 + monitor_hmp_printf(hmp, " Page Rates (pps): \ttransfer=%" PRIu64,
233 + info->ram->pages_per_second);
234 if (info->ram->dirty_pages_rate) {
236 - monitor_printf(mon, ", dirty=%" PRIu64,
237 - info->ram->dirty_pages_rate);
235 + monitor_hmp_printf(hmp, ", dirty=%" PRIu64,
236 + info->ram->dirty_pages_rate);
237 }
239 - monitor_printf(mon, "\n");
238 + monitor_hmp_printf(hmp, "\n");
239
241 - monitor_printf(mon, " Others: \t\tdirty_syncs=%" PRIu64,
242 - info->ram->dirty_sync_count);
240 + monitor_hmp_printf(hmp, " Others: \t\tdirty_syncs=%" PRIu64,
241 + info->ram->dirty_sync_count);
242 if (info->ram->postcopy_requests) {
244 - monitor_printf(mon, ", postcopy_req=%" PRIu64,
245 - info->ram->postcopy_requests);
243 + monitor_hmp_printf(hmp, ", postcopy_req=%" PRIu64,
244 + info->ram->postcopy_requests);
245 }
246 if (info->ram->downtime_bytes) {
248 - monitor_printf(mon, ", downtime_bytes=%" PRIu64,
249 - info->ram->downtime_bytes);
247 + monitor_hmp_printf(hmp, ", downtime_bytes=%" PRIu64,
248 + info->ram->downtime_bytes);
249 }
250 if (info->ram->dirty_sync_missed_zero_copy) {
252 - monitor_printf(mon, ", zerocopy_fallbacks=%" PRIu64,
253 - info->ram->dirty_sync_missed_zero_copy);
251 + monitor_hmp_printf(hmp, ", zerocopy_fallbacks=%" PRIu64,
252 + info->ram->dirty_sync_missed_zero_copy);
253 }
255 - monitor_printf(mon, "\n");
254 + monitor_hmp_printf(hmp, "\n");
255 }
256
257 if (!show_all) {
258 goto out;
259 }
260
262 - migration_global_dump(mon);
261 + migration_global_dump(hmp);
262
263 if (info->xbzrle_cache) {
265 - monitor_printf(mon, "XBZRLE: size=%" PRIu64
266 - ", transferred=%" PRIu64
267 - ", pages=%" PRIu64
268 - ", miss=%" PRIu64 "\n"
269 - " miss_rate=%0.2f"
270 - ", encode_rate=%0.2f"
271 - ", overflow=%" PRIu64 "\n",
272 - info->xbzrle_cache->cache_size,
273 - info->xbzrle_cache->bytes,
274 - info->xbzrle_cache->pages,
275 - info->xbzrle_cache->cache_miss,
276 - info->xbzrle_cache->cache_miss_rate,
277 - info->xbzrle_cache->encoding_rate,
278 - info->xbzrle_cache->overflow);
264 + monitor_hmp_printf(hmp, "XBZRLE: size=%" PRIu64
265 + ", transferred=%" PRIu64
266 + ", pages=%" PRIu64
267 + ", miss=%" PRIu64 "\n"
268 + " miss_rate=%0.2f"
269 + ", encode_rate=%0.2f"
270 + ", overflow=%" PRIu64 "\n",
271 + info->xbzrle_cache->cache_size,
272 + info->xbzrle_cache->bytes,
273 + info->xbzrle_cache->pages,
274 + info->xbzrle_cache->cache_miss,
275 + info->xbzrle_cache->cache_miss_rate,
276 + info->xbzrle_cache->encoding_rate,
277 + info->xbzrle_cache->overflow);
278 }
279
280 if (info->has_cpu_throttle_percentage) {
282 - monitor_printf(mon, "CPU Throttle (%%): %" PRIu64 "\n",
283 - info->cpu_throttle_percentage);
281 + monitor_hmp_printf(hmp, "CPU Throttle (%%): %" PRIu64 "\n",
282 + info->cpu_throttle_percentage);
283 }
284
285 if (info->has_dirty_limit_throttle_time_per_round) {
287 - monitor_printf(mon, "Dirty-limit Throttle (us): %" PRIu64 "\n",
288 - info->dirty_limit_throttle_time_per_round);
286 + monitor_hmp_printf(hmp, "Dirty-limit Throttle (us): %" PRIu64 "\n",
287 + info->dirty_limit_throttle_time_per_round);
288 }
289
290 if (info->has_dirty_limit_ring_full_time) {
292 - monitor_printf(mon, "Dirty-limit Ring Full (us): %" PRIu64 "\n",
293 - info->dirty_limit_ring_full_time);
291 + monitor_hmp_printf(hmp, "Dirty-limit Ring Full (us): %" PRIu64 "\n",
292 + info->dirty_limit_ring_full_time);
293 }
294
296 - migration_dump_blocktime(mon, info);
295 + migration_dump_blocktime(hmp, info);
296 out:
297 qapi_free_MigrationInfo(info);
298 }
299
300 void hmp_info_migrate_capabilities(MonitorHMP *hmp, const QDict *qdict)
301 {
303 - Monitor *mon = MONITOR(hmp);
302 MigrationCapabilityStatusList *caps, *cap;
303
304 caps = qmp_query_migrate_capabilities(NULL);
305
306 if (caps) {
307 for (cap = caps; cap; cap = cap->next) {
310 - monitor_printf(mon, "%s: %s\n",
311 - MigrationCapability_str(cap->value->capability),
312 - cap->value->state ? "on" : "off");
308 + monitor_hmp_printf(hmp, "%s: %s\n",
309 + MigrationCapability_str(cap->value->capability),
310 + cap->value->state ? "on" : "off");
311 }
312 }
313
314 qapi_free_MigrationCapabilityStatusList(caps);
315 }
316
319 -static void monitor_print_cpr_exec_command(Monitor *mon, strList *args)
317 +static void monitor_print_cpr_exec_command(MonitorHMP *hmp, strList *args)
318 {
321 - monitor_printf(mon, "%s:",
319 + monitor_hmp_printf(hmp, "%s:",
320 MigrationParameter_str(MIGRATION_PARAMETER_CPR_EXEC_COMMAND));
321
322 while (args) {
325 - monitor_printf(mon, " %s", args->value);
323 + monitor_hmp_printf(hmp, " %s", args->value);
324 args = args->next;
325 }
328 - monitor_printf(mon, "\n");
326 + monitor_hmp_printf(hmp, "\n");
327 }
328
329 void hmp_info_migrate_parameters(MonitorHMP *hmp, const QDict *qdict)
330 {
333 - Monitor *mon = MONITOR(hmp);
331 MigrationParameters *params;
332 MigrationState *s = migrate_get_current();
333
334 params = qmp_query_migrate_parameters(NULL);
335
336 if (params) {
340 - monitor_printf(mon, "%s: %" PRIu64 " ms\n",
337 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " ms\n",
338 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_INITIAL),
339 params->announce_initial);
343 - monitor_printf(mon, "%s: %" PRIu64 " ms\n",
340 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " ms\n",
341 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_MAX),
342 params->announce_max);
346 - monitor_printf(mon, "%s: %" PRIu64 "\n",
343 + monitor_hmp_printf(hmp, "%s: %" PRIu64 "\n",
344 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_ROUNDS),
345 params->announce_rounds);
349 - monitor_printf(mon, "%s: %" PRIu64 " ms\n",
346 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " ms\n",
347 MigrationParameter_str(MIGRATION_PARAMETER_ANNOUNCE_STEP),
348 params->announce_step);
349 assert(params->has_throttle_trigger_threshold);
353 - monitor_printf(mon, "%s: %u\n",
350 + monitor_hmp_printf(hmp, "%s: %u\n",
351 MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD),
352 params->throttle_trigger_threshold);
353 assert(params->has_cpu_throttle_initial);
357 - monitor_printf(mon, "%s: %u\n",
354 + monitor_hmp_printf(hmp, "%s: %u\n",
355 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL),
356 params->cpu_throttle_initial);
357 assert(params->has_cpu_throttle_increment);
361 - monitor_printf(mon, "%s: %u\n",
358 + monitor_hmp_printf(hmp, "%s: %u\n",
359 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT),
360 params->cpu_throttle_increment);
361 assert(params->has_cpu_throttle_tailslow);
365 - monitor_printf(mon, "%s: %s\n",
362 + monitor_hmp_printf(hmp, "%s: %s\n",
363 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_TAILSLOW),
364 params->cpu_throttle_tailslow ? "on" : "off");
365 assert(params->has_max_cpu_throttle);
369 - monitor_printf(mon, "%s: %u\n",
366 + monitor_hmp_printf(hmp, "%s: %u\n",
367 MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE),
368 params->max_cpu_throttle);
369 assert(params->tls_creds);
373 - monitor_printf(mon, "%s: '%s'\n",
370 + monitor_hmp_printf(hmp, "%s: '%s'\n",
371 MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS),
372 params->tls_creds->u.s);
373 assert(params->tls_hostname);
377 - monitor_printf(mon, "%s: '%s'\n",
374 + monitor_hmp_printf(hmp, "%s: '%s'\n",
375 MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME),
376 params->tls_hostname->u.s);
377 assert(params->tls_authz);
381 - monitor_printf(mon, "%s: '%s'\n",
378 + monitor_hmp_printf(hmp, "%s: '%s'\n",
379 MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ),
380 params->tls_authz->u.s);
381 assert(params->has_max_bandwidth);
385 - monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n",
382 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " bytes/second\n",
383 MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH),
384 params->max_bandwidth);
385 assert(params->has_avail_switchover_bandwidth);
389 - monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n",
386 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " bytes/second\n",
387 MigrationParameter_str(MIGRATION_PARAMETER_AVAIL_SWITCHOVER_BANDWIDTH),
388 params->avail_switchover_bandwidth);
389 assert(params->has_max_postcopy_bandwidth);
393 - monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n",
390 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " bytes/second\n",
391 MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH),
392 params->max_postcopy_bandwidth);
393 assert(params->has_downtime_limit);
397 - monitor_printf(mon, "%s: %" PRIu64 " ms\n",
394 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " ms\n",
395 MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
396 params->downtime_limit);
397 assert(params->has_x_checkpoint_delay);
401 - monitor_printf(mon, "%s: %u ms\n",
398 + monitor_hmp_printf(hmp, "%s: %u ms\n",
399 MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY),
400 params->x_checkpoint_delay);
404 - monitor_printf(mon, "%s: %u\n",
401 + monitor_hmp_printf(hmp, "%s: %u\n",
402 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS),
403 params->multifd_channels);
407 - monitor_printf(mon, "%s: %s\n",
404 + monitor_hmp_printf(hmp, "%s: %s\n",
405 MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION),
406 MultiFDCompression_str(params->multifd_compression));
407 assert(params->has_zero_page_detection);
411 - monitor_printf(mon, "%s: %s\n",
408 + monitor_hmp_printf(hmp, "%s: %s\n",
409 MigrationParameter_str(MIGRATION_PARAMETER_ZERO_PAGE_DETECTION),
410 qapi_enum_lookup(&ZeroPageDetection_lookup,
411 params->zero_page_detection));
415 - monitor_printf(mon, "%s: %" PRIu64 " bytes\n",
412 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " bytes\n",
413 MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
414 params->xbzrle_cache_size);
415
416 if (s->has_block_bitmap_mapping) {
417 const BitmapMigrationNodeAliasList *bmnal;
418
422 - monitor_printf(mon, "%s:\n",
423 - MigrationParameter_str(
424 - MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING));
419 + monitor_hmp_printf(hmp, "%s:\n",
420 + MigrationParameter_str(
421 + MIGRATION_PARAMETER_BLOCK_BITMAP_MAPPING));
422
423 for (bmnal = params->block_bitmap_mapping;
424 bmnal;
@@ -430,47 +427,47 @@ void hmp_info_migrate_parameters(MonitorHMP *hmp, const QDict *qdict)
427 const BitmapMigrationNodeAlias *bmna = bmnal->value;
428 const BitmapMigrationBitmapAliasList *bmbal;
429
433 - monitor_printf(mon, " '%s' -> '%s'\n",
434 - bmna->node_name, bmna->alias);
430 + monitor_hmp_printf(hmp, " '%s' -> '%s'\n",
431 + bmna->node_name, bmna->alias);
432
433 for (bmbal = bmna->bitmaps; bmbal; bmbal = bmbal->next) {
434 const BitmapMigrationBitmapAlias *bmba = bmbal->value;
435
439 - monitor_printf(mon, " '%s' -> '%s'\n",
440 - bmba->name, bmba->alias);
436 + monitor_hmp_printf(hmp, " '%s' -> '%s'\n",
437 + bmba->name, bmba->alias);
438 }
439 }
440 }
441
445 - monitor_printf(mon, "%s: %" PRIu64 " ms\n",
442 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " ms\n",
443 MigrationParameter_str(MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD),
444 params->x_vcpu_dirty_limit_period);
445
449 - monitor_printf(mon, "%s: %" PRIu64 " MB/s\n",
446 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " MB/s\n",
447 MigrationParameter_str(MIGRATION_PARAMETER_VCPU_DIRTY_LIMIT),
448 params->vcpu_dirty_limit);
449
450 assert(params->has_mode);
454 - monitor_printf(mon, "%s: %s\n",
451 + monitor_hmp_printf(hmp, "%s: %s\n",
452 MigrationParameter_str(MIGRATION_PARAMETER_MODE),
453 qapi_enum_lookup(&MigMode_lookup, params->mode));
454
455 if (params->has_direct_io) {
459 - monitor_printf(mon, "%s: %s\n",
460 - MigrationParameter_str(
461 - MIGRATION_PARAMETER_DIRECT_IO),
462 - params->direct_io ? "on" : "off");
456 + monitor_hmp_printf(hmp, "%s: %s\n",
457 + MigrationParameter_str(
458 + MIGRATION_PARAMETER_DIRECT_IO),
459 + params->direct_io ? "on" : "off");
460 }
461
462 if (params->has_x_rdma_chunk_size) {
466 - monitor_printf(mon, "%s: %" PRIu64 " bytes\n",
467 - MigrationParameter_str(
468 - MIGRATION_PARAMETER_X_RDMA_CHUNK_SIZE),
469 - params->x_rdma_chunk_size);
463 + monitor_hmp_printf(hmp, "%s: %" PRIu64 " bytes\n",
464 + MigrationParameter_str(
465 + MIGRATION_PARAMETER_X_RDMA_CHUNK_SIZE),
466 + params->x_rdma_chunk_size);
467 }
468
469 assert(params->has_cpr_exec_command);
473 - monitor_print_cpr_exec_command(mon, params->cpr_exec_command);
470 + monitor_print_cpr_exec_command(hmp, params->cpr_exec_command);
471 }
472
473 qapi_free_MigrationParameters(params);
@@ -879,8 +876,8 @@ void hmp_migrate(MonitorHMP *hmp, const QDict *qdict)
876 HMPMigrationStatus *status;
877
878 if (!hmp->use_readline) {
882 - monitor_printf(mon, "terminal does not allow synchronous "
883 - "migration, continuing detached\n");
879 + monitor_hmp_printf(hmp, "terminal does not allow synchronous "
880 + "migration, continuing detached\n");
881 return;
882 }
883 monitor_suspend(mon);
monitor/hmp-cmds.c
+60 -81
@@ -105,26 +105,24 @@ strList *hmp_split_at_comma(const char *str)
105
106 void hmp_info_name(MonitorHMP *hmp, const QDict *qdict)
107 {
108 - Monitor *mon = MONITOR(hmp);
108 NameInfo *info;
109
110 info = qmp_query_name(NULL);
111 if (info->name) {
113 - monitor_printf(mon, "%s\n", info->name);
112 + monitor_hmp_printf(hmp, "%s\n", info->name);
113 }
114 qapi_free_NameInfo(info);
115 }
116
117 void hmp_info_version(MonitorHMP *hmp, const QDict *qdict)
118 {
120 - Monitor *mon = MONITOR(hmp);
119 VersionInfo *info;
120
121 info = qmp_query_version(NULL);
122
125 - monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
126 - info->qemu->major, info->qemu->minor, info->qemu->micro,
127 - info->package);
123 + monitor_hmp_printf(hmp, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
124 + info->qemu->major, info->qemu->minor, info->qemu->micro,
125 + info->package);
126
127 qapi_free_VersionInfo(info);
128 }
@@ -145,13 +143,12 @@ void hmp_stop(MonitorHMP *hmp, const QDict *qdict)
143
144 void hmp_sync_profile(MonitorHMP *hmp, const QDict *qdict)
145 {
148 - Monitor *mon = MONITOR(hmp);
146 const char *op = qdict_get_try_str(qdict, "op");
147
148 if (op == NULL) {
149 bool on = qsp_is_enabled();
150
154 - monitor_printf(mon, "sync-profile is %s\n", on ? "on" : "off");
151 + monitor_hmp_printf(hmp, "sync-profile is %s\n", on ? "on" : "off");
152 return;
153 }
154 if (!strcmp(op, "on")) {
@@ -179,14 +176,13 @@ void hmp_exit_preconfig(MonitorHMP *hmp, const QDict *qdict)
176
177 void hmp_cpu(MonitorHMP *hmp, const QDict *qdict)
178 {
182 - Monitor *mon = MONITOR(hmp);
179 int64_t cpu_index;
180
181 /* XXX: drop the monitor_hmp_set_cpu() usage when all HMP commands that
182 use it are converted to the QAPI */
183 cpu_index = qdict_get_int(qdict, "index");
184 if (monitor_hmp_set_cpu(hmp, cpu_index) < 0) {
189 - monitor_printf(mon, "invalid CPU index\n");
185 + monitor_hmp_printf(hmp, "invalid CPU index\n");
186 }
187 }
188
@@ -200,7 +196,6 @@ void hmp_cont(MonitorHMP *hmp, const QDict *qdict)
196
197 void hmp_change(MonitorHMP *hmp, const QDict *qdict)
198 {
203 - Monitor *mon = MONITOR(hmp);
199 const char *device = qdict_get_str(qdict, "device");
200 const char *target = qdict_get_str(qdict, "target");
201 const char *arg = qdict_get_try_str(qdict, "arg");
@@ -210,11 +205,11 @@ void hmp_change(MonitorHMP *hmp, const QDict *qdict)
205
206 #ifdef CONFIG_VNC
207 if (strcmp(device, "vnc") == 0) {
213 - hmp_change_vnc(mon, device, target, arg, read_only, force, &err);
208 + hmp_change_vnc(hmp, device, target, arg, read_only, force, &err);
209 } else
210 #endif
211 {
217 - hmp_change_medium(mon, device, target, arg, read_only, force, &err);
212 + hmp_change_medium(hmp, device, target, arg, read_only, force, &err);
213 }
214
215 hmp_handle_error(hmp, err);
@@ -242,21 +237,20 @@ void hmp_closefd(MonitorHMP *hmp, const QDict *qdict)
237
238 void hmp_info_iothreads(MonitorHMP *hmp, const QDict *qdict)
239 {
245 - Monitor *mon = MONITOR(hmp);
240 IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
241 IOThreadInfoList *info;
242 IOThreadInfo *value;
243
244 for (info = info_list; info; info = info->next) {
245 value = info->value;
252 - monitor_printf(mon, "%s:\n", value->id);
253 - monitor_printf(mon, " thread_id=%" PRId64 "\n", value->thread_id);
254 - monitor_printf(mon, " poll-max-ns=%" PRId64 "\n", value->poll_max_ns);
255 - monitor_printf(mon, " poll-grow=%" PRId64 "\n", value->poll_grow);
256 - monitor_printf(mon, " poll-shrink=%" PRId64 "\n", value->poll_shrink);
257 - monitor_printf(mon, " poll-weight=%" PRId64 "\n", value->poll_weight);
258 - monitor_printf(mon, " aio-max-batch=%" PRId64 "\n",
259 - value->aio_max_batch);
246 + monitor_hmp_printf(hmp, "%s:\n", value->id);
247 + monitor_hmp_printf(hmp, " thread_id=%" PRId64 "\n", value->thread_id);
248 + monitor_hmp_printf(hmp, " poll-max-ns=%" PRId64 "\n", value->poll_max_ns);
249 + monitor_hmp_printf(hmp, " poll-grow=%" PRId64 "\n", value->poll_grow);
250 + monitor_hmp_printf(hmp, " poll-shrink=%" PRId64 "\n", value->poll_shrink);
251 + monitor_hmp_printf(hmp, " poll-weight=%" PRId64 "\n", value->poll_weight);
252 + monitor_hmp_printf(hmp, " aio-max-batch=%" PRId64 "\n",
253 + value->aio_max_batch);
254 }
255
256 qapi_free_IOThreadInfoList(info_list);
@@ -264,26 +258,23 @@ void hmp_info_iothreads(MonitorHMP *hmp, const QDict *qdict)
258
259 void hmp_help(MonitorHMP *hmp, const QDict *qdict)
260 {
267 - Monitor *mon = MONITOR(hmp);
268 - hmp_help_cmd(mon, qdict_get_try_str(qdict, "name"));
261 + hmp_help_cmd(hmp, qdict_get_try_str(qdict, "name"));
262 }
263
264 void hmp_clear(MonitorHMP *hmp, const QDict *qdict)
265 {
273 - Monitor *mon = MONITOR(hmp);
266 /*
267 * Send an ANSI escape sequence:
268 * "\x1b[H" - move cursor to top-left
269 * "\x1b[2J" - clear visible screen
270 * "\x1b[3J" - clear scrollback
271 */
280 - monitor_printf(mon, "\x1b[H\x1b[2J\x1b[3J");
272 + monitor_hmp_printf(hmp, "\x1b[H\x1b[2J\x1b[3J");
273 }
274
275 void hmp_info_help(MonitorHMP *hmp, const QDict *qdict)
276 {
285 - Monitor *mon = MONITOR(hmp);
286 - hmp_help_cmd(mon, "info");
277 + hmp_help_cmd(hmp, "info");
278 }
279
280 void hmp_info_sync_profile(MonitorHMP *hmp, const QDict *qdict)
@@ -299,7 +290,6 @@ void hmp_info_sync_profile(MonitorHMP *hmp, const QDict *qdict)
290
291 void hmp_info_history(MonitorHMP *hmp, const QDict *qdict)
292 {
302 - Monitor *mon = MONITOR(hmp);
293 int i;
294 const char *str;
295
@@ -312,7 +302,7 @@ void hmp_info_history(MonitorHMP *hmp, const QDict *qdict)
302 if (!str) {
303 break;
304 }
315 - monitor_printf(mon, "%d: '%s'\n", i, str);
305 + monitor_hmp_printf(hmp, "%d: '%s'\n", i, str);
306 i++;
307 }
308 }
@@ -328,7 +318,6 @@ void hmp_logfile(MonitorHMP *hmp, const QDict *qdict)
318
319 void hmp_log(MonitorHMP *hmp, const QDict *qdict)
320 {
331 - Monitor *mon = MONITOR(hmp);
321 int mask;
322 const char *items = qdict_get_str(qdict, "items");
323 Error *err = NULL;
@@ -338,7 +327,7 @@ void hmp_log(MonitorHMP *hmp, const QDict *qdict)
327 } else {
328 mask = qemu_str_to_log_mask(items);
329 if (!mask) {
341 - hmp_help_cmd(mon, "log");
330 + hmp_help_cmd(hmp, "log");
331 return;
332 }
333 }
@@ -350,7 +339,6 @@ void hmp_log(MonitorHMP *hmp, const QDict *qdict)
339
340 void hmp_gdbserver(MonitorHMP *hmp, const QDict *qdict)
341 {
353 - Monitor *mon = MONITOR(hmp);
342 Error *err = NULL;
343 const char *device = qdict_get_try_str(qdict, "device");
344
@@ -361,43 +349,41 @@ void hmp_gdbserver(MonitorHMP *hmp, const QDict *qdict)
349 if (!gdbserver_start(device, &err)) {
350 error_report_err(err);
351 } else if (strcmp(device, "none") == 0) {
364 - monitor_printf(mon, "Disabled gdbserver\n");
352 + monitor_hmp_printf(hmp, "Disabled gdbserver\n");
353 } else {
366 - monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
367 - device);
354 + monitor_hmp_printf(hmp, "Waiting for gdb connection on device '%s'\n",
355 + device);
356 }
357 }
358
359 void hmp_print(MonitorHMP *hmp, const QDict *qdict)
360 {
373 - Monitor *mon = MONITOR(hmp);
361 int format = qdict_get_int(qdict, "format");
362 hwaddr val = qdict_get_int(qdict, "val");
363
364 switch(format) {
365 case 'o':
379 - monitor_printf(mon, "%#" HWADDR_PRIo, val);
366 + monitor_hmp_printf(hmp, "0x%" HWADDR_PRIo, val);
367 break;
368 case 'x':
382 - monitor_printf(mon, "%#" HWADDR_PRIx, val);
369 + monitor_hmp_printf(hmp, "0x%" HWADDR_PRIx, val);
370 break;
371 case 'u':
385 - monitor_printf(mon, "%" HWADDR_PRIu, val);
372 + monitor_hmp_printf(hmp, "%" HWADDR_PRIu, val);
373 break;
374 default:
375 case 'd':
389 - monitor_printf(mon, "%" HWADDR_PRId, val);
376 + monitor_hmp_printf(hmp, "%" HWADDR_PRId, val);
377 break;
378 case 'c':
392 - monitor_printc(mon, val);
379 + monitor_hmp_printc(hmp, val);
380 break;
381 }
395 - monitor_printf(mon, "\n");
382 + monitor_hmp_printf(hmp, "\n");
383 }
384
385 void hmp_sum(MonitorHMP *hmp, const QDict *qdict)
386 {
400 - Monitor *mon = MONITOR(hmp);
387 uint32_t addr;
388 uint16_t sum;
389 uint32_t start = qdict_get_int(qdict, "start");
@@ -411,12 +397,11 @@ void hmp_sum(MonitorHMP *hmp, const QDict *qdict)
397 sum = (sum >> 1) | (sum << 15);
398 sum += val;
399 }
414 - monitor_printf(mon, "%05d\n", sum);
400 + monitor_hmp_printf(hmp, "%05d\n", sum);
401 }
402
403 void hmp_ioport_read(MonitorHMP *hmp, const QDict *qdict)
404 {
419 - Monitor *mon = MONITOR(hmp);
405 int size = qdict_get_int(qdict, "size");
406 int addr = qdict_get_int(qdict, "addr");
407 int has_index = qdict_haskey(qdict, "index");
@@ -445,8 +430,8 @@ void hmp_ioport_read(MonitorHMP *hmp, const QDict *qdict)
430 suffix = 'l';
431 break;
432 }
448 - monitor_printf(mon, "port%c[0x%04x] = 0x%0*x\n",
449 - suffix, addr, size * 2, val);
433 + monitor_hmp_printf(hmp, "port%c[0x%04x] = 0x%0*x\n",
434 + suffix, addr, size * 2, val);
435 }
436
437 void hmp_ioport_write(MonitorHMP *hmp, const QDict *qdict)
@@ -473,7 +458,6 @@ void hmp_ioport_write(MonitorHMP *hmp, const QDict *qdict)
458
459 void hmp_boot_set(MonitorHMP *hmp, const QDict *qdict)
460 {
476 - Monitor *mon = MONITOR(hmp);
461 Error *local_err = NULL;
462 const char *bootdevice = qdict_get_str(qdict, "bootdevice");
463
@@ -481,7 +465,7 @@ void hmp_boot_set(MonitorHMP *hmp, const QDict *qdict)
465 if (local_err) {
466 error_report_err(local_err);
467 } else {
484 - monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
468 + monitor_hmp_printf(hmp, "boot device list now set to %s\n", bootdevice);
469 }
470 }
471
@@ -507,7 +491,7 @@ void hmp_dumpdtb(MonitorHMP *hmp, const QDict *qdict)
491 return;
492 }
493
510 - monitor_printf(MONITOR(hmp), "DTB dumped to '%s'\n", filename);
494 + monitor_hmp_printf(hmp, "DTB dumped to '%s'\n", filename);
495 }
496 #endif
497
@@ -573,14 +557,13 @@ int monitor_hmp_get_cpu_index(MonitorHMP *hmp)
557
558 void hmp_info_registers(MonitorHMP *hmp, const QDict *qdict)
559 {
576 - Monitor *mon = MONITOR(hmp);
560 bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
561 int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
562 CPUState *cs;
563
564 if (all_cpus) {
565 CPU_FOREACH(cs) {
583 - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
566 + monitor_hmp_printf(hmp, "\nCPU#%d\n", cs->cpu_index);
567 cpu_dump_state(cs, NULL, CPU_DUMP_FPU | CPU_DUMP_VPU);
568 }
569 } else {
@@ -588,14 +571,14 @@ void hmp_info_registers(MonitorHMP *hmp, const QDict *qdict)
571
572 if (!cs) {
573 if (vcpu >= 0) {
591 - monitor_printf(mon, "CPU#%d not available\n", vcpu);
574 + monitor_hmp_printf(hmp, "CPU#%d not available\n", vcpu);
575 } else {
593 - monitor_printf(mon, "No CPU available\n");
576 + monitor_hmp_printf(hmp, "No CPU available\n");
577 }
578 return;
579 }
580
598 - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
581 + monitor_hmp_printf(hmp, "\nCPU#%d\n", cs->cpu_index);
582 cpu_dump_state(cs, NULL, CPU_DUMP_FPU | CPU_DUMP_VPU);
583 }
584 }
@@ -603,7 +586,6 @@ void hmp_info_registers(MonitorHMP *hmp, const QDict *qdict)
586 static void memory_dump(MonitorHMP *hmp, int count, int format, int wsize,
587 uint64_t addr, bool is_physical)
588 {
606 - Monitor *mon = MONITOR(hmp);
589 int l, line_size, i, max_digits, len;
590 uint8_t buf[16];
591 uint64_t v;
@@ -612,12 +594,12 @@ static void memory_dump(MonitorHMP *hmp, int count, int format, int wsize,
594 const bool big_endian = target_big_endian();
595
596 if (!cs && (format == 'i' || !is_physical)) {
615 - monitor_printf(mon, "Can not dump without CPU\n");
597 + monitor_hmp_printf(hmp, "Can not dump without CPU\n");
598 return;
599 }
600
601 if (format == 'i') {
620 - monitor_disas(mon, cs, addr, count, is_physical);
602 + monitor_disas(hmp, cs, addr, count, is_physical);
603 return;
604 }
605
@@ -647,7 +629,7 @@ static void memory_dump(MonitorHMP *hmp, int count, int format, int wsize,
629 }
630
631 while (len > 0) {
650 - monitor_printf(mon, "%0*" PRIx64 ":", addr_width, addr);
632 + monitor_hmp_printf(hmp, "%0*" PRIx64 ":", addr_width, addr);
633 l = len;
634 if (l > line_size) {
635 l = line_size;
@@ -657,12 +639,12 @@ static void memory_dump(MonitorHMP *hmp, int count, int format, int wsize,
639 MemTxResult r = address_space_read(as, addr,
640 MEMTXATTRS_UNSPECIFIED, buf, l);
641 if (r != MEMTX_OK) {
660 - monitor_printf(mon, " Cannot access memory\n");
642 + monitor_hmp_printf(hmp, " Cannot access memory\n");
643 break;
644 }
645 } else {
646 if (cpu_memory_rw_debug(cs, addr, buf, l, 0) < 0) {
665 - monitor_printf(mon, " Cannot access memory\n");
647 + monitor_hmp_printf(hmp, " Cannot access memory\n");
648 break;
649 }
650 }
@@ -683,27 +665,27 @@ static void memory_dump(MonitorHMP *hmp, int count, int format, int wsize,
665 v = (big_endian ? ldq_be_p : ldq_le_p)(buf + i);
666 break;
667 }
686 - monitor_printf(mon, " ");
668 + monitor_hmp_printf(hmp, " ");
669 switch (format) {
670 case 'o':
689 - monitor_printf(mon, "0%*" PRIo64, max_digits, v);
671 + monitor_hmp_printf(hmp, "0%*" PRIo64, max_digits, v);
672 break;
673 case 'x':
692 - monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
674 + monitor_hmp_printf(hmp, "0x%0*" PRIx64, max_digits, v);
675 break;
676 case 'u':
695 - monitor_printf(mon, "%*" PRIu64, max_digits, v);
677 + monitor_hmp_printf(hmp, "%*" PRIu64, max_digits, v);
678 break;
679 case 'd':
698 - monitor_printf(mon, "%*" PRId64, max_digits, v);
680 + monitor_hmp_printf(hmp, "%*" PRId64, max_digits, v);
681 break;
682 case 'c':
701 - monitor_printc(mon, v);
683 + monitor_hmp_printc(hmp, v);
684 break;
685 }
686 i += wsize;
687 }
706 - monitor_printf(mon, "\n");
688 + monitor_hmp_printf(hmp, "\n");
689 addr += l;
690 len -= l;
691 }
@@ -731,7 +713,6 @@ void hmp_physical_memory_dump(MonitorHMP *hmp, const QDict *qdict)
713
714 void hmp_gpa2hva(MonitorHMP *hmp, const QDict *qdict)
715 {
734 - Monitor *mon = MONITOR(hmp);
716 hwaddr addr = qdict_get_int(qdict, "addr");
717 Error *local_err = NULL;
718 MemoryRegion *mr = NULL;
@@ -743,29 +724,28 @@ void hmp_gpa2hva(MonitorHMP *hmp, const QDict *qdict)
724 return;
725 }
726
746 - monitor_printf(mon, "Host virtual address for 0x%" HWADDR_PRIx
747 - " (%s) is %p\n",
748 - addr, mr->name, ptr);
727 + monitor_hmp_printf(hmp, "Host virtual address for 0x%" HWADDR_PRIx
728 + " (%s) is %p\n",
729 + addr, mr->name, ptr);
730
731 memory_region_unref(mr);
732 }
733
734 void hmp_gva2gpa(MonitorHMP *hmp, const QDict *qdict)
735 {
755 - Monitor *mon = MONITOR(hmp);
736 vaddr addr = qdict_get_int(qdict, "addr");
737 CPUState *cs = monitor_hmp_get_cpu(hmp);
738 TranslateForDebugResult tres;
739
740 if (!cs) {
761 - monitor_printf(mon, "No cpu\n");
741 + monitor_hmp_printf(hmp, "No cpu\n");
742 return;
743 }
744
745 if (!cpu_translate_for_debug(cs, addr, &tres)) {
766 - monitor_printf(mon, "Unmapped\n");
746 + monitor_hmp_printf(hmp, "Unmapped\n");
747 } else {
768 - monitor_printf(mon, "gpa: 0x%" HWADDR_PRIx "\n", tres.physaddr);
748 + monitor_hmp_printf(hmp, "gpa: 0x%" HWADDR_PRIx "\n", tres.physaddr);
749 }
750 }
751
@@ -806,7 +786,6 @@ out:
786
787 void hmp_gpa2hpa(MonitorHMP *hmp, const QDict *qdict)
788 {
809 - Monitor *mon = MONITOR(hmp);
789 hwaddr addr = qdict_get_int(qdict, "addr");
790 Error *local_err = NULL;
791 MemoryRegion *mr = NULL;
@@ -823,9 +802,9 @@ void hmp_gpa2hpa(MonitorHMP *hmp, const QDict *qdict)
802 if (local_err) {
803 error_report_err(local_err);
804 } else {
826 - monitor_printf(mon, "Host physical address for 0x%" HWADDR_PRIx
827 - " (%s) is 0x%" PRIx64 "\n",
828 - addr, mr->name, (uint64_t) physaddr);
805 + monitor_hmp_printf(hmp, "Host physical address for 0x%" HWADDR_PRIx
806 + " (%s) is 0x%" PRIx64 "\n",
807 + addr, mr->name, (uint64_t) physaddr);
808 }
809
810 memory_region_unref(mr);
monitor/hmp.c
+66 -77
@@ -80,8 +80,6 @@ static void monitor_hmp_set_readline(Object *obj, bool val, Error **errp)
80 hmp->use_readline = val;
81 }
82
83 -int monitor_hmp_vprintf(Monitor *mon, const char *fmt, va_list ap)
84 - G_GNUC_PRINTF(2, 0);
83 static void monitor_hmp_accept_input(Monitor *mon);
84 static void monitor_hmp_complete(UserCreatable *uc, Error **errp);
85 static bool monitor_hmp_prepare_delete(UserCreatable *uc, Error **errp);
@@ -95,7 +93,6 @@ static void monitor_hmp_class_init(ObjectClass *cls, const void *data)
93 monitor_hmp_get_readline,
94 monitor_hmp_set_readline);
95
98 - moncls->vprintf = monitor_hmp_vprintf;
96 moncls->accept_input = monitor_hmp_accept_input;
97
98 ucc->complete = monitor_hmp_complete;
@@ -114,12 +111,6 @@ static void monitor_hmp_init(Object *obj)
111 hmp->use_readline = true;
112 }
113
117 -int monitor_hmp_vprintf(Monitor *mon, const char *fmt, va_list ap)
118 -{
119 - g_autofree char *buf = g_strdup_vprintf(fmt, ap);
120 - return monitor_puts(mon, buf);
121 -}
122 -
114 static void monitor_hmp_accept_input(Monitor *mon)
115 {
116 qemu_mutex_lock(&mon->mon_lock);
@@ -166,8 +157,7 @@ int monitor_hmp_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
157 /* prompt is printed on return from the command handler */
158 return 0;
159 } else {
169 - monitor_printf(&hmp->parent_obj,
170 - "terminal does not support password prompting\n");
160 + monitor_hmp_printf(hmp, "terminal does not support password prompting\n");
161 return -ENOTTY;
162 }
163 }
@@ -319,7 +309,7 @@ static bool cmd_available(const HMPCommand *cmd)
309 return phase_check(PHASE_MACHINE_READY) || cmd_can_preconfig(cmd);
310 }
311
322 -static void help_cmd_dump_one(Monitor *mon,
312 +static void help_cmd_dump_one(MonitorHMP *mon,
313 const HMPCommand *cmd,
314 char **prefix_args,
315 int prefix_args_nb)
@@ -331,13 +321,13 @@ static void help_cmd_dump_one(Monitor *mon,
321 }
322
323 for (i = 0; i < prefix_args_nb; i++) {
334 - monitor_printf(mon, "%s ", prefix_args[i]);
324 + monitor_hmp_printf(mon, "%s ", prefix_args[i]);
325 }
336 - monitor_printf(mon, "%s %s -- %s\n", cmd->name, cmd->params, cmd->help);
326 + monitor_hmp_printf(mon, "%s %s -- %s\n", cmd->name, cmd->params, cmd->help);
327 }
328
329 /* @args[@arg_index] is the valid command need to find in @cmds */
340 -static void help_cmd_dump(Monitor *mon, const HMPCommand *cmds,
330 +static void help_cmd_dump(MonitorHMP *mon, const HMPCommand *cmds,
331 char **args, int nb_args, int arg_index)
332 {
333 const HMPCommand *cmd;
@@ -367,13 +357,13 @@ static void help_cmd_dump(Monitor *mon, const HMPCommand *cmds,
357 }
358
359 /* Command not found */
370 - monitor_printf(mon, "unknown command: '");
360 + monitor_hmp_printf(mon, "unknown command: '");
361 for (i = 0; i <= arg_index; i++) {
372 - monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
362 + monitor_hmp_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
363 }
364 }
365
376 -void hmp_help_cmd(Monitor *mon, const char *name)
366 +void hmp_help_cmd(MonitorHMP *mon, const char *name)
367 {
368 char *args[MAX_ARGS];
369 int nb_args = 0;
@@ -383,15 +373,15 @@ void hmp_help_cmd(Monitor *mon, const char *name)
373 /* special case for log, directly dump and return */
374 if (!strcmp(name, "log")) {
375 const QEMULogItem *item;
386 - monitor_printf(mon, "Log items (comma separated):\n");
387 - monitor_printf(mon, "%-15s %s\n", "none", "remove all logs");
376 + monitor_hmp_printf(mon, "Log items (comma separated):\n");
377 + monitor_hmp_printf(mon, "%-15s %s\n", "none", "remove all logs");
378 for (item = qemu_log_items; item->mask != 0; item++) {
389 - monitor_printf(mon, "%-15s %s\n", item->name, item->help);
379 + monitor_hmp_printf(mon, "%-15s %s\n", item->name, item->help);
380 }
381 #ifdef CONFIG_TRACE_LOG
392 - monitor_printf(mon, "trace:PATTERN enable trace events\n");
393 - monitor_printf(mon, "\nUse \"log trace:help\" to get a list of "
394 - "trace events.\n\n");
382 + monitor_hmp_printf(mon, "trace:PATTERN enable trace events\n");
383 + monitor_hmp_printf(mon, "\nUse \"log trace:help\" to get a list of "
384 + "trace events.\n\n");
385 #endif
386 return;
387 }
@@ -455,12 +445,12 @@ static sigjmp_buf expr_env;
445 static int get_monitor_def(MonitorHMP *mon, int64_t *pval, const char *name);
446
447 static G_NORETURN G_GNUC_PRINTF(2, 3)
458 -void expr_error(Monitor *mon, const char *fmt, ...)
448 +void expr_error(MonitorHMP *mon, const char *fmt, ...)
449 {
450 va_list ap;
451 va_start(ap, fmt);
462 - monitor_vprintf(mon, fmt, ap);
463 - monitor_printf(mon, "\n");
452 + monitor_hmp_vprintf(mon, fmt, ap);
453 + monitor_hmp_printf(mon, "\n");
454 va_end(ap);
455 siglongjmp(expr_env, 1);
456 }
@@ -475,9 +465,9 @@ static void next(void)
465 }
466 }
467
478 -static int64_t expr_sum(Monitor *mon);
468 +static int64_t expr_sum(MonitorHMP *mon);
469
480 -static int64_t expr_unary(Monitor *mon)
470 +static int64_t expr_unary(MonitorHMP *mon)
471 {
472 int64_t n;
473 char *p;
@@ -535,8 +525,8 @@ static int64_t expr_unary(Monitor *mon)
525 pch++;
526 }
527 *q = 0;
538 - if (!gdb_get_register(MONITOR_HMP(mon), &reg, buf)
539 - && get_monitor_def(MONITOR_HMP(mon), &reg, buf) < 0) {
528 + if (!gdb_get_register(mon, &reg, buf)
529 + && get_monitor_def(mon, &reg, buf) < 0) {
530 expr_error(mon, "unknown register");
531 }
532 n = reg;
@@ -564,7 +554,7 @@ static int64_t expr_unary(Monitor *mon)
554 return n;
555 }
556
567 -static int64_t expr_prod(Monitor *mon)
557 +static int64_t expr_prod(MonitorHMP *mon)
558 {
559 int64_t val, val2;
560 int op;
@@ -598,7 +588,7 @@ static int64_t expr_prod(Monitor *mon)
588 return val;
589 }
590
601 -static int64_t expr_logic(Monitor *mon)
591 +static int64_t expr_logic(MonitorHMP *mon)
592 {
593 int64_t val, val2;
594 int op;
@@ -627,7 +617,7 @@ static int64_t expr_logic(Monitor *mon)
617 return val;
618 }
619
630 -static int64_t expr_sum(Monitor *mon)
620 +static int64_t expr_sum(MonitorHMP *mon)
621 {
622 int64_t val, val2;
623 int op;
@@ -649,7 +639,7 @@ static int64_t expr_sum(Monitor *mon)
639 return val;
640 }
641
652 -static int get_expr(Monitor *mon, int64_t *pval, const char **pp)
642 +static int get_expr(MonitorHMP *mon, int64_t *pval, const char **pp)
643 {
644 pch = *pp;
645 if (sigsetjmp(expr_env, 0)) {
@@ -664,7 +654,7 @@ static int get_expr(Monitor *mon, int64_t *pval, const char **pp)
654 return 0;
655 }
656
667 -static int get_double(Monitor *mon, double *pval, const char **pp)
657 +static int get_double(MonitorHMP *mon, double *pval, const char **pp)
658 {
659 const char *p = *pp;
660 char *tailp;
@@ -672,12 +662,12 @@ static int get_double(Monitor *mon, double *pval, const char **pp)
662
663 d = strtod(p, &tailp);
664 if (tailp == p) {
675 - monitor_printf(mon, "Number expected\n");
665 + monitor_hmp_printf(mon, "Number expected\n");
666 return -1;
667 }
668 if (d != d || d - d != 0) {
669 /* NaN or infinity */
680 - monitor_printf(mon, "Bad number\n");
670 + monitor_hmp_printf(mon, "Bad number\n");
671 return -1;
672 }
673 *pval = d;
@@ -788,7 +778,6 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
778 const char **cmdp,
779 HMPCommand *table)
780 {
791 - Monitor *mon = &hmp->parent_obj;
781 const char *p;
782 const HMPCommand *cmd;
783 char cmdname[256];
@@ -801,14 +790,14 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
790
791 cmd = search_dispatch_table(table, cmdname);
792 if (!cmd) {
804 - monitor_printf(mon, "unknown command: '%.*s'\n",
805 - (int)(p - cmdp_start), cmdp_start);
793 + monitor_hmp_printf(hmp, "unknown command: '%.*s'\n",
794 + (int)(p - cmdp_start), cmdp_start);
795 return NULL;
796 }
797 if (!cmd_available(cmd)) {
809 - monitor_printf(mon, "Command '%.*s' not available "
810 - "until machine initialization has completed.\n",
811 - (int)(p - cmdp_start), cmdp_start);
798 + monitor_hmp_printf(hmp, "Command '%.*s' not available "
799 + "until machine initialization has completed.\n",
800 + (int)(p - cmdp_start), cmdp_start);
801 return NULL;
802 }
803
@@ -832,7 +821,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
821 * Else, insert command arguments into a QDict, and return it.
822 * Note: On success, caller has to free the QDict structure.
823 */
835 -static QDict *monitor_parse_arguments(Monitor *mon,
824 +static QDict *monitor_parse_arguments(MonitorHMP *mon,
825 const char **endp,
826 const HMPCommand *cmd)
827 {
@@ -873,15 +862,15 @@ static QDict *monitor_parse_arguments(Monitor *mon,
862 if (ret < 0) {
863 switch (c) {
864 case 'F':
876 - monitor_printf(mon, "%s: filename expected\n",
877 - cmd->name);
865 + monitor_hmp_printf(mon, "%s: filename expected\n",
866 + cmd->name);
867 break;
868 case 'B':
880 - monitor_printf(mon, "%s: block device name expected\n",
881 - cmd->name);
869 + monitor_hmp_printf(mon, "%s: block device name expected\n",
870 + cmd->name);
871 break;
872 default:
884 - monitor_printf(mon, "%s: string expected\n", cmd->name);
873 + monitor_hmp_printf(mon, "%s: string expected\n", cmd->name);
874 break;
875 }
876 goto fail;
@@ -968,8 +957,8 @@ static QDict *monitor_parse_arguments(Monitor *mon,
957 }
958 next:
959 if (*p != '\0' && !qemu_isspace(*p)) {
971 - monitor_printf(mon, "invalid char in format: '%c'\n",
972 - *p);
960 + monitor_hmp_printf(mon, "invalid char in format: '%c'\n",
961 + *p);
962 goto fail;
963 }
964 if (format < 0) {
@@ -1030,12 +1019,12 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1019 }
1020 /* Check if 'i' is greater than 32-bit */
1021 if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
1033 - monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
1034 - monitor_printf(mon, "integer is for 32-bit values\n");
1022 + monitor_hmp_printf(mon, "\'%s\' has failed: ", cmd->name);
1023 + monitor_hmp_printf(mon, "integer is for 32-bit values\n");
1024 goto fail;
1025 } else if (c == 'M') {
1026 if (val < 0) {
1038 - monitor_printf(mon, "enter a positive value\n");
1027 + monitor_hmp_printf(mon, "enter a positive value\n");
1028 goto fail;
1029 }
1030 val *= MiB;
@@ -1060,7 +1049,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1049 }
1050 ret = qemu_strtosz_MiB(p, &end, &val);
1051 if (ret < 0 || val > INT64_MAX) {
1063 - monitor_printf(mon, "invalid size\n");
1052 + monitor_hmp_printf(mon, "invalid size\n");
1053 goto fail;
1054 }
1055 qdict_put_int(qdict, key, val);
@@ -1094,7 +1083,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1083 }
1084 }
1085 if (*p && !qemu_isspace(*p)) {
1097 - monitor_printf(mon, "Unknown unit suffix\n");
1086 + monitor_hmp_printf(mon, "Unknown unit suffix\n");
1087 goto fail;
1088 }
1089 qdict_put(qdict, key, qnum_from_double(val));
@@ -1117,7 +1106,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1106 } else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {
1107 val = false;
1108 } else {
1120 - monitor_printf(mon, "Expected 'on' or 'off'\n");
1109 + monitor_hmp_printf(mon, "Expected 'on' or 'off'\n");
1110 goto fail;
1111 }
1112 qdict_put_bool(qdict, key, val);
@@ -1141,8 +1130,8 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1130 p++;
1131 if (c != *p) {
1132 if (!is_valid_option(p, typestr)) {
1144 - monitor_printf(mon, "%s: unsupported option -%c\n",
1145 - cmd->name, *p);
1133 + monitor_hmp_printf(mon, "%s: unsupported option -%c\n",
1134 + cmd->name, *p);
1135 goto fail;
1136 } else {
1137 skip_key = 1;
@@ -1159,8 +1148,8 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1148 }
1149 ret = get_str(buf, sizeof(buf), &p);
1150 if (ret < 0) {
1162 - monitor_printf(mon, "%s: value expected for -%c\n",
1163 - cmd->name, *tmp);
1151 + monitor_hmp_printf(mon, "%s: value expected for -%c\n",
1152 + cmd->name, *tmp);
1153 goto fail;
1154 }
1155 qdict_put_str(qdict, key, buf);
@@ -1191,8 +1180,8 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1180 }
1181 len = strlen(p);
1182 if (len <= 0) {
1194 - monitor_printf(mon, "%s: string expected\n",
1195 - cmd->name);
1183 + monitor_hmp_printf(mon, "%s: string expected\n",
1184 + cmd->name);
1185 goto fail;
1186 }
1187 qdict_put_str(qdict, key, p);
@@ -1201,7 +1190,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1190 break;
1191 default:
1192 bad_type:
1204 - monitor_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
1193 + monitor_hmp_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
1194 goto fail;
1195 }
1196 g_free(key);
@@ -1212,8 +1201,8 @@ static QDict *monitor_parse_arguments(Monitor *mon,
1201 p++;
1202 }
1203 if (*p != '\0') {
1215 - monitor_printf(mon, "%s: extraneous characters at the end of line\n",
1216 - cmd->name);
1204 + monitor_hmp_printf(mon, "%s: extraneous characters at the end of line\n",
1205 + cmd->name);
1206 goto fail;
1207 }
1208
@@ -1281,19 +1270,19 @@ void handle_hmp_command(MonitorHMP *hmp, const char *cmdline)
1270
1271 if (!cmd->cmd && !cmd->cmd_info_hrt) {
1272 /* FIXME: is it useful to try autoload modules here ??? */
1284 - monitor_printf(&hmp->parent_obj, "Command \"%.*s\" is not available.\n",
1285 - (int)(cmdline - cmd_start), cmd_start);
1273 + monitor_hmp_printf(hmp, "Command \"%.*s\" is not available.\n",
1274 + (int)(cmdline - cmd_start), cmd_start);
1275 return;
1276 }
1277
1289 - qdict = monitor_parse_arguments(&hmp->parent_obj, &cmdline, cmd);
1278 + qdict = monitor_parse_arguments(hmp, &cmdline, cmd);
1279 if (!qdict) {
1280 while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {
1281 cmdline--;
1282 }
1294 - monitor_printf(&hmp->parent_obj,
1295 - "Try \"help %.*s\" for more information\n",
1296 - (int)(cmdline - cmd_start), cmd_start);
1283 + monitor_hmp_printf(hmp,
1284 + "Try \"help %.*s\" for more information\n",
1285 + (int)(cmdline - cmd_start), cmd_start);
1286 return;
1287 }
1288
@@ -1539,7 +1528,7 @@ static void monitor_read(void *opaque, const uint8_t *buf, int size)
1528 }
1529 } else {
1530 if (size == 0 || buf[size - 1] != 0) {
1542 - monitor_printf(&hmp->parent_obj, "corrupted command\n");
1531 + monitor_hmp_printf(hmp, "corrupted command\n");
1532 } else {
1533 handle_hmp_command(hmp, (char *)buf);
1534 }
@@ -1580,8 +1569,8 @@ static void monitor_event(void *opaque, QEMUChrEvent event)
1569 break;
1570
1571 case CHR_EVENT_OPENED:
1583 - monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
1584 - "information\n", QEMU_VERSION);
1572 + monitor_hmp_printf(hmp, "QEMU %s monitor - type 'help' for more "
1573 + "information\n", QEMU_VERSION);
1574 qemu_mutex_lock(&mon->mon_lock);
1575 hmp->reset_seen = 1;
1576 if (!mon->mux_out && hmp->use_readline) {
@@ -1613,7 +1602,7 @@ static void G_GNUC_PRINTF(2, 3) monitor_readline_printf(void *opaque,
1602 MonitorHMP *hmp = opaque;
1603 va_list ap;
1604 va_start(ap, fmt);
1616 - monitor_vprintf(&hmp->parent_obj, fmt, ap);
1605 + monitor_hmp_vprintf(hmp, fmt, ap);
1606 va_end(ap);
1607 }
1608
monitor/monitor-internal.h
-6
@@ -108,12 +108,6 @@ typedef struct HMPCommand {
108 struct MonitorClass {
109 ObjectClass parent_class;
110
111 - /*
112 - * If non-NULL, the monitor is able to print messages
113 - * for attention of the client user
114 - */
115 - int (*vprintf)(Monitor *mon, const char *fmt, va_list ap)
116 - G_GNUC_PRINTF(2, 0);
111 /*
112 * If non-NULL, the monitor is able to send event
113 * notifications back to the client
monitor/monitor.c
+14 -19
@@ -272,58 +272,53 @@ int monitor_puts(Monitor *mon, const char *str)
272 return monitor_puts_locked(mon, str);
273 }
274
275 -int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
275 +int monitor_hmp_vprintf(MonitorHMP *mon, const char *fmt, va_list ap)
276 {
277 - MonitorClass *moncls;
277 + g_autofree char *buf = g_strdup_vprintf(fmt, ap);
278
279 if (!mon) {
280 return -1;
281 }
282
283 - moncls = MONITOR_GET_CLASS(mon);
284 - if (!moncls->vprintf) {
285 - return -1;
286 - }
287 -
288 - return moncls->vprintf(mon, fmt, ap);
283 + return monitor_puts(MONITOR(mon), buf);
284 }
285
291 -int monitor_printf(Monitor *mon, const char *fmt, ...)
286 +int monitor_hmp_printf(MonitorHMP *mon, const char *fmt, ...)
287 {
288 int ret;
289
290 va_list ap;
291 va_start(ap, fmt);
297 - ret = monitor_vprintf(mon, fmt, ap);
292 + ret = monitor_hmp_vprintf(mon, fmt, ap);
293 va_end(ap);
294 return ret;
295 }
296
302 -void monitor_printc(Monitor *mon, int c)
297 +void monitor_hmp_printc(MonitorHMP *mon, int c)
298 {
304 - monitor_printf(mon, "'");
299 + monitor_hmp_printf(mon, "'");
300 switch(c) {
301 case '\'':
307 - monitor_printf(mon, "\\'");
302 + monitor_hmp_printf(mon, "\\'");
303 break;
304 case '\\':
310 - monitor_printf(mon, "\\\\");
305 + monitor_hmp_printf(mon, "\\\\");
306 break;
307 case '\n':
313 - monitor_printf(mon, "\\n");
308 + monitor_hmp_printf(mon, "\\n");
309 break;
310 case '\r':
316 - monitor_printf(mon, "\\r");
311 + monitor_hmp_printf(mon, "\\r");
312 break;
313 default:
314 if (c >= 32 && c <= 126) {
320 - monitor_printf(mon, "%c", c);
315 + monitor_hmp_printf(mon, "%c", c);
316 } else {
322 - monitor_printf(mon, "\\x%02x", c);
317 + monitor_hmp_printf(mon, "\\x%02x", c);
318 }
319 break;
320 }
326 - monitor_printf(mon, "'");
321 + monitor_hmp_printf(mon, "'");
322 }
323
324 static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
net/net-hmp-cmds.c
+15 -16
@@ -28,26 +28,25 @@
28 #include "qemu/help_option.h"
29 #include "qemu/option.h"
30
31 -static void hmp_print_client_info(Monitor *mon, NetworkClientInfo *ci)
31 +static void hmp_print_client_info(MonitorHMP *hmp, NetworkClientInfo *ci)
32 {
33 NetFilterInfoList *f;
34
35 - monitor_printf(mon, "%s: index=%" PRIu32 ",type=%s,%s\n",
36 - ci->name, ci->queue_index,
37 - NetClientDriver_str(ci->type), ci->info_str);
35 + monitor_hmp_printf(hmp, "%s: index=%" PRIu32 ",type=%s,%s\n",
36 + ci->name, ci->queue_index,
37 + NetClientDriver_str(ci->type), ci->info_str);
38 if (ci->filters) {
39 - monitor_printf(mon, "filters:\n");
39 + monitor_hmp_printf(hmp, "filters:\n");
40 for (f = ci->filters; f; f = f->next) {
41 - monitor_printf(mon, " - %s: type=%s%s%s\n",
42 - f->value->name, f->value->type,
43 - f->value->info[0] ? "," : "", f->value->info);
41 + monitor_hmp_printf(hmp, " - %s: type=%s%s%s\n",
42 + f->value->name, f->value->type,
43 + f->value->info[0] ? "," : "", f->value->info);
44 }
45 }
46 }
47
48 void hmp_info_network(MonitorHMP *hmp, const QDict *qdict)
49 {
50 - Monitor *mon = MONITOR(hmp);
50 Error *err = NULL;
51 g_autoptr(NetworkInfo) info = qmp_x_query_network(&err);
52 NetHubInfoList *h;
@@ -60,13 +59,13 @@ void hmp_info_network(MonitorHMP *hmp, const QDict *qdict)
59 for (h = info->hubs; h; h = h->next) {
60 NetHubPortInfoList *p;
61
63 - monitor_printf(mon, "hub %d\n", (int)h->value->id);
62 + monitor_hmp_printf(hmp, "hub %d\n", (int)h->value->id);
63 for (p = h->value->ports; p; p = p->next) {
64 if (p->value->peer) {
66 - monitor_printf(mon, " \\ %s: ", p->value->name);
67 - hmp_print_client_info(mon, p->value->peer);
65 + monitor_hmp_printf(hmp, " \\ %s: ", p->value->name);
66 + hmp_print_client_info(hmp, p->value->peer);
67 } else {
69 - monitor_printf(mon, " \\ %s\n", p->value->name);
68 + monitor_hmp_printf(hmp, " \\ %s\n", p->value->name);
69 }
70 }
71 }
@@ -75,11 +74,11 @@ void hmp_info_network(MonitorHMP *hmp, const QDict *qdict)
74 NetworkClientInfo *ci = entry->value;
75
76 if (!ci->peer || ci->type == NET_CLIENT_DRIVER_NIC) {
78 - hmp_print_client_info(mon, ci);
77 + hmp_print_client_info(hmp, ci);
78 } /* else it's a netdev connected to a NIC, printed with the NIC */
79 if (ci->peer && ci->type == NET_CLIENT_DRIVER_NIC) {
81 - monitor_printf(mon, " \\ ");
82 - hmp_print_client_info(mon, ci->peer);
80 + monitor_hmp_printf(hmp, " \\ ");
81 + hmp_print_client_info(hmp, ci->peer);
82 }
83 }
84 }
net/slirp.c
+14 -17
@@ -711,22 +711,22 @@ error:
711 return -1;
712 }
713
714 -static SlirpState *slirp_lookup(Monitor *mon, const char *id)
714 +static SlirpState *slirp_lookup(MonitorHMP *hmp, const char *id)
715 {
716 if (id) {
717 NetClientState *nc = qemu_find_netdev(id);
718 if (!nc) {
719 - monitor_printf(mon, "unrecognized netdev id '%s'\n", id);
719 + monitor_hmp_printf(hmp, "unrecognized netdev id '%s'\n", id);
720 return NULL;
721 }
722 if (strcmp(nc->model, "user")) {
723 - monitor_printf(mon, "invalid device specified\n");
723 + monitor_hmp_printf(hmp, "invalid device specified\n");
724 return NULL;
725 }
726 return DO_UPCAST(SlirpState, nc, nc);
727 } else {
728 if (QTAILQ_EMPTY(&slirp_stacks)) {
729 - monitor_printf(mon, "user mode network stack not in use\n");
729 + monitor_hmp_printf(hmp, "user mode network stack not in use\n");
730 return NULL;
731 }
732 return QTAILQ_FIRST(&slirp_stacks);
@@ -735,7 +735,6 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *id)
735
736 void hmp_hostfwd_remove(MonitorHMP *hmp, const QDict *qdict)
737 {
738 - Monitor *mon = MONITOR(hmp);
738 /* TODO: support removing unix fwd */
739 struct sockaddr_in host_addr = {
740 .sin_family = AF_INET,
@@ -753,10 +752,10 @@ void hmp_hostfwd_remove(MonitorHMP *hmp, const QDict *qdict)
752 const char *arg2 = qdict_get_try_str(qdict, "arg2");
753
754 if (arg2) {
756 - s = slirp_lookup(mon, arg1);
755 + s = slirp_lookup(hmp, arg1);
756 src_str = arg2;
757 } else {
759 - s = slirp_lookup(mon, NULL);
758 + s = slirp_lookup(hmp, NULL);
759 src_str = arg1;
760 }
761 if (!s) {
@@ -795,12 +794,12 @@ void hmp_hostfwd_remove(MonitorHMP *hmp, const QDict *qdict)
794 err = slirp_remove_hostfwd(s->slirp, is_udp, host_addr.sin_addr, host_port);
795 #endif
796
798 - monitor_printf(mon, "host forwarding rule for %s %s\n", src_str,
799 - err ? "not found" : "removed");
797 + monitor_hmp_printf(hmp, "host forwarding rule for %s %s\n", src_str,
798 + err ? "not found" : "removed");
799 return;
800
801 fail_syntax:
803 - monitor_printf(mon, "invalid format\n");
802 + monitor_hmp_printf(hmp, "invalid format\n");
803 }
804
805 static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp)
@@ -960,17 +959,16 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp)
959
960 void hmp_hostfwd_add(MonitorHMP *hmp, const QDict *qdict)
961 {
963 - Monitor *mon = MONITOR(hmp);
962 const char *redir_str;
963 SlirpState *s;
964 const char *arg1 = qdict_get_str(qdict, "arg1");
965 const char *arg2 = qdict_get_try_str(qdict, "arg2");
966
967 if (arg2) {
970 - s = slirp_lookup(mon, arg1);
968 + s = slirp_lookup(hmp, arg1);
969 redir_str = arg2;
970 } else {
973 - s = slirp_lookup(mon, NULL);
971 + s = slirp_lookup(hmp, NULL);
972 redir_str = arg1;
973 }
974 if (s) {
@@ -1228,16 +1226,15 @@ UsernetInfoList *qmp_x_query_usernet(Error **errp)
1226
1227 void hmp_info_usernet(MonitorHMP *hmp, const QDict *qdict)
1228 {
1231 - Monitor *mon = MONITOR(hmp);
1229 g_autoptr(UsernetInfoList) list = NULL;
1230 UsernetInfoList *entry;
1231
1232 list = qmp_x_query_usernet(&error_abort);
1233 for (entry = list; entry; entry = entry->next) {
1234 UsernetInfo *ui = entry->value;
1238 - monitor_printf(mon, "Hub %d (%s):\n%s",
1239 - ui->has_hub_id ? (int)ui->hub_id : -1,
1240 - ui->hub_name, ui->info);
1235 + monitor_hmp_printf(hmp, "Hub %d (%s):\n%s",
1236 + ui->has_hub_id ? (int)ui->hub_id : -1,
1237 + ui->hub_name, ui->info);
1238 }
1239 }
1240
qom/qom-hmp-cmds.c
+12 -15
@@ -20,13 +20,12 @@
20
21 void hmp_qom_list(MonitorHMP *hmp, const QDict *qdict)
22 {
23 - Monitor *mon = MONITOR(hmp);
23 const char *path = qdict_get_try_str(qdict, "path");
24 ObjectPropertyInfoList *list;
25 Error *err = NULL;
26
27 if (path == NULL) {
29 - monitor_printf(mon, "/\n");
28 + monitor_hmp_printf(hmp, "/\n");
29 return;
30 }
31
@@ -36,8 +35,8 @@ void hmp_qom_list(MonitorHMP *hmp, const QDict *qdict)
35 while (list != NULL) {
36 ObjectPropertyInfo *value = list->value;
37
39 - monitor_printf(mon, "%s (%s)\n",
40 - value->name, value->type);
38 + monitor_hmp_printf(hmp, "%s (%s)\n",
39 + value->name, value->type);
40 list = list->next;
41 }
42 qapi_free_ObjectPropertyInfoList(start);
@@ -75,7 +74,6 @@ void hmp_qom_set(MonitorHMP *hmp, const QDict *qdict)
74
75 void hmp_qom_get(MonitorHMP *hmp, const QDict *qdict)
76 {
78 - Monitor *mon = MONITOR(hmp);
77 const char *path = qdict_get_str(qdict, "path");
78 const char *property = qdict_get_str(qdict, "property");
79 Error *err = NULL;
@@ -83,7 +81,7 @@ void hmp_qom_get(MonitorHMP *hmp, const QDict *qdict)
81
82 if (err == NULL) {
83 GString *str = qobject_to_json_pretty(obj, true);
86 - monitor_printf(mon, "%s\n", str->str);
84 + monitor_hmp_printf(hmp, "%s\n", str->str);
85 g_string_free(str, true);
86 }
87
@@ -96,7 +94,7 @@ typedef struct QOMCompositionState {
94 int indent;
95 } QOMCompositionState;
96
99 -static void print_qom_composition(Monitor *mon, Object *obj, int indent);
97 +static void print_qom_composition(MonitorHMP *hmp, Object *obj, int indent);
98
99 static int qom_composition_compare(const void *a, const void *b)
100 {
@@ -110,7 +108,7 @@ static int insert_qom_composition_child(Object *obj, void *opaque)
108 return 0;
109 }
110
113 -static void print_qom_composition(Monitor *mon, Object *obj, int indent)
111 +static void print_qom_composition(MonitorHMP *hmp, Object *obj, int indent)
112 {
113 GArray *children = g_array_new(false, false, sizeof(Object *));
114 const char *name;
@@ -121,14 +119,14 @@ static void print_qom_composition(Monitor *mon, Object *obj, int indent)
119 } else {
120 name = object_get_canonical_path_component(obj);
121 }
124 - monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
125 - object_get_typename(obj));
122 + monitor_hmp_printf(hmp, "%*s/%s (%s)\n", indent, "", name,
123 + object_get_typename(obj));
124
125 object_child_foreach(obj, insert_qom_composition_child, children);
126 g_array_sort(children, qom_composition_compare);
127
128 for (i = 0; i < children->len; i++) {
131 - print_qom_composition(mon, g_array_index(children, Object *, i),
129 + print_qom_composition(hmp, g_array_index(children, Object *, i),
130 indent + 2);
131 }
132 g_array_free(children, TRUE);
@@ -136,7 +134,6 @@ static void print_qom_composition(Monitor *mon, Object *obj, int indent)
134
135 void hmp_info_qom_tree(MonitorHMP *hmp, const QDict *dict)
136 {
139 - Monitor *mon = MONITOR(hmp);
137 const char *path = qdict_get_try_str(dict, "path");
138 Object *obj;
139 bool ambiguous = false;
@@ -144,17 +141,17 @@ void hmp_info_qom_tree(MonitorHMP *hmp, const QDict *dict)
141 if (path) {
142 obj = object_resolve_path(path, &ambiguous);
143 if (!obj) {
147 - monitor_printf(mon, "Path '%s' could not be resolved.\n", path);
144 + monitor_hmp_printf(hmp, "Path '%s' could not be resolved.\n", path);
145 return;
146 }
147 if (ambiguous) {
151 - monitor_printf(mon, "Warning: Path '%s' is ambiguous.\n", path);
148 + monitor_hmp_printf(hmp, "Warning: Path '%s' is ambiguous.\n", path);
149 return;
150 }
151 } else {
152 obj = qdev_get_machine();
153 }
157 - print_qom_composition(mon, obj, 0);
154 + print_qom_composition(hmp, obj, 0);
155 }
156
157 void hmp_object_add(MonitorHMP *hmp, const QDict *qdict)
replay/replay-debugging.c
+2 -3
@@ -33,11 +33,10 @@ bool replay_running_debug(void)
33
34 void hmp_info_replay(MonitorHMP *hmp, const QDict *qdict)
35 {
36 - Monitor *mon = MONITOR(hmp);
36 if (replay_mode == REPLAY_MODE_NONE) {
38 - monitor_printf(mon, "Record/replay is not active\n");
37 + monitor_hmp_printf(hmp, "Record/replay is not active\n");
38 } else {
40 - monitor_printf(mon,
39 + monitor_hmp_printf(hmp,
40 "%s execution '%s': instruction count = %"PRId64"\n",
41 replay_mode == REPLAY_MODE_RECORD ? "Recording" : "Replaying",
42 replay_get_filename(), replay_get_current_icount());
stats/stats-hmp-cmds.c
+28 -29
@@ -14,11 +14,11 @@
14 #include "qobject/qdict.h"
15 #include "qapi/error.h"
16
17 -static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value)
17 +static void print_stats_schema_value(MonitorHMP *hmp, StatsSchemaValue *value)
18 {
19 const char *unit = NULL;
20 - monitor_printf(mon, " %s (%s%s", value->name, StatsType_str(value->type),
21 - value->has_unit || value->exponent ? ", " : "");
20 + monitor_hmp_printf(hmp, " %s (%s%s", value->name, StatsType_str(value->type),
21 + value->has_unit || value->exponent ? ", " : "");
22
23 if (value->has_unit) {
24 if (value->unit == STATS_UNIT_SECONDS) {
@@ -31,29 +31,29 @@ static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value)
31 if (unit && value->base == 10 &&
32 value->exponent >= -18 && value->exponent <= 18 &&
33 value->exponent % 3 == 0) {
34 - monitor_puts(mon, si_prefix(value->exponent));
34 + monitor_puts(MONITOR(hmp), si_prefix(value->exponent));
35 } else if (unit && value->base == 2 &&
36 value->exponent >= 0 && value->exponent <= 60 &&
37 value->exponent % 10 == 0) {
38
39 - monitor_puts(mon, iec_binary_prefix(value->exponent));
39 + monitor_puts(MONITOR(hmp), iec_binary_prefix(value->exponent));
40 } else if (value->exponent) {
41 /* Use exponential notation and write the unit's English name */
42 - monitor_printf(mon, "* %d^%d%s",
43 - value->base, value->exponent,
44 - value->has_unit ? " " : "");
42 + monitor_hmp_printf(hmp, "* %d^%d%s",
43 + value->base, value->exponent,
44 + value->has_unit ? " " : "");
45 unit = NULL;
46 }
47
48 if (value->has_unit) {
49 - monitor_puts(mon, unit ? unit : StatsUnit_str(value->unit));
49 + monitor_puts(MONITOR(hmp), unit ? unit : StatsUnit_str(value->unit));
50 }
51
52 /* Print bucket size for linear histograms */
53 if (value->type == STATS_TYPE_LINEAR_HISTOGRAM && value->has_bucket_size) {
54 - monitor_printf(mon, ", bucket size=%d", value->bucket_size);
54 + monitor_hmp_printf(hmp, ", bucket size=%d", value->bucket_size);
55 }
56 - monitor_printf(mon, ")");
56 + monitor_hmp_printf(hmp, ")");
57 }
58
59 static StatsSchemaValueList *find_schema_value_list(
@@ -71,7 +71,7 @@ static StatsSchemaValueList *find_schema_value_list(
71 return NULL;
72 }
73
74 -static void print_stats_results(Monitor *mon, StatsTarget target,
74 +static void print_stats_results(MonitorHMP *hmp, StatsTarget target,
75 bool show_provider,
76 StatsResult *result,
77 StatsSchemaList *schema)
@@ -82,14 +82,14 @@ static void print_stats_results(Monitor *mon, StatsTarget target,
82 StatsList *stats_list;
83
84 if (!schema_value_list) {
85 - monitor_printf(mon, "failed to find schema list for %s\n",
86 - StatsProvider_str(result->provider));
85 + monitor_hmp_printf(hmp, "failed to find schema list for %s\n",
86 + StatsProvider_str(result->provider));
87 return;
88 }
89
90 if (show_provider) {
91 - monitor_printf(mon, "provider: %s\n",
92 - StatsProvider_str(result->provider));
91 + monitor_hmp_printf(hmp, "provider: %s\n",
92 + StatsProvider_str(result->provider));
93 }
94
95 for (stats_list = result->stats; stats_list;
@@ -103,31 +103,31 @@ static void print_stats_results(Monitor *mon, StatsTarget target,
103 /* Find schema entry */
104 while (!g_str_equal(stats->name, schema_value->name)) {
105 if (!schema_value_list->next) {
106 - monitor_printf(mon, "failed to find schema entry for %s\n",
107 - stats->name);
106 + monitor_hmp_printf(hmp, "failed to find schema entry for %s\n",
107 + stats->name);
108 return;
109 }
110 schema_value_list = schema_value_list->next;
111 schema_value = schema_value_list->value;
112 }
113
114 - print_stats_schema_value(mon, schema_value);
114 + print_stats_schema_value(hmp, schema_value);
115
116 if (stats_value->type == QTYPE_QNUM) {
117 - monitor_printf(mon, ": %" PRId64 "\n", stats_value->u.scalar);
117 + monitor_hmp_printf(hmp, ": %" PRId64 "\n", stats_value->u.scalar);
118 } else if (stats_value->type == QTYPE_QBOOL) {
119 - monitor_printf(mon, ": %s\n", stats_value->u.boolean ? "yes" : "no");
119 + monitor_hmp_printf(hmp, ": %s\n", stats_value->u.boolean ? "yes" : "no");
120 } else if (stats_value->type == QTYPE_QLIST) {
121 uint64List *list;
122 int i;
123
124 - monitor_printf(mon, ": ");
124 + monitor_hmp_printf(hmp, ": ");
125 for (list = stats_value->u.list, i = 1;
126 list;
127 list = list->next, i++) {
128 - monitor_printf(mon, "[%d]=%" PRId64 " ", i, list->value);
128 + monitor_hmp_printf(hmp, "[%d]=%" PRId64 " ", i, list->value);
129 }
130 - monitor_printf(mon, "\n");
130 + monitor_hmp_printf(hmp, "\n");
131 }
132 }
133 }
@@ -189,7 +189,6 @@ static StatsFilter *stats_filter(StatsTarget target, const char *names,
189
190 void hmp_info_stats(MonitorHMP *hmp, const QDict *qdict)
191 {
192 - Monitor *mon = MONITOR(hmp);
192 const char *target_str = qdict_get_str(qdict, "target");
193 const char *provider_str = qdict_get_try_str(qdict, "provider");
194 const char *names = qdict_get_try_str(qdict, "names");
@@ -204,13 +203,13 @@ void hmp_info_stats(MonitorHMP *hmp, const QDict *qdict)
203
204 target = qapi_enum_parse(&StatsTarget_lookup, target_str, -1, &err);
205 if (err) {
207 - monitor_printf(mon, "invalid stats target %s\n", target_str);
206 + monitor_hmp_printf(hmp, "invalid stats target %s\n", target_str);
207 goto exit_no_print;
208 }
209 if (provider_str) {
210 provider = qapi_enum_parse(&StatsProvider_lookup, provider_str, -1, &err);
211 if (err) {
213 - monitor_printf(mon, "invalid stats provider %s\n", provider_str);
212 + monitor_hmp_printf(hmp, "invalid stats provider %s\n", provider_str);
213 goto exit_no_print;
214 }
215 }
@@ -241,12 +240,12 @@ void hmp_info_stats(MonitorHMP *hmp, const QDict *qdict)
240 goto exit;
241 }
242 for (entry = stats; entry; entry = entry->next) {
244 - print_stats_results(mon, target, provider_str == NULL, entry->value, schema);
243 + print_stats_results(hmp, target, provider_str == NULL, entry->value, schema);
244 }
245
246 exit:
247 if (err) {
249 - monitor_printf(mon, "%s\n", error_get_pretty(err));
248 + monitor_hmp_printf(hmp, "%s\n", error_get_pretty(err));
249 }
250 exit_no_print:
251 error_free(err);
stubs/hmp-cmd-info_sev.c
+1 -2
@@ -12,6 +12,5 @@
12
13 void hmp_info_sev(MonitorHMP *hmp, const QDict *qdict)
14 {
15 - Monitor *mon = MONITOR(hmp);
16 - monitor_printf(mon, "SEV is not available in this QEMU\n");
15 + monitor_hmp_printf(hmp, "SEV is not available in this QEMU\n");
16 }
stubs/monitor-core.c
+1 -1
@@ -17,7 +17,7 @@ void qapi_event_emit(QAPIEvent event, QDict *qdict)
17 {
18 }
19
20 -int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
20 +int monitor_hmp_vprintf(MonitorHMP *mon, const char *fmt, va_list ap)
21 {
22 /*
23 * Pretend 'g_test_message' is our monitor console to
system/dirtylimit-hmp-cmds.c
+4 -6
@@ -17,7 +17,6 @@
17
18 void hmp_cancel_vcpu_dirty_limit(MonitorHMP *hmp, const QDict *qdict)
19 {
20 - Monitor *mon = MONITOR(hmp);
20 int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
21 Error *err = NULL;
22
@@ -27,8 +26,8 @@ void hmp_cancel_vcpu_dirty_limit(MonitorHMP *hmp, const QDict *qdict)
26 return;
27 }
28
30 - monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
31 - "dirty limit for virtual CPU]\n");
29 + monitor_hmp_printf(hmp, "[Please use 'info vcpu_dirty_limit' to query "
30 + "dirty limit for virtual CPU]\n");
31 }
32
33 void hmp_set_vcpu_dirty_limit(MonitorHMP *hmp, const QDict *qdict)
@@ -50,13 +49,12 @@ out:
49
50 void hmp_info_vcpu_dirty_limit(MonitorHMP *hmp, const QDict *qdict)
51 {
53 - Monitor *mon = MONITOR(hmp);
52 DirtyLimitInfoList *info;
53 g_autoptr(DirtyLimitInfoList) head = NULL;
54 Error *err = NULL;
55
56 if (!dirtylimit_in_service()) {
59 - monitor_printf(mon, "Dirty page limit not enabled!\n");
57 + monitor_hmp_printf(hmp, "Dirty page limit not enabled!\n");
58 return;
59 }
60
@@ -67,7 +65,7 @@ void hmp_info_vcpu_dirty_limit(MonitorHMP *hmp, const QDict *qdict)
65 }
66
67 for (info = head; info != NULL; info = info->next) {
70 - monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
68 + monitor_hmp_printf(hmp, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
69 " current rate %"PRIi64 " (MB/s)\n",
70 info->value->cpu_index,
71 info->value->limit_rate,
system/qdev-monitor.c
+10 -9
@@ -763,9 +763,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
763 return ret;
764 }
765
766 -#define qdev_printf(fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)
766 +#define qdev_printf(fmt, ...) \
767 + monitor_hmp_printf(hmp, "%*s" fmt, indent, "", ## __VA_ARGS__)
768
768 -static void qdev_print_props(Monitor *mon, DeviceState *dev, DeviceClass *dc,
769 +static void qdev_print_props(MonitorHMP *hmp, DeviceState *dev, DeviceClass *dc,
770 int indent)
771 {
772 for (int i = 0, n = dc->props_count_; i < n; ++i) {
@@ -798,8 +799,9 @@ static void bus_print_dev(BusState *bus, Monitor *mon, DeviceState *dev, int ind
799 }
800 }
801
801 -static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
802 +static void qdev_print(MonitorHMP *hmp, DeviceState *dev, int indent)
803 {
804 + Monitor *mon = MONITOR(hmp);
805 ObjectClass *class;
806 NamedGPIOList *ngl;
807 NamedClockList *ncl;
@@ -823,13 +825,13 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
825 }
826 class = object_get_class(OBJECT(dev));
827 do {
826 - qdev_print_props(mon, dev, DEVICE_CLASS(class), indent);
828 + qdev_print_props(hmp, dev, DEVICE_CLASS(class), indent);
829 class = object_class_get_parent(class);
830 } while (class != object_class_by_name(TYPE_DEVICE));
831 bus_print_dev(dev->parent_bus, mon, dev, indent);
832 }
833
832 -static void qbus_print(Monitor *mon, BusState *bus, int indent, bool details)
834 +static void qbus_print(MonitorHMP *hmp, BusState *bus, int indent, bool details)
835 {
836 BusChild *kid;
837
@@ -842,10 +844,10 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent, bool details)
844 qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)),
845 dev->id ? dev->id : "");
846 if (details) {
845 - qdev_print(mon, dev, indent + 2);
847 + qdev_print(hmp, dev, indent + 2);
848 }
849 QLIST_FOREACH(child_bus, &dev->child_bus, sibling) {
848 - qbus_print(mon, child_bus, indent + 2, details);
850 + qbus_print(hmp, child_bus, indent + 2, details);
851 }
852 }
853 }
@@ -853,11 +855,10 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent, bool details)
855
856 void hmp_info_qtree(MonitorHMP *hmp, const QDict *qdict)
857 {
856 - Monitor *mon = MONITOR(hmp);
858 bool details = !qdict_get_try_bool(qdict, "brief", false);
859
860 if (sysbus_get_default()) {
860 - qbus_print(mon, sysbus_get_default(), 0, details);
861 + qbus_print(hmp, sysbus_get_default(), 0, details);
862 }
863 }
864
system/runstate-hmp-cmds.c
+7 -9
@@ -25,33 +25,31 @@
25
26 void hmp_info_status(MonitorHMP *hmp, const QDict *qdict)
27 {
28 - Monitor *mon = MONITOR(hmp);
28 StatusInfo *info;
29
30 info = qmp_query_status(NULL);
31
33 - monitor_printf(mon, "VM status: %s",
34 - info->running ? "running" : "paused");
32 + monitor_hmp_printf(hmp, "VM status: %s",
33 + info->running ? "running" : "paused");
34
35 if (!info->running && info->status != RUN_STATE_PAUSED) {
37 - monitor_printf(mon, " (%s)", RunState_str(info->status));
36 + monitor_hmp_printf(hmp, " (%s)", RunState_str(info->status));
37 }
38
40 - monitor_printf(mon, "\n");
39 + monitor_hmp_printf(hmp, "\n");
40
41 qapi_free_StatusInfo(info);
42 }
43
44 void hmp_one_insn_per_tb(MonitorHMP *hmp, const QDict *qdict)
45 {
47 - Monitor *mon = MONITOR(hmp);
46 const char *option = qdict_get_try_str(qdict, "option");
47 AccelState *accel = current_accel();
48 bool newval;
49
50 if (!object_property_find(OBJECT(accel), "one-insn-per-tb")) {
53 - monitor_printf(mon,
54 - "This accelerator does not support setting one-insn-per-tb\n");
51 + monitor_hmp_printf(hmp,
52 + "This accelerator does not support setting one-insn-per-tb\n");
53 return;
54 }
55
@@ -60,7 +58,7 @@ void hmp_one_insn_per_tb(MonitorHMP *hmp, const QDict *qdict)
58 } else if (!strcmp(option, "off")) {
59 newval = false;
60 } else {
63 - monitor_printf(mon, "unexpected option %s\n", option);
61 + monitor_hmp_printf(hmp, "unexpected option %s\n", option);
62 return;
63 }
64 /* If the property exists then setting it can never fail */
system/tpm-hmp-cmds.c
+14 -15
@@ -13,7 +13,6 @@
13
14 void hmp_info_tpm(MonitorHMP *hmp, const QDict *qdict)
15 {
16 - Monitor *mon = MONITOR(hmp);
16 #ifdef CONFIG_TPM
17 TPMInfoList *info_list, *info;
18 Error *err = NULL;
@@ -23,44 +22,44 @@ void hmp_info_tpm(MonitorHMP *hmp, const QDict *qdict)
22
23 info_list = qmp_query_tpm(&err);
24 if (err) {
26 - monitor_printf(mon, "TPM device not supported\n");
25 + monitor_hmp_printf(hmp, "TPM device not supported\n");
26 error_free(err);
27 return;
28 }
29
30 if (info_list) {
32 - monitor_printf(mon, "TPM device:\n");
31 + monitor_hmp_printf(hmp, "TPM device:\n");
32 }
33
34 for (info = info_list; info; info = info->next) {
35 TPMInfo *ti = info->value;
37 - monitor_printf(mon, " tpm%d: model=%s\n",
38 - c, TpmModel_str(ti->model));
36 + monitor_hmp_printf(hmp, " tpm%d: model=%s\n",
37 + c, TpmModel_str(ti->model));
38
40 - monitor_printf(mon, " \\ %s: type=%s",
41 - ti->id, TpmType_str(ti->options->type));
39 + monitor_hmp_printf(hmp, " \\ %s: type=%s",
40 + ti->id, TpmType_str(ti->options->type));
41
42 switch (ti->options->type) {
43 case TPM_TYPE_PASSTHROUGH:
44 tpo = ti->options->u.passthrough.data;
46 - monitor_printf(mon, "%s%s%s%s",
47 - tpo->path ? ",path=" : "",
48 - tpo->path ?: "",
49 - tpo->cancel_path ? ",cancel-path=" : "",
50 - tpo->cancel_path ?: "");
45 + monitor_hmp_printf(hmp, "%s%s%s%s",
46 + tpo->path ? ",path=" : "",
47 + tpo->path ?: "",
48 + tpo->cancel_path ? ",cancel-path=" : "",
49 + tpo->cancel_path ?: "");
50 break;
51 case TPM_TYPE_EMULATOR:
52 teo = ti->options->u.emulator.data;
54 - monitor_printf(mon, ",chardev=%s", teo->chardev);
53 + monitor_hmp_printf(hmp, ",chardev=%s", teo->chardev);
54 break;
55 case TPM_TYPE__MAX:
56 break;
57 }
59 - monitor_printf(mon, "\n");
58 + monitor_hmp_printf(hmp, "\n");
59 c++;
60 }
61 qapi_free_TPMInfoList(info_list);
62 #else
64 - monitor_printf(mon, "TPM device not supported\n");
63 + monitor_hmp_printf(hmp, "TPM device not supported\n");
64 #endif /* CONFIG_TPM */
65 }
target/i386/cpu-apic.c
+1 -2
@@ -85,7 +85,6 @@ void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)
85
86 void hmp_info_local_apic(MonitorHMP *hmp, const QDict *qdict)
87 {
88 - Monitor *mon = MONITOR(hmp);
88 CPUState *cs;
89
90 if (qdict_haskey(qdict, "apic-id")) {
@@ -101,7 +100,7 @@ void hmp_info_local_apic(MonitorHMP *hmp, const QDict *qdict)
100
101
102 if (!cs) {
104 - monitor_printf(mon, "No CPU available\n");
103 + monitor_hmp_printf(hmp, "No CPU available\n");
104 return;
105 }
106 x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU);
target/i386/monitor.c
+75 -77
@@ -48,27 +48,27 @@ static hwaddr addr_canonical(CPUArchState *env, hwaddr addr)
48 return addr;
49 }
50
51 -static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr,
51 +static void print_pte(MonitorHMP *hmp, CPUArchState *env, hwaddr addr,
52 hwaddr pte, hwaddr mask)
53 {
54 addr = addr_canonical(env, addr);
55
56 - monitor_printf(mon, HWADDR_FMT_plx ": " HWADDR_FMT_plx
57 - " %c%c%c%c%c%c%c%c%c\n",
58 - addr,
59 - pte & mask,
60 - pte & PG_NX_MASK ? 'X' : '-',
61 - pte & PG_GLOBAL_MASK ? 'G' : '-',
62 - pte & PG_PSE_MASK ? 'P' : '-',
63 - pte & PG_DIRTY_MASK ? 'D' : '-',
64 - pte & PG_ACCESSED_MASK ? 'A' : '-',
65 - pte & PG_PCD_MASK ? 'C' : '-',
66 - pte & PG_PWT_MASK ? 'T' : '-',
67 - pte & PG_USER_MASK ? 'U' : '-',
68 - pte & PG_RW_MASK ? 'W' : '-');
56 + monitor_hmp_printf(hmp, HWADDR_FMT_plx ": " HWADDR_FMT_plx
57 + " %c%c%c%c%c%c%c%c%c\n",
58 + addr,
59 + pte & mask,
60 + pte & PG_NX_MASK ? 'X' : '-',
61 + pte & PG_GLOBAL_MASK ? 'G' : '-',
62 + pte & PG_PSE_MASK ? 'P' : '-',
63 + pte & PG_DIRTY_MASK ? 'D' : '-',
64 + pte & PG_ACCESSED_MASK ? 'A' : '-',
65 + pte & PG_PCD_MASK ? 'C' : '-',
66 + pte & PG_PWT_MASK ? 'T' : '-',
67 + pte & PG_USER_MASK ? 'U' : '-',
68 + pte & PG_RW_MASK ? 'W' : '-');
69 }
70
71 -static void tlb_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
71 +static void tlb_info_32(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
72 {
73 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
74 unsigned int l1, l2;
@@ -80,13 +80,13 @@ static void tlb_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
80 if (pde & PG_PRESENT_MASK) {
81 if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
82 /* 4M pages */
83 - print_pte(mon, env, (l1 << 22), pde, ~((1 << 21) - 1));
83 + print_pte(hmp, env, (l1 << 22), pde, ~((1 << 21) - 1));
84 } else {
85 for(l2 = 0; l2 < 1024; l2++) {
86 pte = address_space_ldl_le(as, (pde & ~0xfff) + l2 * 4,
87 attrs, NULL);
88 if (pte & PG_PRESENT_MASK) {
89 - print_pte(mon, env, (l1 << 22) + (l2 << 12),
89 + print_pte(hmp, env, (l1 << 22) + (l2 << 12),
90 pte & ~PG_PSE_MASK,
91 ~0xfff);
92 }
@@ -96,7 +96,7 @@ static void tlb_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
96 }
97 }
98
99 -static void tlb_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
99 +static void tlb_info_pae32(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
100 {
101 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
102 unsigned int l1, l2, l3;
@@ -113,7 +113,7 @@ static void tlb_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
113 if (pde & PG_PRESENT_MASK) {
114 if (pde & PG_PSE_MASK) {
115 /* 2M pages with PAE, CR4.PSE is ignored */
116 - print_pte(mon, env, (l1 << 30) + (l2 << 21), pde,
116 + print_pte(hmp, env, (l1 << 30) + (l2 << 21), pde,
117 ~((hwaddr)(1 << 20) - 1));
118 } else {
119 pt_addr = pde & 0x3fffffffff000ULL;
@@ -121,7 +121,7 @@ static void tlb_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
121 pte = address_space_ldq_le(as, pt_addr + l3 * 8,
122 attrs, NULL);
123 if (pte & PG_PRESENT_MASK) {
124 - print_pte(mon, env, (l1 << 30) + (l2 << 21)
124 + print_pte(hmp, env, (l1 << 30) + (l2 << 21)
125 + (l3 << 12),
126 pte & ~PG_PSE_MASK,
127 ~(hwaddr)0xfff);
@@ -135,7 +135,7 @@ static void tlb_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
135 }
136
137 #ifdef TARGET_X86_64
138 -static void tlb_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as,
138 +static void tlb_info_la48(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as,
139 uint64_t l0, uint64_t pml4_addr)
140 {
141 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
@@ -158,7 +158,7 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as,
158
159 if (pdpe & PG_PSE_MASK) {
160 /* 1G pages, CR4.PSE is ignored */
161 - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30),
161 + print_pte(hmp, env, (l0 << 48) + (l1 << 39) + (l2 << 30),
162 pdpe, 0x3ffffc0000000ULL);
163 continue;
164 }
@@ -172,7 +172,7 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as,
172
173 if (pde & PG_PSE_MASK) {
174 /* 2M pages, CR4.PSE is ignored */
175 - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30) +
175 + print_pte(hmp, env, (l0 << 48) + (l1 << 39) + (l2 << 30) +
176 (l3 << 21), pde, 0x3ffffffe00000ULL);
177 continue;
178 }
@@ -182,7 +182,7 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as,
182 pte = address_space_ldq_le(as, pt_addr + l4 * 8,
183 attrs, NULL);
184 if (pte & PG_PRESENT_MASK) {
185 - print_pte(mon, env, (l0 << 48) + (l1 << 39) +
185 + print_pte(hmp, env, (l0 << 48) + (l1 << 39) +
186 (l2 << 30) + (l3 << 21) + (l4 << 12),
187 pte & ~PG_PSE_MASK, 0x3fffffffff000ULL);
188 }
@@ -192,7 +192,7 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as,
192 }
193 }
194
195 -static void tlb_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
195 +static void tlb_info_la57(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
196 {
197 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
198 uint64_t l0;
@@ -203,7 +203,7 @@ static void tlb_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
203 for (l0 = 0; l0 < 512; l0++) {
204 pml5e = address_space_ldq_le(as, pml5_addr + l0 * 8, attrs, NULL);
205 if (pml5e & PG_PRESENT_MASK) {
206 - tlb_info_la48(mon, env, as, l0, pml5e & 0x3fffffffff000ULL);
206 + tlb_info_la48(hmp, env, as, l0, pml5e & 0x3fffffffff000ULL);
207 }
208 }
209 }
@@ -211,18 +211,17 @@ static void tlb_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
211
212 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
213 {
214 - Monitor *mon = MONITOR(hmp);
214 CPUArchState *env;
215 AddressSpace *as;
216
217 env = monitor_hmp_get_cpu_env(hmp);
218 if (!env) {
220 - monitor_printf(mon, "No CPU available\n");
219 + monitor_hmp_printf(hmp, "No CPU available\n");
220 return;
221 }
222
223 if (!(env->cr[0] & CR0_PG_MASK)) {
225 - monitor_printf(mon, "PG disabled\n");
224 + monitor_hmp_printf(hmp, "PG disabled\n");
225 return;
226 }
227 as = cpu_get_address_space(env_cpu(env), X86ASIdx_MEM);
@@ -230,21 +229,21 @@ void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
229 #ifdef TARGET_X86_64
230 if (env->hflags & HF_LMA_MASK) {
231 if (env->cr[4] & CR4_LA57_MASK) {
233 - tlb_info_la57(mon, env, as);
232 + tlb_info_la57(hmp, env, as);
233 } else {
235 - tlb_info_la48(mon, env, as, 0, env->cr[3] & 0x3fffffffff000ULL);
234 + tlb_info_la48(hmp, env, as, 0, env->cr[3] & 0x3fffffffff000ULL);
235 }
236 } else
237 #endif
238 {
240 - tlb_info_pae32(mon, env, as);
239 + tlb_info_pae32(hmp, env, as);
240 }
241 } else {
243 - tlb_info_32(mon, env, as);
242 + tlb_info_32(hmp, env, as);
243 }
244 }
245
247 -static void mem_print(Monitor *mon, CPUArchState *env,
246 +static void mem_print(MonitorHMP *hmp, CPUArchState *env,
247 hwaddr *pstart, int *plast_prot,
248 hwaddr end, int prot)
249 {
@@ -252,14 +251,14 @@ static void mem_print(Monitor *mon, CPUArchState *env,
251 prot1 = *plast_prot;
252 if (prot != prot1) {
253 if (*pstart != -1) {
255 - monitor_printf(mon, HWADDR_FMT_plx "-" HWADDR_FMT_plx " "
256 - HWADDR_FMT_plx " %c%c%c\n",
257 - addr_canonical(env, *pstart),
258 - addr_canonical(env, end),
259 - addr_canonical(env, end - *pstart),
260 - prot1 & PG_USER_MASK ? 'u' : '-',
261 - 'r',
262 - prot1 & PG_RW_MASK ? 'w' : '-');
254 + monitor_hmp_printf(hmp, HWADDR_FMT_plx "-" HWADDR_FMT_plx " "
255 + HWADDR_FMT_plx " %c%c%c\n",
256 + addr_canonical(env, *pstart),
257 + addr_canonical(env, end),
258 + addr_canonical(env, end - *pstart),
259 + prot1 & PG_USER_MASK ? 'u' : '-',
260 + 'r',
261 + prot1 & PG_RW_MASK ? 'w' : '-');
262 }
263 if (prot != 0)
264 *pstart = end;
@@ -269,7 +268,7 @@ static void mem_print(Monitor *mon, CPUArchState *env,
268 }
269 }
270
272 -static void mem_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
271 +static void mem_info_32(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
272 {
273 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
274 unsigned int l1, l2;
@@ -286,7 +285,7 @@ static void mem_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
285 if (pde & PG_PRESENT_MASK) {
286 if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
287 prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
289 - mem_print(mon, env, &start, &last_prot, end, prot);
288 + mem_print(hmp, env, &start, &last_prot, end, prot);
289 } else {
290 for(l2 = 0; l2 < 1024; l2++) {
291 pte = address_space_ldl_le(as, (pde & ~0xfff) + l2 * 4,
@@ -298,19 +297,19 @@ static void mem_info_32(Monitor *mon, CPUArchState *env, AddressSpace *as)
297 } else {
298 prot = 0;
299 }
301 - mem_print(mon, env, &start, &last_prot, end, prot);
300 + mem_print(hmp, env, &start, &last_prot, end, prot);
301 }
302 }
303 } else {
304 prot = 0;
306 - mem_print(mon, env, &start, &last_prot, end, prot);
305 + mem_print(hmp, env, &start, &last_prot, end, prot);
306 }
307 }
308 /* Flush last range */
310 - mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 32, 0);
309 + mem_print(hmp, env, &start, &last_prot, (hwaddr)1 << 32, 0);
310 }
311
313 -static void mem_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
312 +static void mem_info_pae32(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
313 {
314 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
315 unsigned int l1, l2, l3;
@@ -334,7 +333,7 @@ static void mem_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
333 if (pde & PG_PSE_MASK) {
334 prot = pde & (PG_USER_MASK | PG_RW_MASK |
335 PG_PRESENT_MASK);
337 - mem_print(mon, env, &start, &last_prot, end, prot);
336 + mem_print(hmp, env, &start, &last_prot, end, prot);
337 } else {
338 pt_addr = pde & 0x3fffffffff000ULL;
339 for (l3 = 0; l3 < 512; l3++) {
@@ -347,26 +346,26 @@ static void mem_info_pae32(Monitor *mon, CPUArchState *env, AddressSpace *as)
346 } else {
347 prot = 0;
348 }
350 - mem_print(mon, env, &start, &last_prot, end, prot);
349 + mem_print(hmp, env, &start, &last_prot, end, prot);
350 }
351 }
352 } else {
353 prot = 0;
355 - mem_print(mon, env, &start, &last_prot, end, prot);
354 + mem_print(hmp, env, &start, &last_prot, end, prot);
355 }
356 }
357 } else {
358 prot = 0;
360 - mem_print(mon, env, &start, &last_prot, end, prot);
359 + mem_print(hmp, env, &start, &last_prot, end, prot);
360 }
361 }
362 /* Flush last range */
364 - mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 32, 0);
363 + mem_print(hmp, env, &start, &last_prot, (hwaddr)1 << 32, 0);
364 }
365
366
367 #ifdef TARGET_X86_64
369 -static void mem_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as)
368 +static void mem_info_la48(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
369 {
370 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
371 int prot, last_prot;
@@ -390,7 +389,7 @@ static void mem_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as)
389 prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
390 PG_PRESENT_MASK);
391 prot &= pml4e;
393 - mem_print(mon, env, &start, &last_prot, end, prot);
392 + mem_print(hmp, env, &start, &last_prot, end, prot);
393 } else {
394 pd_addr = pdpe & 0x3fffffffff000ULL;
395 for (l3 = 0; l3 < 512; l3++) {
@@ -402,7 +401,7 @@ static void mem_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as)
401 prot = pde & (PG_USER_MASK | PG_RW_MASK |
402 PG_PRESENT_MASK);
403 prot &= pml4e & pdpe;
405 - mem_print(mon, env, &start,
404 + mem_print(hmp, env, &start,
405 &last_prot, end, prot);
406 } else {
407 pt_addr = pde & 0x3fffffffff000ULL;
@@ -420,32 +419,32 @@ static void mem_info_la48(Monitor *mon, CPUArchState *env, AddressSpace *as)
419 } else {
420 prot = 0;
421 }
423 - mem_print(mon, env, &start,
422 + mem_print(hmp, env, &start,
423 &last_prot, end, prot);
424 }
425 }
426 } else {
427 prot = 0;
429 - mem_print(mon, env, &start,
428 + mem_print(hmp, env, &start,
429 &last_prot, end, prot);
430 }
431 }
432 }
433 } else {
434 prot = 0;
436 - mem_print(mon, env, &start, &last_prot, end, prot);
435 + mem_print(hmp, env, &start, &last_prot, end, prot);
436 }
437 }
438 } else {
439 prot = 0;
441 - mem_print(mon, env, &start, &last_prot, end, prot);
440 + mem_print(hmp, env, &start, &last_prot, end, prot);
441 }
442 }
443 /* Flush last range */
445 - mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 48, 0);
444 + mem_print(hmp, env, &start, &last_prot, (hwaddr)1 << 48, 0);
445 }
446
448 -static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
447 +static void mem_info_la57(MonitorHMP *hmp, CPUArchState *env, AddressSpace *as)
448 {
449 const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
450 int prot, last_prot;
@@ -461,7 +460,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
460 end = l0 << 48;
461 if (!(pml5e & PG_PRESENT_MASK)) {
462 prot = 0;
464 - mem_print(mon, env, &start, &last_prot, end, prot);
463 + mem_print(hmp, env, &start, &last_prot, end, prot);
464 continue;
465 }
466
@@ -471,7 +470,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
470 end = (l0 << 48) + (l1 << 39);
471 if (!(pml4e & PG_PRESENT_MASK)) {
472 prot = 0;
474 - mem_print(mon, env, &start, &last_prot, end, prot);
473 + mem_print(hmp, env, &start, &last_prot, end, prot);
474 continue;
475 }
476
@@ -481,7 +480,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
480 end = (l0 << 48) + (l1 << 39) + (l2 << 30);
481 if (pdpe & PG_PRESENT_MASK) {
482 prot = 0;
484 - mem_print(mon, env, &start, &last_prot, end, prot);
483 + mem_print(hmp, env, &start, &last_prot, end, prot);
484 continue;
485 }
486
@@ -489,7 +488,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
488 prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
489 PG_PRESENT_MASK);
490 prot &= pml5e & pml4e;
492 - mem_print(mon, env, &start, &last_prot, end, prot);
491 + mem_print(hmp, env, &start, &last_prot, end, prot);
492 continue;
493 }
494
@@ -500,7 +499,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
499 end = (l0 << 48) + (l1 << 39) + (l2 << 30) + (l3 << 21);
500 if (pde & PG_PRESENT_MASK) {
501 prot = 0;
503 - mem_print(mon, env, &start, &last_prot, end, prot);
502 + mem_print(hmp, env, &start, &last_prot, end, prot);
503 continue;
504 }
505
@@ -508,7 +507,7 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
507 prot = pde & (PG_USER_MASK | PG_RW_MASK |
508 PG_PRESENT_MASK);
509 prot &= pml5e & pml4e & pdpe;
511 - mem_print(mon, env, &start, &last_prot, end, prot);
510 + mem_print(hmp, env, &start, &last_prot, end, prot);
511 continue;
512 }
513
@@ -525,31 +524,30 @@ static void mem_info_la57(Monitor *mon, CPUArchState *env, AddressSpace *as)
524 } else {
525 prot = 0;
526 }
528 - mem_print(mon, env, &start, &last_prot, end, prot);
527 + mem_print(hmp, env, &start, &last_prot, end, prot);
528 }
529 }
530 }
531 }
532 }
533 /* Flush last range */
535 - mem_print(mon, env, &start, &last_prot, (hwaddr)1 << 57, 0);
534 + mem_print(hmp, env, &start, &last_prot, (hwaddr)1 << 57, 0);
535 }
536 #endif /* TARGET_X86_64 */
537
538 void hmp_info_mem(MonitorHMP *hmp, const QDict *qdict)
539 {
541 - Monitor *mon = MONITOR(hmp);
540 CPUArchState *env;
541 AddressSpace *as;
542
543 env = monitor_hmp_get_cpu_env(hmp);
544 if (!env) {
547 - monitor_printf(mon, "No CPU available\n");
545 + monitor_hmp_printf(hmp, "No CPU available\n");
546 return;
547 }
548
549 if (!(env->cr[0] & CR0_PG_MASK)) {
552 - monitor_printf(mon, "PG disabled\n");
550 + monitor_hmp_printf(hmp, "PG disabled\n");
551 return;
552 }
553 as = cpu_get_address_space(env_cpu(env), X86ASIdx_MEM);
@@ -557,17 +555,17 @@ void hmp_info_mem(MonitorHMP *hmp, const QDict *qdict)
555 #ifdef TARGET_X86_64
556 if (env->hflags & HF_LMA_MASK) {
557 if (env->cr[4] & CR4_LA57_MASK) {
560 - mem_info_la57(mon, env, as);
558 + mem_info_la57(hmp, env, as);
559 } else {
562 - mem_info_la48(mon, env, as);
560 + mem_info_la48(hmp, env, as);
561 }
562 } else
563 #endif
564 {
567 - mem_info_pae32(mon, env, as);
565 + mem_info_pae32(hmp, env, as);
566 }
567 } else {
570 - mem_info_32(mon, env, as);
568 + mem_info_32(hmp, env, as);
569 }
570 }
571
target/i386/sev.c
+17 -18
@@ -786,33 +786,32 @@ SevInfo *qmp_query_sev(Error **errp)
786
787 void hmp_info_sev(MonitorHMP *hmp, const QDict *qdict)
788 {
789 - Monitor *mon = MONITOR(hmp);
789 SevInfo *info = sev_get_info();
790
791 if (!info || !info->enabled) {
793 - monitor_printf(mon, "SEV is not enabled\n");
792 + monitor_hmp_printf(hmp, "SEV is not enabled\n");
793 goto out;
794 }
795
797 - monitor_printf(mon, "SEV type: %s\n", SevGuestType_str(info->sev_type));
798 - monitor_printf(mon, "state: %s\n", SevState_str(info->state));
799 - monitor_printf(mon, "build: %d\n", info->build_id);
800 - monitor_printf(mon, "api version: %d.%d\n", info->api_major,
801 - info->api_minor);
796 + monitor_hmp_printf(hmp, "SEV type: %s\n", SevGuestType_str(info->sev_type));
797 + monitor_hmp_printf(hmp, "state: %s\n", SevState_str(info->state));
798 + monitor_hmp_printf(hmp, "build: %d\n", info->build_id);
799 + monitor_hmp_printf(hmp, "api version: %d.%d\n", info->api_major,
800 + info->api_minor);
801
802 if (sev_snp_enabled()) {
804 - monitor_printf(mon, "debug: %s\n",
805 - info->u.sev_snp.snp_policy & SEV_SNP_POLICY_DBG ? "on"
806 - : "off");
807 - monitor_printf(mon, "SMT allowed: %s\n",
808 - info->u.sev_snp.snp_policy & SEV_SNP_POLICY_SMT ? "on"
809 - : "off");
803 + monitor_hmp_printf(hmp, "debug: %s\n",
804 + info->u.sev_snp.snp_policy & SEV_SNP_POLICY_DBG ? "on"
805 + : "off");
806 + monitor_hmp_printf(hmp, "SMT allowed: %s\n",
807 + info->u.sev_snp.snp_policy & SEV_SNP_POLICY_SMT ? "on"
808 + : "off");
809 } else {
811 - monitor_printf(mon, "handle: %d\n", info->u.sev.handle);
812 - monitor_printf(mon, "debug: %s\n",
813 - info->u.sev.policy & SEV_POLICY_NODBG ? "off" : "on");
814 - monitor_printf(mon, "key-sharing: %s\n",
815 - info->u.sev.policy & SEV_POLICY_NOKS ? "off" : "on");
810 + monitor_hmp_printf(hmp, "handle: %d\n", info->u.sev.handle);
811 + monitor_hmp_printf(hmp, "debug: %s\n",
812 + info->u.sev.policy & SEV_POLICY_NODBG ? "off" : "on");
813 + monitor_hmp_printf(hmp, "key-sharing: %s\n",
814 + info->u.sev.policy & SEV_POLICY_NOKS ? "off" : "on");
815 }
816
817 out:
target/m68k/monitor.c
+1 -2
@@ -12,11 +12,10 @@
12
13 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
14 {
15 - Monitor *mon = MONITOR(hmp);
15 CPUArchState *env1 = monitor_hmp_get_cpu_env(hmp);
16
17 if (!env1) {
19 - monitor_printf(mon, "No CPU available\n");
18 + monitor_hmp_printf(hmp, "No CPU available\n");
19 return;
20 }
21
target/ppc/monitor.c
+1 -2
@@ -13,11 +13,10 @@
13
14 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
15 {
16 - Monitor *mon = MONITOR(hmp);
16 CPUArchState *env1 = monitor_hmp_get_cpu_env(hmp);
17
18 if (!env1) {
20 - monitor_printf(mon, "No CPU available\n");
19 + monitor_hmp_printf(hmp, "No CPU available\n");
20 return;
21 }
22 dump_mmu(env1);
target/riscv/monitor.c
+27 -28
@@ -51,13 +51,13 @@ static target_ulong addr_canonical(int va_bits, target_ulong addr)
51 return addr;
52 }
53
54 -static void print_pte_header(Monitor *mon)
54 +static void print_pte_header(MonitorHMP *hmp)
55 {
56 - monitor_printf(mon, PTE_HEADER_FIELDS);
57 - monitor_printf(mon, PTE_HEADER_DELIMITER);
56 + monitor_hmp_printf(hmp, PTE_HEADER_FIELDS);
57 + monitor_hmp_printf(hmp, PTE_HEADER_DELIMITER);
58 }
59
60 -static void print_pte(Monitor *mon, int va_bits, target_ulong vaddr,
60 +static void print_pte(MonitorHMP *hmp, int va_bits, target_ulong vaddr,
61 hwaddr paddr, target_ulong size, int attr)
62 {
63 /* sanity check on vaddr */
@@ -69,20 +69,20 @@ static void print_pte(Monitor *mon, int va_bits, target_ulong vaddr,
69 return;
70 }
71
72 - monitor_printf(mon, TARGET_FMT_lx " " HWADDR_FMT_plx " " TARGET_FMT_lx
73 - " %c%c%c%c%c%c%c\n",
74 - addr_canonical(va_bits, vaddr),
75 - paddr, size,
76 - attr & PTE_R ? 'r' : '-',
77 - attr & PTE_W ? 'w' : '-',
78 - attr & PTE_X ? 'x' : '-',
79 - attr & PTE_U ? 'u' : '-',
80 - attr & PTE_G ? 'g' : '-',
81 - attr & PTE_A ? 'a' : '-',
82 - attr & PTE_D ? 'd' : '-');
72 + monitor_hmp_printf(hmp, TARGET_FMT_lx " " HWADDR_FMT_plx " " TARGET_FMT_lx
73 + " %c%c%c%c%c%c%c\n",
74 + addr_canonical(va_bits, vaddr),
75 + paddr, size,
76 + attr & PTE_R ? 'r' : '-',
77 + attr & PTE_W ? 'w' : '-',
78 + attr & PTE_X ? 'x' : '-',
79 + attr & PTE_U ? 'u' : '-',
80 + attr & PTE_G ? 'g' : '-',
81 + attr & PTE_A ? 'a' : '-',
82 + attr & PTE_D ? 'd' : '-');
83 }
84
85 -static void walk_pte(Monitor *mon, AddressSpace *as,
85 +static void walk_pte(MonitorHMP *hmp, AddressSpace *as,
86 hwaddr base, target_ulong start,
87 int level, int ptidxbits, int ptesize, int va_bits,
88 target_ulong *vbase, hwaddr *pbase, hwaddr *last_paddr,
@@ -126,7 +126,7 @@ static void walk_pte(Monitor *mon, AddressSpace *as,
126 if ((*last_attr != attr) ||
127 (*last_paddr + *last_size != paddr) ||
128 (last_start + *last_size != start)) {
129 - print_pte(mon, va_bits, *vbase, *pbase,
129 + print_pte(hmp, va_bits, *vbase, *pbase,
130 *last_paddr + *last_size - *pbase, *last_attr);
131
132 *vbase = start;
@@ -139,7 +139,7 @@ static void walk_pte(Monitor *mon, AddressSpace *as,
139 *last_size = pgsize;
140 } else {
141 /* pointer to the next level of the page table */
142 - walk_pte(mon, as, paddr, start, level - 1, ptidxbits, ptesize,
142 + walk_pte(hmp, as, paddr, start, level - 1, ptidxbits, ptesize,
143 va_bits, vbase, pbase, last_paddr,
144 last_size, last_attr);
145 }
@@ -150,7 +150,7 @@ static void walk_pte(Monitor *mon, AddressSpace *as,
150
151 }
152
153 -static void mem_info_svxx(Monitor *mon, CPUArchState *env)
153 +static void mem_info_svxx(MonitorHMP *hmp, CPUArchState *env)
154 {
155 AddressSpace *as = env_cpu(env)->as;
156 int levels, ptidxbits, ptesize, vm, va_bits;
@@ -198,7 +198,7 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env)
198 va_bits = PGSHIFT + levels * ptidxbits;
199
200 /* print header */
201 - print_pte_header(mon);
201 + print_pte_header(hmp);
202
203 vbase = -1;
204 pbase = -1;
@@ -207,43 +207,42 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env)
207 last_attr = 0;
208
209 /* walk page tables, starting from address 0 */
210 - walk_pte(mon, as, base, 0, levels - 1, ptidxbits, ptesize, va_bits,
210 + walk_pte(hmp, as, base, 0, levels - 1, ptidxbits, ptesize, va_bits,
211 &vbase, &pbase, &last_paddr, &last_size, &last_attr);
212
213 /* don't forget the last one */
214 - print_pte(mon, va_bits, vbase, pbase,
214 + print_pte(hmp, va_bits, vbase, pbase,
215 last_paddr + last_size - pbase, last_attr);
216 }
217
218 void hmp_info_mem(MonitorHMP *hmp, const QDict *qdict)
219 {
220 - Monitor *mon = MONITOR(hmp);
220 CPUArchState *env;
221
222 env = monitor_hmp_get_cpu_env(hmp);
223 if (!env) {
225 - monitor_printf(mon, "No CPU available\n");
224 + monitor_hmp_printf(hmp, "No CPU available\n");
225 return;
226 }
227
228 if (!riscv_cpu_cfg(env)->mmu) {
230 - monitor_printf(mon, "S-mode MMU unavailable\n");
229 + monitor_hmp_printf(hmp, "S-mode MMU unavailable\n");
230 return;
231 }
232
233 if (riscv_cpu_mxl(env) == MXL_RV32) {
234 if (!(env->satp & SATP32_MODE)) {
236 - monitor_printf(mon, "No translation or protection\n");
235 + monitor_hmp_printf(hmp, "No translation or protection\n");
236 return;
237 }
238 } else {
239 if (!(env->satp & SATP64_MODE)) {
241 - monitor_printf(mon, "No translation or protection\n");
240 + monitor_hmp_printf(hmp, "No translation or protection\n");
241 return;
242 }
243 }
244
246 - mem_info_svxx(mon, env);
245 + mem_info_svxx(hmp, env);
246 }
247
248 #ifdef CONFIG_TCG
target/sh4/monitor.c
+14 -15
@@ -26,33 +26,32 @@
26 #include "monitor/monitor.h"
27 #include "monitor/hmp.h"
28
29 -static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
29 +static void print_tlb(MonitorHMP *hmp, int idx, tlb_t *tlb)
30 {
31 - monitor_printf(mon, " tlb%i:\t"
32 - "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
33 - "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
34 - "dirty=%hhu writethrough=%hhu\n",
35 - idx,
36 - tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
37 - tlb->v, tlb->sh, tlb->c, tlb->pr,
38 - tlb->d, tlb->wt);
31 + monitor_hmp_printf(hmp, " tlb%i:\t"
32 + "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
33 + "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
34 + "dirty=%hhu writethrough=%hhu\n",
35 + idx,
36 + tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
37 + tlb->v, tlb->sh, tlb->c, tlb->pr,
38 + tlb->d, tlb->wt);
39 }
40
41 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
42 {
43 - Monitor *mon = MONITOR(hmp);
43 CPUArchState *env = monitor_hmp_get_cpu_env(hmp);
44 int i;
45
46 if (!env) {
48 - monitor_printf(mon, "No CPU available\n");
47 + monitor_hmp_printf(hmp, "No CPU available\n");
48 return;
49 }
50
52 - monitor_printf (mon, "ITLB:\n");
51 + monitor_hmp_printf(hmp, "ITLB:\n");
52 for (i = 0 ; i < ITLB_SIZE ; i++)
54 - print_tlb (mon, i, &env->itlb[i]);
55 - monitor_printf (mon, "UTLB:\n");
53 + print_tlb(hmp, i, &env->itlb[i]);
54 + monitor_hmp_printf(hmp, "UTLB:\n");
55 for (i = 0 ; i < UTLB_SIZE ; i++)
57 - print_tlb (mon, i, &env->utlb[i]);
56 + print_tlb(hmp, i, &env->utlb[i]);
57 }
target/sparc/monitor.c
+1 -2
@@ -29,11 +29,10 @@
29
30 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
31 {
32 - Monitor *mon = MONITOR(hmp);
32 CPUArchState *env1 = monitor_hmp_get_cpu_env(hmp);
33
34 if (!env1) {
36 - monitor_printf(mon, "No CPU available\n");
35 + monitor_hmp_printf(hmp, "No CPU available\n");
36 return;
37 }
38 dump_mmu(env1);
target/xtensa/monitor.c
+1 -2
@@ -28,11 +28,10 @@
28
29 void hmp_info_tlb(MonitorHMP *hmp, const QDict *qdict)
30 {
31 - Monitor *mon = MONITOR(hmp);
31 CPUArchState *env1 = monitor_hmp_get_cpu_env(hmp);
32
33 if (!env1) {
35 - monitor_printf(mon, "No CPU available\n");
34 + monitor_hmp_printf(hmp, "No CPU available\n");
35 return;
36 }
37 dump_mmu(env1);
tests/unit/test-util-sockets.c
+1 -1
@@ -75,7 +75,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
75 */
76 Monitor *monitor_cur(void) { return cur_mon; }
77 Monitor *monitor_set_cur(Coroutine *co, Monitor *mon) { abort(); }
78 -int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); }
78 +int monitor_hmp_vprintf(MonitorHMP *mon, const char *fmt, va_list ap) { abort(); }
79
80 #ifndef _WIN32
81 static void test_socket_fd_pass_name_good(void)
tools/qemu-vnc/clipboard.c
+2 -2
@@ -62,7 +62,7 @@ vnc_dbus_clipboard_request_cancelled(VncDBusClipboardRequest *req)
62 "Cancelled clipboard request");
63
64 g_clear_object(&req->invocation);
65 - g_clear_handle_id(&req->timeout_id, g_source_remove);;
65 + g_clear_handle_id(&req->timeout_id, g_source_remove);
66 }
67
68 static gboolean
@@ -137,7 +137,7 @@ vnc_dbus_clipboard_update_info(QemuClipboardInfo *info)
137 vnc_dbus_clipboard_complete_request(
138 req->invocation, info, req->type);
139 g_clear_object(&req->invocation);
140 - g_clear_handle_id(&req->timeout_id, g_source_remove);;
140 + g_clear_handle_id(&req->timeout_id, g_source_remove);
141 return;
142 }
143
tools/qemu-vnc/stubs.c
+1 -1
@@ -42,7 +42,7 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
42 return NULL;
43 }
44
45 -int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
45 +int monitor_hmp_vprintf(MonitorHMP *mon, const char *fmt, va_list ap)
46 {
47 return -1;
48 }
trace/trace-hmp-cmds.c
+5 -7
@@ -49,7 +49,6 @@ void hmp_trace_event(MonitorHMP *hmp, const QDict *qdict)
49 #ifdef CONFIG_TRACE_SIMPLE
50 void hmp_trace_file(MonitorHMP *hmp, const QDict *qdict)
51 {
52 - Monitor *mon = MONITOR(hmp);
52 const char *op = qdict_get_try_str(qdict, "op");
53 const char *arg = qdict_get_try_str(qdict, "arg");
54
@@ -66,15 +65,14 @@ void hmp_trace_file(MonitorHMP *hmp, const QDict *qdict)
65 st_set_trace_file(arg);
66 }
67 } else {
69 - monitor_printf(mon, "unexpected argument \"%s\"\n", op);
70 - hmp_help_cmd(mon, "trace-file");
68 + monitor_hmp_printf(hmp, "unexpected argument \"%s\"\n", op);
69 + hmp_help_cmd(hmp, "trace-file");
70 }
71 }
72 #endif
73
74 void hmp_info_trace_events(MonitorHMP *hmp, const QDict *qdict)
75 {
77 - Monitor *mon = MONITOR(hmp);
76 const char *name = qdict_get_try_str(qdict, "name");
77 TraceEventInfoList *events;
78 TraceEventInfoList *elem;
@@ -91,9 +89,9 @@ void hmp_info_trace_events(MonitorHMP *hmp, const QDict *qdict)
89 }
90
91 for (elem = events; elem != NULL; elem = elem->next) {
94 - monitor_printf(mon, "%s : state %u\n",
95 - elem->value->name,
96 - elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0);
92 + monitor_hmp_printf(hmp, "%s : state %u\n",
93 + elem->value->name,
94 + elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0);
95 }
96 qapi_free_TraceEventInfoList(events);
97 }
ui/ui-hmp-cmds.c
+55 -60
@@ -81,20 +81,19 @@ void hmp_mouse_set(MonitorHMP *hmp, const QDict *qdict)
81
82 void hmp_info_mice(MonitorHMP *hmp, const QDict *qdict)
83 {
84 - Monitor *mon = MONITOR(hmp);
84 MouseInfoList *mice_list, *mouse;
85
86 mice_list = qmp_query_mice(NULL);
87 if (!mice_list) {
89 - monitor_printf(mon, "No mouse devices connected\n");
88 + monitor_hmp_printf(hmp, "No mouse devices connected\n");
89 return;
90 }
91
92 for (mouse = mice_list; mouse; mouse = mouse->next) {
94 - monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n",
95 - mouse->value->current ? '*' : ' ',
96 - mouse->value->index, mouse->value->name,
97 - mouse->value->absolute ? " (absolute)" : "");
93 + monitor_hmp_printf(hmp, "%c Mouse #%" PRId64 ": %s%s\n",
94 + mouse->value->current ? '*' : ' ',
95 + mouse->value->index, mouse->value->name,
96 + mouse->value->absolute ? " (absolute)" : "");
97 }
98
99 qapi_free_MouseInfoList(mice_list);
@@ -102,48 +101,48 @@ void hmp_info_mice(MonitorHMP *hmp, const QDict *qdict)
101
102 #ifdef CONFIG_VNC
103 /* Helper for hmp_info_vnc_clients, _servers */
105 -static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info,
104 +static void hmp_info_VncBasicInfo(MonitorHMP *hmp, VncBasicInfo *info,
105 const char *name)
106 {
108 - monitor_printf(mon, " %s: %s:%s (%s%s)\n",
109 - name,
110 - info->host,
111 - info->service,
112 - NetworkAddressFamily_str(info->family),
113 - info->websocket ? " (Websocket)" : "");
107 + monitor_hmp_printf(hmp, " %s: %s:%s (%s%s)\n",
108 + name,
109 + info->host,
110 + info->service,
111 + NetworkAddressFamily_str(info->family),
112 + info->websocket ? " (Websocket)" : "");
113 }
114
115 /* Helper displaying and auth and crypt info */
117 -static void hmp_info_vnc_authcrypt(Monitor *mon, const char *indent,
116 +static void hmp_info_vnc_authcrypt(MonitorHMP *hmp, const char *indent,
117 VncPrimaryAuth auth,
118 VncVencryptSubAuth *vencrypt)
119 {
121 - monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent,
122 - VncPrimaryAuth_str(auth),
123 - vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none");
120 + monitor_hmp_printf(hmp, "%sAuth: %s (Sub: %s)\n", indent,
121 + VncPrimaryAuth_str(auth),
122 + vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none");
123 }
124
126 -static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client)
125 +static void hmp_info_vnc_clients(MonitorHMP *hmp, VncClientInfoList *client)
126 {
127 while (client) {
128 VncClientInfo *cinfo = client->value;
129
131 - hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client");
132 - monitor_printf(mon, " x509_dname: %s\n",
133 - cinfo->x509_dname ?: "none");
134 - monitor_printf(mon, " sasl_username: %s\n",
135 - cinfo->sasl_username ?: "none");
130 + hmp_info_VncBasicInfo(hmp, qapi_VncClientInfo_base(cinfo), "Client");
131 + monitor_hmp_printf(hmp, " x509_dname: %s\n",
132 + cinfo->x509_dname ?: "none");
133 + monitor_hmp_printf(hmp, " sasl_username: %s\n",
134 + cinfo->sasl_username ?: "none");
135
136 client = client->next;
137 }
138 }
139
141 -static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server)
140 +static void hmp_info_vnc_servers(MonitorHMP *hmp, VncServerInfo2List *server)
141 {
142 while (server) {
143 VncServerInfo2 *sinfo = server->value;
145 - hmp_info_VncBasicInfo(mon, qapi_VncServerInfo2_base(sinfo), "Server");
146 - hmp_info_vnc_authcrypt(mon, " ", sinfo->auth,
144 + hmp_info_VncBasicInfo(hmp, qapi_VncServerInfo2_base(sinfo), "Server");
145 + hmp_info_vnc_authcrypt(hmp, " ", sinfo->auth,
146 sinfo->has_vencrypt ? &sinfo->vencrypt : NULL);
147 server = server->next;
148 }
@@ -151,7 +150,6 @@ static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server)
150
151 void hmp_info_vnc(MonitorHMP *hmp, const QDict *qdict)
152 {
154 - Monitor *mon = MONITOR(hmp);
153 VncInfo2List *info2l, *info2l_head;
154 Error *err = NULL;
155
@@ -161,26 +159,26 @@ void hmp_info_vnc(MonitorHMP *hmp, const QDict *qdict)
159 return;
160 }
161 if (!info2l) {
164 - monitor_printf(mon, "None\n");
162 + monitor_hmp_printf(hmp, "None\n");
163 return;
164 }
165
166 while (info2l) {
167 VncInfo2 *info = info2l->value;
170 - monitor_printf(mon, "%s:\n", info->id);
171 - hmp_info_vnc_servers(mon, info->server);
172 - hmp_info_vnc_clients(mon, info->clients);
168 + monitor_hmp_printf(hmp, "%s:\n", info->id);
169 + hmp_info_vnc_servers(hmp, info->server);
170 + hmp_info_vnc_clients(hmp, info->clients);
171 if (!info->server) {
172 /*
173 * The server entry displays its auth, we only need to
174 * display in the case of 'reverse' connections where
175 * there's no server.
176 */
179 - hmp_info_vnc_authcrypt(mon, " ", info->auth,
177 + hmp_info_vnc_authcrypt(hmp, " ", info->auth,
178 info->has_vencrypt ? &info->vencrypt : NULL);
179 }
180 if (info->display) {
183 - monitor_printf(mon, " Display: %s\n", info->display);
181 + monitor_hmp_printf(hmp, " Display: %s\n", info->display);
182 }
183 info2l = info2l->next;
184 }
@@ -193,7 +191,6 @@ void hmp_info_vnc(MonitorHMP *hmp, const QDict *qdict)
191 #ifdef CONFIG_SPICE
192 void hmp_info_spice(MonitorHMP *hmp, const QDict *qdict)
193 {
196 - Monitor *mon = MONITOR(hmp);
194 SpiceChannelList *chan;
195 SpiceInfo *info;
196 const char *channel_name;
@@ -214,38 +211,38 @@ void hmp_info_spice(MonitorHMP *hmp, const QDict *qdict)
211 info = qmp_query_spice(NULL);
212
213 if (!info->enabled) {
217 - monitor_printf(mon, "Server: disabled\n");
214 + monitor_hmp_printf(hmp, "Server: disabled\n");
215 goto out;
216 }
217
221 - monitor_printf(mon, "Server:\n");
218 + monitor_hmp_printf(hmp, "Server:\n");
219 if (info->has_port) {
223 - monitor_printf(mon, " address: %s:%" PRId64 "\n",
224 - info->host, info->port);
220 + monitor_hmp_printf(hmp, " address: %s:%" PRId64 "\n",
221 + info->host, info->port);
222 }
223 if (info->has_tls_port) {
227 - monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n",
228 - info->host, info->tls_port);
224 + monitor_hmp_printf(hmp, " address: %s:%" PRId64 " [tls]\n",
225 + info->host, info->tls_port);
226 }
230 - monitor_printf(mon, " migrated: %s\n",
231 - info->migrated ? "true" : "false");
232 - monitor_printf(mon, " auth: %s\n", info->auth);
233 - monitor_printf(mon, " compiled: %s\n", info->compiled_version);
234 - monitor_printf(mon, " mouse-mode: %s\n",
235 - SpiceQueryMouseMode_str(info->mouse_mode));
227 + monitor_hmp_printf(hmp, " migrated: %s\n",
228 + info->migrated ? "true" : "false");
229 + monitor_hmp_printf(hmp, " auth: %s\n", info->auth);
230 + monitor_hmp_printf(hmp, " compiled: %s\n", info->compiled_version);
231 + monitor_hmp_printf(hmp, " mouse-mode: %s\n",
232 + SpiceQueryMouseMode_str(info->mouse_mode));
233
234 if (!info->has_channels || info->channels == NULL) {
238 - monitor_printf(mon, "Channels: none\n");
235 + monitor_hmp_printf(hmp, "Channels: none\n");
236 } else {
237 for (chan = info->channels; chan; chan = chan->next) {
241 - monitor_printf(mon, "Channel:\n");
242 - monitor_printf(mon, " address: %s:%s%s\n",
243 - chan->value->host, chan->value->port,
244 - chan->value->tls ? " [tls]" : "");
245 - monitor_printf(mon, " session: %" PRId64 "\n",
246 - chan->value->connection_id);
247 - monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n",
248 - chan->value->channel_type, chan->value->channel_id);
238 + monitor_hmp_printf(hmp, "Channel:\n");
239 + monitor_hmp_printf(hmp, " address: %s:%s%s\n",
240 + chan->value->host, chan->value->port,
241 + chan->value->tls ? " [tls]" : "");
242 + monitor_hmp_printf(hmp, " session: %" PRId64 "\n",
243 + chan->value->connection_id);
244 + monitor_hmp_printf(hmp, " channel: %" PRId64 ":%" PRId64 "\n",
245 + chan->value->channel_type, chan->value->channel_id);
246
247 channel_name = "unknown";
248 if (chan->value->channel_type > 0 &&
@@ -254,7 +251,7 @@ void hmp_info_spice(MonitorHMP *hmp, const QDict *qdict)
251 channel_name = channel_names[chan->value->channel_type];
252 }
253
257 - monitor_printf(mon, " channel name: %s\n", channel_name);
254 + monitor_hmp_printf(hmp, " channel name: %s\n", channel_name);
255 }
256 }
257
@@ -333,7 +330,7 @@ static void hmp_change_read_arg(void *opaque, const char *password,
330 monitor_hmp_read_command(opaque, 1);
331 }
332
336 -void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
333 +void hmp_change_vnc(MonitorHMP *hmp, const char *device, const char *target,
334 const char *arg, const char *read_only, bool force,
335 Error **errp)
336 {
@@ -346,7 +343,6 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
343 return;
344 }
345 if (!arg) {
349 - MonitorHMP *hmp = MONITOR_HMP(mon);
346 monitor_hmp_read_password(hmp, hmp_change_read_arg, NULL);
347 } else {
348 qmp_change_vnc_password(arg, errp);
@@ -371,7 +367,6 @@ static int index_from_key(const char *key, size_t key_length)
367
368 void hmp_sendkey(MonitorHMP *hmp, const QDict *qdict)
369 {
374 - Monitor *mon = MONITOR(hmp);
370 const char *keys = qdict_get_str(qdict, "keys");
371 KeyValue *v = NULL;
372 KeyValueList *head = NULL, **tail = &head;
@@ -432,7 +427,7 @@ out:
427 return;
428
429 err_out:
435 - monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys);
430 + monitor_hmp_printf(hmp, "invalid parameter: %.*s\n", keyname_len, keys);
431 goto out;
432 }
433
util/error-report.c
+1 -1
@@ -36,7 +36,7 @@ static int G_GNUC_PRINTF(2, 0)
36 error_vprintf_hmp(MonitorHMP *hmp, const char *fmt, va_list ap)
37 {
38 if (hmp) {
39 - return monitor_vprintf(MONITOR(hmp), fmt, ap);
39 + return monitor_hmp_vprintf(hmp, fmt, ap);
40 }
41
42 return vfprintf(stderr, fmt, ap);
util/qemu-print.c
+15 -2
@@ -13,6 +13,7 @@
13 #include "qemu/osdep.h"
14 #include "monitor/monitor.h"
15 #include "monitor/hmp.h"
16 +#include "qom/object.h"
17 #include "qemu/qemu-print.h"
18
19 /*
@@ -23,8 +24,16 @@
24 int qemu_vprintf(const char *fmt, va_list ap)
25 {
26 Monitor *cur_mon = monitor_cur();
27 +
28 + /* for all monitors: QMP & HMP */
29 if (cur_mon) {
27 - return monitor_vprintf(cur_mon, fmt, ap);
30 + /* don't use monitor_cur_hmp(), to avoid a second lookup */
31 + MonitorHMP *hmp = (MonitorHMP *)
32 + object_dynamic_cast(OBJECT(cur_mon), TYPE_MONITOR_HMP);
33 + if (!hmp) {
34 + return -1;
35 + }
36 + return monitor_hmp_vprintf(hmp, fmt, ap);
37 }
38 return vprintf(fmt, ap);
39 }
@@ -55,7 +64,11 @@ int qemu_printf(const char *fmt, ...)
64 int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
65 {
66 if (!stream) {
58 - return monitor_vprintf(monitor_cur(), fmt, ap);
67 + MonitorHMP *hmp = monitor_cur_hmp();
68 + if (!hmp) {
69 + return -1;
70 + }
71 + return monitor_hmp_vprintf(hmp, fmt, ap);
72 }
73 return vfprintf(stream, fmt, ap);
74 }