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