Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * HMP commands related to machines and CPUs |
| 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 | * |
| 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. |
| 14 | */ |
| 15 | |
| 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" |
Tao Xu | aa57020 | 2019-08-09 14:57:22 +0800 | [diff] [blame] | 26 | #include "hw/boards.h" |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 27 | |
| 28 | void hmp_info_cpus(Monitor *mon, const QDict *qdict) |
| 29 | { |
| 30 | CpuInfoFastList *cpu_list, *cpu; |
| 31 | |
| 32 | cpu_list = qmp_query_cpus_fast(NULL); |
| 33 | |
| 34 | for (cpu = cpu_list; cpu; cpu = cpu->next) { |
| 35 | int active = ' '; |
| 36 | |
Kevin Wolf | 87e6f4a | 2020-10-05 17:58:43 +0200 | [diff] [blame] | 37 | if (cpu->value->cpu_index == monitor_get_cpu_index(mon)) { |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 38 | active = '*'; |
| 39 | } |
| 40 | |
| 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); |
| 44 | } |
| 45 | |
| 46 | qapi_free_CpuInfoFastList(cpu_list); |
| 47 | } |
| 48 | |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 49 | void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) |
| 50 | { |
| 51 | Error *err = NULL; |
| 52 | HotpluggableCPUList *l = qmp_query_hotpluggable_cpus(&err); |
| 53 | HotpluggableCPUList *saved = l; |
| 54 | CpuInstanceProperties *c; |
| 55 | |
Daniel P. Berrangé | 0ca117a | 2021-10-28 16:18:25 +0100 | [diff] [blame] | 56 | if (hmp_handle_error(mon, err)) { |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 57 | return; |
| 58 | } |
| 59 | |
| 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); |
| 67 | } |
| 68 | |
| 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); |
| 73 | } |
| 74 | if (c->has_socket_id) { |
| 75 | monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->socket_id); |
| 76 | } |
Like Xu | 176d2cd | 2019-06-12 16:40:58 +0800 | [diff] [blame] | 77 | if (c->has_die_id) { |
| 78 | monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id); |
| 79 | } |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 80 | if (c->has_core_id) { |
| 81 | monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); |
| 82 | } |
| 83 | if (c->has_thread_id) { |
| 84 | monitor_printf(mon, " thread-id: \"%" PRIu64 "\"\n", c->thread_id); |
| 85 | } |
| 86 | |
| 87 | l = l->next; |
| 88 | } |
| 89 | |
| 90 | qapi_free_HotpluggableCPUList(saved); |
| 91 | } |
| 92 | |
| 93 | void hmp_info_memdev(Monitor *mon, const QDict *qdict) |
| 94 | { |
| 95 | Error *err = NULL; |
| 96 | MemdevList *memdev_list = qmp_query_memdev(&err); |
| 97 | MemdevList *m = memdev_list; |
| 98 | Visitor *v; |
| 99 | char *str; |
| 100 | |
| 101 | while (m) { |
| 102 | v = string_output_visitor_new(false, &str); |
Markus Armbruster | 1f58424 | 2020-04-24 10:43:35 +0200 | [diff] [blame] | 103 | visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort); |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 104 | monitor_printf(mon, "memory backend: %s\n", m->value->id); |
| 105 | monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); |
| 106 | monitor_printf(mon, " merge: %s\n", |
| 107 | m->value->merge ? "true" : "false"); |
| 108 | monitor_printf(mon, " dump: %s\n", |
| 109 | m->value->dump ? "true" : "false"); |
| 110 | monitor_printf(mon, " prealloc: %s\n", |
| 111 | m->value->prealloc ? "true" : "false"); |
David Hildenbrand | 7428e7b | 2021-05-10 13:43:26 +0200 | [diff] [blame] | 112 | monitor_printf(mon, " share: %s\n", |
| 113 | m->value->share ? "true" : "false"); |
David Hildenbrand | baa014e | 2021-05-10 13:43:28 +0200 | [diff] [blame] | 114 | if (m->value->has_reserve) { |
| 115 | monitor_printf(mon, " reserve: %s\n", |
| 116 | m->value->reserve ? "true" : "false"); |
| 117 | } |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 118 | monitor_printf(mon, " policy: %s\n", |
| 119 | HostMemPolicy_str(m->value->policy)); |
| 120 | visit_complete(v, &str); |
| 121 | monitor_printf(mon, " host nodes: %s\n", str); |
| 122 | |
| 123 | g_free(str); |
| 124 | visit_free(v); |
| 125 | m = m->next; |
| 126 | } |
| 127 | |
| 128 | monitor_printf(mon, "\n"); |
| 129 | |
| 130 | qapi_free_MemdevList(memdev_list); |
Vladimir Sementsov-Ogievskiy | 187c614 | 2019-12-05 20:46:18 +0300 | [diff] [blame] | 131 | hmp_handle_error(mon, err); |
Markus Armbruster | 55225c8 | 2019-06-19 22:10:44 +0200 | [diff] [blame] | 132 | } |