2 * Human Monitor Interface
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
15 #include "qmp-commands.h"
17 void hmp_info_name(Monitor
*mon
)
21 info
= qmp_query_name(NULL
);
23 monitor_printf(mon
, "%s\n", info
->name
);
25 qapi_free_NameInfo(info
);
28 void hmp_info_version(Monitor
*mon
)
32 info
= qmp_query_version(NULL
);
34 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
35 info
->qemu
.major
, info
->qemu
.minor
, info
->qemu
.micro
,
38 qapi_free_VersionInfo(info
);
41 void hmp_info_kvm(Monitor
*mon
)
45 info
= qmp_query_kvm(NULL
);
46 monitor_printf(mon
, "kvm support: ");
48 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
50 monitor_printf(mon
, "not compiled\n");
53 qapi_free_KvmInfo(info
);
56 void hmp_info_status(Monitor
*mon
)
60 info
= qmp_query_status(NULL
);
62 monitor_printf(mon
, "VM status: %s%s",
63 info
->running
? "running" : "paused",
64 info
->singlestep
? " (single step mode)" : "");
66 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
67 monitor_printf(mon
, " (%s)", RunState_lookup
[info
->status
]);
70 monitor_printf(mon
, "\n");
72 qapi_free_StatusInfo(info
);
75 void hmp_info_uuid(Monitor
*mon
)
79 info
= qmp_query_uuid(NULL
);
80 monitor_printf(mon
, "%s\n", info
->UUID
);
81 qapi_free_UuidInfo(info
);
84 void hmp_info_chardev(Monitor
*mon
)
86 ChardevInfoList
*char_info
, *info
;
88 char_info
= qmp_query_chardev(NULL
);
89 for (info
= char_info
; info
; info
= info
->next
) {
90 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
91 info
->value
->filename
);
94 qapi_free_ChardevInfoList(char_info
);
97 void hmp_info_mice(Monitor
*mon
)
99 MouseInfoList
*mice_list
, *mouse
;
101 mice_list
= qmp_query_mice(NULL
);
103 monitor_printf(mon
, "No mouse devices connected\n");
107 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
108 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
109 mouse
->value
->current
? '*' : ' ',
110 mouse
->value
->index
, mouse
->value
->name
,
111 mouse
->value
->absolute
? " (absolute)" : "");
114 qapi_free_MouseInfoList(mice_list
);
117 void hmp_info_migrate(Monitor
*mon
)
121 info
= qmp_query_migrate(NULL
);
123 if (info
->has_status
) {
124 monitor_printf(mon
, "Migration status: %s\n", info
->status
);
128 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
129 info
->ram
->transferred
>> 10);
130 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
131 info
->ram
->remaining
>> 10);
132 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
133 info
->ram
->total
>> 10);
136 if (info
->has_disk
) {
137 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
138 info
->disk
->transferred
>> 10);
139 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
140 info
->disk
->remaining
>> 10);
141 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
142 info
->disk
->total
>> 10);
145 qapi_free_MigrationInfo(info
);
148 void hmp_info_cpus(Monitor
*mon
)
150 CpuInfoList
*cpu_list
, *cpu
;
152 cpu_list
= qmp_query_cpus(NULL
);
154 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
157 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
161 monitor_printf(mon
, "%c CPU #%" PRId64
": ", active
, cpu
->value
->CPU
);
163 if (cpu
->value
->has_pc
) {
164 monitor_printf(mon
, "pc=0x%016" PRIx64
, cpu
->value
->pc
);
166 if (cpu
->value
->has_nip
) {
167 monitor_printf(mon
, "nip=0x%016" PRIx64
, cpu
->value
->nip
);
169 if (cpu
->value
->has_npc
) {
170 monitor_printf(mon
, "pc=0x%016" PRIx64
, cpu
->value
->pc
);
171 monitor_printf(mon
, "npc=0x%016" PRIx64
, cpu
->value
->npc
);
173 if (cpu
->value
->has_PC
) {
174 monitor_printf(mon
, "PC=0x%016" PRIx64
, cpu
->value
->PC
);
177 if (cpu
->value
->halted
) {
178 monitor_printf(mon
, " (halted)");
181 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
184 qapi_free_CpuInfoList(cpu_list
);
187 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
189 monitor_suspend(mon
);
193 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
198 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
200 qmp_system_reset(NULL
);
203 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
205 qmp_system_powerdown(NULL
);
208 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
212 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
213 use it are converted to the QAPI */
214 cpu_index
= qdict_get_int(qdict
, "index");
215 if (monitor_set_cpu(cpu_index
) < 0) {
216 monitor_printf(mon
, "invalid CPU index\n");