1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
|
/*
* HMP commands related to machines and CPUs
*
* Copyright IBM, Corp. 2011
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
* Contributions after 2012-01-13 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "qemu/osdep.h"
#include "monitor/hmp.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/qapi-commands-machine.h"
#include "qobject/qdict.h"
#include "qapi/string-output-visitor.h"
#include "qemu/error-report.h"
#include "system/numa.h"
#include "hw/boards.h"
void hmp_info_cpus(Monitor *mon, const QDict *qdict)
{
CpuInfoFastList *cpu_list, *cpu;
cpu_list = qmp_query_cpus_fast(NULL);
for (cpu = cpu_list; cpu; cpu = cpu->next) {
int active = ' ';
if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) {
active = '*';
}
monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
cpu->value->cpu_index);
monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
}
qapi_free_CpuInfoFastList(cpu_list);
}
void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err);
HotpluggableCPUList *saved = l;
CpuInstanceProperties *c;
if (hmp_handle_error(mon, err)) {
return;
}
monitor_printf(mon, "Hotpluggable CPUs:\n");
while (l) {
monitor_printf(mon, " type: \"%s\"\n", l->value->type);
monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n",
l->value->vcpus_count);
if (l->value->qom_path) {
monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path);
}
c = l->value->props;
monitor_printf(mon, " CPUInstance Properties:\n");
if (c->has_node_id) {
monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id);
}
if (c->has_drawer_id) {
monitor_printf(mon, " drawer-id: \"%" PRIu64 "\"\n", c->drawer_id);
}
if (c->has_book_id) {
monitor_printf(mon, " book-id: \"%" PRIu64 "\"\n", c->book_id);
}
if (c->has_socket_id) {
monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
}
if (c->has_die_id) {
monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
}
if (c->has_cluster_id) {
monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n",
c->cluster_id);
}
if (c->has_module_id) {
monitor_printf(mon, " module-id: \"%" PRIu64 "\"\n",
c->module_id);
}
if (c->has_core_id) {
monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
}
if (c->has_thread_id) {
monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id);
}
l = l->next;
}
qapi_free_HotpluggableCPUList(saved);
}
void hmp_info_memdev(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemdevList *memdev_list = qmp_query_memdev(&err);
MemdevList *m = memdev_list;
Visitor *v;
char *str;
while (m) {
v = string_output_visitor_new(false, &str);
visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
monitor_printf(mon, "memory backend: %s\n", m->value->id);
monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
monitor_printf(mon, " merge: %s\n",
m->value->merge ? "true" : "false");
monitor_printf(mon, " dump: %s\n",
m->value->dump ? "true" : "false");
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " share: %s\n",
m->value->share ? "true" : "false");
if (m->value->has_reserve) {
monitor_printf(mon, " reserve: %s\n",
m->value->reserve ? "true" : "false");
}
monitor_printf(mon, " policy: %s\n",
HostMemPolicy_str(m->value->policy));
visit_complete(v, &str);
monitor_printf(mon, " host nodes: %s\n", str);
g_free(str);
visit_free(v);
m = m->next;
}
monitor_printf(mon, "\n");
qapi_free_MemdevList(memdev_list);
hmp_handle_error(mon, err);
}
void hmp_info_kvm(Monitor *mon, const QDict *qdict)
{
KvmInfo *info;
info = qmp_query_kvm(NULL);
monitor_printf(mon, "kvm support: ");
if (info->present) {
monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
} else {
monitor_printf(mon, "not compiled\n");
}
qapi_free_KvmInfo(info);
}
void hmp_info_uuid(Monitor *mon, const QDict *qdict)
{
UuidInfo *info;
info = qmp_query_uuid(NULL);
monitor_printf(mon, "%s\n", info->UUID);
qapi_free_UuidInfo(info);
}
void hmp_info_balloon(Monitor *mon, const QDict *qdict)
{
BalloonInfo *info;
Error *err = NULL;
info = qmp_query_balloon(&err);
if (hmp_handle_error(mon, err)) {
return;
}
monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
qapi_free_BalloonInfo(info);
}
void hmp_system_reset(Monitor *mon, const QDict *qdict)
{
qmp_system_reset(NULL);
}
void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
{
qmp_system_powerdown(NULL);
}
void hmp_memsave(Monitor *mon, const QDict *qdict)
{
uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val");
Error *err = NULL;
int cpu_index = monitor_get_cpu_index(mon);
if (cpu_index < 0) {
monitor_printf(mon, "No CPU available\n");
return;
}
qmp_memsave(addr, size, filename, true, cpu_index, &err);
hmp_handle_error(mon, err);
}
void hmp_pmemsave(Monitor *mon, const QDict *qdict)
{
uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val");
Error *err = NULL;
qmp_pmemsave(addr, size, filename, &err);
hmp_handle_error(mon, err);
}
void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
qmp_system_wakeup(&err);
hmp_handle_error(mon, err);
}
void hmp_nmi(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
qmp_inject_nmi(&err);
hmp_handle_error(mon, err);
}
void hmp_balloon(Monitor *mon, const QDict *qdict)
{
int64_t value = qdict_get_int(qdict, "value");
Error *err = NULL;
qmp_balloon(value, &err);
hmp_handle_error(mon, err);
}
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
MemoryDeviceInfoList *info;
VirtioPMEMDeviceInfo *vpi;
VirtioMEMDeviceInfo *vmi;
MemoryDeviceInfo *value;
PCDIMMDeviceInfo *di;
SgxEPCDeviceInfo *se;
HvBalloonDeviceInfo *hi;
for (info = info_list; info; info = info->next) {
value = info->value;
if (value) {
switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM:
case MEMORY_DEVICE_INFO_KIND_NVDIMM:
di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
value->u.dimm.data : value->u.nvdimm.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
di->id ? di->id : "");
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
monitor_printf(mon, " node: %" PRId64 "\n", di->node);
monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
monitor_printf(mon, " memdev: %s\n", di->memdev);
monitor_printf(mon, " hotplugged: %s\n",
di->hotplugged ? "true" : "false");
monitor_printf(mon, " hotpluggable: %s\n",
di->hotpluggable ? "true" : "false");
break;
case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
vpi = value->u.virtio_pmem.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
vpi->id ? vpi->id : "");
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size);
monitor_printf(mon, " memdev: %s\n", vpi->memdev);
break;
case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM:
vmi = value->u.virtio_mem.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
vmi->id ? vmi->id : "");
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vmi->memaddr);
monitor_printf(mon, " node: %" PRId64 "\n", vmi->node);
monitor_printf(mon, " requested-size: %" PRIu64 "\n",
vmi->requested_size);
monitor_printf(mon, " size: %" PRIu64 "\n", vmi->size);
monitor_printf(mon, " max-size: %" PRIu64 "\n", vmi->max_size);
monitor_printf(mon, " block-size: %" PRIu64 "\n",
vmi->block_size);
monitor_printf(mon, " memdev: %s\n", vmi->memdev);
break;
case MEMORY_DEVICE_INFO_KIND_SGX_EPC:
se = value->u.sgx_epc.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
se->id ? se->id : "");
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", se->memaddr);
monitor_printf(mon, " size: %" PRIu64 "\n", se->size);
monitor_printf(mon, " node: %" PRId64 "\n", se->node);
monitor_printf(mon, " memdev: %s\n", se->memdev);
break;
case MEMORY_DEVICE_INFO_KIND_HV_BALLOON:
hi = value->u.hv_balloon.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
hi->id ? hi->id : "");
if (hi->has_memaddr) {
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n",
hi->memaddr);
}
monitor_printf(mon, " max-size: %" PRIu64 "\n", hi->max_size);
if (hi->memdev) {
monitor_printf(mon, " memdev: %s\n", hi->memdev);
}
break;
default:
g_assert_not_reached();
}
}
}
qapi_free_MemoryDeviceInfoList(info_list);
hmp_handle_error(mon, err);
}
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
GuidInfo *info = qmp_query_vm_generation_id(&err);
if (info) {
monitor_printf(mon, "%s\n", info->guid);
}
hmp_handle_error(mon, err);
qapi_free_GuidInfo(info);
}
void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemoryInfo *info = qmp_query_memory_size_summary(&err);
if (info) {
monitor_printf(mon, "base memory: %" PRIu64 "\n",
info->base_memory);
if (info->has_plugged_memory) {
monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
info->plugged_memory);
}
qapi_free_MemoryInfo(info);
}
hmp_handle_error(mon, err);
}
|