Merge tag 'pull-la-20220704' of https://gitlab.com/rth7680/qemu into staging
[qemu/rayw.git] / hw / core / machine-hmp-cmds.c
blob5cb5eecbfc9fe83066c702a754a01f97811ee85d
1 /*
2 * HMP commands related to machines and CPUs
4 * Copyright IBM, Corp. 2011
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
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.
16 #include "qemu/osdep.h"
17 #include "monitor/hmp.h"
18 #include "monitor/monitor.h"
19 #include "qapi/error.h"
20 #include "qapi/qapi-builtin-visit.h"
21 #include "qapi/qapi-commands-machine.h"
22 #include "qapi/qmp/qdict.h"
23 #include "qapi/string-output-visitor.h"
24 #include "qemu/error-report.h"
25 #include "sysemu/numa.h"
26 #include "hw/boards.h"
28 void hmp_info_cpus(Monitor *mon, const QDict *qdict)
30 CpuInfoFastList *cpu_list, *cpu;
32 cpu_list = qmp_query_cpus_fast(NULL);
34 for (cpu = cpu_list; cpu; cpu = cpu->next) {
35 int active = ' ';
37 if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) {
38 active = '*';
41 monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
42 cpu->value->cpu_index);
43 monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
46 qapi_free_CpuInfoFastList(cpu_list);
49 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
51 Error *err = NULL;
52 HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err);
53 HotpluggableCPUList *saved = l;
54 CpuInstanceProperties *c;
56 if (hmp_handle_error(mon, err)) {
57 return;
60 monitor_printf(mon, "Hotpluggable CPUs:\n");
61 while (l) {
62 monitor_printf(mon, " type: \"%s\"\n", l->value->type);
63 monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n",
64 l->value->vcpus_count);
65 if (l->value->has_qom_path) {
66 monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path);
69 c = l->value->props;
70 monitor_printf(mon, " CPUInstance Properties:\n");
71 if (c->has_node_id) {
72 monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_id);
74 if (c->has_socket_id) {
75 monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id);
77 if (c->has_die_id) {
78 monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
80 if (c->has_cluster_id) {
81 monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n",
82 c->cluster_id);
84 if (c->has_core_id) {
85 monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
87 if (c->has_thread_id) {
88 monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id);
91 l = l->next;
94 qapi_free_HotpluggableCPUList(saved);
97 void hmp_info_memdev(Monitor *mon, const QDict *qdict)
99 Error *err = NULL;
100 MemdevList *memdev_list = qmp_query_memdev(&err);
101 MemdevList *m = memdev_list;
102 Visitor *v;
103 char *str;
105 while (m) {
106 v = string_output_visitor_new(false, &str);
107 visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
108 monitor_printf(mon, "memory backend: %s\n", m->value->id);
109 monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
110 monitor_printf(mon, " merge: %s\n",
111 m->value->merge ? "true" : "false");
112 monitor_printf(mon, " dump: %s\n",
113 m->value->dump ? "true" : "false");
114 monitor_printf(mon, " prealloc: %s\n",
115 m->value->prealloc ? "true" : "false");
116 monitor_printf(mon, " share: %s\n",
117 m->value->share ? "true" : "false");
118 if (m->value->has_reserve) {
119 monitor_printf(mon, " reserve: %s\n",
120 m->value->reserve ? "true" : "false");
122 monitor_printf(mon, " policy: %s\n",
123 HostMemPolicy_str(m->value->policy));
124 visit_complete(v, &str);
125 monitor_printf(mon, " host nodes: %s\n", str);
127 g_free(str);
128 visit_free(v);
129 m = m->next;
132 monitor_printf(mon, "\n");
134 qapi_free_MemdevList(memdev_list);
135 hmp_handle_error(mon, err);