2019-06-19 23:10:44 +03:00
|
|
|
/*
|
|
|
|
* 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 "qapi/qmp/qdict.h"
|
|
|
|
#include "qapi/string-output-visitor.h"
|
|
|
|
#include "qemu/error-report.h"
|
|
|
|
#include "sysemu/numa.h"
|
2019-08-09 09:57:22 +03:00
|
|
|
#include "hw/boards.h"
|
2019-06-19 23:10:44 +03:00
|
|
|
|
|
|
|
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 = ' ';
|
|
|
|
|
2020-10-05 18:58:43 +03:00
|
|
|
if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) {
|
2019-06-19 23:10:44 +03:00
|
|
|
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 (err != NULL) {
|
2019-12-05 20:46:18 +03:00
|
|
|
hmp_handle_error(mon, err);
|
2019-06-19 23:10:44 +03:00
|
|
|
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->has_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_socket_id) {
|
|
|
|
monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
|
|
|
|
}
|
2019-06-12 11:40:58 +03:00
|
|
|
if (c->has_die_id) {
|
|
|
|
monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
|
|
|
|
}
|
2019-06-19 23:10:44 +03:00
|
|
|
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);
|
2020-04-24 11:43:35 +03:00
|
|
|
visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
|
2019-06-19 23:10:44 +03:00
|
|
|
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");
|
2021-05-10 14:43:26 +03:00
|
|
|
monitor_printf(mon, " share: %s\n",
|
|
|
|
m->value->share ? "true" : "false");
|
2019-06-19 23:10:44 +03:00
|
|
|
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);
|
2019-12-05 20:46:18 +03:00
|
|
|
hmp_handle_error(mon, err);
|
2019-06-19 23:10:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void hmp_info_numa(Monitor *mon, const QDict *qdict)
|
|
|
|
{
|
2019-08-09 09:57:22 +03:00
|
|
|
int i, nb_numa_nodes;
|
2019-06-19 23:10:44 +03:00
|
|
|
NumaNodeMem *node_mem;
|
2021-02-22 15:54:55 +03:00
|
|
|
CpuInfoFastList *cpu_list, *cpu;
|
2019-08-09 09:57:22 +03:00
|
|
|
MachineState *ms = MACHINE(qdev_get_machine());
|
|
|
|
|
|
|
|
nb_numa_nodes = ms->numa_state ? ms->numa_state->num_nodes : 0;
|
|
|
|
monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
|
|
|
|
if (!nb_numa_nodes) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-19 23:10:44 +03:00
|
|
|
|
2021-02-22 15:54:55 +03:00
|
|
|
cpu_list = qmp_query_cpus_fast(&error_abort);
|
2019-06-19 23:10:44 +03:00
|
|
|
node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
|
|
|
|
|
2019-08-09 09:57:22 +03:00
|
|
|
query_numa_node_mem(node_mem, ms);
|
2019-06-19 23:10:44 +03:00
|
|
|
for (i = 0; i < nb_numa_nodes; i++) {
|
|
|
|
monitor_printf(mon, "node %d cpus:", i);
|
|
|
|
for (cpu = cpu_list; cpu; cpu = cpu->next) {
|
|
|
|
if (cpu->value->has_props && cpu->value->props->has_node_id &&
|
|
|
|
cpu->value->props->node_id == i) {
|
2021-02-22 15:54:55 +03:00
|
|
|
monitor_printf(mon, " %" PRIi64, cpu->value->cpu_index);
|
2019-06-19 23:10:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
monitor_printf(mon, "\n");
|
|
|
|
monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
|
|
|
|
node_mem[i].node_mem >> 20);
|
|
|
|
monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i,
|
|
|
|
node_mem[i].node_plugged_mem >> 20);
|
|
|
|
}
|
2021-02-22 15:54:55 +03:00
|
|
|
qapi_free_CpuInfoFastList(cpu_list);
|
2019-06-19 23:10:44 +03:00
|
|
|
g_free(node_mem);
|
|
|
|
}
|