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