root / hmp.c @ feature-archipelago
History | View | Annotate | Download (48.1 kB)
1 | 48a32bed | Anthony Liguori | /*
|
---|---|---|---|
2 | 48a32bed | Anthony Liguori | * Human Monitor Interface
|
3 | 48a32bed | Anthony Liguori | *
|
4 | 48a32bed | Anthony Liguori | * Copyright IBM, Corp. 2011
|
5 | 48a32bed | Anthony Liguori | *
|
6 | 48a32bed | Anthony Liguori | * Authors:
|
7 | 48a32bed | Anthony Liguori | * Anthony Liguori <aliguori@us.ibm.com>
|
8 | 48a32bed | Anthony Liguori | *
|
9 | 48a32bed | Anthony Liguori | * This work is licensed under the terms of the GNU GPL, version 2. See
|
10 | 48a32bed | Anthony Liguori | * the COPYING file in the top-level directory.
|
11 | 48a32bed | Anthony Liguori | *
|
12 | 6b620ca3 | Paolo Bonzini | * Contributions after 2012-01-13 are licensed under the terms of the
|
13 | 6b620ca3 | Paolo Bonzini | * GNU GPL, version 2 or (at your option) any later version.
|
14 | 48a32bed | Anthony Liguori | */
|
15 | 48a32bed | Anthony Liguori | |
16 | 48a32bed | Anthony Liguori | #include "hmp.h" |
17 | 1422e32d | Paolo Bonzini | #include "net/net.h" |
18 | dccfcd0e | Paolo Bonzini | #include "sysemu/char.h" |
19 | 1de7afc9 | Paolo Bonzini | #include "qemu/option.h" |
20 | 1de7afc9 | Paolo Bonzini | #include "qemu/timer.h" |
21 | 48a32bed | Anthony Liguori | #include "qmp-commands.h" |
22 | 1de7afc9 | Paolo Bonzini | #include "qemu/sockets.h" |
23 | 83c9089e | Paolo Bonzini | #include "monitor/monitor.h" |
24 | cff8b2c6 | Paolo Bonzini | #include "qapi/opts-visitor.h" |
25 | 28ecbaee | Paolo Bonzini | #include "ui/console.h" |
26 | bd093a36 | Wenchao Xia | #include "block/qapi.h" |
27 | 587da2c3 | Kevin Wolf | #include "qemu-io.h" |
28 | 48a32bed | Anthony Liguori | |
29 | 0cfd6a9a | Luiz Capitulino | static void hmp_handle_error(Monitor *mon, Error **errp) |
30 | 0cfd6a9a | Luiz Capitulino | { |
31 | 0cfd6a9a | Luiz Capitulino | if (error_is_set(errp)) {
|
32 | 0cfd6a9a | Luiz Capitulino | monitor_printf(mon, "%s\n", error_get_pretty(*errp));
|
33 | 0cfd6a9a | Luiz Capitulino | error_free(*errp); |
34 | 0cfd6a9a | Luiz Capitulino | } |
35 | 0cfd6a9a | Luiz Capitulino | } |
36 | 0cfd6a9a | Luiz Capitulino | |
37 | 84f2d0ea | Wenchao Xia | void hmp_info_name(Monitor *mon, const QDict *qdict) |
38 | 48a32bed | Anthony Liguori | { |
39 | 48a32bed | Anthony Liguori | NameInfo *info; |
40 | 48a32bed | Anthony Liguori | |
41 | 48a32bed | Anthony Liguori | info = qmp_query_name(NULL);
|
42 | 48a32bed | Anthony Liguori | if (info->has_name) {
|
43 | 48a32bed | Anthony Liguori | monitor_printf(mon, "%s\n", info->name);
|
44 | 48a32bed | Anthony Liguori | } |
45 | 48a32bed | Anthony Liguori | qapi_free_NameInfo(info); |
46 | 48a32bed | Anthony Liguori | } |
47 | b9c15f16 | Luiz Capitulino | |
48 | 84f2d0ea | Wenchao Xia | void hmp_info_version(Monitor *mon, const QDict *qdict) |
49 | b9c15f16 | Luiz Capitulino | { |
50 | b9c15f16 | Luiz Capitulino | VersionInfo *info; |
51 | b9c15f16 | Luiz Capitulino | |
52 | b9c15f16 | Luiz Capitulino | info = qmp_query_version(NULL);
|
53 | b9c15f16 | Luiz Capitulino | |
54 | b9c15f16 | Luiz Capitulino | monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n", |
55 | b9c15f16 | Luiz Capitulino | info->qemu.major, info->qemu.minor, info->qemu.micro, |
56 | b9c15f16 | Luiz Capitulino | info->package); |
57 | b9c15f16 | Luiz Capitulino | |
58 | b9c15f16 | Luiz Capitulino | qapi_free_VersionInfo(info); |
59 | b9c15f16 | Luiz Capitulino | } |
60 | 292a2602 | Luiz Capitulino | |
61 | 84f2d0ea | Wenchao Xia | void hmp_info_kvm(Monitor *mon, const QDict *qdict) |
62 | 292a2602 | Luiz Capitulino | { |
63 | 292a2602 | Luiz Capitulino | KvmInfo *info; |
64 | 292a2602 | Luiz Capitulino | |
65 | 292a2602 | Luiz Capitulino | info = qmp_query_kvm(NULL);
|
66 | 292a2602 | Luiz Capitulino | monitor_printf(mon, "kvm support: ");
|
67 | 292a2602 | Luiz Capitulino | if (info->present) {
|
68 | 292a2602 | Luiz Capitulino | monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"); |
69 | 292a2602 | Luiz Capitulino | } else {
|
70 | 292a2602 | Luiz Capitulino | monitor_printf(mon, "not compiled\n");
|
71 | 292a2602 | Luiz Capitulino | } |
72 | 292a2602 | Luiz Capitulino | |
73 | 292a2602 | Luiz Capitulino | qapi_free_KvmInfo(info); |
74 | 292a2602 | Luiz Capitulino | } |
75 | 292a2602 | Luiz Capitulino | |
76 | 84f2d0ea | Wenchao Xia | void hmp_info_status(Monitor *mon, const QDict *qdict) |
77 | 1fa9a5e4 | Luiz Capitulino | { |
78 | 1fa9a5e4 | Luiz Capitulino | StatusInfo *info; |
79 | 1fa9a5e4 | Luiz Capitulino | |
80 | 1fa9a5e4 | Luiz Capitulino | info = qmp_query_status(NULL);
|
81 | 1fa9a5e4 | Luiz Capitulino | |
82 | 1fa9a5e4 | Luiz Capitulino | monitor_printf(mon, "VM status: %s%s",
|
83 | 1fa9a5e4 | Luiz Capitulino | info->running ? "running" : "paused", |
84 | 1fa9a5e4 | Luiz Capitulino | info->singlestep ? " (single step mode)" : ""); |
85 | 1fa9a5e4 | Luiz Capitulino | |
86 | 1fa9a5e4 | Luiz Capitulino | if (!info->running && info->status != RUN_STATE_PAUSED) {
|
87 | 1fa9a5e4 | Luiz Capitulino | monitor_printf(mon, " (%s)", RunState_lookup[info->status]);
|
88 | 1fa9a5e4 | Luiz Capitulino | } |
89 | 1fa9a5e4 | Luiz Capitulino | |
90 | 1fa9a5e4 | Luiz Capitulino | monitor_printf(mon, "\n");
|
91 | 1fa9a5e4 | Luiz Capitulino | |
92 | 1fa9a5e4 | Luiz Capitulino | qapi_free_StatusInfo(info); |
93 | 1fa9a5e4 | Luiz Capitulino | } |
94 | 1fa9a5e4 | Luiz Capitulino | |
95 | 84f2d0ea | Wenchao Xia | void hmp_info_uuid(Monitor *mon, const QDict *qdict) |
96 | efab767e | Luiz Capitulino | { |
97 | efab767e | Luiz Capitulino | UuidInfo *info; |
98 | efab767e | Luiz Capitulino | |
99 | efab767e | Luiz Capitulino | info = qmp_query_uuid(NULL);
|
100 | efab767e | Luiz Capitulino | monitor_printf(mon, "%s\n", info->UUID);
|
101 | efab767e | Luiz Capitulino | qapi_free_UuidInfo(info); |
102 | efab767e | Luiz Capitulino | } |
103 | c5a415a0 | Luiz Capitulino | |
104 | 84f2d0ea | Wenchao Xia | void hmp_info_chardev(Monitor *mon, const QDict *qdict) |
105 | c5a415a0 | Luiz Capitulino | { |
106 | c5a415a0 | Luiz Capitulino | ChardevInfoList *char_info, *info; |
107 | c5a415a0 | Luiz Capitulino | |
108 | c5a415a0 | Luiz Capitulino | char_info = qmp_query_chardev(NULL);
|
109 | c5a415a0 | Luiz Capitulino | for (info = char_info; info; info = info->next) {
|
110 | c5a415a0 | Luiz Capitulino | monitor_printf(mon, "%s: filename=%s\n", info->value->label,
|
111 | c5a415a0 | Luiz Capitulino | info->value->filename); |
112 | c5a415a0 | Luiz Capitulino | } |
113 | c5a415a0 | Luiz Capitulino | |
114 | c5a415a0 | Luiz Capitulino | qapi_free_ChardevInfoList(char_info); |
115 | c5a415a0 | Luiz Capitulino | } |
116 | 7a7f325e | Luiz Capitulino | |
117 | 84f2d0ea | Wenchao Xia | void hmp_info_mice(Monitor *mon, const QDict *qdict) |
118 | e235cec3 | Luiz Capitulino | { |
119 | e235cec3 | Luiz Capitulino | MouseInfoList *mice_list, *mouse; |
120 | e235cec3 | Luiz Capitulino | |
121 | e235cec3 | Luiz Capitulino | mice_list = qmp_query_mice(NULL);
|
122 | e235cec3 | Luiz Capitulino | if (!mice_list) {
|
123 | e235cec3 | Luiz Capitulino | monitor_printf(mon, "No mouse devices connected\n");
|
124 | e235cec3 | Luiz Capitulino | return;
|
125 | e235cec3 | Luiz Capitulino | } |
126 | e235cec3 | Luiz Capitulino | |
127 | e235cec3 | Luiz Capitulino | for (mouse = mice_list; mouse; mouse = mouse->next) {
|
128 | e235cec3 | Luiz Capitulino | monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n", |
129 | e235cec3 | Luiz Capitulino | mouse->value->current ? '*' : ' ', |
130 | e235cec3 | Luiz Capitulino | mouse->value->index, mouse->value->name, |
131 | e235cec3 | Luiz Capitulino | mouse->value->absolute ? " (absolute)" : ""); |
132 | e235cec3 | Luiz Capitulino | } |
133 | e235cec3 | Luiz Capitulino | |
134 | e235cec3 | Luiz Capitulino | qapi_free_MouseInfoList(mice_list); |
135 | e235cec3 | Luiz Capitulino | } |
136 | e235cec3 | Luiz Capitulino | |
137 | 84f2d0ea | Wenchao Xia | void hmp_info_migrate(Monitor *mon, const QDict *qdict) |
138 | 791e7c82 | Luiz Capitulino | { |
139 | 791e7c82 | Luiz Capitulino | MigrationInfo *info; |
140 | bbf6da32 | Orit Wasserman | MigrationCapabilityStatusList *caps, *cap; |
141 | 791e7c82 | Luiz Capitulino | |
142 | 791e7c82 | Luiz Capitulino | info = qmp_query_migrate(NULL);
|
143 | bbf6da32 | Orit Wasserman | caps = qmp_query_migrate_capabilities(NULL);
|
144 | bbf6da32 | Orit Wasserman | |
145 | bbf6da32 | Orit Wasserman | /* do not display parameters during setup */
|
146 | bbf6da32 | Orit Wasserman | if (info->has_status && caps) {
|
147 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "capabilities: ");
|
148 | bbf6da32 | Orit Wasserman | for (cap = caps; cap; cap = cap->next) {
|
149 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "%s: %s ",
|
150 | bbf6da32 | Orit Wasserman | MigrationCapability_lookup[cap->value->capability], |
151 | bbf6da32 | Orit Wasserman | cap->value->state ? "on" : "off"); |
152 | bbf6da32 | Orit Wasserman | } |
153 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "\n");
|
154 | bbf6da32 | Orit Wasserman | } |
155 | 791e7c82 | Luiz Capitulino | |
156 | 791e7c82 | Luiz Capitulino | if (info->has_status) {
|
157 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "Migration status: %s\n", info->status);
|
158 | 7aa939af | Juan Quintela | monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n", |
159 | 7aa939af | Juan Quintela | info->total_time); |
160 | 2c52ddf1 | Juan Quintela | if (info->has_expected_downtime) {
|
161 | 2c52ddf1 | Juan Quintela | monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n", |
162 | 2c52ddf1 | Juan Quintela | info->expected_downtime); |
163 | 2c52ddf1 | Juan Quintela | } |
164 | 9c5a9fcf | Juan Quintela | if (info->has_downtime) {
|
165 | 9c5a9fcf | Juan Quintela | monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n", |
166 | 9c5a9fcf | Juan Quintela | info->downtime); |
167 | 9c5a9fcf | Juan Quintela | } |
168 | ed4fbd10 | Michael R. Hines | if (info->has_setup_time) {
|
169 | ed4fbd10 | Michael R. Hines | monitor_printf(mon, "setup: %" PRIu64 " milliseconds\n", |
170 | ed4fbd10 | Michael R. Hines | info->setup_time); |
171 | ed4fbd10 | Michael R. Hines | } |
172 | 791e7c82 | Luiz Capitulino | } |
173 | 791e7c82 | Luiz Capitulino | |
174 | 791e7c82 | Luiz Capitulino | if (info->has_ram) {
|
175 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", |
176 | 791e7c82 | Luiz Capitulino | info->ram->transferred >> 10);
|
177 | 7e114f8c | Michael R. Hines | monitor_printf(mon, "throughput: %0.2f mbps\n",
|
178 | 7e114f8c | Michael R. Hines | info->ram->mbps); |
179 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", |
180 | 791e7c82 | Luiz Capitulino | info->ram->remaining >> 10);
|
181 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", |
182 | 791e7c82 | Luiz Capitulino | info->ram->total >> 10);
|
183 | 004d4c10 | Orit Wasserman | monitor_printf(mon, "duplicate: %" PRIu64 " pages\n", |
184 | 004d4c10 | Orit Wasserman | info->ram->duplicate); |
185 | f1c72795 | Peter Lieven | monitor_printf(mon, "skipped: %" PRIu64 " pages\n", |
186 | f1c72795 | Peter Lieven | info->ram->skipped); |
187 | 004d4c10 | Orit Wasserman | monitor_printf(mon, "normal: %" PRIu64 " pages\n", |
188 | 004d4c10 | Orit Wasserman | info->ram->normal); |
189 | 004d4c10 | Orit Wasserman | monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n", |
190 | 004d4c10 | Orit Wasserman | info->ram->normal_bytes >> 10);
|
191 | 8d017193 | Juan Quintela | if (info->ram->dirty_pages_rate) {
|
192 | 8d017193 | Juan Quintela | monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", |
193 | 8d017193 | Juan Quintela | info->ram->dirty_pages_rate); |
194 | 8d017193 | Juan Quintela | } |
195 | 791e7c82 | Luiz Capitulino | } |
196 | 791e7c82 | Luiz Capitulino | |
197 | 791e7c82 | Luiz Capitulino | if (info->has_disk) {
|
198 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n", |
199 | 791e7c82 | Luiz Capitulino | info->disk->transferred >> 10);
|
200 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n", |
201 | 791e7c82 | Luiz Capitulino | info->disk->remaining >> 10);
|
202 | 791e7c82 | Luiz Capitulino | monitor_printf(mon, "total disk: %" PRIu64 " kbytes\n", |
203 | 791e7c82 | Luiz Capitulino | info->disk->total >> 10);
|
204 | 791e7c82 | Luiz Capitulino | } |
205 | 791e7c82 | Luiz Capitulino | |
206 | f36d55af | Orit Wasserman | if (info->has_xbzrle_cache) {
|
207 | f36d55af | Orit Wasserman | monitor_printf(mon, "cache size: %" PRIu64 " bytes\n", |
208 | f36d55af | Orit Wasserman | info->xbzrle_cache->cache_size); |
209 | f36d55af | Orit Wasserman | monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n", |
210 | f36d55af | Orit Wasserman | info->xbzrle_cache->bytes >> 10);
|
211 | f36d55af | Orit Wasserman | monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n", |
212 | f36d55af | Orit Wasserman | info->xbzrle_cache->pages); |
213 | f36d55af | Orit Wasserman | monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n", |
214 | f36d55af | Orit Wasserman | info->xbzrle_cache->cache_miss); |
215 | f36d55af | Orit Wasserman | monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n", |
216 | f36d55af | Orit Wasserman | info->xbzrle_cache->overflow); |
217 | f36d55af | Orit Wasserman | } |
218 | f36d55af | Orit Wasserman | |
219 | 791e7c82 | Luiz Capitulino | qapi_free_MigrationInfo(info); |
220 | bbf6da32 | Orit Wasserman | qapi_free_MigrationCapabilityStatusList(caps); |
221 | bbf6da32 | Orit Wasserman | } |
222 | bbf6da32 | Orit Wasserman | |
223 | 84f2d0ea | Wenchao Xia | void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict) |
224 | bbf6da32 | Orit Wasserman | { |
225 | bbf6da32 | Orit Wasserman | MigrationCapabilityStatusList *caps, *cap; |
226 | bbf6da32 | Orit Wasserman | |
227 | bbf6da32 | Orit Wasserman | caps = qmp_query_migrate_capabilities(NULL);
|
228 | bbf6da32 | Orit Wasserman | |
229 | bbf6da32 | Orit Wasserman | if (caps) {
|
230 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "capabilities: ");
|
231 | bbf6da32 | Orit Wasserman | for (cap = caps; cap; cap = cap->next) {
|
232 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "%s: %s ",
|
233 | bbf6da32 | Orit Wasserman | MigrationCapability_lookup[cap->value->capability], |
234 | bbf6da32 | Orit Wasserman | cap->value->state ? "on" : "off"); |
235 | bbf6da32 | Orit Wasserman | } |
236 | bbf6da32 | Orit Wasserman | monitor_printf(mon, "\n");
|
237 | bbf6da32 | Orit Wasserman | } |
238 | bbf6da32 | Orit Wasserman | |
239 | bbf6da32 | Orit Wasserman | qapi_free_MigrationCapabilityStatusList(caps); |
240 | 791e7c82 | Luiz Capitulino | } |
241 | 791e7c82 | Luiz Capitulino | |
242 | 84f2d0ea | Wenchao Xia | void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict) |
243 | 9e1ba4cc | Orit Wasserman | { |
244 | 9e1ba4cc | Orit Wasserman | monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n", |
245 | 9e1ba4cc | Orit Wasserman | qmp_query_migrate_cache_size(NULL) >> 10); |
246 | 9e1ba4cc | Orit Wasserman | } |
247 | 9e1ba4cc | Orit Wasserman | |
248 | 84f2d0ea | Wenchao Xia | void hmp_info_cpus(Monitor *mon, const QDict *qdict) |
249 | de0b36b6 | Luiz Capitulino | { |
250 | de0b36b6 | Luiz Capitulino | CpuInfoList *cpu_list, *cpu; |
251 | de0b36b6 | Luiz Capitulino | |
252 | de0b36b6 | Luiz Capitulino | cpu_list = qmp_query_cpus(NULL);
|
253 | de0b36b6 | Luiz Capitulino | |
254 | de0b36b6 | Luiz Capitulino | for (cpu = cpu_list; cpu; cpu = cpu->next) {
|
255 | de0b36b6 | Luiz Capitulino | int active = ' '; |
256 | de0b36b6 | Luiz Capitulino | |
257 | de0b36b6 | Luiz Capitulino | if (cpu->value->CPU == monitor_get_cpu_index()) {
|
258 | de0b36b6 | Luiz Capitulino | active = '*';
|
259 | de0b36b6 | Luiz Capitulino | } |
260 | de0b36b6 | Luiz Capitulino | |
261 | 852bef0e | Aurelien Jarno | monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CPU); |
262 | de0b36b6 | Luiz Capitulino | |
263 | de0b36b6 | Luiz Capitulino | if (cpu->value->has_pc) {
|
264 | 852bef0e | Aurelien Jarno | monitor_printf(mon, " pc=0x%016" PRIx64, cpu->value->pc);
|
265 | de0b36b6 | Luiz Capitulino | } |
266 | de0b36b6 | Luiz Capitulino | if (cpu->value->has_nip) {
|
267 | 852bef0e | Aurelien Jarno | monitor_printf(mon, " nip=0x%016" PRIx64, cpu->value->nip);
|
268 | de0b36b6 | Luiz Capitulino | } |
269 | de0b36b6 | Luiz Capitulino | if (cpu->value->has_npc) {
|
270 | 852bef0e | Aurelien Jarno | monitor_printf(mon, " npc=0x%016" PRIx64, cpu->value->npc);
|
271 | de0b36b6 | Luiz Capitulino | } |
272 | de0b36b6 | Luiz Capitulino | if (cpu->value->has_PC) {
|
273 | 852bef0e | Aurelien Jarno | monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->PC);
|
274 | de0b36b6 | Luiz Capitulino | } |
275 | de0b36b6 | Luiz Capitulino | |
276 | de0b36b6 | Luiz Capitulino | if (cpu->value->halted) {
|
277 | de0b36b6 | Luiz Capitulino | monitor_printf(mon, " (halted)");
|
278 | de0b36b6 | Luiz Capitulino | } |
279 | de0b36b6 | Luiz Capitulino | |
280 | de0b36b6 | Luiz Capitulino | monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id); |
281 | de0b36b6 | Luiz Capitulino | } |
282 | de0b36b6 | Luiz Capitulino | |
283 | de0b36b6 | Luiz Capitulino | qapi_free_CpuInfoList(cpu_list); |
284 | de0b36b6 | Luiz Capitulino | } |
285 | de0b36b6 | Luiz Capitulino | |
286 | 84f2d0ea | Wenchao Xia | void hmp_info_block(Monitor *mon, const QDict *qdict) |
287 | b2023818 | Luiz Capitulino | { |
288 | b2023818 | Luiz Capitulino | BlockInfoList *block_list, *info; |
289 | bd093a36 | Wenchao Xia | ImageInfo *image_info; |
290 | e73fe2b4 | Wenchao Xia | const char *device = qdict_get_try_str(qdict, "device"); |
291 | e73fe2b4 | Wenchao Xia | bool verbose = qdict_get_try_bool(qdict, "verbose", 0); |
292 | b2023818 | Luiz Capitulino | |
293 | b2023818 | Luiz Capitulino | block_list = qmp_query_block(NULL);
|
294 | b2023818 | Luiz Capitulino | |
295 | b2023818 | Luiz Capitulino | for (info = block_list; info; info = info->next) {
|
296 | e73fe2b4 | Wenchao Xia | if (device && strcmp(device, info->value->device)) {
|
297 | e73fe2b4 | Wenchao Xia | continue;
|
298 | e73fe2b4 | Wenchao Xia | } |
299 | b2023818 | Luiz Capitulino | |
300 | fbe2e26c | Kevin Wolf | if (info != block_list) {
|
301 | fbe2e26c | Kevin Wolf | monitor_printf(mon, "\n");
|
302 | fbe2e26c | Kevin Wolf | } |
303 | fbe2e26c | Kevin Wolf | |
304 | fbe2e26c | Kevin Wolf | monitor_printf(mon, "%s", info->value->device);
|
305 | fbe2e26c | Kevin Wolf | if (info->value->has_inserted) {
|
306 | fbe2e26c | Kevin Wolf | monitor_printf(mon, ": %s (%s%s%s)\n",
|
307 | fbe2e26c | Kevin Wolf | info->value->inserted->file, |
308 | fbe2e26c | Kevin Wolf | info->value->inserted->drv, |
309 | fbe2e26c | Kevin Wolf | info->value->inserted->ro ? ", read-only" : "", |
310 | fbe2e26c | Kevin Wolf | info->value->inserted->encrypted ? ", encrypted" : ""); |
311 | fbe2e26c | Kevin Wolf | } else {
|
312 | fbe2e26c | Kevin Wolf | monitor_printf(mon, ": [not inserted]\n");
|
313 | b2023818 | Luiz Capitulino | } |
314 | b2023818 | Luiz Capitulino | |
315 | fbe2e26c | Kevin Wolf | if (info->value->has_io_status && info->value->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
|
316 | fbe2e26c | Kevin Wolf | monitor_printf(mon, " I/O status: %s\n",
|
317 | b2023818 | Luiz Capitulino | BlockDeviceIoStatus_lookup[info->value->io_status]); |
318 | b2023818 | Luiz Capitulino | } |
319 | b2023818 | Luiz Capitulino | |
320 | fbe2e26c | Kevin Wolf | if (info->value->removable) {
|
321 | fbe2e26c | Kevin Wolf | monitor_printf(mon, " Removable device: %slocked, tray %s\n",
|
322 | fbe2e26c | Kevin Wolf | info->value->locked ? "" : "not ", |
323 | fbe2e26c | Kevin Wolf | info->value->tray_open ? "open" : "closed"); |
324 | fbe2e26c | Kevin Wolf | } |
325 | 727f005e | Zhi Yong Wu | |
326 | fbe2e26c | Kevin Wolf | |
327 | fbe2e26c | Kevin Wolf | if (!info->value->has_inserted) {
|
328 | fbe2e26c | Kevin Wolf | continue;
|
329 | fbe2e26c | Kevin Wolf | } |
330 | fbe2e26c | Kevin Wolf | |
331 | fbe2e26c | Kevin Wolf | if (info->value->inserted->has_backing_file) {
|
332 | fbe2e26c | Kevin Wolf | monitor_printf(mon, |
333 | fbe2e26c | Kevin Wolf | " Backing file: %s "
|
334 | fbe2e26c | Kevin Wolf | "(chain depth: %" PRId64 ")\n", |
335 | fbe2e26c | Kevin Wolf | info->value->inserted->backing_file, |
336 | fbe2e26c | Kevin Wolf | info->value->inserted->backing_file_depth); |
337 | fbe2e26c | Kevin Wolf | } |
338 | fbe2e26c | Kevin Wolf | |
339 | fbe2e26c | Kevin Wolf | if (info->value->inserted->bps
|
340 | fbe2e26c | Kevin Wolf | || info->value->inserted->bps_rd |
341 | fbe2e26c | Kevin Wolf | || info->value->inserted->bps_wr |
342 | fbe2e26c | Kevin Wolf | || info->value->inserted->iops |
343 | fbe2e26c | Kevin Wolf | || info->value->inserted->iops_rd |
344 | fbe2e26c | Kevin Wolf | || info->value->inserted->iops_wr) |
345 | fbe2e26c | Kevin Wolf | { |
346 | fbe2e26c | Kevin Wolf | monitor_printf(mon, " I/O throttling: bps=%" PRId64
|
347 | fbe2e26c | Kevin Wolf | " bps_rd=%" PRId64 " bps_wr=%" PRId64 |
348 | 3e9fab69 | Benoรฎt Canet | " bps_max=%" PRId64
|
349 | 3e9fab69 | Benoรฎt Canet | " bps_rd_max=%" PRId64
|
350 | 3e9fab69 | Benoรฎt Canet | " bps_wr_max=%" PRId64
|
351 | fbe2e26c | Kevin Wolf | " iops=%" PRId64 " iops_rd=%" PRId64 |
352 | 3e9fab69 | Benoรฎt Canet | " iops_wr=%" PRId64
|
353 | 3e9fab69 | Benoรฎt Canet | " iops_max=%" PRId64
|
354 | 3e9fab69 | Benoรฎt Canet | " iops_rd_max=%" PRId64
|
355 | 2024c1df | Benoรฎt Canet | " iops_wr_max=%" PRId64
|
356 | 2024c1df | Benoรฎt Canet | " iops_size=%" PRId64 "\n", |
357 | 727f005e | Zhi Yong Wu | info->value->inserted->bps, |
358 | 727f005e | Zhi Yong Wu | info->value->inserted->bps_rd, |
359 | 727f005e | Zhi Yong Wu | info->value->inserted->bps_wr, |
360 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->bps_max, |
361 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->bps_rd_max, |
362 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->bps_wr_max, |
363 | 727f005e | Zhi Yong Wu | info->value->inserted->iops, |
364 | 727f005e | Zhi Yong Wu | info->value->inserted->iops_rd, |
365 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->iops_wr, |
366 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->iops_max, |
367 | 3e9fab69 | Benoรฎt Canet | info->value->inserted->iops_rd_max, |
368 | 2024c1df | Benoรฎt Canet | info->value->inserted->iops_wr_max, |
369 | 2024c1df | Benoรฎt Canet | info->value->inserted->iops_size); |
370 | fbe2e26c | Kevin Wolf | } |
371 | bd093a36 | Wenchao Xia | |
372 | fbe2e26c | Kevin Wolf | if (verbose) {
|
373 | fbe2e26c | Kevin Wolf | monitor_printf(mon, "\nImages:\n");
|
374 | fbe2e26c | Kevin Wolf | image_info = info->value->inserted->image; |
375 | fbe2e26c | Kevin Wolf | while (1) { |
376 | fbe2e26c | Kevin Wolf | bdrv_image_info_dump((fprintf_function)monitor_printf, |
377 | fbe2e26c | Kevin Wolf | mon, image_info); |
378 | fbe2e26c | Kevin Wolf | if (image_info->has_backing_image) {
|
379 | fbe2e26c | Kevin Wolf | image_info = image_info->backing_image; |
380 | fbe2e26c | Kevin Wolf | } else {
|
381 | fbe2e26c | Kevin Wolf | break;
|
382 | bd093a36 | Wenchao Xia | } |
383 | bd093a36 | Wenchao Xia | } |
384 | b2023818 | Luiz Capitulino | } |
385 | b2023818 | Luiz Capitulino | } |
386 | b2023818 | Luiz Capitulino | |
387 | b2023818 | Luiz Capitulino | qapi_free_BlockInfoList(block_list); |
388 | b2023818 | Luiz Capitulino | } |
389 | b2023818 | Luiz Capitulino | |
390 | 84f2d0ea | Wenchao Xia | void hmp_info_blockstats(Monitor *mon, const QDict *qdict) |
391 | f11f57e4 | Luiz Capitulino | { |
392 | f11f57e4 | Luiz Capitulino | BlockStatsList *stats_list, *stats; |
393 | f11f57e4 | Luiz Capitulino | |
394 | f11f57e4 | Luiz Capitulino | stats_list = qmp_query_blockstats(NULL);
|
395 | f11f57e4 | Luiz Capitulino | |
396 | f11f57e4 | Luiz Capitulino | for (stats = stats_list; stats; stats = stats->next) {
|
397 | f11f57e4 | Luiz Capitulino | if (!stats->value->has_device) {
|
398 | f11f57e4 | Luiz Capitulino | continue;
|
399 | f11f57e4 | Luiz Capitulino | } |
400 | f11f57e4 | Luiz Capitulino | |
401 | f11f57e4 | Luiz Capitulino | monitor_printf(mon, "%s:", stats->value->device);
|
402 | f11f57e4 | Luiz Capitulino | monitor_printf(mon, " rd_bytes=%" PRId64
|
403 | f11f57e4 | Luiz Capitulino | " wr_bytes=%" PRId64
|
404 | f11f57e4 | Luiz Capitulino | " rd_operations=%" PRId64
|
405 | f11f57e4 | Luiz Capitulino | " wr_operations=%" PRId64
|
406 | f11f57e4 | Luiz Capitulino | " flush_operations=%" PRId64
|
407 | f11f57e4 | Luiz Capitulino | " wr_total_time_ns=%" PRId64
|
408 | f11f57e4 | Luiz Capitulino | " rd_total_time_ns=%" PRId64
|
409 | f11f57e4 | Luiz Capitulino | " flush_total_time_ns=%" PRId64
|
410 | f11f57e4 | Luiz Capitulino | "\n",
|
411 | f11f57e4 | Luiz Capitulino | stats->value->stats->rd_bytes, |
412 | f11f57e4 | Luiz Capitulino | stats->value->stats->wr_bytes, |
413 | f11f57e4 | Luiz Capitulino | stats->value->stats->rd_operations, |
414 | f11f57e4 | Luiz Capitulino | stats->value->stats->wr_operations, |
415 | f11f57e4 | Luiz Capitulino | stats->value->stats->flush_operations, |
416 | f11f57e4 | Luiz Capitulino | stats->value->stats->wr_total_time_ns, |
417 | f11f57e4 | Luiz Capitulino | stats->value->stats->rd_total_time_ns, |
418 | f11f57e4 | Luiz Capitulino | stats->value->stats->flush_total_time_ns); |
419 | f11f57e4 | Luiz Capitulino | } |
420 | f11f57e4 | Luiz Capitulino | |
421 | f11f57e4 | Luiz Capitulino | qapi_free_BlockStatsList(stats_list); |
422 | f11f57e4 | Luiz Capitulino | } |
423 | f11f57e4 | Luiz Capitulino | |
424 | 84f2d0ea | Wenchao Xia | void hmp_info_vnc(Monitor *mon, const QDict *qdict) |
425 | 2b54aa87 | Luiz Capitulino | { |
426 | 2b54aa87 | Luiz Capitulino | VncInfo *info; |
427 | 2b54aa87 | Luiz Capitulino | Error *err = NULL;
|
428 | 2b54aa87 | Luiz Capitulino | VncClientInfoList *client; |
429 | 2b54aa87 | Luiz Capitulino | |
430 | 2b54aa87 | Luiz Capitulino | info = qmp_query_vnc(&err); |
431 | 2b54aa87 | Luiz Capitulino | if (err) {
|
432 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, "%s\n", error_get_pretty(err));
|
433 | 2b54aa87 | Luiz Capitulino | error_free(err); |
434 | 2b54aa87 | Luiz Capitulino | return;
|
435 | 2b54aa87 | Luiz Capitulino | } |
436 | 2b54aa87 | Luiz Capitulino | |
437 | 2b54aa87 | Luiz Capitulino | if (!info->enabled) {
|
438 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, "Server: disabled\n");
|
439 | 2b54aa87 | Luiz Capitulino | goto out;
|
440 | 2b54aa87 | Luiz Capitulino | } |
441 | 2b54aa87 | Luiz Capitulino | |
442 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, "Server:\n");
|
443 | 2b54aa87 | Luiz Capitulino | if (info->has_host && info->has_service) {
|
444 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, " address: %s:%s\n", info->host, info->service);
|
445 | 2b54aa87 | Luiz Capitulino | } |
446 | 2b54aa87 | Luiz Capitulino | if (info->has_auth) {
|
447 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, " auth: %s\n", info->auth);
|
448 | 2b54aa87 | Luiz Capitulino | } |
449 | 2b54aa87 | Luiz Capitulino | |
450 | 2b54aa87 | Luiz Capitulino | if (!info->has_clients || info->clients == NULL) { |
451 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, "Client: none\n");
|
452 | 2b54aa87 | Luiz Capitulino | } else {
|
453 | 2b54aa87 | Luiz Capitulino | for (client = info->clients; client; client = client->next) {
|
454 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, "Client:\n");
|
455 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, " address: %s:%s\n",
|
456 | 2b54aa87 | Luiz Capitulino | client->value->host, client->value->service); |
457 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, " x509_dname: %s\n",
|
458 | 2b54aa87 | Luiz Capitulino | client->value->x509_dname ? |
459 | 2b54aa87 | Luiz Capitulino | client->value->x509_dname : "none");
|
460 | 2b54aa87 | Luiz Capitulino | monitor_printf(mon, " username: %s\n",
|
461 | 2b54aa87 | Luiz Capitulino | client->value->has_sasl_username ? |
462 | 2b54aa87 | Luiz Capitulino | client->value->sasl_username : "none");
|
463 | 2b54aa87 | Luiz Capitulino | } |
464 | 2b54aa87 | Luiz Capitulino | } |
465 | 2b54aa87 | Luiz Capitulino | |
466 | 2b54aa87 | Luiz Capitulino | out:
|
467 | 2b54aa87 | Luiz Capitulino | qapi_free_VncInfo(info); |
468 | 2b54aa87 | Luiz Capitulino | } |
469 | 2b54aa87 | Luiz Capitulino | |
470 | 84f2d0ea | Wenchao Xia | void hmp_info_spice(Monitor *mon, const QDict *qdict) |
471 | d1f29646 | Luiz Capitulino | { |
472 | d1f29646 | Luiz Capitulino | SpiceChannelList *chan; |
473 | d1f29646 | Luiz Capitulino | SpiceInfo *info; |
474 | d1f29646 | Luiz Capitulino | |
475 | d1f29646 | Luiz Capitulino | info = qmp_query_spice(NULL);
|
476 | d1f29646 | Luiz Capitulino | |
477 | d1f29646 | Luiz Capitulino | if (!info->enabled) {
|
478 | d1f29646 | Luiz Capitulino | monitor_printf(mon, "Server: disabled\n");
|
479 | d1f29646 | Luiz Capitulino | goto out;
|
480 | d1f29646 | Luiz Capitulino | } |
481 | d1f29646 | Luiz Capitulino | |
482 | d1f29646 | Luiz Capitulino | monitor_printf(mon, "Server:\n");
|
483 | d1f29646 | Luiz Capitulino | if (info->has_port) {
|
484 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " address: %s:%" PRId64 "\n", |
485 | d1f29646 | Luiz Capitulino | info->host, info->port); |
486 | d1f29646 | Luiz Capitulino | } |
487 | d1f29646 | Luiz Capitulino | if (info->has_tls_port) {
|
488 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n", |
489 | d1f29646 | Luiz Capitulino | info->host, info->tls_port); |
490 | d1f29646 | Luiz Capitulino | } |
491 | 61c4efe2 | Yonit Halperin | monitor_printf(mon, " migrated: %s\n",
|
492 | 61c4efe2 | Yonit Halperin | info->migrated ? "true" : "false"); |
493 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " auth: %s\n", info->auth);
|
494 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " compiled: %s\n", info->compiled_version);
|
495 | 4efee029 | Alon Levy | monitor_printf(mon, " mouse-mode: %s\n",
|
496 | 4efee029 | Alon Levy | SpiceQueryMouseMode_lookup[info->mouse_mode]); |
497 | d1f29646 | Luiz Capitulino | |
498 | d1f29646 | Luiz Capitulino | if (!info->has_channels || info->channels == NULL) { |
499 | d1f29646 | Luiz Capitulino | monitor_printf(mon, "Channels: none\n");
|
500 | d1f29646 | Luiz Capitulino | } else {
|
501 | d1f29646 | Luiz Capitulino | for (chan = info->channels; chan; chan = chan->next) {
|
502 | d1f29646 | Luiz Capitulino | monitor_printf(mon, "Channel:\n");
|
503 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " address: %s:%s%s\n",
|
504 | d1f29646 | Luiz Capitulino | chan->value->host, chan->value->port, |
505 | d1f29646 | Luiz Capitulino | chan->value->tls ? " [tls]" : ""); |
506 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " session: %" PRId64 "\n", |
507 | d1f29646 | Luiz Capitulino | chan->value->connection_id); |
508 | d1f29646 | Luiz Capitulino | monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n", |
509 | d1f29646 | Luiz Capitulino | chan->value->channel_type, chan->value->channel_id); |
510 | d1f29646 | Luiz Capitulino | } |
511 | d1f29646 | Luiz Capitulino | } |
512 | d1f29646 | Luiz Capitulino | |
513 | d1f29646 | Luiz Capitulino | out:
|
514 | d1f29646 | Luiz Capitulino | qapi_free_SpiceInfo(info); |
515 | d1f29646 | Luiz Capitulino | } |
516 | d1f29646 | Luiz Capitulino | |
517 | 84f2d0ea | Wenchao Xia | void hmp_info_balloon(Monitor *mon, const QDict *qdict) |
518 | 96637bcd | Luiz Capitulino | { |
519 | 96637bcd | Luiz Capitulino | BalloonInfo *info; |
520 | 96637bcd | Luiz Capitulino | Error *err = NULL;
|
521 | 96637bcd | Luiz Capitulino | |
522 | 96637bcd | Luiz Capitulino | info = qmp_query_balloon(&err); |
523 | 96637bcd | Luiz Capitulino | if (err) {
|
524 | 96637bcd | Luiz Capitulino | monitor_printf(mon, "%s\n", error_get_pretty(err));
|
525 | 96637bcd | Luiz Capitulino | error_free(err); |
526 | 96637bcd | Luiz Capitulino | return;
|
527 | 96637bcd | Luiz Capitulino | } |
528 | 96637bcd | Luiz Capitulino | |
529 | 01ceb97e | Luiz Capitulino | monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20); |
530 | 96637bcd | Luiz Capitulino | |
531 | 96637bcd | Luiz Capitulino | qapi_free_BalloonInfo(info); |
532 | 96637bcd | Luiz Capitulino | } |
533 | 96637bcd | Luiz Capitulino | |
534 | 79627472 | Luiz Capitulino | static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) |
535 | 79627472 | Luiz Capitulino | { |
536 | 79627472 | Luiz Capitulino | PciMemoryRegionList *region; |
537 | 79627472 | Luiz Capitulino | |
538 | 79627472 | Luiz Capitulino | monitor_printf(mon, " Bus %2" PRId64 ", ", dev->bus); |
539 | 79627472 | Luiz Capitulino | monitor_printf(mon, "device %3" PRId64 ", function %" PRId64 ":\n", |
540 | 79627472 | Luiz Capitulino | dev->slot, dev->function); |
541 | 79627472 | Luiz Capitulino | monitor_printf(mon, " ");
|
542 | 79627472 | Luiz Capitulino | |
543 | 79627472 | Luiz Capitulino | if (dev->class_info.has_desc) {
|
544 | 79627472 | Luiz Capitulino | monitor_printf(mon, "%s", dev->class_info.desc);
|
545 | 79627472 | Luiz Capitulino | } else {
|
546 | 6f88009e | Tomoki Sekiyama | monitor_printf(mon, "Class %04" PRId64, dev->class_info.q_class);
|
547 | 79627472 | Luiz Capitulino | } |
548 | 79627472 | Luiz Capitulino | |
549 | 79627472 | Luiz Capitulino | monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n", |
550 | 79627472 | Luiz Capitulino | dev->id.vendor, dev->id.device); |
551 | 79627472 | Luiz Capitulino | |
552 | 79627472 | Luiz Capitulino | if (dev->has_irq) {
|
553 | 79627472 | Luiz Capitulino | monitor_printf(mon, " IRQ %" PRId64 ".\n", dev->irq); |
554 | 79627472 | Luiz Capitulino | } |
555 | 79627472 | Luiz Capitulino | |
556 | 79627472 | Luiz Capitulino | if (dev->has_pci_bridge) {
|
557 | 79627472 | Luiz Capitulino | monitor_printf(mon, " BUS %" PRId64 ".\n", |
558 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.number); |
559 | 79627472 | Luiz Capitulino | monitor_printf(mon, " secondary bus %" PRId64 ".\n", |
560 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.secondary); |
561 | 79627472 | Luiz Capitulino | monitor_printf(mon, " subordinate bus %" PRId64 ".\n", |
562 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.subordinate); |
563 | 79627472 | Luiz Capitulino | |
564 | 79627472 | Luiz Capitulino | monitor_printf(mon, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n", |
565 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.io_range->base, |
566 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.io_range->limit); |
567 | 79627472 | Luiz Capitulino | |
568 | 79627472 | Luiz Capitulino | monitor_printf(mon, |
569 | 79627472 | Luiz Capitulino | " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n", |
570 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.memory_range->base, |
571 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.memory_range->limit); |
572 | 79627472 | Luiz Capitulino | |
573 | 79627472 | Luiz Capitulino | monitor_printf(mon, " prefetchable memory range "
|
574 | 79627472 | Luiz Capitulino | "[0x%08"PRIx64", 0x%08"PRIx64"]\n", |
575 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.prefetchable_range->base, |
576 | 79627472 | Luiz Capitulino | dev->pci_bridge->bus.prefetchable_range->limit); |
577 | 79627472 | Luiz Capitulino | } |
578 | 79627472 | Luiz Capitulino | |
579 | 79627472 | Luiz Capitulino | for (region = dev->regions; region; region = region->next) {
|
580 | 79627472 | Luiz Capitulino | uint64_t addr, size; |
581 | 79627472 | Luiz Capitulino | |
582 | 79627472 | Luiz Capitulino | addr = region->value->address; |
583 | 79627472 | Luiz Capitulino | size = region->value->size; |
584 | 79627472 | Luiz Capitulino | |
585 | 79627472 | Luiz Capitulino | monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar); |
586 | 79627472 | Luiz Capitulino | |
587 | 79627472 | Luiz Capitulino | if (!strcmp(region->value->type, "io")) { |
588 | 79627472 | Luiz Capitulino | monitor_printf(mon, "I/O at 0x%04" PRIx64
|
589 | 79627472 | Luiz Capitulino | " [0x%04" PRIx64 "].\n", |
590 | 79627472 | Luiz Capitulino | addr, addr + size - 1);
|
591 | 79627472 | Luiz Capitulino | } else {
|
592 | 79627472 | Luiz Capitulino | monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64
|
593 | 79627472 | Luiz Capitulino | " [0x%08" PRIx64 "].\n", |
594 | 79627472 | Luiz Capitulino | region->value->mem_type_64 ? 64 : 32, |
595 | 79627472 | Luiz Capitulino | region->value->prefetch ? " prefetchable" : "", |
596 | 79627472 | Luiz Capitulino | addr, addr + size - 1);
|
597 | 79627472 | Luiz Capitulino | } |
598 | 79627472 | Luiz Capitulino | } |
599 | 79627472 | Luiz Capitulino | |
600 | 79627472 | Luiz Capitulino | monitor_printf(mon, " id \"%s\"\n", dev->qdev_id);
|
601 | 79627472 | Luiz Capitulino | |
602 | 79627472 | Luiz Capitulino | if (dev->has_pci_bridge) {
|
603 | 79627472 | Luiz Capitulino | if (dev->pci_bridge->has_devices) {
|
604 | 79627472 | Luiz Capitulino | PciDeviceInfoList *cdev; |
605 | 79627472 | Luiz Capitulino | for (cdev = dev->pci_bridge->devices; cdev; cdev = cdev->next) {
|
606 | 79627472 | Luiz Capitulino | hmp_info_pci_device(mon, cdev->value); |
607 | 79627472 | Luiz Capitulino | } |
608 | 79627472 | Luiz Capitulino | } |
609 | 79627472 | Luiz Capitulino | } |
610 | 79627472 | Luiz Capitulino | } |
611 | 79627472 | Luiz Capitulino | |
612 | 84f2d0ea | Wenchao Xia | void hmp_info_pci(Monitor *mon, const QDict *qdict) |
613 | 79627472 | Luiz Capitulino | { |
614 | f46cee37 | Stefan Berger | PciInfoList *info_list, *info; |
615 | 79627472 | Luiz Capitulino | Error *err = NULL;
|
616 | 79627472 | Luiz Capitulino | |
617 | f46cee37 | Stefan Berger | info_list = qmp_query_pci(&err); |
618 | 79627472 | Luiz Capitulino | if (err) {
|
619 | 79627472 | Luiz Capitulino | monitor_printf(mon, "PCI devices not supported\n");
|
620 | 79627472 | Luiz Capitulino | error_free(err); |
621 | 79627472 | Luiz Capitulino | return;
|
622 | 79627472 | Luiz Capitulino | } |
623 | 79627472 | Luiz Capitulino | |
624 | f46cee37 | Stefan Berger | for (info = info_list; info; info = info->next) {
|
625 | 79627472 | Luiz Capitulino | PciDeviceInfoList *dev; |
626 | 79627472 | Luiz Capitulino | |
627 | 79627472 | Luiz Capitulino | for (dev = info->value->devices; dev; dev = dev->next) {
|
628 | 79627472 | Luiz Capitulino | hmp_info_pci_device(mon, dev->value); |
629 | 79627472 | Luiz Capitulino | } |
630 | 79627472 | Luiz Capitulino | } |
631 | 79627472 | Luiz Capitulino | |
632 | f46cee37 | Stefan Berger | qapi_free_PciInfoList(info_list); |
633 | 79627472 | Luiz Capitulino | } |
634 | 79627472 | Luiz Capitulino | |
635 | 84f2d0ea | Wenchao Xia | void hmp_info_block_jobs(Monitor *mon, const QDict *qdict) |
636 | fb5458cd | Stefan Hajnoczi | { |
637 | fb5458cd | Stefan Hajnoczi | BlockJobInfoList *list; |
638 | fb5458cd | Stefan Hajnoczi | Error *err = NULL;
|
639 | fb5458cd | Stefan Hajnoczi | |
640 | fb5458cd | Stefan Hajnoczi | list = qmp_query_block_jobs(&err); |
641 | fb5458cd | Stefan Hajnoczi | assert(!err); |
642 | fb5458cd | Stefan Hajnoczi | |
643 | fb5458cd | Stefan Hajnoczi | if (!list) {
|
644 | fb5458cd | Stefan Hajnoczi | monitor_printf(mon, "No active jobs\n");
|
645 | fb5458cd | Stefan Hajnoczi | return;
|
646 | fb5458cd | Stefan Hajnoczi | } |
647 | fb5458cd | Stefan Hajnoczi | |
648 | fb5458cd | Stefan Hajnoczi | while (list) {
|
649 | fb5458cd | Stefan Hajnoczi | if (strcmp(list->value->type, "stream") == 0) { |
650 | fb5458cd | Stefan Hajnoczi | monitor_printf(mon, "Streaming device %s: Completed %" PRId64
|
651 | fb5458cd | Stefan Hajnoczi | " of %" PRId64 " bytes, speed limit %" PRId64 |
652 | fb5458cd | Stefan Hajnoczi | " bytes/s\n",
|
653 | fb5458cd | Stefan Hajnoczi | list->value->device, |
654 | fb5458cd | Stefan Hajnoczi | list->value->offset, |
655 | fb5458cd | Stefan Hajnoczi | list->value->len, |
656 | fb5458cd | Stefan Hajnoczi | list->value->speed); |
657 | fb5458cd | Stefan Hajnoczi | } else {
|
658 | fb5458cd | Stefan Hajnoczi | monitor_printf(mon, "Type %s, device %s: Completed %" PRId64
|
659 | fb5458cd | Stefan Hajnoczi | " of %" PRId64 " bytes, speed limit %" PRId64 |
660 | fb5458cd | Stefan Hajnoczi | " bytes/s\n",
|
661 | fb5458cd | Stefan Hajnoczi | list->value->type, |
662 | fb5458cd | Stefan Hajnoczi | list->value->device, |
663 | fb5458cd | Stefan Hajnoczi | list->value->offset, |
664 | fb5458cd | Stefan Hajnoczi | list->value->len, |
665 | fb5458cd | Stefan Hajnoczi | list->value->speed); |
666 | fb5458cd | Stefan Hajnoczi | } |
667 | fb5458cd | Stefan Hajnoczi | list = list->next; |
668 | fb5458cd | Stefan Hajnoczi | } |
669 | fb5458cd | Stefan Hajnoczi | } |
670 | fb5458cd | Stefan Hajnoczi | |
671 | d1a0cf73 | Stefan Berger | void hmp_info_tpm(Monitor *mon, const QDict *qdict) |
672 | d1a0cf73 | Stefan Berger | { |
673 | d1a0cf73 | Stefan Berger | TPMInfoList *info_list, *info; |
674 | d1a0cf73 | Stefan Berger | Error *err = NULL;
|
675 | d1a0cf73 | Stefan Berger | unsigned int c = 0; |
676 | d1a0cf73 | Stefan Berger | TPMPassthroughOptions *tpo; |
677 | d1a0cf73 | Stefan Berger | |
678 | d1a0cf73 | Stefan Berger | info_list = qmp_query_tpm(&err); |
679 | d1a0cf73 | Stefan Berger | if (err) {
|
680 | d1a0cf73 | Stefan Berger | monitor_printf(mon, "TPM device not supported\n");
|
681 | d1a0cf73 | Stefan Berger | error_free(err); |
682 | d1a0cf73 | Stefan Berger | return;
|
683 | d1a0cf73 | Stefan Berger | } |
684 | d1a0cf73 | Stefan Berger | |
685 | d1a0cf73 | Stefan Berger | if (info_list) {
|
686 | d1a0cf73 | Stefan Berger | monitor_printf(mon, "TPM device:\n");
|
687 | d1a0cf73 | Stefan Berger | } |
688 | d1a0cf73 | Stefan Berger | |
689 | d1a0cf73 | Stefan Berger | for (info = info_list; info; info = info->next) {
|
690 | d1a0cf73 | Stefan Berger | TPMInfo *ti = info->value; |
691 | d1a0cf73 | Stefan Berger | monitor_printf(mon, " tpm%d: model=%s\n",
|
692 | d1a0cf73 | Stefan Berger | c, TpmModel_lookup[ti->model]); |
693 | d1a0cf73 | Stefan Berger | |
694 | d1a0cf73 | Stefan Berger | monitor_printf(mon, " \\ %s: type=%s",
|
695 | 88ca7bcf | Corey Bryant | ti->id, TpmTypeOptionsKind_lookup[ti->options->kind]); |
696 | d1a0cf73 | Stefan Berger | |
697 | 88ca7bcf | Corey Bryant | switch (ti->options->kind) {
|
698 | 88ca7bcf | Corey Bryant | case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:
|
699 | 88ca7bcf | Corey Bryant | tpo = ti->options->passthrough; |
700 | d1a0cf73 | Stefan Berger | monitor_printf(mon, "%s%s%s%s",
|
701 | d1a0cf73 | Stefan Berger | tpo->has_path ? ",path=" : "", |
702 | d1a0cf73 | Stefan Berger | tpo->has_path ? tpo->path : "",
|
703 | d1a0cf73 | Stefan Berger | tpo->has_cancel_path ? ",cancel-path=" : "", |
704 | d1a0cf73 | Stefan Berger | tpo->has_cancel_path ? tpo->cancel_path : "");
|
705 | d1a0cf73 | Stefan Berger | break;
|
706 | d1a0cf73 | Stefan Berger | case TPM_TYPE_OPTIONS_KIND_MAX:
|
707 | d1a0cf73 | Stefan Berger | break;
|
708 | d1a0cf73 | Stefan Berger | } |
709 | d1a0cf73 | Stefan Berger | monitor_printf(mon, "\n");
|
710 | d1a0cf73 | Stefan Berger | c++; |
711 | d1a0cf73 | Stefan Berger | } |
712 | d1a0cf73 | Stefan Berger | qapi_free_TPMInfoList(info_list); |
713 | d1a0cf73 | Stefan Berger | } |
714 | d1a0cf73 | Stefan Berger | |
715 | 7a7f325e | Luiz Capitulino | void hmp_quit(Monitor *mon, const QDict *qdict) |
716 | 7a7f325e | Luiz Capitulino | { |
717 | 7a7f325e | Luiz Capitulino | monitor_suspend(mon); |
718 | 7a7f325e | Luiz Capitulino | qmp_quit(NULL);
|
719 | 7a7f325e | Luiz Capitulino | } |
720 | 5f158f21 | Luiz Capitulino | |
721 | 5f158f21 | Luiz Capitulino | void hmp_stop(Monitor *mon, const QDict *qdict) |
722 | 5f158f21 | Luiz Capitulino | { |
723 | 5f158f21 | Luiz Capitulino | qmp_stop(NULL);
|
724 | 5f158f21 | Luiz Capitulino | } |
725 | 38d22653 | Luiz Capitulino | |
726 | 38d22653 | Luiz Capitulino | void hmp_system_reset(Monitor *mon, const QDict *qdict) |
727 | 38d22653 | Luiz Capitulino | { |
728 | 38d22653 | Luiz Capitulino | qmp_system_reset(NULL);
|
729 | 38d22653 | Luiz Capitulino | } |
730 | 5bc465e4 | Luiz Capitulino | |
731 | 5bc465e4 | Luiz Capitulino | void hmp_system_powerdown(Monitor *mon, const QDict *qdict) |
732 | 5bc465e4 | Luiz Capitulino | { |
733 | 5bc465e4 | Luiz Capitulino | qmp_system_powerdown(NULL);
|
734 | 5bc465e4 | Luiz Capitulino | } |
735 | 755f1968 | Luiz Capitulino | |
736 | 755f1968 | Luiz Capitulino | void hmp_cpu(Monitor *mon, const QDict *qdict) |
737 | 755f1968 | Luiz Capitulino | { |
738 | 755f1968 | Luiz Capitulino | int64_t cpu_index; |
739 | 755f1968 | Luiz Capitulino | |
740 | 755f1968 | Luiz Capitulino | /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
|
741 | 755f1968 | Luiz Capitulino | use it are converted to the QAPI */
|
742 | 755f1968 | Luiz Capitulino | cpu_index = qdict_get_int(qdict, "index");
|
743 | 755f1968 | Luiz Capitulino | if (monitor_set_cpu(cpu_index) < 0) { |
744 | 755f1968 | Luiz Capitulino | monitor_printf(mon, "invalid CPU index\n");
|
745 | 755f1968 | Luiz Capitulino | } |
746 | 755f1968 | Luiz Capitulino | } |
747 | 0cfd6a9a | Luiz Capitulino | |
748 | 0cfd6a9a | Luiz Capitulino | void hmp_memsave(Monitor *mon, const QDict *qdict) |
749 | 0cfd6a9a | Luiz Capitulino | { |
750 | 0cfd6a9a | Luiz Capitulino | uint32_t size = qdict_get_int(qdict, "size");
|
751 | 0cfd6a9a | Luiz Capitulino | const char *filename = qdict_get_str(qdict, "filename"); |
752 | 0cfd6a9a | Luiz Capitulino | uint64_t addr = qdict_get_int(qdict, "val");
|
753 | 0cfd6a9a | Luiz Capitulino | Error *errp = NULL;
|
754 | 0cfd6a9a | Luiz Capitulino | |
755 | 0cfd6a9a | Luiz Capitulino | qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp);
|
756 | 0cfd6a9a | Luiz Capitulino | hmp_handle_error(mon, &errp); |
757 | 0cfd6a9a | Luiz Capitulino | } |
758 | 6d3962bf | Luiz Capitulino | |
759 | 6d3962bf | Luiz Capitulino | void hmp_pmemsave(Monitor *mon, const QDict *qdict) |
760 | 6d3962bf | Luiz Capitulino | { |
761 | 6d3962bf | Luiz Capitulino | uint32_t size = qdict_get_int(qdict, "size");
|
762 | 6d3962bf | Luiz Capitulino | const char *filename = qdict_get_str(qdict, "filename"); |
763 | 6d3962bf | Luiz Capitulino | uint64_t addr = qdict_get_int(qdict, "val");
|
764 | 6d3962bf | Luiz Capitulino | Error *errp = NULL;
|
765 | 6d3962bf | Luiz Capitulino | |
766 | 6d3962bf | Luiz Capitulino | qmp_pmemsave(addr, size, filename, &errp); |
767 | 6d3962bf | Luiz Capitulino | hmp_handle_error(mon, &errp); |
768 | 1f590cf9 | Lei Li | } |
769 | 1f590cf9 | Lei Li | |
770 | 3949e594 | Markus Armbruster | void hmp_ringbuf_write(Monitor *mon, const QDict *qdict) |
771 | 1f590cf9 | Lei Li | { |
772 | 1f590cf9 | Lei Li | const char *chardev = qdict_get_str(qdict, "device"); |
773 | 1f590cf9 | Lei Li | const char *data = qdict_get_str(qdict, "data"); |
774 | 1f590cf9 | Lei Li | Error *errp = NULL;
|
775 | 1f590cf9 | Lei Li | |
776 | 3949e594 | Markus Armbruster | qmp_ringbuf_write(chardev, data, false, 0, &errp); |
777 | 1f590cf9 | Lei Li | |
778 | 1f590cf9 | Lei Li | hmp_handle_error(mon, &errp); |
779 | 6d3962bf | Luiz Capitulino | } |
780 | e42e818b | Luiz Capitulino | |
781 | 3949e594 | Markus Armbruster | void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) |
782 | 49b6d722 | Lei Li | { |
783 | 49b6d722 | Lei Li | uint32_t size = qdict_get_int(qdict, "size");
|
784 | 49b6d722 | Lei Li | const char *chardev = qdict_get_str(qdict, "device"); |
785 | 3ab651fc | Markus Armbruster | char *data;
|
786 | 49b6d722 | Lei Li | Error *errp = NULL;
|
787 | 543f3412 | Markus Armbruster | int i;
|
788 | 49b6d722 | Lei Li | |
789 | 3949e594 | Markus Armbruster | data = qmp_ringbuf_read(chardev, size, false, 0, &errp); |
790 | 49b6d722 | Lei Li | if (errp) {
|
791 | 49b6d722 | Lei Li | monitor_printf(mon, "%s\n", error_get_pretty(errp));
|
792 | 49b6d722 | Lei Li | error_free(errp); |
793 | 49b6d722 | Lei Li | return;
|
794 | 49b6d722 | Lei Li | } |
795 | 49b6d722 | Lei Li | |
796 | 543f3412 | Markus Armbruster | for (i = 0; data[i]; i++) { |
797 | 543f3412 | Markus Armbruster | unsigned char ch = data[i]; |
798 | 543f3412 | Markus Armbruster | |
799 | 543f3412 | Markus Armbruster | if (ch == '\\') { |
800 | 543f3412 | Markus Armbruster | monitor_printf(mon, "\\\\");
|
801 | 543f3412 | Markus Armbruster | } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) { |
802 | 543f3412 | Markus Armbruster | monitor_printf(mon, "\\u%04X", ch);
|
803 | 543f3412 | Markus Armbruster | } else {
|
804 | 543f3412 | Markus Armbruster | monitor_printf(mon, "%c", ch);
|
805 | 543f3412 | Markus Armbruster | } |
806 | 543f3412 | Markus Armbruster | |
807 | 543f3412 | Markus Armbruster | } |
808 | 543f3412 | Markus Armbruster | monitor_printf(mon, "\n");
|
809 | 3ab651fc | Markus Armbruster | g_free(data); |
810 | 49b6d722 | Lei Li | } |
811 | 49b6d722 | Lei Li | |
812 | e42e818b | Luiz Capitulino | static void hmp_cont_cb(void *opaque, int err) |
813 | e42e818b | Luiz Capitulino | { |
814 | e42e818b | Luiz Capitulino | if (!err) {
|
815 | 8b7f6fbb | Luiz Capitulino | qmp_cont(NULL);
|
816 | e42e818b | Luiz Capitulino | } |
817 | e42e818b | Luiz Capitulino | } |
818 | e42e818b | Luiz Capitulino | |
819 | 8b7f6fbb | Luiz Capitulino | static bool key_is_missing(const BlockInfo *bdev) |
820 | 8b7f6fbb | Luiz Capitulino | { |
821 | 8b7f6fbb | Luiz Capitulino | return (bdev->inserted && bdev->inserted->encryption_key_missing);
|
822 | 8b7f6fbb | Luiz Capitulino | } |
823 | 8b7f6fbb | Luiz Capitulino | |
824 | e42e818b | Luiz Capitulino | void hmp_cont(Monitor *mon, const QDict *qdict) |
825 | e42e818b | Luiz Capitulino | { |
826 | 8b7f6fbb | Luiz Capitulino | BlockInfoList *bdev_list, *bdev; |
827 | e42e818b | Luiz Capitulino | Error *errp = NULL;
|
828 | e42e818b | Luiz Capitulino | |
829 | 8b7f6fbb | Luiz Capitulino | bdev_list = qmp_query_block(NULL);
|
830 | 8b7f6fbb | Luiz Capitulino | for (bdev = bdev_list; bdev; bdev = bdev->next) {
|
831 | 8b7f6fbb | Luiz Capitulino | if (key_is_missing(bdev->value)) {
|
832 | 8b7f6fbb | Luiz Capitulino | monitor_read_block_device_key(mon, bdev->value->device, |
833 | 8b7f6fbb | Luiz Capitulino | hmp_cont_cb, NULL);
|
834 | 8b7f6fbb | Luiz Capitulino | goto out;
|
835 | e42e818b | Luiz Capitulino | } |
836 | e42e818b | Luiz Capitulino | } |
837 | 8b7f6fbb | Luiz Capitulino | |
838 | 8b7f6fbb | Luiz Capitulino | qmp_cont(&errp); |
839 | 8b7f6fbb | Luiz Capitulino | hmp_handle_error(mon, &errp); |
840 | 8b7f6fbb | Luiz Capitulino | |
841 | 8b7f6fbb | Luiz Capitulino | out:
|
842 | 8b7f6fbb | Luiz Capitulino | qapi_free_BlockInfoList(bdev_list); |
843 | e42e818b | Luiz Capitulino | } |
844 | ab49ab5c | Luiz Capitulino | |
845 | 9b9df25a | Gerd Hoffmann | void hmp_system_wakeup(Monitor *mon, const QDict *qdict) |
846 | 9b9df25a | Gerd Hoffmann | { |
847 | 9b9df25a | Gerd Hoffmann | qmp_system_wakeup(NULL);
|
848 | 9b9df25a | Gerd Hoffmann | } |
849 | 9b9df25a | Gerd Hoffmann | |
850 | ab49ab5c | Luiz Capitulino | void hmp_inject_nmi(Monitor *mon, const QDict *qdict) |
851 | ab49ab5c | Luiz Capitulino | { |
852 | ab49ab5c | Luiz Capitulino | Error *errp = NULL;
|
853 | ab49ab5c | Luiz Capitulino | |
854 | ab49ab5c | Luiz Capitulino | qmp_inject_nmi(&errp); |
855 | ab49ab5c | Luiz Capitulino | hmp_handle_error(mon, &errp); |
856 | ab49ab5c | Luiz Capitulino | } |
857 | 4b37156c | Luiz Capitulino | |
858 | 4b37156c | Luiz Capitulino | void hmp_set_link(Monitor *mon, const QDict *qdict) |
859 | 4b37156c | Luiz Capitulino | { |
860 | 4b37156c | Luiz Capitulino | const char *name = qdict_get_str(qdict, "name"); |
861 | 4b37156c | Luiz Capitulino | int up = qdict_get_bool(qdict, "up"); |
862 | 4b37156c | Luiz Capitulino | Error *errp = NULL;
|
863 | 4b37156c | Luiz Capitulino | |
864 | 4b37156c | Luiz Capitulino | qmp_set_link(name, up, &errp); |
865 | 4b37156c | Luiz Capitulino | hmp_handle_error(mon, &errp); |
866 | 4b37156c | Luiz Capitulino | } |
867 | a4dea8a9 | Luiz Capitulino | |
868 | a4dea8a9 | Luiz Capitulino | void hmp_block_passwd(Monitor *mon, const QDict *qdict) |
869 | a4dea8a9 | Luiz Capitulino | { |
870 | a4dea8a9 | Luiz Capitulino | const char *device = qdict_get_str(qdict, "device"); |
871 | a4dea8a9 | Luiz Capitulino | const char *password = qdict_get_str(qdict, "password"); |
872 | a4dea8a9 | Luiz Capitulino | Error *errp = NULL;
|
873 | a4dea8a9 | Luiz Capitulino | |
874 | 12d3ba82 | Benoรฎt Canet | qmp_block_passwd(true, device, false, NULL, password, &errp); |
875 | a4dea8a9 | Luiz Capitulino | hmp_handle_error(mon, &errp); |
876 | a4dea8a9 | Luiz Capitulino | } |
877 | d72f3264 | Luiz Capitulino | |
878 | d72f3264 | Luiz Capitulino | void hmp_balloon(Monitor *mon, const QDict *qdict) |
879 | d72f3264 | Luiz Capitulino | { |
880 | d72f3264 | Luiz Capitulino | int64_t value = qdict_get_int(qdict, "value");
|
881 | d72f3264 | Luiz Capitulino | Error *errp = NULL;
|
882 | d72f3264 | Luiz Capitulino | |
883 | d72f3264 | Luiz Capitulino | qmp_balloon(value, &errp); |
884 | 84d18f06 | Markus Armbruster | if (errp) {
|
885 | d72f3264 | Luiz Capitulino | monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp));
|
886 | d72f3264 | Luiz Capitulino | error_free(errp); |
887 | d72f3264 | Luiz Capitulino | } |
888 | d72f3264 | Luiz Capitulino | } |
889 | 5e7caacb | Luiz Capitulino | |
890 | 5e7caacb | Luiz Capitulino | void hmp_block_resize(Monitor *mon, const QDict *qdict) |
891 | 5e7caacb | Luiz Capitulino | { |
892 | 5e7caacb | Luiz Capitulino | const char *device = qdict_get_str(qdict, "device"); |
893 | 5e7caacb | Luiz Capitulino | int64_t size = qdict_get_int(qdict, "size");
|
894 | 5e7caacb | Luiz Capitulino | Error *errp = NULL;
|
895 | 5e7caacb | Luiz Capitulino | |
896 | 3b1dbd11 | Benoรฎt Canet | qmp_block_resize(true, device, false, NULL, size, &errp); |
897 | 5e7caacb | Luiz Capitulino | hmp_handle_error(mon, &errp); |
898 | 5e7caacb | Luiz Capitulino | } |
899 | 6106e249 | Luiz Capitulino | |
900 | d9b902db | Paolo Bonzini | void hmp_drive_mirror(Monitor *mon, const QDict *qdict) |
901 | d9b902db | Paolo Bonzini | { |
902 | d9b902db | Paolo Bonzini | const char *device = qdict_get_str(qdict, "device"); |
903 | d9b902db | Paolo Bonzini | const char *filename = qdict_get_str(qdict, "target"); |
904 | d9b902db | Paolo Bonzini | const char *format = qdict_get_try_str(qdict, "format"); |
905 | d9b902db | Paolo Bonzini | int reuse = qdict_get_try_bool(qdict, "reuse", 0); |
906 | d9b902db | Paolo Bonzini | int full = qdict_get_try_bool(qdict, "full", 0); |
907 | d9b902db | Paolo Bonzini | enum NewImageMode mode;
|
908 | d9b902db | Paolo Bonzini | Error *errp = NULL;
|
909 | d9b902db | Paolo Bonzini | |
910 | d9b902db | Paolo Bonzini | if (!filename) {
|
911 | d9b902db | Paolo Bonzini | error_set(&errp, QERR_MISSING_PARAMETER, "target");
|
912 | d9b902db | Paolo Bonzini | hmp_handle_error(mon, &errp); |
913 | d9b902db | Paolo Bonzini | return;
|
914 | d9b902db | Paolo Bonzini | } |
915 | d9b902db | Paolo Bonzini | |
916 | d9b902db | Paolo Bonzini | if (reuse) {
|
917 | d9b902db | Paolo Bonzini | mode = NEW_IMAGE_MODE_EXISTING; |
918 | d9b902db | Paolo Bonzini | } else {
|
919 | d9b902db | Paolo Bonzini | mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; |
920 | d9b902db | Paolo Bonzini | } |
921 | d9b902db | Paolo Bonzini | |
922 | d9b902db | Paolo Bonzini | qmp_drive_mirror(device, filename, !!format, format, |
923 | d9b902db | Paolo Bonzini | full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, |
924 | 08e4ed6c | Paolo Bonzini | true, mode, false, 0, false, 0, false, 0, |
925 | b952b558 | Paolo Bonzini | false, 0, false, 0, &errp); |
926 | d9b902db | Paolo Bonzini | hmp_handle_error(mon, &errp); |
927 | d9b902db | Paolo Bonzini | } |
928 | d9b902db | Paolo Bonzini | |
929 | de90930a | Stefan Hajnoczi | void hmp_drive_backup(Monitor *mon, const QDict *qdict) |
930 | de90930a | Stefan Hajnoczi | { |
931 | de90930a | Stefan Hajnoczi | const char *device = qdict_get_str(qdict, "device"); |
932 | de90930a | Stefan Hajnoczi | const char *filename = qdict_get_str(qdict, "target"); |
933 | de90930a | Stefan Hajnoczi | const char *format = qdict_get_try_str(qdict, "format"); |
934 | de90930a | Stefan Hajnoczi | int reuse = qdict_get_try_bool(qdict, "reuse", 0); |
935 | de90930a | Stefan Hajnoczi | int full = qdict_get_try_bool(qdict, "full", 0); |
936 | de90930a | Stefan Hajnoczi | enum NewImageMode mode;
|
937 | de90930a | Stefan Hajnoczi | Error *errp = NULL;
|
938 | de90930a | Stefan Hajnoczi | |
939 | de90930a | Stefan Hajnoczi | if (!filename) {
|
940 | de90930a | Stefan Hajnoczi | error_set(&errp, QERR_MISSING_PARAMETER, "target");
|
941 | de90930a | Stefan Hajnoczi | hmp_handle_error(mon, &errp); |
942 | de90930a | Stefan Hajnoczi | return;
|
943 | de90930a | Stefan Hajnoczi | } |
944 | de90930a | Stefan Hajnoczi | |
945 | de90930a | Stefan Hajnoczi | if (reuse) {
|
946 | de90930a | Stefan Hajnoczi | mode = NEW_IMAGE_MODE_EXISTING; |
947 | de90930a | Stefan Hajnoczi | } else {
|
948 | de90930a | Stefan Hajnoczi | mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; |
949 | de90930a | Stefan Hajnoczi | } |
950 | de90930a | Stefan Hajnoczi | |
951 | de90930a | Stefan Hajnoczi | qmp_drive_backup(device, filename, !!format, format, |
952 | de90930a | Stefan Hajnoczi | full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, |
953 | de90930a | Stefan Hajnoczi | true, mode, false, 0, false, 0, false, 0, &errp); |
954 | de90930a | Stefan Hajnoczi | hmp_handle_error(mon, &errp); |
955 | de90930a | Stefan Hajnoczi | } |
956 | de90930a | Stefan Hajnoczi | |
957 | 6106e249 | Luiz Capitulino | void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) |
958 | 6106e249 | Luiz Capitulino | { |
959 | 6106e249 | Luiz Capitulino | const char *device = qdict_get_str(qdict, "device"); |
960 | 6106e249 | Luiz Capitulino | const char *filename = qdict_get_try_str(qdict, "snapshot-file"); |
961 | 6106e249 | Luiz Capitulino | const char *format = qdict_get_try_str(qdict, "format"); |
962 | 6cc2a415 | Paolo Bonzini | int reuse = qdict_get_try_bool(qdict, "reuse", 0); |
963 | 6cc2a415 | Paolo Bonzini | enum NewImageMode mode;
|
964 | 6106e249 | Luiz Capitulino | Error *errp = NULL;
|
965 | 6106e249 | Luiz Capitulino | |
966 | 6106e249 | Luiz Capitulino | if (!filename) {
|
967 | 6106e249 | Luiz Capitulino | /* In the future, if 'snapshot-file' is not specified, the snapshot
|
968 | 6106e249 | Luiz Capitulino | will be taken internally. Today it's actually required. */
|
969 | 6106e249 | Luiz Capitulino | error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file");
|
970 | 6106e249 | Luiz Capitulino | hmp_handle_error(mon, &errp); |
971 | 6106e249 | Luiz Capitulino | return;
|
972 | 6106e249 | Luiz Capitulino | } |
973 | 6106e249 | Luiz Capitulino | |
974 | 6cc2a415 | Paolo Bonzini | mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS; |
975 | 0901f67e | Benoรฎt Canet | qmp_blockdev_snapshot_sync(true, device, false, NULL, |
976 | 0901f67e | Benoรฎt Canet | filename, false, NULL, |
977 | 0901f67e | Benoรฎt Canet | !!format, format, |
978 | 6cc2a415 | Paolo Bonzini | true, mode, &errp);
|
979 | 6106e249 | Luiz Capitulino | hmp_handle_error(mon, &errp); |
980 | 6106e249 | Luiz Capitulino | } |
981 | 6cdedb07 | Luiz Capitulino | |
982 | 775ca88e | Wenchao Xia | void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict) |
983 | 775ca88e | Wenchao Xia | { |
984 | 775ca88e | Wenchao Xia | const char *device = qdict_get_str(qdict, "device"); |
985 | 775ca88e | Wenchao Xia | const char *name = qdict_get_str(qdict, "name"); |
986 | 775ca88e | Wenchao Xia | Error *errp = NULL;
|
987 | 775ca88e | Wenchao Xia | |
988 | 775ca88e | Wenchao Xia | qmp_blockdev_snapshot_internal_sync(device, name, &errp); |
989 | 775ca88e | Wenchao Xia | hmp_handle_error(mon, &errp); |
990 | 775ca88e | Wenchao Xia | } |
991 | 775ca88e | Wenchao Xia | |
992 | 7a4ed2ee | Wenchao Xia | void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict) |
993 | 7a4ed2ee | Wenchao Xia | { |
994 | 7a4ed2ee | Wenchao Xia | const char *device = qdict_get_str(qdict, "device"); |
995 | 7a4ed2ee | Wenchao Xia | const char *name = qdict_get_str(qdict, "name"); |
996 | 7a4ed2ee | Wenchao Xia | const char *id = qdict_get_try_str(qdict, "id"); |
997 | 7a4ed2ee | Wenchao Xia | Error *errp = NULL;
|
998 | 7a4ed2ee | Wenchao Xia | |
999 | 7a4ed2ee | Wenchao Xia | qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id, |
1000 | 7a4ed2ee | Wenchao Xia | true, name, &errp);
|
1001 | 7a4ed2ee | Wenchao Xia | hmp_handle_error(mon, &errp); |
1002 | 7a4ed2ee | Wenchao Xia | } |
1003 | 7a4ed2ee | Wenchao Xia | |
1004 | 6cdedb07 | Luiz Capitulino | void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) |
1005 | 6cdedb07 | Luiz Capitulino | { |
1006 | 6cdedb07 | Luiz Capitulino | qmp_migrate_cancel(NULL);
|
1007 | 6cdedb07 | Luiz Capitulino | } |
1008 | 4f0a993b | Luiz Capitulino | |
1009 | 4f0a993b | Luiz Capitulino | void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) |
1010 | 4f0a993b | Luiz Capitulino | { |
1011 | 4f0a993b | Luiz Capitulino | double value = qdict_get_double(qdict, "value"); |
1012 | 4f0a993b | Luiz Capitulino | qmp_migrate_set_downtime(value, NULL);
|
1013 | 4f0a993b | Luiz Capitulino | } |
1014 | 3dc85383 | Luiz Capitulino | |
1015 | 9e1ba4cc | Orit Wasserman | void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) |
1016 | 9e1ba4cc | Orit Wasserman | { |
1017 | 9e1ba4cc | Orit Wasserman | int64_t value = qdict_get_int(qdict, "value");
|
1018 | 9e1ba4cc | Orit Wasserman | Error *err = NULL;
|
1019 | 9e1ba4cc | Orit Wasserman | |
1020 | 9e1ba4cc | Orit Wasserman | qmp_migrate_set_cache_size(value, &err); |
1021 | 9e1ba4cc | Orit Wasserman | if (err) {
|
1022 | 9e1ba4cc | Orit Wasserman | monitor_printf(mon, "%s\n", error_get_pretty(err));
|
1023 | 9e1ba4cc | Orit Wasserman | error_free(err); |
1024 | 9e1ba4cc | Orit Wasserman | return;
|
1025 | 9e1ba4cc | Orit Wasserman | } |
1026 | 9e1ba4cc | Orit Wasserman | } |
1027 | 9e1ba4cc | Orit Wasserman | |
1028 | 3dc85383 | Luiz Capitulino | void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict) |
1029 | 3dc85383 | Luiz Capitulino | { |
1030 | 3dc85383 | Luiz Capitulino | int64_t value = qdict_get_int(qdict, "value");
|
1031 | 3dc85383 | Luiz Capitulino | qmp_migrate_set_speed(value, NULL);
|
1032 | 3dc85383 | Luiz Capitulino | } |
1033 | fbf796fd | Luiz Capitulino | |
1034 | 00458433 | Orit Wasserman | void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) |
1035 | 00458433 | Orit Wasserman | { |
1036 | 00458433 | Orit Wasserman | const char *cap = qdict_get_str(qdict, "capability"); |
1037 | 00458433 | Orit Wasserman | bool state = qdict_get_bool(qdict, "state"); |
1038 | 00458433 | Orit Wasserman | Error *err = NULL;
|
1039 | 00458433 | Orit Wasserman | MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
|
1040 | 00458433 | Orit Wasserman | int i;
|
1041 | 00458433 | Orit Wasserman | |
1042 | 00458433 | Orit Wasserman | for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { |
1043 | 00458433 | Orit Wasserman | if (strcmp(cap, MigrationCapability_lookup[i]) == 0) { |
1044 | 00458433 | Orit Wasserman | caps->value = g_malloc0(sizeof(*caps->value));
|
1045 | 00458433 | Orit Wasserman | caps->value->capability = i; |
1046 | 00458433 | Orit Wasserman | caps->value->state = state; |
1047 | 00458433 | Orit Wasserman | caps->next = NULL;
|
1048 | 00458433 | Orit Wasserman | qmp_migrate_set_capabilities(caps, &err); |
1049 | 00458433 | Orit Wasserman | break;
|
1050 | 00458433 | Orit Wasserman | } |
1051 | 00458433 | Orit Wasserman | } |
1052 | 00458433 | Orit Wasserman | |
1053 | 00458433 | Orit Wasserman | if (i == MIGRATION_CAPABILITY_MAX) {
|
1054 | 00458433 | Orit Wasserman | error_set(&err, QERR_INVALID_PARAMETER, cap); |
1055 | 00458433 | Orit Wasserman | } |
1056 | 00458433 | Orit Wasserman | |
1057 | 00458433 | Orit Wasserman | qapi_free_MigrationCapabilityStatusList(caps); |
1058 | 00458433 | Orit Wasserman | |
1059 | 00458433 | Orit Wasserman | if (err) {
|
1060 | a31ca017 | Orit Wasserman | monitor_printf(mon, "migrate_set_capability: %s\n",
|
1061 | 00458433 | Orit Wasserman | error_get_pretty(err)); |
1062 | 00458433 | Orit Wasserman | error_free(err); |
1063 | 00458433 | Orit Wasserman | } |
1064 | 00458433 | Orit Wasserman | } |
1065 | 00458433 | Orit Wasserman | |
1066 | fbf796fd | Luiz Capitulino | void hmp_set_password(Monitor *mon, const QDict *qdict) |
1067 | fbf796fd | Luiz Capitulino | { |
1068 | fbf796fd | Luiz Capitulino | const char *protocol = qdict_get_str(qdict, "protocol"); |
1069 | fbf796fd | Luiz Capitulino | const char *password = qdict_get_str(qdict, "password"); |
1070 | fbf796fd | Luiz Capitulino | const char *connected = qdict_get_try_str(qdict, "connected"); |
1071 | fbf796fd | Luiz Capitulino | Error *err = NULL;
|
1072 | fbf796fd | Luiz Capitulino | |
1073 | fbf796fd | Luiz Capitulino | qmp_set_password(protocol, password, !!connected, connected, &err); |
1074 | fbf796fd | Luiz Capitulino | hmp_handle_error(mon, &err); |
1075 | fbf796fd | Luiz Capitulino | } |
1076 | 9ad5372d | Luiz Capitulino | |
1077 | 9ad5372d | Luiz Capitulino | void hmp_expire_password(Monitor *mon, const QDict *qdict) |
1078 | 9ad5372d | Luiz Capitulino | { |
1079 | 9ad5372d | Luiz Capitulino | const char *protocol = qdict_get_str(qdict, "protocol"); |
1080 | 9ad5372d | Luiz Capitulino | const char *whenstr = qdict_get_str(qdict, "time"); |
1081 | 9ad5372d | Luiz Capitulino | Error *err = NULL;
|
1082 | 9ad5372d | Luiz Capitulino | |
1083 | 9ad5372d | Luiz Capitulino | qmp_expire_password(protocol, whenstr, &err); |
1084 | 9ad5372d | Luiz Capitulino | hmp_handle_error(mon, &err); |
1085 | 9ad5372d | Luiz Capitulino | } |
1086 | c245b6a3 | Luiz Capitulino | |
1087 | c245b6a3 | Luiz Capitulino | void hmp_eject(Monitor *mon, const QDict *qdict) |
1088 | c245b6a3 | Luiz Capitulino | { |
1089 | c245b6a3 | Luiz Capitulino | int force = qdict_get_try_bool(qdict, "force", 0); |
1090 | c245b6a3 | Luiz Capitulino | const char *device = qdict_get_str(qdict, "device"); |
1091 | c245b6a3 | Luiz Capitulino | Error *err = NULL;
|
1092 | c245b6a3 | Luiz Capitulino | |
1093 | c245b6a3 | Luiz Capitulino | qmp_eject(device, true, force, &err);
|
1094 | c245b6a3 | Luiz Capitulino | hmp_handle_error(mon, &err); |
1095 | c245b6a3 | Luiz Capitulino | } |
1096 | 333a96ec | Luiz Capitulino | |
1097 | c60bf339 | Stefan Hajnoczi | static void hmp_change_read_arg(void *opaque, const char *password, |
1098 | c60bf339 | Stefan Hajnoczi | void *readline_opaque)
|
1099 | 333a96ec | Luiz Capitulino | { |
1100 | 333a96ec | Luiz Capitulino | qmp_change_vnc_password(password, NULL);
|
1101 | c60bf339 | Stefan Hajnoczi | monitor_read_command(opaque, 1);
|
1102 | 333a96ec | Luiz Capitulino | } |
1103 | 333a96ec | Luiz Capitulino | |
1104 | 333a96ec | Luiz Capitulino | void hmp_change(Monitor *mon, const QDict *qdict) |
1105 | 333a96ec | Luiz Capitulino | { |
1106 | 333a96ec | Luiz Capitulino | const char *device = qdict_get_str(qdict, "device"); |
1107 | 333a96ec | Luiz Capitulino | const char *target = qdict_get_str(qdict, "target"); |
1108 | 333a96ec | Luiz Capitulino | const char *arg = qdict_get_try_str(qdict, "arg"); |
1109 | 333a96ec | Luiz Capitulino | Error *err = NULL;
|
1110 | 333a96ec | Luiz Capitulino | |
1111 | 333a96ec | Luiz Capitulino | if (strcmp(device, "vnc") == 0 && |
1112 | 333a96ec | Luiz Capitulino | (strcmp(target, "passwd") == 0 || |
1113 | 333a96ec | Luiz Capitulino | strcmp(target, "password") == 0)) { |
1114 | 333a96ec | Luiz Capitulino | if (!arg) {
|
1115 | 333a96ec | Luiz Capitulino | monitor_read_password(mon, hmp_change_read_arg, NULL);
|
1116 | 333a96ec | Luiz Capitulino | return;
|
1117 | 333a96ec | Luiz Capitulino | } |
1118 | 333a96ec | Luiz Capitulino | } |
1119 | 333a96ec | Luiz Capitulino | |
1120 | 333a96ec | Luiz Capitulino | qmp_change(device, target, !!arg, arg, &err); |
1121 | 84d18f06 | Markus Armbruster | if (err &&
|
1122 | ab878ddf | Luiz Capitulino | error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { |
1123 | eef5ad10 | Luiz Capitulino | error_free(err); |
1124 | eef5ad10 | Luiz Capitulino | monitor_read_block_device_key(mon, device, NULL, NULL); |
1125 | 333a96ec | Luiz Capitulino | return;
|
1126 | 333a96ec | Luiz Capitulino | } |
1127 | 333a96ec | Luiz Capitulino | hmp_handle_error(mon, &err); |
1128 | 333a96ec | Luiz Capitulino | } |
1129 | 80047da5 | Luiz Capitulino | |
1130 | 80047da5 | Luiz Capitulino | void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) |
1131 | 80047da5 | Luiz Capitulino | { |
1132 | 80047da5 | Luiz Capitulino | Error *err = NULL;
|
1133 | 80047da5 | Luiz Capitulino | |
1134 | 80047da5 | Luiz Capitulino | qmp_block_set_io_throttle(qdict_get_str(qdict, "device"),
|
1135 | 80047da5 | Luiz Capitulino | qdict_get_int(qdict, "bps"),
|
1136 | 80047da5 | Luiz Capitulino | qdict_get_int(qdict, "bps_rd"),
|
1137 | 80047da5 | Luiz Capitulino | qdict_get_int(qdict, "bps_wr"),
|
1138 | 80047da5 | Luiz Capitulino | qdict_get_int(qdict, "iops"),
|
1139 | 80047da5 | Luiz Capitulino | qdict_get_int(qdict, "iops_rd"),
|
1140 | 3e9fab69 | Benoรฎt Canet | qdict_get_int(qdict, "iops_wr"),
|
1141 | 3e9fab69 | Benoรฎt Canet | false, /* no burst max via HMP */ |
1142 | 3e9fab69 | Benoรฎt Canet | 0,
|
1143 | 3e9fab69 | Benoรฎt Canet | false,
|
1144 | 3e9fab69 | Benoรฎt Canet | 0,
|
1145 | 3e9fab69 | Benoรฎt Canet | false,
|
1146 | 3e9fab69 | Benoรฎt Canet | 0,
|
1147 | 3e9fab69 | Benoรฎt Canet | false,
|
1148 | 3e9fab69 | Benoรฎt Canet | 0,
|
1149 | 3e9fab69 | Benoรฎt Canet | false,
|
1150 | 3e9fab69 | Benoรฎt Canet | 0,
|
1151 | 3e9fab69 | Benoรฎt Canet | false,
|
1152 | 2024c1df | Benoรฎt Canet | 0,
|
1153 | 2024c1df | Benoรฎt Canet | false, /* No default I/O size */ |
1154 | 3e9fab69 | Benoรฎt Canet | 0, &err);
|
1155 | 80047da5 | Luiz Capitulino | hmp_handle_error(mon, &err); |
1156 | 80047da5 | Luiz Capitulino | } |
1157 | 12bd451f | Stefan Hajnoczi | |
1158 | 12bd451f | Stefan Hajnoczi | void hmp_block_stream(Monitor *mon, const QDict *qdict) |
1159 | 12bd451f | Stefan Hajnoczi | { |
1160 | 12bd451f | Stefan Hajnoczi | Error *error = NULL;
|
1161 | 12bd451f | Stefan Hajnoczi | const char *device = qdict_get_str(qdict, "device"); |
1162 | 12bd451f | Stefan Hajnoczi | const char *base = qdict_get_try_str(qdict, "base"); |
1163 | c83c66c3 | Stefan Hajnoczi | int64_t speed = qdict_get_try_int(qdict, "speed", 0); |
1164 | 12bd451f | Stefan Hajnoczi | |
1165 | c83c66c3 | Stefan Hajnoczi | qmp_block_stream(device, base != NULL, base,
|
1166 | 1d809098 | Paolo Bonzini | qdict_haskey(qdict, "speed"), speed,
|
1167 | 46663e5e | Anthony Liguori | true, BLOCKDEV_ON_ERROR_REPORT, &error);
|
1168 | 12bd451f | Stefan Hajnoczi | |
1169 | 12bd451f | Stefan Hajnoczi | hmp_handle_error(mon, &error); |
1170 | 12bd451f | Stefan Hajnoczi | } |
1171 | 2d47c6e9 | Stefan Hajnoczi | |
1172 | 2d47c6e9 | Stefan Hajnoczi | void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict) |
1173 | 2d47c6e9 | Stefan Hajnoczi | { |
1174 | 2d47c6e9 | Stefan Hajnoczi | Error *error = NULL;
|
1175 | 2d47c6e9 | Stefan Hajnoczi | const char *device = qdict_get_str(qdict, "device"); |
1176 | c6db2395 | Paolo Bonzini | int64_t value = qdict_get_int(qdict, "speed");
|
1177 | 2d47c6e9 | Stefan Hajnoczi | |
1178 | 2d47c6e9 | Stefan Hajnoczi | qmp_block_job_set_speed(device, value, &error); |
1179 | 2d47c6e9 | Stefan Hajnoczi | |
1180 | 2d47c6e9 | Stefan Hajnoczi | hmp_handle_error(mon, &error); |
1181 | 2d47c6e9 | Stefan Hajnoczi | } |
1182 | 370521a1 | Stefan Hajnoczi | |
1183 | 370521a1 | Stefan Hajnoczi | void hmp_block_job_cancel(Monitor *mon, const QDict *qdict) |
1184 | 370521a1 | Stefan Hajnoczi | { |
1185 | 370521a1 | Stefan Hajnoczi | Error *error = NULL;
|
1186 | 370521a1 | Stefan Hajnoczi | const char *device = qdict_get_str(qdict, "device"); |
1187 | 6e37fb81 | Paolo Bonzini | bool force = qdict_get_try_bool(qdict, "force", 0); |
1188 | 370521a1 | Stefan Hajnoczi | |
1189 | 6e37fb81 | Paolo Bonzini | qmp_block_job_cancel(device, true, force, &error);
|
1190 | 6e37fb81 | Paolo Bonzini | |
1191 | 6e37fb81 | Paolo Bonzini | hmp_handle_error(mon, &error); |
1192 | 6e37fb81 | Paolo Bonzini | } |
1193 | 6e37fb81 | Paolo Bonzini | |
1194 | 6e37fb81 | Paolo Bonzini | void hmp_block_job_pause(Monitor *mon, const QDict *qdict) |
1195 | 6e37fb81 | Paolo Bonzini | { |
1196 | 6e37fb81 | Paolo Bonzini | Error *error = NULL;
|
1197 | 6e37fb81 | Paolo Bonzini | const char *device = qdict_get_str(qdict, "device"); |
1198 | 6e37fb81 | Paolo Bonzini | |
1199 | 6e37fb81 | Paolo Bonzini | qmp_block_job_pause(device, &error); |
1200 | 6e37fb81 | Paolo Bonzini | |
1201 | 6e37fb81 | Paolo Bonzini | hmp_handle_error(mon, &error); |
1202 | 6e37fb81 | Paolo Bonzini | } |
1203 | 6e37fb81 | Paolo Bonzini | |
1204 | 6e37fb81 | Paolo Bonzini | void hmp_block_job_resume(Monitor *mon, const QDict *qdict) |
1205 | 6e37fb81 | Paolo Bonzini | { |
1206 | 6e37fb81 | Paolo Bonzini | Error *error = NULL;
|
1207 | 6e37fb81 | Paolo Bonzini | const char *device = qdict_get_str(qdict, "device"); |
1208 | 6e37fb81 | Paolo Bonzini | |
1209 | 6e37fb81 | Paolo Bonzini | qmp_block_job_resume(device, &error); |
1210 | 370521a1 | Stefan Hajnoczi | |
1211 | 370521a1 | Stefan Hajnoczi | hmp_handle_error(mon, &error); |
1212 | 370521a1 | Stefan Hajnoczi | } |
1213 | e1c37d0e | Luiz Capitulino | |
1214 | aeae883b | Paolo Bonzini | void hmp_block_job_complete(Monitor *mon, const QDict *qdict) |
1215 | aeae883b | Paolo Bonzini | { |
1216 | aeae883b | Paolo Bonzini | Error *error = NULL;
|
1217 | aeae883b | Paolo Bonzini | const char *device = qdict_get_str(qdict, "device"); |
1218 | aeae883b | Paolo Bonzini | |
1219 | aeae883b | Paolo Bonzini | qmp_block_job_complete(device, &error); |
1220 | aeae883b | Paolo Bonzini | |
1221 | aeae883b | Paolo Bonzini | hmp_handle_error(mon, &error); |
1222 | aeae883b | Paolo Bonzini | } |
1223 | aeae883b | Paolo Bonzini | |
1224 | e1c37d0e | Luiz Capitulino | typedef struct MigrationStatus |
1225 | e1c37d0e | Luiz Capitulino | { |
1226 | e1c37d0e | Luiz Capitulino | QEMUTimer *timer; |
1227 | e1c37d0e | Luiz Capitulino | Monitor *mon; |
1228 | e1c37d0e | Luiz Capitulino | bool is_block_migration;
|
1229 | e1c37d0e | Luiz Capitulino | } MigrationStatus; |
1230 | e1c37d0e | Luiz Capitulino | |
1231 | e1c37d0e | Luiz Capitulino | static void hmp_migrate_status_cb(void *opaque) |
1232 | e1c37d0e | Luiz Capitulino | { |
1233 | e1c37d0e | Luiz Capitulino | MigrationStatus *status = opaque; |
1234 | e1c37d0e | Luiz Capitulino | MigrationInfo *info; |
1235 | e1c37d0e | Luiz Capitulino | |
1236 | e1c37d0e | Luiz Capitulino | info = qmp_query_migrate(NULL);
|
1237 | dde3a218 | Soramichi AKIYAMA | if (!info->has_status || strcmp(info->status, "active") == 0 || |
1238 | dde3a218 | Soramichi AKIYAMA | strcmp(info->status, "setup") == 0) { |
1239 | e1c37d0e | Luiz Capitulino | if (info->has_disk) {
|
1240 | e1c37d0e | Luiz Capitulino | int progress;
|
1241 | e1c37d0e | Luiz Capitulino | |
1242 | e1c37d0e | Luiz Capitulino | if (info->disk->remaining) {
|
1243 | e1c37d0e | Luiz Capitulino | progress = info->disk->transferred * 100 / info->disk->total;
|
1244 | e1c37d0e | Luiz Capitulino | } else {
|
1245 | e1c37d0e | Luiz Capitulino | progress = 100;
|
1246 | e1c37d0e | Luiz Capitulino | } |
1247 | e1c37d0e | Luiz Capitulino | |
1248 | e1c37d0e | Luiz Capitulino | monitor_printf(status->mon, "Completed %d %%\r", progress);
|
1249 | e1c37d0e | Luiz Capitulino | monitor_flush(status->mon); |
1250 | e1c37d0e | Luiz Capitulino | } |
1251 | e1c37d0e | Luiz Capitulino | |
1252 | bc72ad67 | Alex Bligh | timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000);
|
1253 | e1c37d0e | Luiz Capitulino | } else {
|
1254 | e1c37d0e | Luiz Capitulino | if (status->is_block_migration) {
|
1255 | e1c37d0e | Luiz Capitulino | monitor_printf(status->mon, "\n");
|
1256 | e1c37d0e | Luiz Capitulino | } |
1257 | e1c37d0e | Luiz Capitulino | monitor_resume(status->mon); |
1258 | bc72ad67 | Alex Bligh | timer_del(status->timer); |
1259 | e1c37d0e | Luiz Capitulino | g_free(status); |
1260 | e1c37d0e | Luiz Capitulino | } |
1261 | e1c37d0e | Luiz Capitulino | |
1262 | e1c37d0e | Luiz Capitulino | qapi_free_MigrationInfo(info); |
1263 | e1c37d0e | Luiz Capitulino | } |
1264 | e1c37d0e | Luiz Capitulino | |
1265 | e1c37d0e | Luiz Capitulino | void hmp_migrate(Monitor *mon, const QDict *qdict) |
1266 | e1c37d0e | Luiz Capitulino | { |
1267 | e1c37d0e | Luiz Capitulino | int detach = qdict_get_try_bool(qdict, "detach", 0); |
1268 | e1c37d0e | Luiz Capitulino | int blk = qdict_get_try_bool(qdict, "blk", 0); |
1269 | e1c37d0e | Luiz Capitulino | int inc = qdict_get_try_bool(qdict, "inc", 0); |
1270 | e1c37d0e | Luiz Capitulino | const char *uri = qdict_get_str(qdict, "uri"); |
1271 | e1c37d0e | Luiz Capitulino | Error *err = NULL;
|
1272 | e1c37d0e | Luiz Capitulino | |
1273 | e1c37d0e | Luiz Capitulino | qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); |
1274 | e1c37d0e | Luiz Capitulino | if (err) {
|
1275 | e1c37d0e | Luiz Capitulino | monitor_printf(mon, "migrate: %s\n", error_get_pretty(err));
|
1276 | e1c37d0e | Luiz Capitulino | error_free(err); |
1277 | e1c37d0e | Luiz Capitulino | return;
|
1278 | e1c37d0e | Luiz Capitulino | } |
1279 | e1c37d0e | Luiz Capitulino | |
1280 | e1c37d0e | Luiz Capitulino | if (!detach) {
|
1281 | e1c37d0e | Luiz Capitulino | MigrationStatus *status; |
1282 | e1c37d0e | Luiz Capitulino | |
1283 | e1c37d0e | Luiz Capitulino | if (monitor_suspend(mon) < 0) { |
1284 | e1c37d0e | Luiz Capitulino | monitor_printf(mon, "terminal does not allow synchronous "
|
1285 | e1c37d0e | Luiz Capitulino | "migration, continuing detached\n");
|
1286 | e1c37d0e | Luiz Capitulino | return;
|
1287 | e1c37d0e | Luiz Capitulino | } |
1288 | e1c37d0e | Luiz Capitulino | |
1289 | e1c37d0e | Luiz Capitulino | status = g_malloc0(sizeof(*status));
|
1290 | e1c37d0e | Luiz Capitulino | status->mon = mon; |
1291 | e1c37d0e | Luiz Capitulino | status->is_block_migration = blk || inc; |
1292 | bc72ad67 | Alex Bligh | status->timer = timer_new_ms(QEMU_CLOCK_REALTIME, hmp_migrate_status_cb, |
1293 | e1c37d0e | Luiz Capitulino | status); |
1294 | bc72ad67 | Alex Bligh | timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); |
1295 | e1c37d0e | Luiz Capitulino | } |
1296 | e1c37d0e | Luiz Capitulino | } |
1297 | a15fef21 | Luiz Capitulino | |
1298 | a15fef21 | Luiz Capitulino | void hmp_device_del(Monitor *mon, const QDict *qdict) |
1299 | a15fef21 | Luiz Capitulino | { |
1300 | a15fef21 | Luiz Capitulino | const char *id = qdict_get_str(qdict, "id"); |
1301 | a15fef21 | Luiz Capitulino | Error *err = NULL;
|
1302 | a15fef21 | Luiz Capitulino | |
1303 | a15fef21 | Luiz Capitulino | qmp_device_del(id, &err); |
1304 | a15fef21 | Luiz Capitulino | hmp_handle_error(mon, &err); |
1305 | a15fef21 | Luiz Capitulino | } |
1306 | 783e9b48 | Wen Congyang | |
1307 | 783e9b48 | Wen Congyang | void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) |
1308 | 783e9b48 | Wen Congyang | { |
1309 | 783e9b48 | Wen Congyang | Error *errp = NULL;
|
1310 | 783e9b48 | Wen Congyang | int paging = qdict_get_try_bool(qdict, "paging", 0); |
1311 | 75363769 | Luiz Capitulino | const char *file = qdict_get_str(qdict, "filename"); |
1312 | 783e9b48 | Wen Congyang | bool has_begin = qdict_haskey(qdict, "begin"); |
1313 | 783e9b48 | Wen Congyang | bool has_length = qdict_haskey(qdict, "length"); |
1314 | b53ccc30 | qiaonuohan | /* kdump-compressed format is not supported for HMP */
|
1315 | b53ccc30 | qiaonuohan | bool has_format = false; |
1316 | 783e9b48 | Wen Congyang | int64_t begin = 0;
|
1317 | 783e9b48 | Wen Congyang | int64_t length = 0;
|
1318 | b53ccc30 | qiaonuohan | enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
|
1319 | 75363769 | Luiz Capitulino | char *prot;
|
1320 | 783e9b48 | Wen Congyang | |
1321 | 783e9b48 | Wen Congyang | if (has_begin) {
|
1322 | 783e9b48 | Wen Congyang | begin = qdict_get_int(qdict, "begin");
|
1323 | 783e9b48 | Wen Congyang | } |
1324 | 783e9b48 | Wen Congyang | if (has_length) {
|
1325 | 783e9b48 | Wen Congyang | length = qdict_get_int(qdict, "length");
|
1326 | 783e9b48 | Wen Congyang | } |
1327 | 783e9b48 | Wen Congyang | |
1328 | 75363769 | Luiz Capitulino | prot = g_strconcat("file:", file, NULL); |
1329 | 75363769 | Luiz Capitulino | |
1330 | 75363769 | Luiz Capitulino | qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, |
1331 | b53ccc30 | qiaonuohan | has_format, dump_format, &errp); |
1332 | 783e9b48 | Wen Congyang | hmp_handle_error(mon, &errp); |
1333 | 75363769 | Luiz Capitulino | g_free(prot); |
1334 | 783e9b48 | Wen Congyang | } |
1335 | 928059a3 | Luiz Capitulino | |
1336 | 928059a3 | Luiz Capitulino | void hmp_netdev_add(Monitor *mon, const QDict *qdict) |
1337 | 928059a3 | Luiz Capitulino | { |
1338 | 928059a3 | Luiz Capitulino | Error *err = NULL;
|
1339 | 928059a3 | Luiz Capitulino | QemuOpts *opts; |
1340 | 928059a3 | Luiz Capitulino | |
1341 | 928059a3 | Luiz Capitulino | opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
|
1342 | 84d18f06 | Markus Armbruster | if (err) {
|
1343 | 928059a3 | Luiz Capitulino | goto out;
|
1344 | 928059a3 | Luiz Capitulino | } |
1345 | 928059a3 | Luiz Capitulino | |
1346 | 928059a3 | Luiz Capitulino | netdev_add(opts, &err); |
1347 | 84d18f06 | Markus Armbruster | if (err) {
|
1348 | 928059a3 | Luiz Capitulino | qemu_opts_del(opts); |
1349 | 928059a3 | Luiz Capitulino | } |
1350 | 928059a3 | Luiz Capitulino | |
1351 | 928059a3 | Luiz Capitulino | out:
|
1352 | 928059a3 | Luiz Capitulino | hmp_handle_error(mon, &err); |
1353 | 928059a3 | Luiz Capitulino | } |
1354 | 5f964155 | Luiz Capitulino | |
1355 | 5f964155 | Luiz Capitulino | void hmp_netdev_del(Monitor *mon, const QDict *qdict) |
1356 | 5f964155 | Luiz Capitulino | { |
1357 | 5f964155 | Luiz Capitulino | const char *id = qdict_get_str(qdict, "id"); |
1358 | 5f964155 | Luiz Capitulino | Error *err = NULL;
|
1359 | 5f964155 | Luiz Capitulino | |
1360 | 5f964155 | Luiz Capitulino | qmp_netdev_del(id, &err); |
1361 | 5f964155 | Luiz Capitulino | hmp_handle_error(mon, &err); |
1362 | 5f964155 | Luiz Capitulino | } |
1363 | 208c9d1b | Corey Bryant | |
1364 | cff8b2c6 | Paolo Bonzini | void hmp_object_add(Monitor *mon, const QDict *qdict) |
1365 | cff8b2c6 | Paolo Bonzini | { |
1366 | cff8b2c6 | Paolo Bonzini | Error *err = NULL;
|
1367 | cff8b2c6 | Paolo Bonzini | QemuOpts *opts; |
1368 | cff8b2c6 | Paolo Bonzini | char *type = NULL; |
1369 | cff8b2c6 | Paolo Bonzini | char *id = NULL; |
1370 | cff8b2c6 | Paolo Bonzini | void *dummy = NULL; |
1371 | cff8b2c6 | Paolo Bonzini | OptsVisitor *ov; |
1372 | cff8b2c6 | Paolo Bonzini | QDict *pdict; |
1373 | cff8b2c6 | Paolo Bonzini | |
1374 | cff8b2c6 | Paolo Bonzini | opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
|
1375 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1376 | cff8b2c6 | Paolo Bonzini | goto out;
|
1377 | cff8b2c6 | Paolo Bonzini | } |
1378 | cff8b2c6 | Paolo Bonzini | |
1379 | cff8b2c6 | Paolo Bonzini | ov = opts_visitor_new(opts); |
1380 | cff8b2c6 | Paolo Bonzini | pdict = qdict_clone_shallow(qdict); |
1381 | cff8b2c6 | Paolo Bonzini | |
1382 | cff8b2c6 | Paolo Bonzini | visit_start_struct(opts_get_visitor(ov), &dummy, NULL, NULL, 0, &err); |
1383 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1384 | cff8b2c6 | Paolo Bonzini | goto out_clean;
|
1385 | cff8b2c6 | Paolo Bonzini | } |
1386 | cff8b2c6 | Paolo Bonzini | |
1387 | cff8b2c6 | Paolo Bonzini | qdict_del(pdict, "qom-type");
|
1388 | cff8b2c6 | Paolo Bonzini | visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err);
|
1389 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1390 | cff8b2c6 | Paolo Bonzini | goto out_clean;
|
1391 | cff8b2c6 | Paolo Bonzini | } |
1392 | cff8b2c6 | Paolo Bonzini | |
1393 | cff8b2c6 | Paolo Bonzini | qdict_del(pdict, "id");
|
1394 | cff8b2c6 | Paolo Bonzini | visit_type_str(opts_get_visitor(ov), &id, "id", &err);
|
1395 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1396 | cff8b2c6 | Paolo Bonzini | goto out_clean;
|
1397 | cff8b2c6 | Paolo Bonzini | } |
1398 | cff8b2c6 | Paolo Bonzini | |
1399 | cff8b2c6 | Paolo Bonzini | object_add(type, id, pdict, opts_get_visitor(ov), &err); |
1400 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1401 | cff8b2c6 | Paolo Bonzini | goto out_clean;
|
1402 | cff8b2c6 | Paolo Bonzini | } |
1403 | cff8b2c6 | Paolo Bonzini | visit_end_struct(opts_get_visitor(ov), &err); |
1404 | cff8b2c6 | Paolo Bonzini | if (err) {
|
1405 | cff8b2c6 | Paolo Bonzini | qmp_object_del(id, NULL);
|
1406 | cff8b2c6 | Paolo Bonzini | } |
1407 | cff8b2c6 | Paolo Bonzini | |
1408 | cff8b2c6 | Paolo Bonzini | out_clean:
|
1409 | cff8b2c6 | Paolo Bonzini | opts_visitor_cleanup(ov); |
1410 | cff8b2c6 | Paolo Bonzini | |
1411 | cff8b2c6 | Paolo Bonzini | QDECREF(pdict); |
1412 | cff8b2c6 | Paolo Bonzini | qemu_opts_del(opts); |
1413 | cff8b2c6 | Paolo Bonzini | g_free(id); |
1414 | cff8b2c6 | Paolo Bonzini | g_free(type); |
1415 | cff8b2c6 | Paolo Bonzini | g_free(dummy); |
1416 | cff8b2c6 | Paolo Bonzini | |
1417 | cff8b2c6 | Paolo Bonzini | out:
|
1418 | cff8b2c6 | Paolo Bonzini | hmp_handle_error(mon, &err); |
1419 | cff8b2c6 | Paolo Bonzini | } |
1420 | cff8b2c6 | Paolo Bonzini | |
1421 | 208c9d1b | Corey Bryant | void hmp_getfd(Monitor *mon, const QDict *qdict) |
1422 | 208c9d1b | Corey Bryant | { |
1423 | 208c9d1b | Corey Bryant | const char *fdname = qdict_get_str(qdict, "fdname"); |
1424 | 208c9d1b | Corey Bryant | Error *errp = NULL;
|
1425 | 208c9d1b | Corey Bryant | |
1426 | 208c9d1b | Corey Bryant | qmp_getfd(fdname, &errp); |
1427 | 208c9d1b | Corey Bryant | hmp_handle_error(mon, &errp); |
1428 | 208c9d1b | Corey Bryant | } |
1429 | 208c9d1b | Corey Bryant | |
1430 | 208c9d1b | Corey Bryant | void hmp_closefd(Monitor *mon, const QDict *qdict) |
1431 | 208c9d1b | Corey Bryant | { |
1432 | 208c9d1b | Corey Bryant | const char *fdname = qdict_get_str(qdict, "fdname"); |
1433 | 208c9d1b | Corey Bryant | Error *errp = NULL;
|
1434 | 208c9d1b | Corey Bryant | |
1435 | 208c9d1b | Corey Bryant | qmp_closefd(fdname, &errp); |
1436 | 208c9d1b | Corey Bryant | hmp_handle_error(mon, &errp); |
1437 | 208c9d1b | Corey Bryant | } |
1438 | e4c8f004 | Amos Kong | |
1439 | e4c8f004 | Amos Kong | void hmp_send_key(Monitor *mon, const QDict *qdict) |
1440 | e4c8f004 | Amos Kong | { |
1441 | e4c8f004 | Amos Kong | const char *keys = qdict_get_str(qdict, "keys"); |
1442 | 9f328977 | Luiz Capitulino | KeyValueList *keylist, *head = NULL, *tmp = NULL; |
1443 | e4c8f004 | Amos Kong | int has_hold_time = qdict_haskey(qdict, "hold-time"); |
1444 | e4c8f004 | Amos Kong | int hold_time = qdict_get_try_int(qdict, "hold-time", -1); |
1445 | e4c8f004 | Amos Kong | Error *err = NULL;
|
1446 | e4c8f004 | Amos Kong | char keyname_buf[16]; |
1447 | e4c8f004 | Amos Kong | char *separator;
|
1448 | 9f328977 | Luiz Capitulino | int keyname_len;
|
1449 | e4c8f004 | Amos Kong | |
1450 | e4c8f004 | Amos Kong | while (1) { |
1451 | e4c8f004 | Amos Kong | separator = strchr(keys, '-');
|
1452 | e4c8f004 | Amos Kong | keyname_len = separator ? separator - keys : strlen(keys); |
1453 | e4c8f004 | Amos Kong | pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
|
1454 | e4c8f004 | Amos Kong | |
1455 | e4c8f004 | Amos Kong | /* Be compatible with old interface, convert user inputted "<" */
|
1456 | e4c8f004 | Amos Kong | if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) { |
1457 | e4c8f004 | Amos Kong | pstrcpy(keyname_buf, sizeof(keyname_buf), "less"); |
1458 | e4c8f004 | Amos Kong | keyname_len = 4;
|
1459 | e4c8f004 | Amos Kong | } |
1460 | e4c8f004 | Amos Kong | keyname_buf[keyname_len] = 0;
|
1461 | e4c8f004 | Amos Kong | |
1462 | e4c8f004 | Amos Kong | keylist = g_malloc0(sizeof(*keylist));
|
1463 | 9f328977 | Luiz Capitulino | keylist->value = g_malloc0(sizeof(*keylist->value));
|
1464 | e4c8f004 | Amos Kong | |
1465 | e4c8f004 | Amos Kong | if (!head) {
|
1466 | e4c8f004 | Amos Kong | head = keylist; |
1467 | e4c8f004 | Amos Kong | } |
1468 | e4c8f004 | Amos Kong | if (tmp) {
|
1469 | e4c8f004 | Amos Kong | tmp->next = keylist; |
1470 | e4c8f004 | Amos Kong | } |
1471 | e4c8f004 | Amos Kong | tmp = keylist; |
1472 | e4c8f004 | Amos Kong | |
1473 | 9f328977 | Luiz Capitulino | if (strstart(keyname_buf, "0x", NULL)) { |
1474 | 9f328977 | Luiz Capitulino | char *endp;
|
1475 | 9f328977 | Luiz Capitulino | int value = strtoul(keyname_buf, &endp, 0); |
1476 | 9f328977 | Luiz Capitulino | if (*endp != '\0') { |
1477 | 9f328977 | Luiz Capitulino | goto err_out;
|
1478 | 9f328977 | Luiz Capitulino | } |
1479 | 9f328977 | Luiz Capitulino | keylist->value->kind = KEY_VALUE_KIND_NUMBER; |
1480 | 9f328977 | Luiz Capitulino | keylist->value->number = value; |
1481 | 9f328977 | Luiz Capitulino | } else {
|
1482 | 9f328977 | Luiz Capitulino | int idx = index_from_key(keyname_buf);
|
1483 | 9f328977 | Luiz Capitulino | if (idx == Q_KEY_CODE_MAX) {
|
1484 | 9f328977 | Luiz Capitulino | goto err_out;
|
1485 | 9f328977 | Luiz Capitulino | } |
1486 | 9f328977 | Luiz Capitulino | keylist->value->kind = KEY_VALUE_KIND_QCODE; |
1487 | 9f328977 | Luiz Capitulino | keylist->value->qcode = idx; |
1488 | 9f328977 | Luiz Capitulino | } |
1489 | 9f328977 | Luiz Capitulino | |
1490 | e4c8f004 | Amos Kong | if (!separator) {
|
1491 | e4c8f004 | Amos Kong | break;
|
1492 | e4c8f004 | Amos Kong | } |
1493 | e4c8f004 | Amos Kong | keys = separator + 1;
|
1494 | e4c8f004 | Amos Kong | } |
1495 | e4c8f004 | Amos Kong | |
1496 | 9f328977 | Luiz Capitulino | qmp_send_key(head, has_hold_time, hold_time, &err); |
1497 | e4c8f004 | Amos Kong | hmp_handle_error(mon, &err); |
1498 | 9f328977 | Luiz Capitulino | |
1499 | 9f328977 | Luiz Capitulino | out:
|
1500 | 9f328977 | Luiz Capitulino | qapi_free_KeyValueList(head); |
1501 | 9f328977 | Luiz Capitulino | return;
|
1502 | 9f328977 | Luiz Capitulino | |
1503 | 9f328977 | Luiz Capitulino | err_out:
|
1504 | 9f328977 | Luiz Capitulino | monitor_printf(mon, "invalid parameter: %s\n", keyname_buf);
|
1505 | 9f328977 | Luiz Capitulino | goto out;
|
1506 | e4c8f004 | Amos Kong | } |
1507 | ad39cf6d | Luiz Capitulino | |
1508 | ad39cf6d | Luiz Capitulino | void hmp_screen_dump(Monitor *mon, const QDict *qdict) |
1509 | ad39cf6d | Luiz Capitulino | { |
1510 | ad39cf6d | Luiz Capitulino | const char *filename = qdict_get_str(qdict, "filename"); |
1511 | ad39cf6d | Luiz Capitulino | Error *err = NULL;
|
1512 | ad39cf6d | Luiz Capitulino | |
1513 | ad39cf6d | Luiz Capitulino | qmp_screendump(filename, &err); |
1514 | ad39cf6d | Luiz Capitulino | hmp_handle_error(mon, &err); |
1515 | ad39cf6d | Luiz Capitulino | } |
1516 | 4057725f | Paolo Bonzini | |
1517 | 4057725f | Paolo Bonzini | void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) |
1518 | 4057725f | Paolo Bonzini | { |
1519 | 4057725f | Paolo Bonzini | const char *uri = qdict_get_str(qdict, "uri"); |
1520 | 4057725f | Paolo Bonzini | int writable = qdict_get_try_bool(qdict, "writable", 0); |
1521 | 4057725f | Paolo Bonzini | int all = qdict_get_try_bool(qdict, "all", 0); |
1522 | 4057725f | Paolo Bonzini | Error *local_err = NULL;
|
1523 | 4057725f | Paolo Bonzini | BlockInfoList *block_list, *info; |
1524 | 4057725f | Paolo Bonzini | SocketAddress *addr; |
1525 | 4057725f | Paolo Bonzini | |
1526 | 4057725f | Paolo Bonzini | if (writable && !all) {
|
1527 | 4057725f | Paolo Bonzini | error_setg(&local_err, "-w only valid together with -a");
|
1528 | 4057725f | Paolo Bonzini | goto exit;
|
1529 | 4057725f | Paolo Bonzini | } |
1530 | 4057725f | Paolo Bonzini | |
1531 | 4057725f | Paolo Bonzini | /* First check if the address is valid and start the server. */
|
1532 | 4057725f | Paolo Bonzini | addr = socket_parse(uri, &local_err); |
1533 | 4057725f | Paolo Bonzini | if (local_err != NULL) { |
1534 | 4057725f | Paolo Bonzini | goto exit;
|
1535 | 4057725f | Paolo Bonzini | } |
1536 | 4057725f | Paolo Bonzini | |
1537 | 4057725f | Paolo Bonzini | qmp_nbd_server_start(addr, &local_err); |
1538 | 4057725f | Paolo Bonzini | qapi_free_SocketAddress(addr); |
1539 | 4057725f | Paolo Bonzini | if (local_err != NULL) { |
1540 | 4057725f | Paolo Bonzini | goto exit;
|
1541 | 4057725f | Paolo Bonzini | } |
1542 | 4057725f | Paolo Bonzini | |
1543 | 4057725f | Paolo Bonzini | if (!all) {
|
1544 | 4057725f | Paolo Bonzini | return;
|
1545 | 4057725f | Paolo Bonzini | } |
1546 | 4057725f | Paolo Bonzini | |
1547 | 4057725f | Paolo Bonzini | /* Then try adding all block devices. If one fails, close all and
|
1548 | 4057725f | Paolo Bonzini | * exit.
|
1549 | 4057725f | Paolo Bonzini | */
|
1550 | 4057725f | Paolo Bonzini | block_list = qmp_query_block(NULL);
|
1551 | 4057725f | Paolo Bonzini | |
1552 | 4057725f | Paolo Bonzini | for (info = block_list; info; info = info->next) {
|
1553 | 4057725f | Paolo Bonzini | if (!info->value->has_inserted) {
|
1554 | 4057725f | Paolo Bonzini | continue;
|
1555 | 4057725f | Paolo Bonzini | } |
1556 | 4057725f | Paolo Bonzini | |
1557 | 4057725f | Paolo Bonzini | qmp_nbd_server_add(info->value->device, true, writable, &local_err);
|
1558 | 4057725f | Paolo Bonzini | |
1559 | 4057725f | Paolo Bonzini | if (local_err != NULL) { |
1560 | 4057725f | Paolo Bonzini | qmp_nbd_server_stop(NULL);
|
1561 | 4057725f | Paolo Bonzini | break;
|
1562 | 4057725f | Paolo Bonzini | } |
1563 | 4057725f | Paolo Bonzini | } |
1564 | 4057725f | Paolo Bonzini | |
1565 | 4057725f | Paolo Bonzini | qapi_free_BlockInfoList(block_list); |
1566 | 4057725f | Paolo Bonzini | |
1567 | 4057725f | Paolo Bonzini | exit:
|
1568 | 4057725f | Paolo Bonzini | hmp_handle_error(mon, &local_err); |
1569 | 4057725f | Paolo Bonzini | } |
1570 | 4057725f | Paolo Bonzini | |
1571 | 4057725f | Paolo Bonzini | void hmp_nbd_server_add(Monitor *mon, const QDict *qdict) |
1572 | 4057725f | Paolo Bonzini | { |
1573 | 4057725f | Paolo Bonzini | const char *device = qdict_get_str(qdict, "device"); |
1574 | 4057725f | Paolo Bonzini | int writable = qdict_get_try_bool(qdict, "writable", 0); |
1575 | 4057725f | Paolo Bonzini | Error *local_err = NULL;
|
1576 | 4057725f | Paolo Bonzini | |
1577 | 4057725f | Paolo Bonzini | qmp_nbd_server_add(device, true, writable, &local_err);
|
1578 | 4057725f | Paolo Bonzini | |
1579 | 4057725f | Paolo Bonzini | if (local_err != NULL) { |
1580 | 4057725f | Paolo Bonzini | hmp_handle_error(mon, &local_err); |
1581 | 4057725f | Paolo Bonzini | } |
1582 | 4057725f | Paolo Bonzini | } |
1583 | 4057725f | Paolo Bonzini | |
1584 | 4057725f | Paolo Bonzini | void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict) |
1585 | 4057725f | Paolo Bonzini | { |
1586 | 4057725f | Paolo Bonzini | Error *errp = NULL;
|
1587 | 4057725f | Paolo Bonzini | |
1588 | 4057725f | Paolo Bonzini | qmp_nbd_server_stop(&errp); |
1589 | 4057725f | Paolo Bonzini | hmp_handle_error(mon, &errp); |
1590 | 4057725f | Paolo Bonzini | } |
1591 | f1088908 | Gerd Hoffmann | |
1592 | abf23329 | Jason J. Herne | void hmp_cpu_add(Monitor *mon, const QDict *qdict) |
1593 | abf23329 | Jason J. Herne | { |
1594 | abf23329 | Jason J. Herne | int cpuid;
|
1595 | abf23329 | Jason J. Herne | Error *err = NULL;
|
1596 | abf23329 | Jason J. Herne | |
1597 | abf23329 | Jason J. Herne | cpuid = qdict_get_int(qdict, "id");
|
1598 | abf23329 | Jason J. Herne | qmp_cpu_add(cpuid, &err); |
1599 | abf23329 | Jason J. Herne | hmp_handle_error(mon, &err); |
1600 | abf23329 | Jason J. Herne | } |
1601 | abf23329 | Jason J. Herne | |
1602 | f1088908 | Gerd Hoffmann | void hmp_chardev_add(Monitor *mon, const QDict *qdict) |
1603 | f1088908 | Gerd Hoffmann | { |
1604 | f1088908 | Gerd Hoffmann | const char *args = qdict_get_str(qdict, "args"); |
1605 | f1088908 | Gerd Hoffmann | Error *err = NULL;
|
1606 | f1088908 | Gerd Hoffmann | QemuOpts *opts; |
1607 | f1088908 | Gerd Hoffmann | |
1608 | f1088908 | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("chardev"), args, 1); |
1609 | f1088908 | Gerd Hoffmann | if (opts == NULL) { |
1610 | 312fd5f2 | Markus Armbruster | error_setg(&err, "Parsing chardev args failed");
|
1611 | f1088908 | Gerd Hoffmann | } else {
|
1612 | f1088908 | Gerd Hoffmann | qemu_chr_new_from_opts(opts, NULL, &err);
|
1613 | f1088908 | Gerd Hoffmann | } |
1614 | f1088908 | Gerd Hoffmann | hmp_handle_error(mon, &err); |
1615 | f1088908 | Gerd Hoffmann | } |
1616 | f1088908 | Gerd Hoffmann | |
1617 | f1088908 | Gerd Hoffmann | void hmp_chardev_remove(Monitor *mon, const QDict *qdict) |
1618 | f1088908 | Gerd Hoffmann | { |
1619 | f1088908 | Gerd Hoffmann | Error *local_err = NULL;
|
1620 | f1088908 | Gerd Hoffmann | |
1621 | f1088908 | Gerd Hoffmann | qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
|
1622 | f1088908 | Gerd Hoffmann | hmp_handle_error(mon, &local_err); |
1623 | f1088908 | Gerd Hoffmann | } |
1624 | 587da2c3 | Kevin Wolf | |
1625 | 587da2c3 | Kevin Wolf | void hmp_qemu_io(Monitor *mon, const QDict *qdict) |
1626 | 587da2c3 | Kevin Wolf | { |
1627 | 587da2c3 | Kevin Wolf | BlockDriverState *bs; |
1628 | 587da2c3 | Kevin Wolf | const char* device = qdict_get_str(qdict, "device"); |
1629 | 587da2c3 | Kevin Wolf | const char* command = qdict_get_str(qdict, "command"); |
1630 | 587da2c3 | Kevin Wolf | Error *err = NULL;
|
1631 | 587da2c3 | Kevin Wolf | |
1632 | 587da2c3 | Kevin Wolf | bs = bdrv_find(device); |
1633 | 587da2c3 | Kevin Wolf | if (bs) {
|
1634 | 587da2c3 | Kevin Wolf | qemuio_command(bs, command); |
1635 | 587da2c3 | Kevin Wolf | } else {
|
1636 | 587da2c3 | Kevin Wolf | error_set(&err, QERR_DEVICE_NOT_FOUND, device); |
1637 | 587da2c3 | Kevin Wolf | } |
1638 | 587da2c3 | Kevin Wolf | |
1639 | 587da2c3 | Kevin Wolf | hmp_handle_error(mon, &err); |
1640 | 587da2c3 | Kevin Wolf | } |
1641 | ab2d0531 | Paolo Bonzini | |
1642 | ab2d0531 | Paolo Bonzini | void hmp_object_del(Monitor *mon, const QDict *qdict) |
1643 | ab2d0531 | Paolo Bonzini | { |
1644 | ab2d0531 | Paolo Bonzini | const char *id = qdict_get_str(qdict, "id"); |
1645 | ab2d0531 | Paolo Bonzini | Error *err = NULL;
|
1646 | ab2d0531 | Paolo Bonzini | |
1647 | ab2d0531 | Paolo Bonzini | qmp_object_del(id, &err); |
1648 | ab2d0531 | Paolo Bonzini | hmp_handle_error(mon, &err); |
1649 | ab2d0531 | Paolo Bonzini | } |