]>
Commit | Line | Data |
---|---|---|
48a32bed AL |
1 | /* |
2 | * Human Monitor Interface | |
3 | * | |
4 | * Copyright IBM, Corp. 2011 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
6b620ca3 PB |
12 | * Contributions after 2012-01-13 are licensed under the terms of the |
13 | * GNU GPL, version 2 or (at your option) any later version. | |
48a32bed AL |
14 | */ |
15 | ||
d38ea87a | 16 | #include "qemu/osdep.h" |
48a32bed | 17 | #include "hmp.h" |
1422e32d | 18 | #include "net/net.h" |
fafa4d50 | 19 | #include "net/eth.h" |
8228e353 | 20 | #include "chardev/char.h" |
4c7b7e9b | 21 | #include "sysemu/block-backend.h" |
52b26205 | 22 | #include "sysemu/sysemu.h" |
213dcb06 | 23 | #include "qemu/config-file.h" |
1de7afc9 PB |
24 | #include "qemu/option.h" |
25 | #include "qemu/timer.h" | |
48a32bed | 26 | #include "qmp-commands.h" |
1de7afc9 | 27 | #include "qemu/sockets.h" |
83c9089e | 28 | #include "monitor/monitor.h" |
318660f8 | 29 | #include "monitor/qdev.h" |
e688df6b | 30 | #include "qapi/error.h" |
cff8b2c6 | 31 | #include "qapi/opts-visitor.h" |
452fcdbc | 32 | #include "qapi/qmp/qdict.h" |
cc7a8ea7 | 33 | #include "qapi/qmp/qerror.h" |
f4a06d13 | 34 | #include "qapi/string-input-visitor.h" |
eb1539b2 HT |
35 | #include "qapi/string-output-visitor.h" |
36 | #include "qapi-visit.h" | |
90998d58 | 37 | #include "qom/object_interfaces.h" |
28ecbaee | 38 | #include "ui/console.h" |
bd269ebc | 39 | #include "block/nbd.h" |
bd093a36 | 40 | #include "block/qapi.h" |
587da2c3 | 41 | #include "qemu-io.h" |
f348b6d1 | 42 | #include "qemu/cutils.h" |
d59ce6f3 | 43 | #include "qemu/error-report.h" |
be9b23c4 | 44 | #include "exec/ramlist.h" |
61b97833 | 45 | #include "hw/intc/intc.h" |
5e22479a | 46 | #include "migration/snapshot.h" |
9d18af93 | 47 | #include "migration/misc.h" |
48a32bed | 48 | |
22fa7da0 CR |
49 | #ifdef CONFIG_SPICE |
50 | #include <spice/enums.h> | |
51 | #endif | |
52 | ||
0cfd6a9a LC |
53 | static void hmp_handle_error(Monitor *mon, Error **errp) |
54 | { | |
415168e0 MA |
55 | assert(errp); |
56 | if (*errp) { | |
193227f9 | 57 | error_report_err(*errp); |
0cfd6a9a LC |
58 | } |
59 | } | |
60 | ||
84f2d0ea | 61 | void hmp_info_name(Monitor *mon, const QDict *qdict) |
48a32bed AL |
62 | { |
63 | NameInfo *info; | |
64 | ||
65 | info = qmp_query_name(NULL); | |
66 | if (info->has_name) { | |
67 | monitor_printf(mon, "%s\n", info->name); | |
68 | } | |
69 | qapi_free_NameInfo(info); | |
70 | } | |
b9c15f16 | 71 | |
84f2d0ea | 72 | void hmp_info_version(Monitor *mon, const QDict *qdict) |
b9c15f16 LC |
73 | { |
74 | VersionInfo *info; | |
75 | ||
76 | info = qmp_query_version(NULL); | |
77 | ||
78 | monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n", | |
4752cdbb | 79 | info->qemu->major, info->qemu->minor, info->qemu->micro, |
b9c15f16 LC |
80 | info->package); |
81 | ||
82 | qapi_free_VersionInfo(info); | |
83 | } | |
292a2602 | 84 | |
84f2d0ea | 85 | void hmp_info_kvm(Monitor *mon, const QDict *qdict) |
292a2602 LC |
86 | { |
87 | KvmInfo *info; | |
88 | ||
89 | info = qmp_query_kvm(NULL); | |
90 | monitor_printf(mon, "kvm support: "); | |
91 | if (info->present) { | |
92 | monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"); | |
93 | } else { | |
94 | monitor_printf(mon, "not compiled\n"); | |
95 | } | |
96 | ||
97 | qapi_free_KvmInfo(info); | |
98 | } | |
99 | ||
84f2d0ea | 100 | void hmp_info_status(Monitor *mon, const QDict *qdict) |
1fa9a5e4 LC |
101 | { |
102 | StatusInfo *info; | |
103 | ||
104 | info = qmp_query_status(NULL); | |
105 | ||
106 | monitor_printf(mon, "VM status: %s%s", | |
107 | info->running ? "running" : "paused", | |
108 | info->singlestep ? " (single step mode)" : ""); | |
109 | ||
110 | if (!info->running && info->status != RUN_STATE_PAUSED) { | |
977c736f | 111 | monitor_printf(mon, " (%s)", RunState_str(info->status)); |
1fa9a5e4 LC |
112 | } |
113 | ||
114 | monitor_printf(mon, "\n"); | |
115 | ||
116 | qapi_free_StatusInfo(info); | |
117 | } | |
118 | ||
84f2d0ea | 119 | void hmp_info_uuid(Monitor *mon, const QDict *qdict) |
efab767e LC |
120 | { |
121 | UuidInfo *info; | |
122 | ||
123 | info = qmp_query_uuid(NULL); | |
124 | monitor_printf(mon, "%s\n", info->UUID); | |
125 | qapi_free_UuidInfo(info); | |
126 | } | |
c5a415a0 | 127 | |
84f2d0ea | 128 | void hmp_info_chardev(Monitor *mon, const QDict *qdict) |
c5a415a0 LC |
129 | { |
130 | ChardevInfoList *char_info, *info; | |
131 | ||
132 | char_info = qmp_query_chardev(NULL); | |
133 | for (info = char_info; info; info = info->next) { | |
134 | monitor_printf(mon, "%s: filename=%s\n", info->value->label, | |
135 | info->value->filename); | |
136 | } | |
137 | ||
138 | qapi_free_ChardevInfoList(char_info); | |
139 | } | |
7a7f325e | 140 | |
84f2d0ea | 141 | void hmp_info_mice(Monitor *mon, const QDict *qdict) |
e235cec3 LC |
142 | { |
143 | MouseInfoList *mice_list, *mouse; | |
144 | ||
145 | mice_list = qmp_query_mice(NULL); | |
146 | if (!mice_list) { | |
147 | monitor_printf(mon, "No mouse devices connected\n"); | |
148 | return; | |
149 | } | |
150 | ||
151 | for (mouse = mice_list; mouse; mouse = mouse->next) { | |
152 | monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n", | |
153 | mouse->value->current ? '*' : ' ', | |
154 | mouse->value->index, mouse->value->name, | |
155 | mouse->value->absolute ? " (absolute)" : ""); | |
156 | } | |
157 | ||
158 | qapi_free_MouseInfoList(mice_list); | |
159 | } | |
160 | ||
84f2d0ea | 161 | void hmp_info_migrate(Monitor *mon, const QDict *qdict) |
791e7c82 LC |
162 | { |
163 | MigrationInfo *info; | |
bbf6da32 | 164 | MigrationCapabilityStatusList *caps, *cap; |
791e7c82 LC |
165 | |
166 | info = qmp_query_migrate(NULL); | |
bbf6da32 OW |
167 | caps = qmp_query_migrate_capabilities(NULL); |
168 | ||
9d18af93 PX |
169 | migration_global_dump(mon); |
170 | ||
bbf6da32 OW |
171 | /* do not display parameters during setup */ |
172 | if (info->has_status && caps) { | |
173 | monitor_printf(mon, "capabilities: "); | |
174 | for (cap = caps; cap; cap = cap->next) { | |
175 | monitor_printf(mon, "%s: %s ", | |
977c736f | 176 | MigrationCapability_str(cap->value->capability), |
bbf6da32 OW |
177 | cap->value->state ? "on" : "off"); |
178 | } | |
179 | monitor_printf(mon, "\n"); | |
180 | } | |
791e7c82 LC |
181 | |
182 | if (info->has_status) { | |
d59ce6f3 | 183 | monitor_printf(mon, "Migration status: %s", |
977c736f | 184 | MigrationStatus_str(info->status)); |
d59ce6f3 DB |
185 | if (info->status == MIGRATION_STATUS_FAILED && |
186 | info->has_error_desc) { | |
187 | monitor_printf(mon, " (%s)\n", info->error_desc); | |
188 | } else { | |
189 | monitor_printf(mon, "\n"); | |
190 | } | |
191 | ||
7aa939af JQ |
192 | monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n", |
193 | info->total_time); | |
2c52ddf1 JQ |
194 | if (info->has_expected_downtime) { |
195 | monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n", | |
196 | info->expected_downtime); | |
197 | } | |
9c5a9fcf JQ |
198 | if (info->has_downtime) { |
199 | monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n", | |
200 | info->downtime); | |
201 | } | |
ed4fbd10 MH |
202 | if (info->has_setup_time) { |
203 | monitor_printf(mon, "setup: %" PRIu64 " milliseconds\n", | |
204 | info->setup_time); | |
205 | } | |
791e7c82 LC |
206 | } |
207 | ||
208 | if (info->has_ram) { | |
209 | monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", | |
210 | info->ram->transferred >> 10); | |
7e114f8c MH |
211 | monitor_printf(mon, "throughput: %0.2f mbps\n", |
212 | info->ram->mbps); | |
791e7c82 LC |
213 | monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", |
214 | info->ram->remaining >> 10); | |
215 | monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", | |
216 | info->ram->total >> 10); | |
004d4c10 OW |
217 | monitor_printf(mon, "duplicate: %" PRIu64 " pages\n", |
218 | info->ram->duplicate); | |
f1c72795 PL |
219 | monitor_printf(mon, "skipped: %" PRIu64 " pages\n", |
220 | info->ram->skipped); | |
004d4c10 OW |
221 | monitor_printf(mon, "normal: %" PRIu64 " pages\n", |
222 | info->ram->normal); | |
223 | monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n", | |
224 | info->ram->normal_bytes >> 10); | |
58570ed8 C |
225 | monitor_printf(mon, "dirty sync count: %" PRIu64 "\n", |
226 | info->ram->dirty_sync_count); | |
030ce1f8 CF |
227 | monitor_printf(mon, "page size: %" PRIu64 " kbytes\n", |
228 | info->ram->page_size >> 10); | |
229 | ||
8d017193 JQ |
230 | if (info->ram->dirty_pages_rate) { |
231 | monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", | |
232 | info->ram->dirty_pages_rate); | |
233 | } | |
d3bf5418 DDAG |
234 | if (info->ram->postcopy_requests) { |
235 | monitor_printf(mon, "postcopy request count: %" PRIu64 "\n", | |
236 | info->ram->postcopy_requests); | |
237 | } | |
791e7c82 LC |
238 | } |
239 | ||
240 | if (info->has_disk) { | |
241 | monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n", | |
242 | info->disk->transferred >> 10); | |
243 | monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n", | |
244 | info->disk->remaining >> 10); | |
245 | monitor_printf(mon, "total disk: %" PRIu64 " kbytes\n", | |
246 | info->disk->total >> 10); | |
247 | } | |
248 | ||
f36d55af OW |
249 | if (info->has_xbzrle_cache) { |
250 | monitor_printf(mon, "cache size: %" PRIu64 " bytes\n", | |
251 | info->xbzrle_cache->cache_size); | |
252 | monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n", | |
253 | info->xbzrle_cache->bytes >> 10); | |
254 | monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n", | |
255 | info->xbzrle_cache->pages); | |
256 | monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n", | |
257 | info->xbzrle_cache->cache_miss); | |
8bc39233 C |
258 | monitor_printf(mon, "xbzrle cache miss rate: %0.2f\n", |
259 | info->xbzrle_cache->cache_miss_rate); | |
f36d55af OW |
260 | monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n", |
261 | info->xbzrle_cache->overflow); | |
262 | } | |
263 | ||
d85a31d1 | 264 | if (info->has_cpu_throttle_percentage) { |
4782893e | 265 | monitor_printf(mon, "cpu throttle percentage: %" PRIu64 "\n", |
d85a31d1 | 266 | info->cpu_throttle_percentage); |
4782893e JH |
267 | } |
268 | ||
791e7c82 | 269 | qapi_free_MigrationInfo(info); |
bbf6da32 OW |
270 | qapi_free_MigrationCapabilityStatusList(caps); |
271 | } | |
272 | ||
84f2d0ea | 273 | void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict) |
bbf6da32 OW |
274 | { |
275 | MigrationCapabilityStatusList *caps, *cap; | |
276 | ||
277 | caps = qmp_query_migrate_capabilities(NULL); | |
278 | ||
279 | if (caps) { | |
bbf6da32 | 280 | for (cap = caps; cap; cap = cap->next) { |
d80a0169 | 281 | monitor_printf(mon, "%s: %s\n", |
977c736f | 282 | MigrationCapability_str(cap->value->capability), |
bbf6da32 OW |
283 | cap->value->state ? "on" : "off"); |
284 | } | |
bbf6da32 OW |
285 | } |
286 | ||
287 | qapi_free_MigrationCapabilityStatusList(caps); | |
791e7c82 LC |
288 | } |
289 | ||
50e9a629 LL |
290 | void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) |
291 | { | |
292 | MigrationParameters *params; | |
293 | ||
294 | params = qmp_query_migrate_parameters(NULL); | |
295 | ||
296 | if (params) { | |
de63ab61 | 297 | assert(params->has_compress_level); |
741d4086 | 298 | monitor_printf(mon, "%s: %u\n", |
977c736f | 299 | MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL), |
50e9a629 | 300 | params->compress_level); |
de63ab61 | 301 | assert(params->has_compress_threads); |
741d4086 | 302 | monitor_printf(mon, "%s: %u\n", |
977c736f | 303 | MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS), |
50e9a629 | 304 | params->compress_threads); |
de63ab61 | 305 | assert(params->has_decompress_threads); |
741d4086 | 306 | monitor_printf(mon, "%s: %u\n", |
977c736f | 307 | MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS), |
50e9a629 | 308 | params->decompress_threads); |
de63ab61 | 309 | assert(params->has_cpu_throttle_initial); |
741d4086 | 310 | monitor_printf(mon, "%s: %u\n", |
977c736f | 311 | MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL), |
d85a31d1 | 312 | params->cpu_throttle_initial); |
de63ab61 | 313 | assert(params->has_cpu_throttle_increment); |
741d4086 | 314 | monitor_printf(mon, "%s: %u\n", |
977c736f | 315 | MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT), |
d85a31d1 | 316 | params->cpu_throttle_increment); |
8cc99dcd | 317 | assert(params->has_tls_creds); |
2c02468c | 318 | monitor_printf(mon, "%s: '%s'\n", |
977c736f | 319 | MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS), |
8cc99dcd MA |
320 | params->tls_creds); |
321 | assert(params->has_tls_hostname); | |
2c02468c | 322 | monitor_printf(mon, "%s: '%s'\n", |
977c736f | 323 | MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME), |
8cc99dcd | 324 | params->tls_hostname); |
2ff30257 | 325 | assert(params->has_max_bandwidth); |
741d4086 | 326 | monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n", |
977c736f | 327 | MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH), |
2ff30257 AA |
328 | params->max_bandwidth); |
329 | assert(params->has_downtime_limit); | |
741d4086 | 330 | monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n", |
977c736f | 331 | MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT), |
2ff30257 | 332 | params->downtime_limit); |
fe39a4d4 | 333 | assert(params->has_x_checkpoint_delay); |
741d4086 | 334 | monitor_printf(mon, "%s: %u\n", |
977c736f | 335 | MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY), |
68b53591 | 336 | params->x_checkpoint_delay); |
2833c59b JQ |
337 | assert(params->has_block_incremental); |
338 | monitor_printf(mon, "%s: %s\n", | |
977c736f MA |
339 | MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL), |
340 | params->block_incremental ? "on" : "off"); | |
741d4086 | 341 | monitor_printf(mon, "%s: %u\n", |
4075fb1c JQ |
342 | MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS), |
343 | params->x_multifd_channels); | |
741d4086 | 344 | monitor_printf(mon, "%s: %u\n", |
0fb86605 JQ |
345 | MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT), |
346 | params->x_multifd_page_count); | |
741d4086 | 347 | monitor_printf(mon, "%s: %" PRIu64 "\n", |
73af8dd8 JQ |
348 | MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), |
349 | params->xbzrle_cache_size); | |
50e9a629 LL |
350 | } |
351 | ||
352 | qapi_free_MigrationParameters(params); | |
353 | } | |
354 | ||
84f2d0ea | 355 | void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict) |
9e1ba4cc OW |
356 | { |
357 | monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n", | |
358 | qmp_query_migrate_cache_size(NULL) >> 10); | |
359 | } | |
360 | ||
84f2d0ea | 361 | void hmp_info_cpus(Monitor *mon, const QDict *qdict) |
de0b36b6 LC |
362 | { |
363 | CpuInfoList *cpu_list, *cpu; | |
364 | ||
365 | cpu_list = qmp_query_cpus(NULL); | |
366 | ||
367 | for (cpu = cpu_list; cpu; cpu = cpu->next) { | |
368 | int active = ' '; | |
369 | ||
370 | if (cpu->value->CPU == monitor_get_cpu_index()) { | |
371 | active = '*'; | |
372 | } | |
373 | ||
852bef0e | 374 | monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CPU); |
de0b36b6 | 375 | |
86f4b687 EB |
376 | switch (cpu->value->arch) { |
377 | case CPU_INFO_ARCH_X86: | |
544a3731 | 378 | monitor_printf(mon, " pc=0x%016" PRIx64, cpu->value->u.x86.pc); |
86f4b687 EB |
379 | break; |
380 | case CPU_INFO_ARCH_PPC: | |
544a3731 | 381 | monitor_printf(mon, " nip=0x%016" PRIx64, cpu->value->u.ppc.nip); |
86f4b687 EB |
382 | break; |
383 | case CPU_INFO_ARCH_SPARC: | |
86ae1911 | 384 | monitor_printf(mon, " pc=0x%016" PRIx64, |
544a3731 | 385 | cpu->value->u.q_sparc.pc); |
86ae1911 | 386 | monitor_printf(mon, " npc=0x%016" PRIx64, |
544a3731 | 387 | cpu->value->u.q_sparc.npc); |
86f4b687 EB |
388 | break; |
389 | case CPU_INFO_ARCH_MIPS: | |
544a3731 | 390 | monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.q_mips.PC); |
86f4b687 EB |
391 | break; |
392 | case CPU_INFO_ARCH_TRICORE: | |
544a3731 | 393 | monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore.PC); |
86f4b687 EB |
394 | break; |
395 | default: | |
396 | break; | |
de0b36b6 LC |
397 | } |
398 | ||
399 | if (cpu->value->halted) { | |
400 | monitor_printf(mon, " (halted)"); | |
401 | } | |
402 | ||
403 | monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id); | |
404 | } | |
405 | ||
406 | qapi_free_CpuInfoList(cpu_list); | |
407 | } | |
408 | ||
289b276c KW |
409 | static void print_block_info(Monitor *mon, BlockInfo *info, |
410 | BlockDeviceInfo *inserted, bool verbose) | |
b2023818 | 411 | { |
bd093a36 | 412 | ImageInfo *image_info; |
b2023818 | 413 | |
8d6adccd KW |
414 | assert(!info || !info->has_inserted || info->inserted == inserted); |
415 | ||
ec18b0a9 | 416 | if (info && *info->device) { |
8d6adccd KW |
417 | monitor_printf(mon, "%s", info->device); |
418 | if (inserted && inserted->has_node_name) { | |
419 | monitor_printf(mon, " (%s)", inserted->node_name); | |
420 | } | |
421 | } else { | |
ec18b0a9 | 422 | assert(info || inserted); |
8d6adccd | 423 | monitor_printf(mon, "%s", |
ec18b0a9 KW |
424 | inserted && inserted->has_node_name ? inserted->node_name |
425 | : info && info->has_qdev ? info->qdev | |
8d6adccd KW |
426 | : "<anonymous>"); |
427 | } | |
428 | ||
289b276c KW |
429 | if (inserted) { |
430 | monitor_printf(mon, ": %s (%s%s%s)\n", | |
431 | inserted->file, | |
432 | inserted->drv, | |
433 | inserted->ro ? ", read-only" : "", | |
434 | inserted->encrypted ? ", encrypted" : ""); | |
435 | } else { | |
436 | monitor_printf(mon, ": [not inserted]\n"); | |
437 | } | |
b2023818 | 438 | |
8d6adccd | 439 | if (info) { |
46eade7b KW |
440 | if (info->has_qdev) { |
441 | monitor_printf(mon, " Attached to: %s\n", info->qdev); | |
442 | } | |
8d6adccd KW |
443 | if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) { |
444 | monitor_printf(mon, " I/O status: %s\n", | |
977c736f | 445 | BlockDeviceIoStatus_str(info->io_status)); |
8d6adccd | 446 | } |
b2023818 | 447 | |
8d6adccd KW |
448 | if (info->removable) { |
449 | monitor_printf(mon, " Removable device: %slocked, tray %s\n", | |
450 | info->locked ? "" : "not ", | |
451 | info->tray_open ? "open" : "closed"); | |
452 | } | |
289b276c | 453 | } |
fbe2e26c | 454 | |
b2023818 | 455 | |
289b276c KW |
456 | if (!inserted) { |
457 | return; | |
458 | } | |
b2023818 | 459 | |
289b276c KW |
460 | monitor_printf(mon, " Cache mode: %s%s%s\n", |
461 | inserted->cache->writeback ? "writeback" : "writethrough", | |
462 | inserted->cache->direct ? ", direct" : "", | |
463 | inserted->cache->no_flush ? ", ignore flushes" : ""); | |
464 | ||
465 | if (inserted->has_backing_file) { | |
466 | monitor_printf(mon, | |
467 | " Backing file: %s " | |
468 | "(chain depth: %" PRId64 ")\n", | |
469 | inserted->backing_file, | |
470 | inserted->backing_file_depth); | |
471 | } | |
727f005e | 472 | |
289b276c KW |
473 | if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) { |
474 | monitor_printf(mon, " Detect zeroes: %s\n", | |
977c736f | 475 | BlockdevDetectZeroesOptions_str(inserted->detect_zeroes)); |
289b276c | 476 | } |
fbe2e26c | 477 | |
289b276c KW |
478 | if (inserted->bps || inserted->bps_rd || inserted->bps_wr || |
479 | inserted->iops || inserted->iops_rd || inserted->iops_wr) | |
480 | { | |
481 | monitor_printf(mon, " I/O throttling: bps=%" PRId64 | |
482 | " bps_rd=%" PRId64 " bps_wr=%" PRId64 | |
483 | " bps_max=%" PRId64 | |
484 | " bps_rd_max=%" PRId64 | |
485 | " bps_wr_max=%" PRId64 | |
486 | " iops=%" PRId64 " iops_rd=%" PRId64 | |
487 | " iops_wr=%" PRId64 | |
488 | " iops_max=%" PRId64 | |
489 | " iops_rd_max=%" PRId64 | |
490 | " iops_wr_max=%" PRId64 | |
b8fe1694 AG |
491 | " iops_size=%" PRId64 |
492 | " group=%s\n", | |
289b276c KW |
493 | inserted->bps, |
494 | inserted->bps_rd, | |
495 | inserted->bps_wr, | |
496 | inserted->bps_max, | |
497 | inserted->bps_rd_max, | |
498 | inserted->bps_wr_max, | |
499 | inserted->iops, | |
500 | inserted->iops_rd, | |
501 | inserted->iops_wr, | |
502 | inserted->iops_max, | |
503 | inserted->iops_rd_max, | |
504 | inserted->iops_wr_max, | |
b8fe1694 AG |
505 | inserted->iops_size, |
506 | inserted->group); | |
289b276c | 507 | } |
fbe2e26c | 508 | |
9419874f | 509 | if (verbose) { |
289b276c KW |
510 | monitor_printf(mon, "\nImages:\n"); |
511 | image_info = inserted->image; | |
512 | while (1) { | |
513 | bdrv_image_info_dump((fprintf_function)monitor_printf, | |
514 | mon, image_info); | |
515 | if (image_info->has_backing_image) { | |
516 | image_info = image_info->backing_image; | |
517 | } else { | |
518 | break; | |
519 | } | |
520 | } | |
521 | } | |
522 | } | |
9e193c5a | 523 | |
289b276c KW |
524 | void hmp_info_block(Monitor *mon, const QDict *qdict) |
525 | { | |
526 | BlockInfoList *block_list, *info; | |
e6bb31ec | 527 | BlockDeviceInfoList *blockdev_list, *blockdev; |
289b276c | 528 | const char *device = qdict_get_try_str(qdict, "device"); |
34acbc95 EB |
529 | bool verbose = qdict_get_try_bool(qdict, "verbose", false); |
530 | bool nodes = qdict_get_try_bool(qdict, "nodes", false); | |
e6bb31ec | 531 | bool printed = false; |
9e193c5a | 532 | |
e6bb31ec KW |
533 | /* Print BlockBackend information */ |
534 | if (!nodes) { | |
f19e44bc | 535 | block_list = qmp_query_block(NULL); |
e6bb31ec KW |
536 | } else { |
537 | block_list = NULL; | |
538 | } | |
fbe2e26c | 539 | |
289b276c KW |
540 | for (info = block_list; info; info = info->next) { |
541 | if (device && strcmp(device, info->value->device)) { | |
542 | continue; | |
465bee1d PL |
543 | } |
544 | ||
289b276c KW |
545 | if (info != block_list) { |
546 | monitor_printf(mon, "\n"); | |
fbe2e26c | 547 | } |
bd093a36 | 548 | |
289b276c KW |
549 | print_block_info(mon, info->value, info->value->has_inserted |
550 | ? info->value->inserted : NULL, | |
551 | verbose); | |
e6bb31ec | 552 | printed = true; |
b2023818 LC |
553 | } |
554 | ||
555 | qapi_free_BlockInfoList(block_list); | |
e6bb31ec KW |
556 | |
557 | if ((!device && !nodes) || printed) { | |
558 | return; | |
559 | } | |
560 | ||
561 | /* Print node information */ | |
562 | blockdev_list = qmp_query_named_block_nodes(NULL); | |
563 | for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) { | |
564 | assert(blockdev->value->has_node_name); | |
565 | if (device && strcmp(device, blockdev->value->node_name)) { | |
566 | continue; | |
567 | } | |
568 | ||
569 | if (blockdev != blockdev_list) { | |
570 | monitor_printf(mon, "\n"); | |
571 | } | |
572 | ||
573 | print_block_info(mon, NULL, blockdev->value, verbose); | |
574 | } | |
575 | qapi_free_BlockDeviceInfoList(blockdev_list); | |
b2023818 LC |
576 | } |
577 | ||
84f2d0ea | 578 | void hmp_info_blockstats(Monitor *mon, const QDict *qdict) |
f11f57e4 LC |
579 | { |
580 | BlockStatsList *stats_list, *stats; | |
581 | ||
f71eaa74 | 582 | stats_list = qmp_query_blockstats(false, false, NULL); |
f11f57e4 LC |
583 | |
584 | for (stats = stats_list; stats; stats = stats->next) { | |
585 | if (!stats->value->has_device) { | |
586 | continue; | |
587 | } | |
588 | ||
589 | monitor_printf(mon, "%s:", stats->value->device); | |
590 | monitor_printf(mon, " rd_bytes=%" PRId64 | |
591 | " wr_bytes=%" PRId64 | |
592 | " rd_operations=%" PRId64 | |
593 | " wr_operations=%" PRId64 | |
594 | " flush_operations=%" PRId64 | |
595 | " wr_total_time_ns=%" PRId64 | |
596 | " rd_total_time_ns=%" PRId64 | |
597 | " flush_total_time_ns=%" PRId64 | |
f4564d53 PL |
598 | " rd_merged=%" PRId64 |
599 | " wr_merged=%" PRId64 | |
cb38fffb | 600 | " idle_time_ns=%" PRId64 |
f11f57e4 LC |
601 | "\n", |
602 | stats->value->stats->rd_bytes, | |
603 | stats->value->stats->wr_bytes, | |
604 | stats->value->stats->rd_operations, | |
605 | stats->value->stats->wr_operations, | |
606 | stats->value->stats->flush_operations, | |
607 | stats->value->stats->wr_total_time_ns, | |
608 | stats->value->stats->rd_total_time_ns, | |
f4564d53 PL |
609 | stats->value->stats->flush_total_time_ns, |
610 | stats->value->stats->rd_merged, | |
cb38fffb AG |
611 | stats->value->stats->wr_merged, |
612 | stats->value->stats->idle_time_ns); | |
f11f57e4 LC |
613 | } |
614 | ||
615 | qapi_free_BlockStatsList(stats_list); | |
616 | } | |
617 | ||
0a9667ec DDAG |
618 | /* Helper for hmp_info_vnc_clients, _servers */ |
619 | static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info, | |
620 | const char *name) | |
621 | { | |
622 | monitor_printf(mon, " %s: %s:%s (%s%s)\n", | |
623 | name, | |
624 | info->host, | |
625 | info->service, | |
977c736f | 626 | NetworkAddressFamily_str(info->family), |
0a9667ec DDAG |
627 | info->websocket ? " (Websocket)" : ""); |
628 | } | |
629 | ||
630 | /* Helper displaying and auth and crypt info */ | |
631 | static void hmp_info_vnc_authcrypt(Monitor *mon, const char *indent, | |
632 | VncPrimaryAuth auth, | |
633 | VncVencryptSubAuth *vencrypt) | |
634 | { | |
635 | monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent, | |
977c736f MA |
636 | VncPrimaryAuth_str(auth), |
637 | vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none"); | |
0a9667ec DDAG |
638 | } |
639 | ||
640 | static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client) | |
641 | { | |
642 | while (client) { | |
643 | VncClientInfo *cinfo = client->value; | |
644 | ||
645 | hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client"); | |
646 | monitor_printf(mon, " x509_dname: %s\n", | |
647 | cinfo->has_x509_dname ? | |
648 | cinfo->x509_dname : "none"); | |
649 | monitor_printf(mon, " sasl_username: %s\n", | |
650 | cinfo->has_sasl_username ? | |
651 | cinfo->sasl_username : "none"); | |
652 | ||
653 | client = client->next; | |
654 | } | |
655 | } | |
656 | ||
657 | static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server) | |
658 | { | |
659 | while (server) { | |
660 | VncServerInfo2 *sinfo = server->value; | |
661 | hmp_info_VncBasicInfo(mon, qapi_VncServerInfo2_base(sinfo), "Server"); | |
662 | hmp_info_vnc_authcrypt(mon, " ", sinfo->auth, | |
663 | sinfo->has_vencrypt ? &sinfo->vencrypt : NULL); | |
664 | server = server->next; | |
665 | } | |
666 | } | |
667 | ||
84f2d0ea | 668 | void hmp_info_vnc(Monitor *mon, const QDict *qdict) |
2b54aa87 | 669 | { |
0a9667ec | 670 | VncInfo2List *info2l; |
2b54aa87 | 671 | Error *err = NULL; |
2b54aa87 | 672 | |
0a9667ec | 673 | info2l = qmp_query_vnc_servers(&err); |
2b54aa87 | 674 | if (err) { |
554a39eb | 675 | hmp_handle_error(mon, &err); |
2b54aa87 LC |
676 | return; |
677 | } | |
0a9667ec DDAG |
678 | if (!info2l) { |
679 | monitor_printf(mon, "None\n"); | |
680 | return; | |
2b54aa87 LC |
681 | } |
682 | ||
0a9667ec DDAG |
683 | while (info2l) { |
684 | VncInfo2 *info = info2l->value; | |
685 | monitor_printf(mon, "%s:\n", info->id); | |
686 | hmp_info_vnc_servers(mon, info->server); | |
687 | hmp_info_vnc_clients(mon, info->clients); | |
688 | if (!info->server) { | |
689 | /* The server entry displays its auth, we only | |
690 | * need to display in the case of 'reverse' connections | |
691 | * where there's no server. | |
692 | */ | |
693 | hmp_info_vnc_authcrypt(mon, " ", info->auth, | |
694 | info->has_vencrypt ? &info->vencrypt : NULL); | |
695 | } | |
696 | if (info->has_display) { | |
697 | monitor_printf(mon, " Display: %s\n", info->display); | |
2b54aa87 | 698 | } |
0a9667ec | 699 | info2l = info2l->next; |
2b54aa87 LC |
700 | } |
701 | ||
0a9667ec DDAG |
702 | qapi_free_VncInfo2List(info2l); |
703 | ||
2b54aa87 LC |
704 | } |
705 | ||
206addd5 | 706 | #ifdef CONFIG_SPICE |
84f2d0ea | 707 | void hmp_info_spice(Monitor *mon, const QDict *qdict) |
d1f29646 LC |
708 | { |
709 | SpiceChannelList *chan; | |
710 | SpiceInfo *info; | |
22fa7da0 CR |
711 | const char *channel_name; |
712 | const char * const channel_names[] = { | |
713 | [SPICE_CHANNEL_MAIN] = "main", | |
714 | [SPICE_CHANNEL_DISPLAY] = "display", | |
715 | [SPICE_CHANNEL_INPUTS] = "inputs", | |
716 | [SPICE_CHANNEL_CURSOR] = "cursor", | |
717 | [SPICE_CHANNEL_PLAYBACK] = "playback", | |
718 | [SPICE_CHANNEL_RECORD] = "record", | |
719 | [SPICE_CHANNEL_TUNNEL] = "tunnel", | |
720 | [SPICE_CHANNEL_SMARTCARD] = "smartcard", | |
721 | [SPICE_CHANNEL_USBREDIR] = "usbredir", | |
722 | [SPICE_CHANNEL_PORT] = "port", | |
7c6044a9 GH |
723 | #if 0 |
724 | /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7, | |
725 | * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable | |
726 | * as quick fix for build failures with older versions. */ | |
22fa7da0 | 727 | [SPICE_CHANNEL_WEBDAV] = "webdav", |
7c6044a9 | 728 | #endif |
22fa7da0 | 729 | }; |
d1f29646 LC |
730 | |
731 | info = qmp_query_spice(NULL); | |
732 | ||
733 | if (!info->enabled) { | |
734 | monitor_printf(mon, "Server: disabled\n"); | |
735 | goto out; | |
736 | } | |
737 | ||
738 | monitor_printf(mon, "Server:\n"); | |
739 | if (info->has_port) { | |
740 | monitor_printf(mon, " address: %s:%" PRId64 "\n", | |
741 | info->host, info->port); | |
742 | } | |
743 | if (info->has_tls_port) { | |
744 | monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n", | |
745 | info->host, info->tls_port); | |
746 | } | |
61c4efe2 YH |
747 | monitor_printf(mon, " migrated: %s\n", |
748 | info->migrated ? "true" : "false"); | |
d1f29646 LC |
749 | monitor_printf(mon, " auth: %s\n", info->auth); |
750 | monitor_printf(mon, " compiled: %s\n", info->compiled_version); | |
4efee029 | 751 | monitor_printf(mon, " mouse-mode: %s\n", |
977c736f | 752 | SpiceQueryMouseMode_str(info->mouse_mode)); |
d1f29646 LC |
753 | |
754 | if (!info->has_channels || info->channels == NULL) { | |
755 | monitor_printf(mon, "Channels: none\n"); | |
756 | } else { | |
757 | for (chan = info->channels; chan; chan = chan->next) { | |
758 | monitor_printf(mon, "Channel:\n"); | |
759 | monitor_printf(mon, " address: %s:%s%s\n", | |
ddf21908 | 760 | chan->value->host, chan->value->port, |
d1f29646 LC |
761 | chan->value->tls ? " [tls]" : ""); |
762 | monitor_printf(mon, " session: %" PRId64 "\n", | |
763 | chan->value->connection_id); | |
764 | monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n", | |
765 | chan->value->channel_type, chan->value->channel_id); | |
22fa7da0 CR |
766 | |
767 | channel_name = "unknown"; | |
768 | if (chan->value->channel_type > 0 && | |
769 | chan->value->channel_type < ARRAY_SIZE(channel_names) && | |
770 | channel_names[chan->value->channel_type]) { | |
771 | channel_name = channel_names[chan->value->channel_type]; | |
772 | } | |
773 | ||
774 | monitor_printf(mon, " channel name: %s\n", channel_name); | |
d1f29646 LC |
775 | } |
776 | } | |
777 | ||
778 | out: | |
779 | qapi_free_SpiceInfo(info); | |
780 | } | |
206addd5 | 781 | #endif |
d1f29646 | 782 | |
84f2d0ea | 783 | void hmp_info_balloon(Monitor *mon, const QDict *qdict) |
96637bcd LC |
784 | { |
785 | BalloonInfo *info; | |
786 | Error *err = NULL; | |
787 | ||
788 | info = qmp_query_balloon(&err); | |
789 | if (err) { | |
554a39eb | 790 | hmp_handle_error(mon, &err); |
96637bcd LC |
791 | return; |
792 | } | |
793 | ||
01ceb97e | 794 | monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20); |
96637bcd LC |
795 | |
796 | qapi_free_BalloonInfo(info); | |
797 | } | |
798 | ||
79627472 LC |
799 | static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) |
800 | { | |
801 | PciMemoryRegionList *region; | |
802 | ||
803 | monitor_printf(mon, " Bus %2" PRId64 ", ", dev->bus); | |
804 | monitor_printf(mon, "device %3" PRId64 ", function %" PRId64 ":\n", | |
805 | dev->slot, dev->function); | |
806 | monitor_printf(mon, " "); | |
807 | ||
9fa02cd1 EB |
808 | if (dev->class_info->has_desc) { |
809 | monitor_printf(mon, "%s", dev->class_info->desc); | |
79627472 | 810 | } else { |
9fa02cd1 | 811 | monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class); |
79627472 LC |
812 | } |
813 | ||
814 | monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n", | |
9fa02cd1 | 815 | dev->id->vendor, dev->id->device); |
79627472 LC |
816 | |
817 | if (dev->has_irq) { | |
818 | monitor_printf(mon, " IRQ %" PRId64 ".\n", dev->irq); | |
819 | } | |
820 | ||
821 | if (dev->has_pci_bridge) { | |
822 | monitor_printf(mon, " BUS %" PRId64 ".\n", | |
9fa02cd1 | 823 | dev->pci_bridge->bus->number); |
79627472 | 824 | monitor_printf(mon, " secondary bus %" PRId64 ".\n", |
9fa02cd1 | 825 | dev->pci_bridge->bus->secondary); |
79627472 | 826 | monitor_printf(mon, " subordinate bus %" PRId64 ".\n", |
9fa02cd1 | 827 | dev->pci_bridge->bus->subordinate); |
79627472 LC |
828 | |
829 | monitor_printf(mon, " IO range [0x%04"PRIx64", 0x%04"PRIx64"]\n", | |
9fa02cd1 EB |
830 | dev->pci_bridge->bus->io_range->base, |
831 | dev->pci_bridge->bus->io_range->limit); | |
79627472 LC |
832 | |
833 | monitor_printf(mon, | |
834 | " memory range [0x%08"PRIx64", 0x%08"PRIx64"]\n", | |
9fa02cd1 EB |
835 | dev->pci_bridge->bus->memory_range->base, |
836 | dev->pci_bridge->bus->memory_range->limit); | |
79627472 LC |
837 | |
838 | monitor_printf(mon, " prefetchable memory range " | |
839 | "[0x%08"PRIx64", 0x%08"PRIx64"]\n", | |
9fa02cd1 EB |
840 | dev->pci_bridge->bus->prefetchable_range->base, |
841 | dev->pci_bridge->bus->prefetchable_range->limit); | |
79627472 LC |
842 | } |
843 | ||
844 | for (region = dev->regions; region; region = region->next) { | |
845 | uint64_t addr, size; | |
846 | ||
847 | addr = region->value->address; | |
848 | size = region->value->size; | |
849 | ||
850 | monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar); | |
851 | ||
852 | if (!strcmp(region->value->type, "io")) { | |
853 | monitor_printf(mon, "I/O at 0x%04" PRIx64 | |
854 | " [0x%04" PRIx64 "].\n", | |
855 | addr, addr + size - 1); | |
856 | } else { | |
857 | monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 | |
858 | " [0x%08" PRIx64 "].\n", | |
859 | region->value->mem_type_64 ? 64 : 32, | |
860 | region->value->prefetch ? " prefetchable" : "", | |
861 | addr, addr + size - 1); | |
862 | } | |
863 | } | |
864 | ||
865 | monitor_printf(mon, " id \"%s\"\n", dev->qdev_id); | |
866 | ||
867 | if (dev->has_pci_bridge) { | |
868 | if (dev->pci_bridge->has_devices) { | |
869 | PciDeviceInfoList *cdev; | |
870 | for (cdev = dev->pci_bridge->devices; cdev; cdev = cdev->next) { | |
871 | hmp_info_pci_device(mon, cdev->value); | |
872 | } | |
873 | } | |
874 | } | |
875 | } | |
876 | ||
61b97833 HP |
877 | static int hmp_info_irq_foreach(Object *obj, void *opaque) |
878 | { | |
879 | InterruptStatsProvider *intc; | |
880 | InterruptStatsProviderClass *k; | |
881 | Monitor *mon = opaque; | |
882 | ||
883 | if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) { | |
884 | intc = INTERRUPT_STATS_PROVIDER(obj); | |
885 | k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj); | |
886 | uint64_t *irq_counts; | |
887 | unsigned int nb_irqs, i; | |
888 | if (k->get_statistics && | |
889 | k->get_statistics(intc, &irq_counts, &nb_irqs)) { | |
890 | if (nb_irqs > 0) { | |
891 | monitor_printf(mon, "IRQ statistics for %s:\n", | |
892 | object_get_typename(obj)); | |
893 | for (i = 0; i < nb_irqs; i++) { | |
894 | if (irq_counts[i] > 0) { | |
895 | monitor_printf(mon, "%2d: %" PRId64 "\n", i, | |
896 | irq_counts[i]); | |
897 | } | |
898 | } | |
899 | } | |
900 | } else { | |
901 | monitor_printf(mon, "IRQ statistics not available for %s.\n", | |
902 | object_get_typename(obj)); | |
903 | } | |
904 | } | |
905 | ||
906 | return 0; | |
907 | } | |
908 | ||
909 | void hmp_info_irq(Monitor *mon, const QDict *qdict) | |
910 | { | |
911 | object_child_foreach_recursive(object_get_root(), | |
912 | hmp_info_irq_foreach, mon); | |
913 | } | |
914 | ||
915 | static int hmp_info_pic_foreach(Object *obj, void *opaque) | |
916 | { | |
917 | InterruptStatsProvider *intc; | |
918 | InterruptStatsProviderClass *k; | |
919 | Monitor *mon = opaque; | |
920 | ||
921 | if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) { | |
922 | intc = INTERRUPT_STATS_PROVIDER(obj); | |
923 | k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj); | |
924 | if (k->print_info) { | |
925 | k->print_info(intc, mon); | |
926 | } else { | |
927 | monitor_printf(mon, "Interrupt controller information not available for %s.\n", | |
928 | object_get_typename(obj)); | |
929 | } | |
930 | } | |
931 | ||
932 | return 0; | |
933 | } | |
934 | ||
935 | void hmp_info_pic(Monitor *mon, const QDict *qdict) | |
936 | { | |
937 | object_child_foreach_recursive(object_get_root(), | |
938 | hmp_info_pic_foreach, mon); | |
939 | } | |
940 | ||
84f2d0ea | 941 | void hmp_info_pci(Monitor *mon, const QDict *qdict) |
79627472 | 942 | { |
f46cee37 | 943 | PciInfoList *info_list, *info; |
79627472 LC |
944 | Error *err = NULL; |
945 | ||
f46cee37 | 946 | info_list = qmp_query_pci(&err); |
79627472 LC |
947 | if (err) { |
948 | monitor_printf(mon, "PCI devices not supported\n"); | |
949 | error_free(err); | |
950 | return; | |
951 | } | |
952 | ||
f46cee37 | 953 | for (info = info_list; info; info = info->next) { |
79627472 LC |
954 | PciDeviceInfoList *dev; |
955 | ||
956 | for (dev = info->value->devices; dev; dev = dev->next) { | |
957 | hmp_info_pci_device(mon, dev->value); | |
958 | } | |
959 | } | |
960 | ||
f46cee37 | 961 | qapi_free_PciInfoList(info_list); |
79627472 LC |
962 | } |
963 | ||
84f2d0ea | 964 | void hmp_info_block_jobs(Monitor *mon, const QDict *qdict) |
fb5458cd SH |
965 | { |
966 | BlockJobInfoList *list; | |
967 | Error *err = NULL; | |
968 | ||
969 | list = qmp_query_block_jobs(&err); | |
970 | assert(!err); | |
971 | ||
972 | if (!list) { | |
973 | monitor_printf(mon, "No active jobs\n"); | |
974 | return; | |
975 | } | |
976 | ||
977 | while (list) { | |
978 | if (strcmp(list->value->type, "stream") == 0) { | |
979 | monitor_printf(mon, "Streaming device %s: Completed %" PRId64 | |
980 | " of %" PRId64 " bytes, speed limit %" PRId64 | |
981 | " bytes/s\n", | |
982 | list->value->device, | |
983 | list->value->offset, | |
984 | list->value->len, | |
985 | list->value->speed); | |
986 | } else { | |
987 | monitor_printf(mon, "Type %s, device %s: Completed %" PRId64 | |
988 | " of %" PRId64 " bytes, speed limit %" PRId64 | |
989 | " bytes/s\n", | |
990 | list->value->type, | |
991 | list->value->device, | |
992 | list->value->offset, | |
993 | list->value->len, | |
994 | list->value->speed); | |
995 | } | |
996 | list = list->next; | |
997 | } | |
93bb1315 GA |
998 | |
999 | qapi_free_BlockJobInfoList(list); | |
fb5458cd SH |
1000 | } |
1001 | ||
d1a0cf73 SB |
1002 | void hmp_info_tpm(Monitor *mon, const QDict *qdict) |
1003 | { | |
1004 | TPMInfoList *info_list, *info; | |
1005 | Error *err = NULL; | |
1006 | unsigned int c = 0; | |
1007 | TPMPassthroughOptions *tpo; | |
f4ede81e | 1008 | TPMEmulatorOptions *teo; |
d1a0cf73 SB |
1009 | |
1010 | info_list = qmp_query_tpm(&err); | |
1011 | if (err) { | |
1012 | monitor_printf(mon, "TPM device not supported\n"); | |
1013 | error_free(err); | |
1014 | return; | |
1015 | } | |
1016 | ||
1017 | if (info_list) { | |
1018 | monitor_printf(mon, "TPM device:\n"); | |
1019 | } | |
1020 | ||
1021 | for (info = info_list; info; info = info->next) { | |
1022 | TPMInfo *ti = info->value; | |
1023 | monitor_printf(mon, " tpm%d: model=%s\n", | |
977c736f | 1024 | c, TpmModel_str(ti->model)); |
d1a0cf73 SB |
1025 | |
1026 | monitor_printf(mon, " \\ %s: type=%s", | |
977c736f | 1027 | ti->id, TpmTypeOptionsKind_str(ti->options->type)); |
d1a0cf73 | 1028 | |
ce21131a | 1029 | switch (ti->options->type) { |
88ca7bcf | 1030 | case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: |
32bafa8f | 1031 | tpo = ti->options->u.passthrough.data; |
d1a0cf73 SB |
1032 | monitor_printf(mon, "%s%s%s%s", |
1033 | tpo->has_path ? ",path=" : "", | |
1034 | tpo->has_path ? tpo->path : "", | |
1035 | tpo->has_cancel_path ? ",cancel-path=" : "", | |
1036 | tpo->has_cancel_path ? tpo->cancel_path : ""); | |
1037 | break; | |
f4ede81e AV |
1038 | case TPM_TYPE_OPTIONS_KIND_EMULATOR: |
1039 | teo = ti->options->u.emulator.data; | |
1040 | monitor_printf(mon, ",chardev=%s", teo->chardev); | |
1041 | break; | |
7fb1cf16 | 1042 | case TPM_TYPE_OPTIONS_KIND__MAX: |
d1a0cf73 SB |
1043 | break; |
1044 | } | |
1045 | monitor_printf(mon, "\n"); | |
1046 | c++; | |
1047 | } | |
1048 | qapi_free_TPMInfoList(info_list); | |
1049 | } | |
1050 | ||
7a7f325e LC |
1051 | void hmp_quit(Monitor *mon, const QDict *qdict) |
1052 | { | |
1053 | monitor_suspend(mon); | |
1054 | qmp_quit(NULL); | |
1055 | } | |
5f158f21 LC |
1056 | |
1057 | void hmp_stop(Monitor *mon, const QDict *qdict) | |
1058 | { | |
1059 | qmp_stop(NULL); | |
1060 | } | |
38d22653 LC |
1061 | |
1062 | void hmp_system_reset(Monitor *mon, const QDict *qdict) | |
1063 | { | |
1064 | qmp_system_reset(NULL); | |
1065 | } | |
5bc465e4 LC |
1066 | |
1067 | void hmp_system_powerdown(Monitor *mon, const QDict *qdict) | |
1068 | { | |
1069 | qmp_system_powerdown(NULL); | |
1070 | } | |
755f1968 LC |
1071 | |
1072 | void hmp_cpu(Monitor *mon, const QDict *qdict) | |
1073 | { | |
1074 | int64_t cpu_index; | |
1075 | ||
1076 | /* XXX: drop the monitor_set_cpu() usage when all HMP commands that | |
1077 | use it are converted to the QAPI */ | |
1078 | cpu_index = qdict_get_int(qdict, "index"); | |
1079 | if (monitor_set_cpu(cpu_index) < 0) { | |
1080 | monitor_printf(mon, "invalid CPU index\n"); | |
1081 | } | |
1082 | } | |
0cfd6a9a LC |
1083 | |
1084 | void hmp_memsave(Monitor *mon, const QDict *qdict) | |
1085 | { | |
1086 | uint32_t size = qdict_get_int(qdict, "size"); | |
1087 | const char *filename = qdict_get_str(qdict, "filename"); | |
1088 | uint64_t addr = qdict_get_int(qdict, "val"); | |
e940f543 | 1089 | Error *err = NULL; |
854e67fe | 1090 | int cpu_index = monitor_get_cpu_index(); |
0cfd6a9a | 1091 | |
854e67fe TH |
1092 | if (cpu_index < 0) { |
1093 | monitor_printf(mon, "No CPU available\n"); | |
1094 | return; | |
1095 | } | |
1096 | ||
1097 | qmp_memsave(addr, size, filename, true, cpu_index, &err); | |
e940f543 | 1098 | hmp_handle_error(mon, &err); |
0cfd6a9a | 1099 | } |
6d3962bf LC |
1100 | |
1101 | void hmp_pmemsave(Monitor *mon, const QDict *qdict) | |
1102 | { | |
1103 | uint32_t size = qdict_get_int(qdict, "size"); | |
1104 | const char *filename = qdict_get_str(qdict, "filename"); | |
1105 | uint64_t addr = qdict_get_int(qdict, "val"); | |
e940f543 | 1106 | Error *err = NULL; |
6d3962bf | 1107 | |
e940f543 MA |
1108 | qmp_pmemsave(addr, size, filename, &err); |
1109 | hmp_handle_error(mon, &err); | |
1f590cf9 LL |
1110 | } |
1111 | ||
3949e594 | 1112 | void hmp_ringbuf_write(Monitor *mon, const QDict *qdict) |
1f590cf9 | 1113 | { |
1f590cf9 LL |
1114 | const char *chardev = qdict_get_str(qdict, "device"); |
1115 | const char *data = qdict_get_str(qdict, "data"); | |
e940f543 | 1116 | Error *err = NULL; |
1f590cf9 | 1117 | |
e940f543 | 1118 | qmp_ringbuf_write(chardev, data, false, 0, &err); |
1f590cf9 | 1119 | |
e940f543 | 1120 | hmp_handle_error(mon, &err); |
6d3962bf | 1121 | } |
e42e818b | 1122 | |
3949e594 | 1123 | void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) |
49b6d722 LL |
1124 | { |
1125 | uint32_t size = qdict_get_int(qdict, "size"); | |
1126 | const char *chardev = qdict_get_str(qdict, "device"); | |
3ab651fc | 1127 | char *data; |
e940f543 | 1128 | Error *err = NULL; |
543f3412 | 1129 | int i; |
49b6d722 | 1130 | |
e940f543 MA |
1131 | data = qmp_ringbuf_read(chardev, size, false, 0, &err); |
1132 | if (err) { | |
554a39eb | 1133 | hmp_handle_error(mon, &err); |
49b6d722 LL |
1134 | return; |
1135 | } | |
1136 | ||
543f3412 MA |
1137 | for (i = 0; data[i]; i++) { |
1138 | unsigned char ch = data[i]; | |
1139 | ||
1140 | if (ch == '\\') { | |
1141 | monitor_printf(mon, "\\\\"); | |
1142 | } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) { | |
1143 | monitor_printf(mon, "\\u%04X", ch); | |
1144 | } else { | |
1145 | monitor_printf(mon, "%c", ch); | |
1146 | } | |
1147 | ||
1148 | } | |
1149 | monitor_printf(mon, "\n"); | |
3ab651fc | 1150 | g_free(data); |
49b6d722 LL |
1151 | } |
1152 | ||
e42e818b LC |
1153 | void hmp_cont(Monitor *mon, const QDict *qdict) |
1154 | { | |
e940f543 | 1155 | Error *err = NULL; |
e42e818b | 1156 | |
e940f543 MA |
1157 | qmp_cont(&err); |
1158 | hmp_handle_error(mon, &err); | |
e42e818b | 1159 | } |
ab49ab5c | 1160 | |
9b9df25a GH |
1161 | void hmp_system_wakeup(Monitor *mon, const QDict *qdict) |
1162 | { | |
1163 | qmp_system_wakeup(NULL); | |
1164 | } | |
1165 | ||
3e5a50d6 | 1166 | void hmp_nmi(Monitor *mon, const QDict *qdict) |
ab49ab5c | 1167 | { |
e940f543 | 1168 | Error *err = NULL; |
ab49ab5c | 1169 | |
e940f543 MA |
1170 | qmp_inject_nmi(&err); |
1171 | hmp_handle_error(mon, &err); | |
ab49ab5c | 1172 | } |
4b37156c LC |
1173 | |
1174 | void hmp_set_link(Monitor *mon, const QDict *qdict) | |
1175 | { | |
1176 | const char *name = qdict_get_str(qdict, "name"); | |
34acbc95 | 1177 | bool up = qdict_get_bool(qdict, "up"); |
e940f543 | 1178 | Error *err = NULL; |
4b37156c | 1179 | |
e940f543 MA |
1180 | qmp_set_link(name, up, &err); |
1181 | hmp_handle_error(mon, &err); | |
4b37156c | 1182 | } |
a4dea8a9 LC |
1183 | |
1184 | void hmp_block_passwd(Monitor *mon, const QDict *qdict) | |
1185 | { | |
1186 | const char *device = qdict_get_str(qdict, "device"); | |
1187 | const char *password = qdict_get_str(qdict, "password"); | |
e940f543 | 1188 | Error *err = NULL; |
a4dea8a9 | 1189 | |
e940f543 MA |
1190 | qmp_block_passwd(true, device, false, NULL, password, &err); |
1191 | hmp_handle_error(mon, &err); | |
a4dea8a9 | 1192 | } |
d72f3264 LC |
1193 | |
1194 | void hmp_balloon(Monitor *mon, const QDict *qdict) | |
1195 | { | |
1196 | int64_t value = qdict_get_int(qdict, "value"); | |
e940f543 | 1197 | Error *err = NULL; |
d72f3264 | 1198 | |
e940f543 | 1199 | qmp_balloon(value, &err); |
554a39eb | 1200 | hmp_handle_error(mon, &err); |
d72f3264 | 1201 | } |
5e7caacb LC |
1202 | |
1203 | void hmp_block_resize(Monitor *mon, const QDict *qdict) | |
1204 | { | |
1205 | const char *device = qdict_get_str(qdict, "device"); | |
1206 | int64_t size = qdict_get_int(qdict, "size"); | |
e940f543 | 1207 | Error *err = NULL; |
5e7caacb | 1208 | |
e940f543 MA |
1209 | qmp_block_resize(true, device, false, NULL, size, &err); |
1210 | hmp_handle_error(mon, &err); | |
5e7caacb | 1211 | } |
6106e249 | 1212 | |
d9b902db PB |
1213 | void hmp_drive_mirror(Monitor *mon, const QDict *qdict) |
1214 | { | |
d9b902db PB |
1215 | const char *filename = qdict_get_str(qdict, "target"); |
1216 | const char *format = qdict_get_try_str(qdict, "format"); | |
34acbc95 EB |
1217 | bool reuse = qdict_get_try_bool(qdict, "reuse", false); |
1218 | bool full = qdict_get_try_bool(qdict, "full", false); | |
e940f543 | 1219 | Error *err = NULL; |
faecd40a EB |
1220 | DriveMirror mirror = { |
1221 | .device = (char *)qdict_get_str(qdict, "device"), | |
1222 | .target = (char *)filename, | |
1223 | .has_format = !!format, | |
1224 | .format = (char *)format, | |
1225 | .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, | |
1226 | .has_mode = true, | |
1227 | .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS, | |
1228 | .unmap = true, | |
1229 | }; | |
d9b902db PB |
1230 | |
1231 | if (!filename) { | |
c6bd8c70 | 1232 | error_setg(&err, QERR_MISSING_PARAMETER, "target"); |
e940f543 | 1233 | hmp_handle_error(mon, &err); |
d9b902db PB |
1234 | return; |
1235 | } | |
faecd40a | 1236 | qmp_drive_mirror(&mirror, &err); |
e940f543 | 1237 | hmp_handle_error(mon, &err); |
d9b902db PB |
1238 | } |
1239 | ||
de90930a SH |
1240 | void hmp_drive_backup(Monitor *mon, const QDict *qdict) |
1241 | { | |
1242 | const char *device = qdict_get_str(qdict, "device"); | |
1243 | const char *filename = qdict_get_str(qdict, "target"); | |
1244 | const char *format = qdict_get_try_str(qdict, "format"); | |
34acbc95 EB |
1245 | bool reuse = qdict_get_try_bool(qdict, "reuse", false); |
1246 | bool full = qdict_get_try_bool(qdict, "full", false); | |
13b9414b | 1247 | bool compress = qdict_get_try_bool(qdict, "compress", false); |
e940f543 | 1248 | Error *err = NULL; |
81206a89 PB |
1249 | DriveBackup backup = { |
1250 | .device = (char *)device, | |
1251 | .target = (char *)filename, | |
1252 | .has_format = !!format, | |
1253 | .format = (char *)format, | |
1254 | .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, | |
1255 | .has_mode = true, | |
1256 | .mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS, | |
13b9414b PB |
1257 | .has_compress = !!compress, |
1258 | .compress = compress, | |
81206a89 | 1259 | }; |
de90930a SH |
1260 | |
1261 | if (!filename) { | |
c6bd8c70 | 1262 | error_setg(&err, QERR_MISSING_PARAMETER, "target"); |
e940f543 | 1263 | hmp_handle_error(mon, &err); |
de90930a SH |
1264 | return; |
1265 | } | |
1266 | ||
81206a89 | 1267 | qmp_drive_backup(&backup, &err); |
e940f543 | 1268 | hmp_handle_error(mon, &err); |
de90930a SH |
1269 | } |
1270 | ||
6106e249 LC |
1271 | void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) |
1272 | { | |
1273 | const char *device = qdict_get_str(qdict, "device"); | |
1274 | const char *filename = qdict_get_try_str(qdict, "snapshot-file"); | |
1275 | const char *format = qdict_get_try_str(qdict, "format"); | |
34acbc95 | 1276 | bool reuse = qdict_get_try_bool(qdict, "reuse", false); |
6cc2a415 | 1277 | enum NewImageMode mode; |
e940f543 | 1278 | Error *err = NULL; |
6106e249 LC |
1279 | |
1280 | if (!filename) { | |
1281 | /* In the future, if 'snapshot-file' is not specified, the snapshot | |
1282 | will be taken internally. Today it's actually required. */ | |
c6bd8c70 | 1283 | error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file"); |
e940f543 | 1284 | hmp_handle_error(mon, &err); |
6106e249 LC |
1285 | return; |
1286 | } | |
1287 | ||
6cc2a415 | 1288 | mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS; |
0901f67e BC |
1289 | qmp_blockdev_snapshot_sync(true, device, false, NULL, |
1290 | filename, false, NULL, | |
1291 | !!format, format, | |
e940f543 MA |
1292 | true, mode, &err); |
1293 | hmp_handle_error(mon, &err); | |
6106e249 | 1294 | } |
6cdedb07 | 1295 | |
775ca88e WX |
1296 | void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict) |
1297 | { | |
1298 | const char *device = qdict_get_str(qdict, "device"); | |
1299 | const char *name = qdict_get_str(qdict, "name"); | |
e940f543 | 1300 | Error *err = NULL; |
775ca88e | 1301 | |
e940f543 MA |
1302 | qmp_blockdev_snapshot_internal_sync(device, name, &err); |
1303 | hmp_handle_error(mon, &err); | |
775ca88e WX |
1304 | } |
1305 | ||
7a4ed2ee WX |
1306 | void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict) |
1307 | { | |
1308 | const char *device = qdict_get_str(qdict, "device"); | |
1309 | const char *name = qdict_get_str(qdict, "name"); | |
1310 | const char *id = qdict_get_try_str(qdict, "id"); | |
e940f543 | 1311 | Error *err = NULL; |
7a4ed2ee WX |
1312 | |
1313 | qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id, | |
e940f543 MA |
1314 | true, name, &err); |
1315 | hmp_handle_error(mon, &err); | |
7a4ed2ee WX |
1316 | } |
1317 | ||
52b26205 JQ |
1318 | void hmp_loadvm(Monitor *mon, const QDict *qdict) |
1319 | { | |
1320 | int saved_vm_running = runstate_is_running(); | |
1321 | const char *name = qdict_get_str(qdict, "name"); | |
927d6638 | 1322 | Error *err = NULL; |
52b26205 JQ |
1323 | |
1324 | vm_stop(RUN_STATE_RESTORE_VM); | |
1325 | ||
5e22479a | 1326 | if (load_snapshot(name, &err) == 0 && saved_vm_running) { |
52b26205 JQ |
1327 | vm_start(); |
1328 | } | |
927d6638 | 1329 | hmp_handle_error(mon, &err); |
52b26205 JQ |
1330 | } |
1331 | ||
d9c7d137 JQ |
1332 | void hmp_savevm(Monitor *mon, const QDict *qdict) |
1333 | { | |
927d6638 JQ |
1334 | Error *err = NULL; |
1335 | ||
5e22479a | 1336 | save_snapshot(qdict_get_try_str(qdict, "name"), &err); |
927d6638 | 1337 | hmp_handle_error(mon, &err); |
d9c7d137 JQ |
1338 | } |
1339 | ||
d905bb7b JQ |
1340 | void hmp_delvm(Monitor *mon, const QDict *qdict) |
1341 | { | |
1342 | BlockDriverState *bs; | |
1343 | Error *err; | |
1344 | const char *name = qdict_get_str(qdict, "name"); | |
1345 | ||
1346 | if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) { | |
1347 | error_reportf_err(err, | |
1348 | "Error while deleting snapshot on device '%s': ", | |
1349 | bdrv_get_device_name(bs)); | |
1350 | } | |
1351 | } | |
1352 | ||
66830618 JQ |
1353 | void hmp_info_snapshots(Monitor *mon, const QDict *qdict) |
1354 | { | |
1355 | BlockDriverState *bs, *bs1; | |
1356 | BdrvNextIterator it1; | |
1357 | QEMUSnapshotInfo *sn_tab, *sn; | |
1358 | bool no_snapshot = true; | |
1359 | int nb_sns, i; | |
1360 | int total; | |
1361 | int *global_snapshots; | |
1362 | AioContext *aio_context; | |
1363 | ||
1364 | typedef struct SnapshotEntry { | |
1365 | QEMUSnapshotInfo sn; | |
1366 | QTAILQ_ENTRY(SnapshotEntry) next; | |
1367 | } SnapshotEntry; | |
1368 | ||
1369 | typedef struct ImageEntry { | |
1370 | const char *imagename; | |
1371 | QTAILQ_ENTRY(ImageEntry) next; | |
1372 | QTAILQ_HEAD(, SnapshotEntry) snapshots; | |
1373 | } ImageEntry; | |
1374 | ||
1375 | QTAILQ_HEAD(, ImageEntry) image_list = | |
1376 | QTAILQ_HEAD_INITIALIZER(image_list); | |
1377 | ||
1378 | ImageEntry *image_entry, *next_ie; | |
1379 | SnapshotEntry *snapshot_entry; | |
1380 | ||
1381 | bs = bdrv_all_find_vmstate_bs(); | |
1382 | if (!bs) { | |
1383 | monitor_printf(mon, "No available block device supports snapshots\n"); | |
1384 | return; | |
1385 | } | |
1386 | aio_context = bdrv_get_aio_context(bs); | |
1387 | ||
1388 | aio_context_acquire(aio_context); | |
1389 | nb_sns = bdrv_snapshot_list(bs, &sn_tab); | |
1390 | aio_context_release(aio_context); | |
1391 | ||
1392 | if (nb_sns < 0) { | |
1393 | monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns); | |
1394 | return; | |
1395 | } | |
1396 | ||
1397 | for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) { | |
1398 | int bs1_nb_sns = 0; | |
1399 | ImageEntry *ie; | |
1400 | SnapshotEntry *se; | |
1401 | AioContext *ctx = bdrv_get_aio_context(bs1); | |
1402 | ||
1403 | aio_context_acquire(ctx); | |
1404 | if (bdrv_can_snapshot(bs1)) { | |
1405 | sn = NULL; | |
1406 | bs1_nb_sns = bdrv_snapshot_list(bs1, &sn); | |
1407 | if (bs1_nb_sns > 0) { | |
1408 | no_snapshot = false; | |
1409 | ie = g_new0(ImageEntry, 1); | |
1410 | ie->imagename = bdrv_get_device_name(bs1); | |
1411 | QTAILQ_INIT(&ie->snapshots); | |
1412 | QTAILQ_INSERT_TAIL(&image_list, ie, next); | |
1413 | for (i = 0; i < bs1_nb_sns; i++) { | |
1414 | se = g_new0(SnapshotEntry, 1); | |
1415 | se->sn = sn[i]; | |
1416 | QTAILQ_INSERT_TAIL(&ie->snapshots, se, next); | |
1417 | } | |
1418 | } | |
1419 | g_free(sn); | |
1420 | } | |
1421 | aio_context_release(ctx); | |
1422 | } | |
1423 | ||
1424 | if (no_snapshot) { | |
1425 | monitor_printf(mon, "There is no snapshot available.\n"); | |
1426 | return; | |
1427 | } | |
1428 | ||
1429 | global_snapshots = g_new0(int, nb_sns); | |
1430 | total = 0; | |
1431 | for (i = 0; i < nb_sns; i++) { | |
1432 | SnapshotEntry *next_sn; | |
1433 | if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) { | |
1434 | global_snapshots[total] = i; | |
1435 | total++; | |
1436 | QTAILQ_FOREACH(image_entry, &image_list, next) { | |
1437 | QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, | |
1438 | next, next_sn) { | |
1439 | if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) { | |
1440 | QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry, | |
1441 | next); | |
1442 | g_free(snapshot_entry); | |
1443 | } | |
1444 | } | |
1445 | } | |
1446 | } | |
1447 | } | |
1448 | ||
1449 | monitor_printf(mon, "List of snapshots present on all disks:\n"); | |
1450 | ||
1451 | if (total > 0) { | |
1452 | bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); | |
1453 | monitor_printf(mon, "\n"); | |
1454 | for (i = 0; i < total; i++) { | |
1455 | sn = &sn_tab[global_snapshots[i]]; | |
1456 | /* The ID is not guaranteed to be the same on all images, so | |
1457 | * overwrite it. | |
1458 | */ | |
1459 | pstrcpy(sn->id_str, sizeof(sn->id_str), "--"); | |
1460 | bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, sn); | |
1461 | monitor_printf(mon, "\n"); | |
1462 | } | |
1463 | } else { | |
1464 | monitor_printf(mon, "None\n"); | |
1465 | } | |
1466 | ||
1467 | QTAILQ_FOREACH(image_entry, &image_list, next) { | |
1468 | if (QTAILQ_EMPTY(&image_entry->snapshots)) { | |
1469 | continue; | |
1470 | } | |
1471 | monitor_printf(mon, | |
1472 | "\nList of partial (non-loadable) snapshots on '%s':\n", | |
1473 | image_entry->imagename); | |
1474 | bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); | |
1475 | monitor_printf(mon, "\n"); | |
1476 | QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) { | |
1477 | bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, | |
1478 | &snapshot_entry->sn); | |
1479 | monitor_printf(mon, "\n"); | |
1480 | } | |
1481 | } | |
1482 | ||
1483 | QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) { | |
1484 | SnapshotEntry *next_sn; | |
1485 | QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next, | |
1486 | next_sn) { | |
1487 | g_free(snapshot_entry); | |
1488 | } | |
1489 | g_free(image_entry); | |
1490 | } | |
1491 | g_free(sn_tab); | |
1492 | g_free(global_snapshots); | |
1493 | ||
1494 | } | |
1495 | ||
6cdedb07 LC |
1496 | void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) |
1497 | { | |
1498 | qmp_migrate_cancel(NULL); | |
1499 | } | |
4f0a993b | 1500 | |
94ae12cb DDAG |
1501 | void hmp_migrate_continue(Monitor *mon, const QDict *qdict) |
1502 | { | |
1503 | Error *err = NULL; | |
1504 | const char *state = qdict_get_str(qdict, "state"); | |
1505 | int val = qapi_enum_parse(&MigrationStatus_lookup, state, -1, &err); | |
1506 | ||
1507 | if (val >= 0) { | |
1508 | qmp_migrate_continue(val, &err); | |
1509 | } | |
1510 | ||
1511 | hmp_handle_error(mon, &err); | |
1512 | } | |
1513 | ||
bf1ae1f4 DDAG |
1514 | void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) |
1515 | { | |
1516 | Error *err = NULL; | |
1517 | const char *uri = qdict_get_str(qdict, "uri"); | |
1518 | ||
1519 | qmp_migrate_incoming(uri, &err); | |
1520 | ||
1fa57f55 | 1521 | hmp_handle_error(mon, &err); |
bf1ae1f4 DDAG |
1522 | } |
1523 | ||
2ff30257 | 1524 | /* Kept for backwards compatibility */ |
4f0a993b LC |
1525 | void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) |
1526 | { | |
1527 | double value = qdict_get_double(qdict, "value"); | |
1528 | qmp_migrate_set_downtime(value, NULL); | |
1529 | } | |
3dc85383 | 1530 | |
9e1ba4cc OW |
1531 | void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) |
1532 | { | |
1533 | int64_t value = qdict_get_int(qdict, "value"); | |
1534 | Error *err = NULL; | |
1535 | ||
1536 | qmp_migrate_set_cache_size(value, &err); | |
554a39eb | 1537 | hmp_handle_error(mon, &err); |
9e1ba4cc OW |
1538 | } |
1539 | ||
2ff30257 | 1540 | /* Kept for backwards compatibility */ |
3dc85383 LC |
1541 | void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict) |
1542 | { | |
1543 | int64_t value = qdict_get_int(qdict, "value"); | |
1544 | qmp_migrate_set_speed(value, NULL); | |
1545 | } | |
fbf796fd | 1546 | |
00458433 OW |
1547 | void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) |
1548 | { | |
1549 | const char *cap = qdict_get_str(qdict, "capability"); | |
1550 | bool state = qdict_get_bool(qdict, "state"); | |
1551 | Error *err = NULL; | |
1552 | MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps)); | |
8e615e34 | 1553 | int val; |
00458433 | 1554 | |
f7abe0ec | 1555 | val = qapi_enum_parse(&MigrationCapability_lookup, cap, -1, &err); |
8e615e34 MAL |
1556 | if (val < 0) { |
1557 | goto end; | |
00458433 OW |
1558 | } |
1559 | ||
8e615e34 MAL |
1560 | caps->value = g_malloc0(sizeof(*caps->value)); |
1561 | caps->value->capability = val; | |
1562 | caps->value->state = state; | |
1563 | caps->next = NULL; | |
1564 | qmp_migrate_set_capabilities(caps, &err); | |
00458433 | 1565 | |
8e615e34 | 1566 | end: |
00458433 | 1567 | qapi_free_MigrationCapabilityStatusList(caps); |
554a39eb | 1568 | hmp_handle_error(mon, &err); |
00458433 OW |
1569 | } |
1570 | ||
50e9a629 LL |
1571 | void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) |
1572 | { | |
1573 | const char *param = qdict_get_str(qdict, "parameter"); | |
69ef1f36 | 1574 | const char *valuestr = qdict_get_str(qdict, "value"); |
f4a06d13 | 1575 | Visitor *v = string_input_visitor_new(valuestr); |
1bda8b3c | 1576 | MigrateSetParameters *p = g_new0(MigrateSetParameters, 1); |
f46bfdbf | 1577 | uint64_t valuebw = 0; |
73af8dd8 | 1578 | uint64_t cache_size; |
50e9a629 | 1579 | Error *err = NULL; |
262517b7 | 1580 | int val, ret; |
69ef1f36 | 1581 | |
f7abe0ec | 1582 | val = qapi_enum_parse(&MigrationParameter_lookup, param, -1, &err); |
262517b7 MAL |
1583 | if (val < 0) { |
1584 | goto cleanup; | |
1585 | } | |
1586 | ||
1587 | switch (val) { | |
1588 | case MIGRATION_PARAMETER_COMPRESS_LEVEL: | |
1589 | p->has_compress_level = true; | |
1590 | visit_type_int(v, param, &p->compress_level, &err); | |
1591 | break; | |
1592 | case MIGRATION_PARAMETER_COMPRESS_THREADS: | |
1593 | p->has_compress_threads = true; | |
1594 | visit_type_int(v, param, &p->compress_threads, &err); | |
1595 | break; | |
1596 | case MIGRATION_PARAMETER_DECOMPRESS_THREADS: | |
1597 | p->has_decompress_threads = true; | |
1598 | visit_type_int(v, param, &p->decompress_threads, &err); | |
1599 | break; | |
1600 | case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL: | |
1601 | p->has_cpu_throttle_initial = true; | |
1602 | visit_type_int(v, param, &p->cpu_throttle_initial, &err); | |
1603 | break; | |
1604 | case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT: | |
1605 | p->has_cpu_throttle_increment = true; | |
1606 | visit_type_int(v, param, &p->cpu_throttle_increment, &err); | |
1607 | break; | |
1608 | case MIGRATION_PARAMETER_TLS_CREDS: | |
1609 | p->has_tls_creds = true; | |
1610 | p->tls_creds = g_new0(StrOrNull, 1); | |
1611 | p->tls_creds->type = QTYPE_QSTRING; | |
1612 | visit_type_str(v, param, &p->tls_creds->u.s, &err); | |
1613 | break; | |
1614 | case MIGRATION_PARAMETER_TLS_HOSTNAME: | |
1615 | p->has_tls_hostname = true; | |
1616 | p->tls_hostname = g_new0(StrOrNull, 1); | |
1617 | p->tls_hostname->type = QTYPE_QSTRING; | |
1618 | visit_type_str(v, param, &p->tls_hostname->u.s, &err); | |
1619 | break; | |
1620 | case MIGRATION_PARAMETER_MAX_BANDWIDTH: | |
1621 | p->has_max_bandwidth = true; | |
1622 | /* | |
1623 | * Can't use visit_type_size() here, because it | |
1624 | * defaults to Bytes rather than Mebibytes. | |
1625 | */ | |
1626 | ret = qemu_strtosz_MiB(valuestr, NULL, &valuebw); | |
1627 | if (ret < 0 || valuebw > INT64_MAX | |
1628 | || (size_t)valuebw != valuebw) { | |
1629 | error_setg(&err, "Invalid size %s", valuestr); | |
50e9a629 LL |
1630 | break; |
1631 | } | |
262517b7 MAL |
1632 | p->max_bandwidth = valuebw; |
1633 | break; | |
1634 | case MIGRATION_PARAMETER_DOWNTIME_LIMIT: | |
1635 | p->has_downtime_limit = true; | |
1636 | visit_type_int(v, param, &p->downtime_limit, &err); | |
1637 | break; | |
1638 | case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY: | |
1639 | p->has_x_checkpoint_delay = true; | |
1640 | visit_type_int(v, param, &p->x_checkpoint_delay, &err); | |
1641 | break; | |
1642 | case MIGRATION_PARAMETER_BLOCK_INCREMENTAL: | |
1643 | p->has_block_incremental = true; | |
1644 | visit_type_bool(v, param, &p->block_incremental, &err); | |
1645 | break; | |
4075fb1c JQ |
1646 | case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS: |
1647 | p->has_x_multifd_channels = true; | |
1648 | visit_type_int(v, param, &p->x_multifd_channels, &err); | |
1649 | break; | |
0fb86605 JQ |
1650 | case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT: |
1651 | p->has_x_multifd_page_count = true; | |
1652 | visit_type_int(v, param, &p->x_multifd_page_count, &err); | |
1653 | break; | |
73af8dd8 JQ |
1654 | case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: |
1655 | p->has_xbzrle_cache_size = true; | |
1656 | visit_type_size(v, param, &cache_size, &err); | |
1657 | if (err || cache_size > INT64_MAX | |
1658 | || (size_t)cache_size != cache_size) { | |
1659 | error_setg(&err, "Invalid size %s", valuestr); | |
1660 | break; | |
1661 | } | |
1662 | p->xbzrle_cache_size = cache_size; | |
1663 | break; | |
262517b7 MAL |
1664 | default: |
1665 | assert(0); | |
50e9a629 LL |
1666 | } |
1667 | ||
262517b7 MAL |
1668 | if (err) { |
1669 | goto cleanup; | |
50e9a629 LL |
1670 | } |
1671 | ||
262517b7 MAL |
1672 | qmp_migrate_set_parameters(p, &err); |
1673 | ||
69ef1f36 | 1674 | cleanup: |
1bda8b3c | 1675 | qapi_free_MigrateSetParameters(p); |
f4a06d13 | 1676 | visit_free(v); |
554a39eb | 1677 | hmp_handle_error(mon, &err); |
50e9a629 LL |
1678 | } |
1679 | ||
b8a185bc MA |
1680 | void hmp_client_migrate_info(Monitor *mon, const QDict *qdict) |
1681 | { | |
1682 | Error *err = NULL; | |
1683 | const char *protocol = qdict_get_str(qdict, "protocol"); | |
1684 | const char *hostname = qdict_get_str(qdict, "hostname"); | |
1685 | bool has_port = qdict_haskey(qdict, "port"); | |
1686 | int port = qdict_get_try_int(qdict, "port", -1); | |
1687 | bool has_tls_port = qdict_haskey(qdict, "tls-port"); | |
1688 | int tls_port = qdict_get_try_int(qdict, "tls-port", -1); | |
1689 | const char *cert_subject = qdict_get_try_str(qdict, "cert-subject"); | |
1690 | ||
1691 | qmp_client_migrate_info(protocol, hostname, | |
1692 | has_port, port, has_tls_port, tls_port, | |
1693 | !!cert_subject, cert_subject, &err); | |
1694 | hmp_handle_error(mon, &err); | |
1695 | } | |
1696 | ||
4886a1bc DDAG |
1697 | void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict) |
1698 | { | |
1699 | Error *err = NULL; | |
1700 | qmp_migrate_start_postcopy(&err); | |
1701 | hmp_handle_error(mon, &err); | |
1702 | } | |
1703 | ||
d89e666e HZ |
1704 | void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) |
1705 | { | |
1706 | Error *err = NULL; | |
1707 | ||
1708 | qmp_x_colo_lost_heartbeat(&err); | |
1709 | hmp_handle_error(mon, &err); | |
1710 | } | |
1711 | ||
fbf796fd LC |
1712 | void hmp_set_password(Monitor *mon, const QDict *qdict) |
1713 | { | |
1714 | const char *protocol = qdict_get_str(qdict, "protocol"); | |
1715 | const char *password = qdict_get_str(qdict, "password"); | |
1716 | const char *connected = qdict_get_try_str(qdict, "connected"); | |
1717 | Error *err = NULL; | |
1718 | ||
1719 | qmp_set_password(protocol, password, !!connected, connected, &err); | |
1720 | hmp_handle_error(mon, &err); | |
1721 | } | |
9ad5372d LC |
1722 | |
1723 | void hmp_expire_password(Monitor *mon, const QDict *qdict) | |
1724 | { | |
1725 | const char *protocol = qdict_get_str(qdict, "protocol"); | |
1726 | const char *whenstr = qdict_get_str(qdict, "time"); | |
1727 | Error *err = NULL; | |
1728 | ||
1729 | qmp_expire_password(protocol, whenstr, &err); | |
1730 | hmp_handle_error(mon, &err); | |
1731 | } | |
c245b6a3 LC |
1732 | |
1733 | void hmp_eject(Monitor *mon, const QDict *qdict) | |
1734 | { | |
34acbc95 | 1735 | bool force = qdict_get_try_bool(qdict, "force", false); |
c245b6a3 LC |
1736 | const char *device = qdict_get_str(qdict, "device"); |
1737 | Error *err = NULL; | |
1738 | ||
fbe2d816 | 1739 | qmp_eject(true, device, false, NULL, true, force, &err); |
c245b6a3 LC |
1740 | hmp_handle_error(mon, &err); |
1741 | } | |
333a96ec | 1742 | |
c60bf339 SH |
1743 | static void hmp_change_read_arg(void *opaque, const char *password, |
1744 | void *readline_opaque) | |
333a96ec LC |
1745 | { |
1746 | qmp_change_vnc_password(password, NULL); | |
c60bf339 | 1747 | monitor_read_command(opaque, 1); |
333a96ec LC |
1748 | } |
1749 | ||
333a96ec LC |
1750 | void hmp_change(Monitor *mon, const QDict *qdict) |
1751 | { | |
1752 | const char *device = qdict_get_str(qdict, "device"); | |
1753 | const char *target = qdict_get_str(qdict, "target"); | |
1754 | const char *arg = qdict_get_try_str(qdict, "arg"); | |
baead0ab HR |
1755 | const char *read_only = qdict_get_try_str(qdict, "read-only-mode"); |
1756 | BlockdevChangeReadOnlyMode read_only_mode = 0; | |
333a96ec LC |
1757 | Error *err = NULL; |
1758 | ||
10686749 | 1759 | if (strcmp(device, "vnc") == 0) { |
baead0ab HR |
1760 | if (read_only) { |
1761 | monitor_printf(mon, | |
1762 | "Parameter 'read-only-mode' is invalid for VNC\n"); | |
1763 | return; | |
1764 | } | |
10686749 HR |
1765 | if (strcmp(target, "passwd") == 0 || |
1766 | strcmp(target, "password") == 0) { | |
1767 | if (!arg) { | |
1768 | monitor_read_password(mon, hmp_change_read_arg, NULL); | |
1769 | return; | |
1770 | } | |
1771 | } | |
1772 | qmp_change("vnc", target, !!arg, arg, &err); | |
1773 | } else { | |
baead0ab HR |
1774 | if (read_only) { |
1775 | read_only_mode = | |
f7abe0ec | 1776 | qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup, |
06c60b6c | 1777 | read_only, |
baead0ab HR |
1778 | BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err); |
1779 | if (err) { | |
1780 | hmp_handle_error(mon, &err); | |
1781 | return; | |
1782 | } | |
1783 | } | |
1784 | ||
70e2cb3b KW |
1785 | qmp_blockdev_change_medium(true, device, false, NULL, target, |
1786 | !!arg, arg, !!read_only, read_only_mode, | |
1787 | &err); | |
333a96ec LC |
1788 | } |
1789 | ||
333a96ec LC |
1790 | hmp_handle_error(mon, &err); |
1791 | } | |
80047da5 LC |
1792 | |
1793 | void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) | |
1794 | { | |
1795 | Error *err = NULL; | |
4dc9397b | 1796 | BlockIOThrottle throttle = { |
3f35c3b1 | 1797 | .has_device = true, |
4dc9397b EB |
1798 | .device = (char *) qdict_get_str(qdict, "device"), |
1799 | .bps = qdict_get_int(qdict, "bps"), | |
1800 | .bps_rd = qdict_get_int(qdict, "bps_rd"), | |
1801 | .bps_wr = qdict_get_int(qdict, "bps_wr"), | |
1802 | .iops = qdict_get_int(qdict, "iops"), | |
1803 | .iops_rd = qdict_get_int(qdict, "iops_rd"), | |
1804 | .iops_wr = qdict_get_int(qdict, "iops_wr"), | |
1805 | }; | |
80047da5 | 1806 | |
4dc9397b | 1807 | qmp_block_set_io_throttle(&throttle, &err); |
80047da5 LC |
1808 | hmp_handle_error(mon, &err); |
1809 | } | |
12bd451f SH |
1810 | |
1811 | void hmp_block_stream(Monitor *mon, const QDict *qdict) | |
1812 | { | |
1813 | Error *error = NULL; | |
1814 | const char *device = qdict_get_str(qdict, "device"); | |
1815 | const char *base = qdict_get_try_str(qdict, "base"); | |
c83c66c3 | 1816 | int64_t speed = qdict_get_try_int(qdict, "speed", 0); |
12bd451f | 1817 | |
11d6fbe0 | 1818 | qmp_block_stream(true, device, device, base != NULL, base, false, NULL, |
312fe09c | 1819 | false, NULL, qdict_haskey(qdict, "speed"), speed, |
46663e5e | 1820 | true, BLOCKDEV_ON_ERROR_REPORT, &error); |
12bd451f SH |
1821 | |
1822 | hmp_handle_error(mon, &error); | |
1823 | } | |
2d47c6e9 SH |
1824 | |
1825 | void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict) | |
1826 | { | |
1827 | Error *error = NULL; | |
1828 | const char *device = qdict_get_str(qdict, "device"); | |
c6db2395 | 1829 | int64_t value = qdict_get_int(qdict, "speed"); |
2d47c6e9 SH |
1830 | |
1831 | qmp_block_job_set_speed(device, value, &error); | |
1832 | ||
1833 | hmp_handle_error(mon, &error); | |
1834 | } | |
370521a1 SH |
1835 | |
1836 | void hmp_block_job_cancel(Monitor *mon, const QDict *qdict) | |
1837 | { | |
1838 | Error *error = NULL; | |
1839 | const char *device = qdict_get_str(qdict, "device"); | |
34acbc95 | 1840 | bool force = qdict_get_try_bool(qdict, "force", false); |
370521a1 | 1841 | |
6e37fb81 PB |
1842 | qmp_block_job_cancel(device, true, force, &error); |
1843 | ||
1844 | hmp_handle_error(mon, &error); | |
1845 | } | |
1846 | ||
1847 | void hmp_block_job_pause(Monitor *mon, const QDict *qdict) | |
1848 | { | |
1849 | Error *error = NULL; | |
1850 | const char *device = qdict_get_str(qdict, "device"); | |
1851 | ||
1852 | qmp_block_job_pause(device, &error); | |
1853 | ||
1854 | hmp_handle_error(mon, &error); | |
1855 | } | |
1856 | ||
1857 | void hmp_block_job_resume(Monitor *mon, const QDict *qdict) | |
1858 | { | |
1859 | Error *error = NULL; | |
1860 | const char *device = qdict_get_str(qdict, "device"); | |
1861 | ||
1862 | qmp_block_job_resume(device, &error); | |
370521a1 SH |
1863 | |
1864 | hmp_handle_error(mon, &error); | |
1865 | } | |
e1c37d0e | 1866 | |
aeae883b PB |
1867 | void hmp_block_job_complete(Monitor *mon, const QDict *qdict) |
1868 | { | |
1869 | Error *error = NULL; | |
1870 | const char *device = qdict_get_str(qdict, "device"); | |
1871 | ||
1872 | qmp_block_job_complete(device, &error); | |
1873 | ||
1874 | hmp_handle_error(mon, &error); | |
1875 | } | |
1876 | ||
e49f35bd | 1877 | typedef struct HMPMigrationStatus |
e1c37d0e LC |
1878 | { |
1879 | QEMUTimer *timer; | |
1880 | Monitor *mon; | |
1881 | bool is_block_migration; | |
e49f35bd | 1882 | } HMPMigrationStatus; |
e1c37d0e LC |
1883 | |
1884 | static void hmp_migrate_status_cb(void *opaque) | |
1885 | { | |
e49f35bd | 1886 | HMPMigrationStatus *status = opaque; |
e1c37d0e LC |
1887 | MigrationInfo *info; |
1888 | ||
1889 | info = qmp_query_migrate(NULL); | |
24b8c39b HZ |
1890 | if (!info->has_status || info->status == MIGRATION_STATUS_ACTIVE || |
1891 | info->status == MIGRATION_STATUS_SETUP) { | |
e1c37d0e LC |
1892 | if (info->has_disk) { |
1893 | int progress; | |
1894 | ||
1895 | if (info->disk->remaining) { | |
1896 | progress = info->disk->transferred * 100 / info->disk->total; | |
1897 | } else { | |
1898 | progress = 100; | |
1899 | } | |
1900 | ||
1901 | monitor_printf(status->mon, "Completed %d %%\r", progress); | |
1902 | monitor_flush(status->mon); | |
1903 | } | |
1904 | ||
bc72ad67 | 1905 | timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000); |
e1c37d0e LC |
1906 | } else { |
1907 | if (status->is_block_migration) { | |
1908 | monitor_printf(status->mon, "\n"); | |
1909 | } | |
d59ce6f3 DB |
1910 | if (info->has_error_desc) { |
1911 | error_report("%s", info->error_desc); | |
1912 | } | |
e1c37d0e | 1913 | monitor_resume(status->mon); |
bc72ad67 | 1914 | timer_del(status->timer); |
e1c37d0e LC |
1915 | g_free(status); |
1916 | } | |
1917 | ||
1918 | qapi_free_MigrationInfo(info); | |
1919 | } | |
1920 | ||
1921 | void hmp_migrate(Monitor *mon, const QDict *qdict) | |
1922 | { | |
34acbc95 EB |
1923 | bool detach = qdict_get_try_bool(qdict, "detach", false); |
1924 | bool blk = qdict_get_try_bool(qdict, "blk", false); | |
1925 | bool inc = qdict_get_try_bool(qdict, "inc", false); | |
e1c37d0e LC |
1926 | const char *uri = qdict_get_str(qdict, "uri"); |
1927 | Error *err = NULL; | |
1928 | ||
1929 | qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); | |
1930 | if (err) { | |
554a39eb | 1931 | hmp_handle_error(mon, &err); |
e1c37d0e LC |
1932 | return; |
1933 | } | |
1934 | ||
1935 | if (!detach) { | |
e49f35bd | 1936 | HMPMigrationStatus *status; |
e1c37d0e LC |
1937 | |
1938 | if (monitor_suspend(mon) < 0) { | |
1939 | monitor_printf(mon, "terminal does not allow synchronous " | |
1940 | "migration, continuing detached\n"); | |
1941 | return; | |
1942 | } | |
1943 | ||
1944 | status = g_malloc0(sizeof(*status)); | |
1945 | status->mon = mon; | |
1946 | status->is_block_migration = blk || inc; | |
bc72ad67 | 1947 | status->timer = timer_new_ms(QEMU_CLOCK_REALTIME, hmp_migrate_status_cb, |
e1c37d0e | 1948 | status); |
bc72ad67 | 1949 | timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); |
e1c37d0e LC |
1950 | } |
1951 | } | |
a15fef21 | 1952 | |
318660f8 MA |
1953 | void hmp_device_add(Monitor *mon, const QDict *qdict) |
1954 | { | |
485febc6 MA |
1955 | Error *err = NULL; |
1956 | ||
1957 | qmp_device_add((QDict *)qdict, NULL, &err); | |
1958 | hmp_handle_error(mon, &err); | |
318660f8 MA |
1959 | } |
1960 | ||
a15fef21 LC |
1961 | void hmp_device_del(Monitor *mon, const QDict *qdict) |
1962 | { | |
1963 | const char *id = qdict_get_str(qdict, "id"); | |
1964 | Error *err = NULL; | |
1965 | ||
1966 | qmp_device_del(id, &err); | |
1967 | hmp_handle_error(mon, &err); | |
1968 | } | |
783e9b48 WC |
1969 | |
1970 | void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) | |
1971 | { | |
e940f543 | 1972 | Error *err = NULL; |
34acbc95 EB |
1973 | bool paging = qdict_get_try_bool(qdict, "paging", false); |
1974 | bool zlib = qdict_get_try_bool(qdict, "zlib", false); | |
1975 | bool lzo = qdict_get_try_bool(qdict, "lzo", false); | |
1976 | bool snappy = qdict_get_try_bool(qdict, "snappy", false); | |
75363769 | 1977 | const char *file = qdict_get_str(qdict, "filename"); |
783e9b48 WC |
1978 | bool has_begin = qdict_haskey(qdict, "begin"); |
1979 | bool has_length = qdict_haskey(qdict, "length"); | |
228de9cf | 1980 | bool has_detach = qdict_haskey(qdict, "detach"); |
783e9b48 WC |
1981 | int64_t begin = 0; |
1982 | int64_t length = 0; | |
228de9cf | 1983 | bool detach = false; |
b53ccc30 | 1984 | enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; |
75363769 | 1985 | char *prot; |
783e9b48 | 1986 | |
1b7a0f75 | 1987 | if (zlib + lzo + snappy > 1) { |
e940f543 MA |
1988 | error_setg(&err, "only one of '-z|-l|-s' can be set"); |
1989 | hmp_handle_error(mon, &err); | |
1b7a0f75 QN |
1990 | return; |
1991 | } | |
1992 | ||
1993 | if (zlib) { | |
1994 | dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; | |
1995 | } | |
1996 | ||
1997 | if (lzo) { | |
1998 | dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; | |
1999 | } | |
2000 | ||
2001 | if (snappy) { | |
2002 | dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; | |
2003 | } | |
2004 | ||
783e9b48 WC |
2005 | if (has_begin) { |
2006 | begin = qdict_get_int(qdict, "begin"); | |
2007 | } | |
2008 | if (has_length) { | |
2009 | length = qdict_get_int(qdict, "length"); | |
2010 | } | |
228de9cf PX |
2011 | if (has_detach) { |
2012 | detach = qdict_get_bool(qdict, "detach"); | |
2013 | } | |
783e9b48 | 2014 | |
75363769 LC |
2015 | prot = g_strconcat("file:", file, NULL); |
2016 | ||
228de9cf PX |
2017 | qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin, |
2018 | has_length, length, true, dump_format, &err); | |
e940f543 | 2019 | hmp_handle_error(mon, &err); |
75363769 | 2020 | g_free(prot); |
783e9b48 | 2021 | } |
928059a3 LC |
2022 | |
2023 | void hmp_netdev_add(Monitor *mon, const QDict *qdict) | |
2024 | { | |
2025 | Error *err = NULL; | |
2026 | QemuOpts *opts; | |
2027 | ||
2028 | opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err); | |
84d18f06 | 2029 | if (err) { |
928059a3 LC |
2030 | goto out; |
2031 | } | |
2032 | ||
2033 | netdev_add(opts, &err); | |
84d18f06 | 2034 | if (err) { |
928059a3 LC |
2035 | qemu_opts_del(opts); |
2036 | } | |
2037 | ||
2038 | out: | |
2039 | hmp_handle_error(mon, &err); | |
2040 | } | |
5f964155 LC |
2041 | |
2042 | void hmp_netdev_del(Monitor *mon, const QDict *qdict) | |
2043 | { | |
2044 | const char *id = qdict_get_str(qdict, "id"); | |
2045 | Error *err = NULL; | |
2046 | ||
2047 | qmp_netdev_del(id, &err); | |
2048 | hmp_handle_error(mon, &err); | |
2049 | } | |
208c9d1b | 2050 | |
cff8b2c6 PB |
2051 | void hmp_object_add(Monitor *mon, const QDict *qdict) |
2052 | { | |
2053 | Error *err = NULL; | |
2054 | QemuOpts *opts; | |
90998d58 | 2055 | Object *obj = NULL; |
cff8b2c6 PB |
2056 | |
2057 | opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); | |
2058 | if (err) { | |
90998d58 DB |
2059 | hmp_handle_error(mon, &err); |
2060 | return; | |
cff8b2c6 PB |
2061 | } |
2062 | ||
3a464105 | 2063 | obj = user_creatable_add_opts(opts, &err); |
90998d58 | 2064 | qemu_opts_del(opts); |
cff8b2c6 | 2065 | |
cff8b2c6 | 2066 | if (err) { |
90998d58 | 2067 | hmp_handle_error(mon, &err); |
cff8b2c6 | 2068 | } |
90998d58 DB |
2069 | if (obj) { |
2070 | object_unref(obj); | |
cff8b2c6 | 2071 | } |
cff8b2c6 PB |
2072 | } |
2073 | ||
208c9d1b CB |
2074 | void hmp_getfd(Monitor *mon, const QDict *qdict) |
2075 | { | |
2076 | const char *fdname = qdict_get_str(qdict, "fdname"); | |
e940f543 | 2077 | Error *err = NULL; |
208c9d1b | 2078 | |
e940f543 MA |
2079 | qmp_getfd(fdname, &err); |
2080 | hmp_handle_error(mon, &err); | |
208c9d1b CB |
2081 | } |
2082 | ||
2083 | void hmp_closefd(Monitor *mon, const QDict *qdict) | |
2084 | { | |
2085 | const char *fdname = qdict_get_str(qdict, "fdname"); | |
e940f543 | 2086 | Error *err = NULL; |
208c9d1b | 2087 | |
e940f543 MA |
2088 | qmp_closefd(fdname, &err); |
2089 | hmp_handle_error(mon, &err); | |
208c9d1b | 2090 | } |
e4c8f004 | 2091 | |
3e5a50d6 | 2092 | void hmp_sendkey(Monitor *mon, const QDict *qdict) |
e4c8f004 AK |
2093 | { |
2094 | const char *keys = qdict_get_str(qdict, "keys"); | |
9f328977 | 2095 | KeyValueList *keylist, *head = NULL, *tmp = NULL; |
e4c8f004 AK |
2096 | int has_hold_time = qdict_haskey(qdict, "hold-time"); |
2097 | int hold_time = qdict_get_try_int(qdict, "hold-time", -1); | |
2098 | Error *err = NULL; | |
e4c8f004 | 2099 | char *separator; |
9f328977 | 2100 | int keyname_len; |
e4c8f004 AK |
2101 | |
2102 | while (1) { | |
2103 | separator = strchr(keys, '-'); | |
2104 | keyname_len = separator ? separator - keys : strlen(keys); | |
e4c8f004 AK |
2105 | |
2106 | /* Be compatible with old interface, convert user inputted "<" */ | |
64ffbe04 WB |
2107 | if (keys[0] == '<' && keyname_len == 1) { |
2108 | keys = "less"; | |
e4c8f004 AK |
2109 | keyname_len = 4; |
2110 | } | |
e4c8f004 | 2111 | |
e4c8f004 | 2112 | keylist = g_malloc0(sizeof(*keylist)); |
9f328977 | 2113 | keylist->value = g_malloc0(sizeof(*keylist->value)); |
e4c8f004 AK |
2114 | |
2115 | if (!head) { | |
2116 | head = keylist; | |
2117 | } | |
2118 | if (tmp) { | |
2119 | tmp->next = keylist; | |
2120 | } | |
2121 | tmp = keylist; | |
2122 | ||
64ffbe04 | 2123 | if (strstart(keys, "0x", NULL)) { |
9f328977 | 2124 | char *endp; |
64ffbe04 WB |
2125 | int value = strtoul(keys, &endp, 0); |
2126 | assert(endp <= keys + keyname_len); | |
2127 | if (endp != keys + keyname_len) { | |
9f328977 LC |
2128 | goto err_out; |
2129 | } | |
568c73a4 | 2130 | keylist->value->type = KEY_VALUE_KIND_NUMBER; |
32bafa8f | 2131 | keylist->value->u.number.data = value; |
9f328977 | 2132 | } else { |
64ffbe04 | 2133 | int idx = index_from_key(keys, keyname_len); |
7fb1cf16 | 2134 | if (idx == Q_KEY_CODE__MAX) { |
9f328977 LC |
2135 | goto err_out; |
2136 | } | |
568c73a4 | 2137 | keylist->value->type = KEY_VALUE_KIND_QCODE; |
32bafa8f | 2138 | keylist->value->u.qcode.data = idx; |
9f328977 LC |
2139 | } |
2140 | ||
e4c8f004 AK |
2141 | if (!separator) { |
2142 | break; | |
2143 | } | |
2144 | keys = separator + 1; | |
2145 | } | |
2146 | ||
9f328977 | 2147 | qmp_send_key(head, has_hold_time, hold_time, &err); |
e4c8f004 | 2148 | hmp_handle_error(mon, &err); |
9f328977 LC |
2149 | |
2150 | out: | |
2151 | qapi_free_KeyValueList(head); | |
2152 | return; | |
2153 | ||
2154 | err_out: | |
64ffbe04 | 2155 | monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys); |
9f328977 | 2156 | goto out; |
e4c8f004 | 2157 | } |
ad39cf6d | 2158 | |
3e5a50d6 | 2159 | void hmp_screendump(Monitor *mon, const QDict *qdict) |
ad39cf6d LC |
2160 | { |
2161 | const char *filename = qdict_get_str(qdict, "filename"); | |
2162 | Error *err = NULL; | |
2163 | ||
2164 | qmp_screendump(filename, &err); | |
2165 | hmp_handle_error(mon, &err); | |
2166 | } | |
4057725f PB |
2167 | |
2168 | void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) | |
2169 | { | |
2170 | const char *uri = qdict_get_str(qdict, "uri"); | |
34acbc95 EB |
2171 | bool writable = qdict_get_try_bool(qdict, "writable", false); |
2172 | bool all = qdict_get_try_bool(qdict, "all", false); | |
4057725f PB |
2173 | Error *local_err = NULL; |
2174 | BlockInfoList *block_list, *info; | |
bd269ebc | 2175 | SocketAddress *addr; |
4057725f PB |
2176 | |
2177 | if (writable && !all) { | |
2178 | error_setg(&local_err, "-w only valid together with -a"); | |
2179 | goto exit; | |
2180 | } | |
2181 | ||
2182 | /* First check if the address is valid and start the server. */ | |
2183 | addr = socket_parse(uri, &local_err); | |
2184 | if (local_err != NULL) { | |
2185 | goto exit; | |
2186 | } | |
2187 | ||
bd269ebc MA |
2188 | nbd_server_start(addr, NULL, &local_err); |
2189 | qapi_free_SocketAddress(addr); | |
4057725f PB |
2190 | if (local_err != NULL) { |
2191 | goto exit; | |
2192 | } | |
2193 | ||
2194 | if (!all) { | |
2195 | return; | |
2196 | } | |
2197 | ||
2198 | /* Then try adding all block devices. If one fails, close all and | |
2199 | * exit. | |
2200 | */ | |
2201 | block_list = qmp_query_block(NULL); | |
2202 | ||
2203 | for (info = block_list; info; info = info->next) { | |
2204 | if (!info->value->has_inserted) { | |
2205 | continue; | |
2206 | } | |
2207 | ||
902a1f94 VSO |
2208 | qmp_nbd_server_add(info->value->device, false, NULL, |
2209 | true, writable, &local_err); | |
4057725f PB |
2210 | |
2211 | if (local_err != NULL) { | |
2212 | qmp_nbd_server_stop(NULL); | |
2213 | break; | |
2214 | } | |
2215 | } | |
2216 | ||
2217 | qapi_free_BlockInfoList(block_list); | |
2218 | ||
2219 | exit: | |
2220 | hmp_handle_error(mon, &local_err); | |
2221 | } | |
2222 | ||
2223 | void hmp_nbd_server_add(Monitor *mon, const QDict *qdict) | |
2224 | { | |
2225 | const char *device = qdict_get_str(qdict, "device"); | |
dba49323 | 2226 | const char *name = qdict_get_try_str(qdict, "name"); |
34acbc95 | 2227 | bool writable = qdict_get_try_bool(qdict, "writable", false); |
4057725f PB |
2228 | Error *local_err = NULL; |
2229 | ||
dba49323 | 2230 | qmp_nbd_server_add(device, !!name, name, true, writable, &local_err); |
08fb10a7 EB |
2231 | hmp_handle_error(mon, &local_err); |
2232 | } | |
4057725f | 2233 | |
08fb10a7 EB |
2234 | void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict) |
2235 | { | |
2236 | const char *name = qdict_get_str(qdict, "name"); | |
2237 | bool force = qdict_get_try_bool(qdict, "force", false); | |
2238 | Error *err = NULL; | |
2239 | ||
2240 | /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */ | |
2241 | qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err); | |
2242 | hmp_handle_error(mon, &err); | |
4057725f PB |
2243 | } |
2244 | ||
2245 | void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict) | |
2246 | { | |
e940f543 | 2247 | Error *err = NULL; |
4057725f | 2248 | |
e940f543 MA |
2249 | qmp_nbd_server_stop(&err); |
2250 | hmp_handle_error(mon, &err); | |
4057725f | 2251 | } |
f1088908 | 2252 | |
abf23329 JH |
2253 | void hmp_cpu_add(Monitor *mon, const QDict *qdict) |
2254 | { | |
2255 | int cpuid; | |
2256 | Error *err = NULL; | |
2257 | ||
2258 | cpuid = qdict_get_int(qdict, "id"); | |
2259 | qmp_cpu_add(cpuid, &err); | |
2260 | hmp_handle_error(mon, &err); | |
2261 | } | |
2262 | ||
f1088908 GH |
2263 | void hmp_chardev_add(Monitor *mon, const QDict *qdict) |
2264 | { | |
2265 | const char *args = qdict_get_str(qdict, "args"); | |
2266 | Error *err = NULL; | |
2267 | QemuOpts *opts; | |
2268 | ||
70b94331 | 2269 | opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true); |
f1088908 | 2270 | if (opts == NULL) { |
312fd5f2 | 2271 | error_setg(&err, "Parsing chardev args failed"); |
f1088908 | 2272 | } else { |
b4948be9 | 2273 | qemu_chr_new_from_opts(opts, &err); |
0a73336d | 2274 | qemu_opts_del(opts); |
f1088908 GH |
2275 | } |
2276 | hmp_handle_error(mon, &err); | |
2277 | } | |
2278 | ||
75b60160 AN |
2279 | void hmp_chardev_change(Monitor *mon, const QDict *qdict) |
2280 | { | |
2281 | const char *args = qdict_get_str(qdict, "args"); | |
2282 | const char *id; | |
2283 | Error *err = NULL; | |
2284 | ChardevBackend *backend = NULL; | |
2285 | ChardevReturn *ret = NULL; | |
2286 | QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, | |
2287 | true); | |
2288 | if (!opts) { | |
2289 | error_setg(&err, "Parsing chardev args failed"); | |
2290 | goto end; | |
2291 | } | |
2292 | ||
2293 | id = qdict_get_str(qdict, "id"); | |
2294 | if (qemu_opts_id(opts)) { | |
2295 | error_setg(&err, "Unexpected 'id' parameter"); | |
2296 | goto end; | |
2297 | } | |
2298 | ||
2299 | backend = qemu_chr_parse_opts(opts, &err); | |
2300 | if (!backend) { | |
2301 | goto end; | |
2302 | } | |
2303 | ||
2304 | ret = qmp_chardev_change(id, backend, &err); | |
2305 | ||
2306 | end: | |
2307 | qapi_free_ChardevReturn(ret); | |
2308 | qapi_free_ChardevBackend(backend); | |
2309 | qemu_opts_del(opts); | |
2310 | hmp_handle_error(mon, &err); | |
2311 | } | |
2312 | ||
f1088908 GH |
2313 | void hmp_chardev_remove(Monitor *mon, const QDict *qdict) |
2314 | { | |
2315 | Error *local_err = NULL; | |
2316 | ||
2317 | qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err); | |
2318 | hmp_handle_error(mon, &local_err); | |
2319 | } | |
587da2c3 | 2320 | |
bd1d5ad9 SF |
2321 | void hmp_chardev_send_break(Monitor *mon, const QDict *qdict) |
2322 | { | |
2323 | Error *local_err = NULL; | |
2324 | ||
2325 | qmp_chardev_send_break(qdict_get_str(qdict, "id"), &local_err); | |
2326 | hmp_handle_error(mon, &local_err); | |
2327 | } | |
2328 | ||
587da2c3 KW |
2329 | void hmp_qemu_io(Monitor *mon, const QDict *qdict) |
2330 | { | |
4c7b7e9b | 2331 | BlockBackend *blk; |
e7f98f2f | 2332 | BlockBackend *local_blk = NULL; |
587da2c3 KW |
2333 | const char* device = qdict_get_str(qdict, "device"); |
2334 | const char* command = qdict_get_str(qdict, "command"); | |
2335 | Error *err = NULL; | |
d7086422 | 2336 | int ret; |
587da2c3 | 2337 | |
4c7b7e9b | 2338 | blk = blk_by_name(device); |
e7f98f2f KW |
2339 | if (!blk) { |
2340 | BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err); | |
2341 | if (bs) { | |
6d0eb64d | 2342 | blk = local_blk = blk_new(0, BLK_PERM_ALL); |
d7086422 KW |
2343 | ret = blk_insert_bs(blk, bs, &err); |
2344 | if (ret < 0) { | |
2345 | goto fail; | |
2346 | } | |
e7f98f2f KW |
2347 | } else { |
2348 | goto fail; | |
2349 | } | |
2350 | } | |
2351 | ||
887354bd KW |
2352 | /* |
2353 | * Notably absent: Proper permission management. This is sad, but it seems | |
2354 | * almost impossible to achieve without changing the semantics and thereby | |
2355 | * limiting the use cases of the qemu-io HMP command. | |
2356 | * | |
2357 | * In an ideal world we would unconditionally create a new BlockBackend for | |
2358 | * qemuio_command(), but we have commands like 'reopen' and want them to | |
2359 | * take effect on the exact BlockBackend whose name the user passed instead | |
2360 | * of just on a temporary copy of it. | |
2361 | * | |
2362 | * Another problem is that deleting the temporary BlockBackend involves | |
2363 | * draining all requests on it first, but some qemu-iotests cases want to | |
2364 | * issue multiple aio_read/write requests and expect them to complete in | |
2365 | * the background while the monitor has already returned. | |
2366 | * | |
2367 | * This is also what prevents us from saving the original permissions and | |
2368 | * restoring them later: We can't revoke permissions until all requests | |
2369 | * have completed, and we don't know when that is nor can we really let | |
2370 | * anything else run before we have revoken them to avoid race conditions. | |
2371 | * | |
2372 | * What happens now is that command() in qemu-io-cmds.c can extend the | |
2373 | * permissions if necessary for the qemu-io command. And they simply stay | |
2374 | * extended, possibly resulting in a read-only guest device keeping write | |
2375 | * permissions. Ugly, but it appears to be the lesser evil. | |
2376 | */ | |
1813d330 | 2377 | qemuio_command(blk, command); |
587da2c3 | 2378 | |
e7f98f2f KW |
2379 | fail: |
2380 | blk_unref(local_blk); | |
587da2c3 KW |
2381 | hmp_handle_error(mon, &err); |
2382 | } | |
ab2d0531 PB |
2383 | |
2384 | void hmp_object_del(Monitor *mon, const QDict *qdict) | |
2385 | { | |
2386 | const char *id = qdict_get_str(qdict, "id"); | |
2387 | Error *err = NULL; | |
2388 | ||
90998d58 | 2389 | user_creatable_del(id, &err); |
ab2d0531 PB |
2390 | hmp_handle_error(mon, &err); |
2391 | } | |
eb1539b2 HT |
2392 | |
2393 | void hmp_info_memdev(Monitor *mon, const QDict *qdict) | |
2394 | { | |
2395 | Error *err = NULL; | |
2396 | MemdevList *memdev_list = qmp_query_memdev(&err); | |
2397 | MemdevList *m = memdev_list; | |
3b098d56 | 2398 | Visitor *v; |
976620ac | 2399 | char *str; |
eb1539b2 HT |
2400 | |
2401 | while (m) { | |
3b098d56 EB |
2402 | v = string_output_visitor_new(false, &str); |
2403 | visit_type_uint16List(v, NULL, &m->value->host_nodes, NULL); | |
e1ff3c67 | 2404 | monitor_printf(mon, "memory backend: %s\n", m->value->id); |
eb1539b2 HT |
2405 | monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); |
2406 | monitor_printf(mon, " merge: %s\n", | |
2407 | m->value->merge ? "true" : "false"); | |
2408 | monitor_printf(mon, " dump: %s\n", | |
2409 | m->value->dump ? "true" : "false"); | |
2410 | monitor_printf(mon, " prealloc: %s\n", | |
2411 | m->value->prealloc ? "true" : "false"); | |
2412 | monitor_printf(mon, " policy: %s\n", | |
977c736f | 2413 | HostMemPolicy_str(m->value->policy)); |
3b098d56 | 2414 | visit_complete(v, &str); |
976620ac | 2415 | monitor_printf(mon, " host nodes: %s\n", str); |
eb1539b2 | 2416 | |
976620ac | 2417 | g_free(str); |
3b098d56 | 2418 | visit_free(v); |
eb1539b2 | 2419 | m = m->next; |
eb1539b2 HT |
2420 | } |
2421 | ||
2422 | monitor_printf(mon, "\n"); | |
ecaf54a0 CF |
2423 | |
2424 | qapi_free_MemdevList(memdev_list); | |
40c71f63 | 2425 | hmp_handle_error(mon, &err); |
eb1539b2 | 2426 | } |
a631892f ZG |
2427 | |
2428 | void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) | |
2429 | { | |
2430 | Error *err = NULL; | |
2431 | MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err); | |
2432 | MemoryDeviceInfoList *info; | |
2433 | MemoryDeviceInfo *value; | |
2434 | PCDIMMDeviceInfo *di; | |
2435 | ||
2436 | for (info = info_list; info; info = info->next) { | |
2437 | value = info->value; | |
2438 | ||
2439 | if (value) { | |
1fd5d4fe | 2440 | switch (value->type) { |
a631892f | 2441 | case MEMORY_DEVICE_INFO_KIND_DIMM: |
32bafa8f | 2442 | di = value->u.dimm.data; |
a631892f ZG |
2443 | |
2444 | monitor_printf(mon, "Memory device [%s]: \"%s\"\n", | |
977c736f | 2445 | MemoryDeviceInfoKind_str(value->type), |
a631892f ZG |
2446 | di->id ? di->id : ""); |
2447 | monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr); | |
2448 | monitor_printf(mon, " slot: %" PRId64 "\n", di->slot); | |
2449 | monitor_printf(mon, " node: %" PRId64 "\n", di->node); | |
2450 | monitor_printf(mon, " size: %" PRIu64 "\n", di->size); | |
2451 | monitor_printf(mon, " memdev: %s\n", di->memdev); | |
2452 | monitor_printf(mon, " hotplugged: %s\n", | |
2453 | di->hotplugged ? "true" : "false"); | |
2454 | monitor_printf(mon, " hotpluggable: %s\n", | |
2455 | di->hotpluggable ? "true" : "false"); | |
2456 | break; | |
2457 | default: | |
2458 | break; | |
2459 | } | |
2460 | } | |
2461 | } | |
2462 | ||
2463 | qapi_free_MemoryDeviceInfoList(info_list); | |
40c71f63 | 2464 | hmp_handle_error(mon, &err); |
a631892f | 2465 | } |
89d7fa9e | 2466 | |
62313160 TW |
2467 | void hmp_info_iothreads(Monitor *mon, const QDict *qdict) |
2468 | { | |
2469 | IOThreadInfoList *info_list = qmp_query_iothreads(NULL); | |
2470 | IOThreadInfoList *info; | |
5fc00480 | 2471 | IOThreadInfo *value; |
62313160 TW |
2472 | |
2473 | for (info = info_list; info; info = info->next) { | |
5fc00480 PH |
2474 | value = info->value; |
2475 | monitor_printf(mon, "%s:\n", value->id); | |
2476 | monitor_printf(mon, " thread_id=%" PRId64 "\n", value->thread_id); | |
2477 | monitor_printf(mon, " poll-max-ns=%" PRId64 "\n", value->poll_max_ns); | |
2478 | monitor_printf(mon, " poll-grow=%" PRId64 "\n", value->poll_grow); | |
2479 | monitor_printf(mon, " poll-shrink=%" PRId64 "\n", value->poll_shrink); | |
62313160 TW |
2480 | } |
2481 | ||
2482 | qapi_free_IOThreadInfoList(info_list); | |
2483 | } | |
2484 | ||
89d7fa9e AF |
2485 | void hmp_qom_list(Monitor *mon, const QDict *qdict) |
2486 | { | |
2487 | const char *path = qdict_get_try_str(qdict, "path"); | |
2488 | ObjectPropertyInfoList *list; | |
2489 | Error *err = NULL; | |
2490 | ||
2491 | if (path == NULL) { | |
2492 | monitor_printf(mon, "/\n"); | |
2493 | return; | |
2494 | } | |
2495 | ||
2496 | list = qmp_qom_list(path, &err); | |
2497 | if (err == NULL) { | |
2498 | ObjectPropertyInfoList *start = list; | |
2499 | while (list != NULL) { | |
2500 | ObjectPropertyInfo *value = list->value; | |
2501 | ||
2502 | monitor_printf(mon, "%s (%s)\n", | |
2503 | value->name, value->type); | |
2504 | list = list->next; | |
2505 | } | |
2506 | qapi_free_ObjectPropertyInfoList(start); | |
2507 | } | |
2508 | hmp_handle_error(mon, &err); | |
2509 | } | |
c0e6ee9e AF |
2510 | |
2511 | void hmp_qom_set(Monitor *mon, const QDict *qdict) | |
2512 | { | |
2513 | const char *path = qdict_get_str(qdict, "path"); | |
2514 | const char *property = qdict_get_str(qdict, "property"); | |
2515 | const char *value = qdict_get_str(qdict, "value"); | |
2516 | Error *err = NULL; | |
2517 | bool ambiguous = false; | |
2518 | Object *obj; | |
2519 | ||
2520 | obj = object_resolve_path(path, &ambiguous); | |
2521 | if (obj == NULL) { | |
75158ebb MA |
2522 | error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, |
2523 | "Device '%s' not found", path); | |
c0e6ee9e AF |
2524 | } else { |
2525 | if (ambiguous) { | |
2526 | monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path); | |
2527 | } | |
2528 | object_property_parse(obj, value, property, &err); | |
2529 | } | |
2530 | hmp_handle_error(mon, &err); | |
2531 | } | |
fafa4d50 SF |
2532 | |
2533 | void hmp_rocker(Monitor *mon, const QDict *qdict) | |
2534 | { | |
2535 | const char *name = qdict_get_str(qdict, "name"); | |
2536 | RockerSwitch *rocker; | |
533fdaed | 2537 | Error *err = NULL; |
fafa4d50 | 2538 | |
533fdaed MA |
2539 | rocker = qmp_query_rocker(name, &err); |
2540 | if (err != NULL) { | |
2541 | hmp_handle_error(mon, &err); | |
fafa4d50 SF |
2542 | return; |
2543 | } | |
2544 | ||
2545 | monitor_printf(mon, "name: %s\n", rocker->name); | |
2546 | monitor_printf(mon, "id: 0x%" PRIx64 "\n", rocker->id); | |
2547 | monitor_printf(mon, "ports: %d\n", rocker->ports); | |
2548 | ||
2549 | qapi_free_RockerSwitch(rocker); | |
2550 | } | |
2551 | ||
2552 | void hmp_rocker_ports(Monitor *mon, const QDict *qdict) | |
2553 | { | |
2554 | RockerPortList *list, *port; | |
2555 | const char *name = qdict_get_str(qdict, "name"); | |
533fdaed | 2556 | Error *err = NULL; |
fafa4d50 | 2557 | |
533fdaed MA |
2558 | list = qmp_query_rocker_ports(name, &err); |
2559 | if (err != NULL) { | |
2560 | hmp_handle_error(mon, &err); | |
fafa4d50 SF |
2561 | return; |
2562 | } | |
2563 | ||
2564 | monitor_printf(mon, " ena/ speed/ auto\n"); | |
2565 | monitor_printf(mon, " port link duplex neg?\n"); | |
2566 | ||
2567 | for (port = list; port; port = port->next) { | |
2568 | monitor_printf(mon, "%10s %-4s %-3s %2s %-3s\n", | |
2569 | port->value->name, | |
2570 | port->value->enabled ? port->value->link_up ? | |
2571 | "up" : "down" : "!ena", | |
2572 | port->value->speed == 10000 ? "10G" : "??", | |
2573 | port->value->duplex ? "FD" : "HD", | |
2574 | port->value->autoneg ? "Yes" : "No"); | |
2575 | } | |
2576 | ||
2577 | qapi_free_RockerPortList(list); | |
2578 | } | |
2579 | ||
2580 | void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict) | |
2581 | { | |
2582 | RockerOfDpaFlowList *list, *info; | |
2583 | const char *name = qdict_get_str(qdict, "name"); | |
2584 | uint32_t tbl_id = qdict_get_try_int(qdict, "tbl_id", -1); | |
533fdaed | 2585 | Error *err = NULL; |
fafa4d50 | 2586 | |
533fdaed MA |
2587 | list = qmp_query_rocker_of_dpa_flows(name, tbl_id != -1, tbl_id, &err); |
2588 | if (err != NULL) { | |
2589 | hmp_handle_error(mon, &err); | |
fafa4d50 SF |
2590 | return; |
2591 | } | |
2592 | ||
2593 | monitor_printf(mon, "prio tbl hits key(mask) --> actions\n"); | |
2594 | ||
2595 | for (info = list; info; info = info->next) { | |
2596 | RockerOfDpaFlow *flow = info->value; | |
2597 | RockerOfDpaFlowKey *key = flow->key; | |
2598 | RockerOfDpaFlowMask *mask = flow->mask; | |
2599 | RockerOfDpaFlowAction *action = flow->action; | |
2600 | ||
2601 | if (flow->hits) { | |
2602 | monitor_printf(mon, "%-4d %-3d %-4" PRIu64, | |
2603 | key->priority, key->tbl_id, flow->hits); | |
2604 | } else { | |
2605 | monitor_printf(mon, "%-4d %-3d ", | |
2606 | key->priority, key->tbl_id); | |
2607 | } | |
2608 | ||
2609 | if (key->has_in_pport) { | |
2610 | monitor_printf(mon, " pport %d", key->in_pport); | |
2611 | if (mask->has_in_pport) { | |
2612 | monitor_printf(mon, "(0x%x)", mask->in_pport); | |
2613 | } | |
2614 | } | |
2615 | ||
2616 | if (key->has_vlan_id) { | |
2617 | monitor_printf(mon, " vlan %d", | |
2618 | key->vlan_id & VLAN_VID_MASK); | |
2619 | if (mask->has_vlan_id) { | |
2620 | monitor_printf(mon, "(0x%x)", mask->vlan_id); | |
2621 | } | |
2622 | } | |
2623 | ||
2624 | if (key->has_tunnel_id) { | |
2625 | monitor_printf(mon, " tunnel %d", key->tunnel_id); | |
2626 | if (mask->has_tunnel_id) { | |
2627 | monitor_printf(mon, "(0x%x)", mask->tunnel_id); | |
2628 | } | |
2629 | } | |
2630 | ||
2631 | if (key->has_eth_type) { | |
2632 | switch (key->eth_type) { | |
2633 | case 0x0806: | |
2634 | monitor_printf(mon, " ARP"); | |
2635 | break; | |
2636 | case 0x0800: | |
2637 | monitor_printf(mon, " IP"); | |
2638 | break; | |
2639 | case 0x86dd: | |
2640 | monitor_printf(mon, " IPv6"); | |
2641 | break; | |
2642 | case 0x8809: | |
2643 | monitor_printf(mon, " LACP"); | |
2644 | break; | |
2645 | case 0x88cc: | |
2646 | monitor_printf(mon, " LLDP"); | |
2647 | break; | |
2648 | default: | |
2649 | monitor_printf(mon, " eth type 0x%04x", key->eth_type); | |
2650 | break; | |
2651 | } | |
2652 | } | |
2653 | ||
2654 | if (key->has_eth_src) { | |
2655 | if ((strcmp(key->eth_src, "01:00:00:00:00:00") == 0) && | |
2656 | (mask->has_eth_src) && | |
2657 | (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) { | |
2658 | monitor_printf(mon, " src <any mcast/bcast>"); | |
2659 | } else if ((strcmp(key->eth_src, "00:00:00:00:00:00") == 0) && | |
2660 | (mask->has_eth_src) && | |
2661 | (strcmp(mask->eth_src, "01:00:00:00:00:00") == 0)) { | |
2662 | monitor_printf(mon, " src <any ucast>"); | |
2663 | } else { | |
2664 | monitor_printf(mon, " src %s", key->eth_src); | |
2665 | if (mask->has_eth_src) { | |
2666 | monitor_printf(mon, "(%s)", mask->eth_src); | |
2667 | } | |
2668 | } | |
2669 | } | |
2670 | ||
2671 | if (key->has_eth_dst) { | |
2672 | if ((strcmp(key->eth_dst, "01:00:00:00:00:00") == 0) && | |
2673 | (mask->has_eth_dst) && | |
2674 | (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) { | |
2675 | monitor_printf(mon, " dst <any mcast/bcast>"); | |
2676 | } else if ((strcmp(key->eth_dst, "00:00:00:00:00:00") == 0) && | |
2677 | (mask->has_eth_dst) && | |
2678 | (strcmp(mask->eth_dst, "01:00:00:00:00:00") == 0)) { | |
2679 | monitor_printf(mon, " dst <any ucast>"); | |
2680 | } else { | |
2681 | monitor_printf(mon, " dst %s", key->eth_dst); | |
2682 | if (mask->has_eth_dst) { | |
2683 | monitor_printf(mon, "(%s)", mask->eth_dst); | |
2684 | } | |
2685 | } | |
2686 | } | |
2687 | ||
2688 | if (key->has_ip_proto) { | |
2689 | monitor_printf(mon, " proto %d", key->ip_proto); | |
2690 | if (mask->has_ip_proto) { | |
2691 | monitor_printf(mon, "(0x%x)", mask->ip_proto); | |
2692 | } | |
2693 | } | |
2694 | ||
2695 | if (key->has_ip_tos) { | |
2696 | monitor_printf(mon, " TOS %d", key->ip_tos); | |
2697 | if (mask->has_ip_tos) { | |
2698 | monitor_printf(mon, "(0x%x)", mask->ip_tos); | |
2699 | } | |
2700 | } | |
2701 | ||
2702 | if (key->has_ip_dst) { | |
2703 | monitor_printf(mon, " dst %s", key->ip_dst); | |
2704 | } | |
2705 | ||
2706 | if (action->has_goto_tbl || action->has_group_id || | |
2707 | action->has_new_vlan_id) { | |
2708 | monitor_printf(mon, " -->"); | |
2709 | } | |
2710 | ||
2711 | if (action->has_new_vlan_id) { | |
2712 | monitor_printf(mon, " apply new vlan %d", | |
2713 | ntohs(action->new_vlan_id)); | |
2714 | } | |
2715 | ||
2716 | if (action->has_group_id) { | |
2717 | monitor_printf(mon, " write group 0x%08x", action->group_id); | |
2718 | } | |
2719 | ||
2720 | if (action->has_goto_tbl) { | |
2721 | monitor_printf(mon, " goto tbl %d", action->goto_tbl); | |
2722 | } | |
2723 | ||
2724 | monitor_printf(mon, "\n"); | |
2725 | } | |
2726 | ||
2727 | qapi_free_RockerOfDpaFlowList(list); | |
2728 | } | |
2729 | ||
2730 | void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) | |
2731 | { | |
2732 | RockerOfDpaGroupList *list, *g; | |
2733 | const char *name = qdict_get_str(qdict, "name"); | |
2734 | uint8_t type = qdict_get_try_int(qdict, "type", 9); | |
533fdaed | 2735 | Error *err = NULL; |
fafa4d50 SF |
2736 | bool set = false; |
2737 | ||
533fdaed MA |
2738 | list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err); |
2739 | if (err != NULL) { | |
2740 | hmp_handle_error(mon, &err); | |
fafa4d50 SF |
2741 | return; |
2742 | } | |
2743 | ||
2744 | monitor_printf(mon, "id (decode) --> buckets\n"); | |
2745 | ||
2746 | for (g = list; g; g = g->next) { | |
2747 | RockerOfDpaGroup *group = g->value; | |
2748 | ||
2749 | monitor_printf(mon, "0x%08x", group->id); | |
2750 | ||
2751 | monitor_printf(mon, " (type %s", group->type == 0 ? "L2 interface" : | |
2752 | group->type == 1 ? "L2 rewrite" : | |
2753 | group->type == 2 ? "L3 unicast" : | |
2754 | group->type == 3 ? "L2 multicast" : | |
2755 | group->type == 4 ? "L2 flood" : | |
2756 | group->type == 5 ? "L3 interface" : | |
2757 | group->type == 6 ? "L3 multicast" : | |
2758 | group->type == 7 ? "L3 ECMP" : | |
2759 | group->type == 8 ? "L2 overlay" : | |
2760 | "unknown"); | |
2761 | ||
2762 | if (group->has_vlan_id) { | |
2763 | monitor_printf(mon, " vlan %d", group->vlan_id); | |
2764 | } | |
2765 | ||
2766 | if (group->has_pport) { | |
2767 | monitor_printf(mon, " pport %d", group->pport); | |
2768 | } | |
2769 | ||
2770 | if (group->has_index) { | |
2771 | monitor_printf(mon, " index %d", group->index); | |
2772 | } | |
2773 | ||
2774 | monitor_printf(mon, ") -->"); | |
2775 | ||
2776 | if (group->has_set_vlan_id && group->set_vlan_id) { | |
2777 | set = true; | |
2778 | monitor_printf(mon, " set vlan %d", | |
2779 | group->set_vlan_id & VLAN_VID_MASK); | |
2780 | } | |
2781 | ||
2782 | if (group->has_set_eth_src) { | |
2783 | if (!set) { | |
2784 | set = true; | |
2785 | monitor_printf(mon, " set"); | |
2786 | } | |
2787 | monitor_printf(mon, " src %s", group->set_eth_src); | |
2788 | } | |
2789 | ||
2790 | if (group->has_set_eth_dst) { | |
2791 | if (!set) { | |
2792 | set = true; | |
2793 | monitor_printf(mon, " set"); | |
2794 | } | |
2795 | monitor_printf(mon, " dst %s", group->set_eth_dst); | |
2796 | } | |
2797 | ||
2798 | set = false; | |
2799 | ||
2800 | if (group->has_ttl_check && group->ttl_check) { | |
2801 | monitor_printf(mon, " check TTL"); | |
2802 | } | |
2803 | ||
2804 | if (group->has_group_id && group->group_id) { | |
2805 | monitor_printf(mon, " group id 0x%08x", group->group_id); | |
2806 | } | |
2807 | ||
2808 | if (group->has_pop_vlan && group->pop_vlan) { | |
2809 | monitor_printf(mon, " pop vlan"); | |
2810 | } | |
2811 | ||
2812 | if (group->has_out_pport) { | |
2813 | monitor_printf(mon, " out pport %d", group->out_pport); | |
2814 | } | |
2815 | ||
2816 | if (group->has_group_ids) { | |
2817 | struct uint32List *id; | |
2818 | ||
2819 | monitor_printf(mon, " groups ["); | |
2820 | for (id = group->group_ids; id; id = id->next) { | |
2821 | monitor_printf(mon, "0x%08x", id->value); | |
2822 | if (id->next) { | |
2823 | monitor_printf(mon, ","); | |
2824 | } | |
2825 | } | |
2826 | monitor_printf(mon, "]"); | |
2827 | } | |
2828 | ||
2829 | monitor_printf(mon, "\n"); | |
2830 | } | |
2831 | ||
2832 | qapi_free_RockerOfDpaGroupList(list); | |
2833 | } | |
4a6b52d6 PX |
2834 | |
2835 | void hmp_info_dump(Monitor *mon, const QDict *qdict) | |
2836 | { | |
2837 | DumpQueryResult *result = qmp_query_dump(NULL); | |
2838 | ||
2839 | assert(result && result->status < DUMP_STATUS__MAX); | |
977c736f | 2840 | monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status)); |
4a6b52d6 PX |
2841 | |
2842 | if (result->status == DUMP_STATUS_ACTIVE) { | |
2843 | float percent = 0; | |
2844 | assert(result->total != 0); | |
2845 | percent = 100.0 * result->completed / result->total; | |
2846 | monitor_printf(mon, "Finished: %.2f %%\n", percent); | |
2847 | } | |
2848 | ||
2849 | qapi_free_DumpQueryResult(result); | |
2850 | } | |
d2d8d46f | 2851 | |
be9b23c4 PX |
2852 | void hmp_info_ramblock(Monitor *mon, const QDict *qdict) |
2853 | { | |
2854 | ram_block_dump(mon); | |
2855 | } | |
2856 | ||
d2d8d46f BR |
2857 | void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) |
2858 | { | |
2859 | Error *err = NULL; | |
2860 | HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err); | |
2861 | HotpluggableCPUList *saved = l; | |
2862 | CpuInstanceProperties *c; | |
2863 | ||
2864 | if (err != NULL) { | |
2865 | hmp_handle_error(mon, &err); | |
2866 | return; | |
2867 | } | |
2868 | ||
2869 | monitor_printf(mon, "Hotpluggable CPUs:\n"); | |
2870 | while (l) { | |
2871 | monitor_printf(mon, " type: \"%s\"\n", l->value->type); | |
2872 | monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n", | |
2873 | l->value->vcpus_count); | |
2874 | if (l->value->has_qom_path) { | |
2875 | monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path); | |
2876 | } | |
2877 | ||
2878 | c = l->value->props; | |
2879 | monitor_printf(mon, " CPUInstance Properties:\n"); | |
27393c33 PK |
2880 | if (c->has_node_id) { |
2881 | monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id); | |
d2d8d46f | 2882 | } |
27393c33 PK |
2883 | if (c->has_socket_id) { |
2884 | monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id); | |
d2d8d46f | 2885 | } |
27393c33 PK |
2886 | if (c->has_core_id) { |
2887 | monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); | |
d2d8d46f | 2888 | } |
27393c33 PK |
2889 | if (c->has_thread_id) { |
2890 | monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id); | |
d2d8d46f BR |
2891 | } |
2892 | ||
2893 | l = l->next; | |
2894 | } | |
2895 | ||
2896 | qapi_free_HotpluggableCPUList(saved); | |
2897 | } | |
39164c13 IM |
2898 | |
2899 | void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) | |
2900 | { | |
72d9196f BW |
2901 | Error *err = NULL; |
2902 | GuidInfo *info = qmp_query_vm_generation_id(&err); | |
39164c13 IM |
2903 | if (info) { |
2904 | monitor_printf(mon, "%s\n", info->guid); | |
2905 | } | |
72d9196f | 2906 | hmp_handle_error(mon, &err); |
39164c13 IM |
2907 | qapi_free_GuidInfo(info); |
2908 | } | |
d0f63c1e VG |
2909 | |
2910 | void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict) | |
2911 | { | |
2912 | Error *err = NULL; | |
2913 | MemoryInfo *info = qmp_query_memory_size_summary(&err); | |
2914 | if (info) { | |
2915 | monitor_printf(mon, "base memory: %" PRIu64 "\n", | |
2916 | info->base_memory); | |
2917 | ||
2918 | if (info->has_plugged_memory) { | |
2919 | monitor_printf(mon, "plugged memory: %" PRIu64 "\n", | |
2920 | info->plugged_memory); | |
2921 | } | |
2922 | ||
2923 | qapi_free_MemoryInfo(info); | |
2924 | } | |
2925 | hmp_handle_error(mon, &err); | |
2926 | } |