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