]>
Commit | Line | Data |
---|---|---|
48a32bed AL |
1 | /* |
2 | * Human Monitor Interface | |
3 | * | |
4 | * Copyright IBM, Corp. 2011 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
14 | #include "hmp.h" | |
15 | #include "qmp-commands.h" | |
16 | ||
17 | void hmp_info_name(Monitor *mon) | |
18 | { | |
19 | NameInfo *info; | |
20 | ||
21 | info = qmp_query_name(NULL); | |
22 | if (info->has_name) { | |
23 | monitor_printf(mon, "%s\n", info->name); | |
24 | } | |
25 | qapi_free_NameInfo(info); | |
26 | } | |
b9c15f16 LC |
27 | |
28 | void hmp_info_version(Monitor *mon) | |
29 | { | |
30 | VersionInfo *info; | |
31 | ||
32 | info = qmp_query_version(NULL); | |
33 | ||
34 | monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n", | |
35 | info->qemu.major, info->qemu.minor, info->qemu.micro, | |
36 | info->package); | |
37 | ||
38 | qapi_free_VersionInfo(info); | |
39 | } | |
292a2602 LC |
40 | |
41 | void hmp_info_kvm(Monitor *mon) | |
42 | { | |
43 | KvmInfo *info; | |
44 | ||
45 | info = qmp_query_kvm(NULL); | |
46 | monitor_printf(mon, "kvm support: "); | |
47 | if (info->present) { | |
48 | monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"); | |
49 | } else { | |
50 | monitor_printf(mon, "not compiled\n"); | |
51 | } | |
52 | ||
53 | qapi_free_KvmInfo(info); | |
54 | } | |
55 | ||
1fa9a5e4 LC |
56 | void hmp_info_status(Monitor *mon) |
57 | { | |
58 | StatusInfo *info; | |
59 | ||
60 | info = qmp_query_status(NULL); | |
61 | ||
62 | monitor_printf(mon, "VM status: %s%s", | |
63 | info->running ? "running" : "paused", | |
64 | info->singlestep ? " (single step mode)" : ""); | |
65 | ||
66 | if (!info->running && info->status != RUN_STATE_PAUSED) { | |
67 | monitor_printf(mon, " (%s)", RunState_lookup[info->status]); | |
68 | } | |
69 | ||
70 | monitor_printf(mon, "\n"); | |
71 | ||
72 | qapi_free_StatusInfo(info); | |
73 | } | |
74 | ||
efab767e LC |
75 | void hmp_info_uuid(Monitor *mon) |
76 | { | |
77 | UuidInfo *info; | |
78 | ||
79 | info = qmp_query_uuid(NULL); | |
80 | monitor_printf(mon, "%s\n", info->UUID); | |
81 | qapi_free_UuidInfo(info); | |
82 | } | |
c5a415a0 LC |
83 | |
84 | void hmp_info_chardev(Monitor *mon) | |
85 | { | |
86 | ChardevInfoList *char_info, *info; | |
87 | ||
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); | |
92 | } | |
93 | ||
94 | qapi_free_ChardevInfoList(char_info); | |
95 | } | |
7a7f325e | 96 | |
e235cec3 LC |
97 | void hmp_info_mice(Monitor *mon) |
98 | { | |
99 | MouseInfoList *mice_list, *mouse; | |
100 | ||
101 | mice_list = qmp_query_mice(NULL); | |
102 | if (!mice_list) { | |
103 | monitor_printf(mon, "No mouse devices connected\n"); | |
104 | return; | |
105 | } | |
106 | ||
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)" : ""); | |
112 | } | |
113 | ||
114 | qapi_free_MouseInfoList(mice_list); | |
115 | } | |
116 | ||
791e7c82 LC |
117 | void hmp_info_migrate(Monitor *mon) |
118 | { | |
119 | MigrationInfo *info; | |
120 | ||
121 | info = qmp_query_migrate(NULL); | |
122 | ||
123 | if (info->has_status) { | |
124 | monitor_printf(mon, "Migration status: %s\n", info->status); | |
125 | } | |
126 | ||
127 | if (info->has_ram) { | |
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); | |
134 | } | |
135 | ||
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); | |
143 | } | |
144 | ||
145 | qapi_free_MigrationInfo(info); | |
146 | } | |
147 | ||
7a7f325e LC |
148 | void hmp_quit(Monitor *mon, const QDict *qdict) |
149 | { | |
150 | monitor_suspend(mon); | |
151 | qmp_quit(NULL); | |
152 | } | |
5f158f21 LC |
153 | |
154 | void hmp_stop(Monitor *mon, const QDict *qdict) | |
155 | { | |
156 | qmp_stop(NULL); | |
157 | } | |
38d22653 LC |
158 | |
159 | void hmp_system_reset(Monitor *mon, const QDict *qdict) | |
160 | { | |
161 | qmp_system_reset(NULL); | |
162 | } | |
5bc465e4 LC |
163 | |
164 | void hmp_system_powerdown(Monitor *mon, const QDict *qdict) | |
165 | { | |
166 | qmp_system_powerdown(NULL); | |
167 | } | |
755f1968 LC |
168 | |
169 | void hmp_cpu(Monitor *mon, const QDict *qdict) | |
170 | { | |
171 | int64_t cpu_index; | |
172 | ||
173 | /* XXX: drop the monitor_set_cpu() usage when all HMP commands that | |
174 | use it are converted to the QAPI */ | |
175 | cpu_index = qdict_get_int(qdict, "index"); | |
176 | if (monitor_set_cpu(cpu_index) < 0) { | |
177 | monitor_printf(mon, "invalid CPU index\n"); | |
178 | } | |
179 | } |