summaryrefslogtreecommitdiffstats
path: root/qemu/numa.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/numa.c')
-rw-r--r--qemu/numa.c104
1 files changed, 29 insertions, 75 deletions
diff --git a/qemu/numa.c b/qemu/numa.c
index 402804bdf..572712ccf 100644
--- a/qemu/numa.c
+++ b/qemu/numa.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include "qemu/osdep.h"
#include "sysemu/numa.h"
#include "exec/cpu-common.h"
#include "qemu/bitmap.h"
@@ -30,7 +31,6 @@
#include "include/exec/cpu-common.h" /* for RAM_ADDR_FMT */
#include "qapi-visit.h"
#include "qapi/opts-visitor.h"
-#include "qapi/dealloc-visitor.h"
#include "hw/boards.h"
#include "sysemu/hostmem.h"
#include "qmp-commands.h"
@@ -218,7 +218,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
{
OptsVisitor *ov = opts_visitor_new(opts);
- visit_type_NumaOptions(opts_get_visitor(ov), &object, NULL, &err);
+ visit_type_NumaOptions(opts_get_visitor(ov), NULL, &object, &err);
opts_visitor_cleanup(ov);
}
@@ -226,9 +226,9 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
goto error;
}
- switch (object->kind) {
+ switch (object->type) {
case NUMA_OPTIONS_KIND_NODE:
- numa_node_parse(object->node, opts, &err);
+ numa_node_parse(object->u.node.data, opts, &err);
if (err) {
goto error;
}
@@ -242,13 +242,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
error:
error_report_err(err);
-
- if (object) {
- QapiDeallocVisitor *dv = qapi_dealloc_visitor_new();
- visit_type_NumaOptions(qapi_dealloc_get_visitor(dv),
- &object, NULL, NULL);
- qapi_dealloc_visitor_cleanup(dv);
- }
+ qapi_free_NumaOptions(object);
return -1;
}
@@ -280,7 +274,7 @@ static void validate_numa_cpus(void)
bitmap_and(seen_cpus, seen_cpus,
numa_info[i].node_cpu, MAX_CPUMASK_BITS);
error_report("CPU(s) present in multiple NUMA nodes: %s",
- enumerate_cpus(seen_cpus, max_cpus));;
+ enumerate_cpus(seen_cpus, max_cpus));
exit(EXIT_FAILURE);
}
bitmap_or(seen_cpus, seen_cpus,
@@ -418,20 +412,23 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
Error *err = NULL;
memory_region_init_ram_from_file(mr, owner, name, ram_size, false,
mem_path, &err);
-
- /* Legacy behavior: if allocation failed, fall back to
- * regular RAM allocation.
- */
if (err) {
error_report_err(err);
- memory_region_init_ram(mr, owner, name, ram_size, &error_abort);
+ if (mem_prealloc) {
+ exit(1);
+ }
+
+ /* Legacy behavior: if allocation failed, fall back to
+ * regular RAM allocation.
+ */
+ memory_region_init_ram(mr, owner, name, ram_size, &error_fatal);
}
#else
fprintf(stderr, "-mem-path not supported on this host\n");
exit(1);
#endif
} else {
- memory_region_init_ram(mr, owner, name, ram_size, &error_abort);
+ memory_region_init_ram(mr, owner, name, ram_size, &error_fatal);
}
vmstate_register_ram_global(mr);
}
@@ -450,17 +447,13 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
memory_region_init(mr, owner, name, ram_size);
for (i = 0; i < MAX_NODES; i++) {
- Error *local_err = NULL;
uint64_t size = numa_info[i].node_mem;
HostMemoryBackend *backend = numa_info[i].node_memdev;
if (!backend) {
continue;
}
- MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err);
- if (local_err) {
- error_report_err(local_err);
- exit(1);
- }
+ MemoryRegion *seg = host_memory_backend_get_memory(backend,
+ &error_fatal);
if (memory_region_is_mapped(seg)) {
char *path = object_get_canonical_path_component(OBJECT(backend));
@@ -487,9 +480,9 @@ static void numa_stat_memory_devices(uint64_t node_mem[])
MemoryDeviceInfo *value = info->value;
if (value) {
- switch (value->kind) {
+ switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM:
- node_mem[value->dimm->node] += value->dimm->size;
+ node_mem[value->u.dimm.data->node] += value->u.dimm.data->size;
break;
default:
break;
@@ -517,7 +510,6 @@ static int query_memdev(Object *obj, void *opaque)
{
MemdevList **list = opaque;
MemdevList *m = NULL;
- Error *err = NULL;
if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
m = g_malloc0(sizeof(*m));
@@ -525,72 +517,34 @@ static int query_memdev(Object *obj, void *opaque)
m->value = g_malloc0(sizeof(*m->value));
m->value->size = object_property_get_int(obj, "size",
- &err);
- if (err) {
- goto error;
- }
-
+ &error_abort);
m->value->merge = object_property_get_bool(obj, "merge",
- &err);
- if (err) {
- goto error;
- }
-
+ &error_abort);
m->value->dump = object_property_get_bool(obj, "dump",
- &err);
- if (err) {
- goto error;
- }
-
+ &error_abort);
m->value->prealloc = object_property_get_bool(obj,
- "prealloc", &err);
- if (err) {
- goto error;
- }
-
+ "prealloc",
+ &error_abort);
m->value->policy = object_property_get_enum(obj,
"policy",
"HostMemPolicy",
- &err);
- if (err) {
- goto error;
- }
-
+ &error_abort);
object_property_get_uint16List(obj, "host-nodes",
- &m->value->host_nodes, &err);
- if (err) {
- goto error;
- }
+ &m->value->host_nodes,
+ &error_abort);
m->next = *list;
*list = m;
}
return 0;
-error:
- g_free(m->value);
- g_free(m);
-
- return -1;
}
MemdevList *qmp_query_memdev(Error **errp)
{
- Object *obj;
+ Object *obj = object_get_objects_root();
MemdevList *list = NULL;
- obj = object_get_objects_root();
- if (obj == NULL) {
- return NULL;
- }
-
- if (object_child_foreach(obj, query_memdev, &list) != 0) {
- goto error;
- }
-
+ object_child_foreach(obj, query_memdev, &list);
return list;
-
-error:
- qapi_free_MemdevList(list);
- return NULL;
}