numa: add check that board supports cpu_index to node mapping

Default node mapping initialization already checks that board
supports cpu_index to node mapping and refuses to start if
it's not supported. Do the same for explicitly provided
mapping "-numa node,cpus=..."

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <1494415802-227633-6-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Igor Mammedov 2017-05-10 13:29:49 +02:00 committed by Eduardo Habkost
parent bd4c1bfe3e
commit 64c2a8f6d3
1 changed files with 10 additions and 3 deletions

13
numa.c
View File

@ -141,10 +141,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
return -1; return -1;
} }
static void parse_numa_node(NumaNodeOptions *node, QemuOpts *opts, Error **errp) static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
QemuOpts *opts, Error **errp)
{ {
uint16_t nodenr; uint16_t nodenr;
uint16List *cpus = NULL; uint16List *cpus = NULL;
MachineClass *mc = MACHINE_GET_CLASS(ms);
if (node->has_nodeid) { if (node->has_nodeid) {
nodenr = node->nodeid; nodenr = node->nodeid;
@ -163,6 +165,10 @@ static void parse_numa_node(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
return; return;
} }
if (!mc->cpu_index_to_instance_props) {
error_report("NUMA is not supported by this machine-type");
exit(1);
}
for (cpus = node->cpus; cpus; cpus = cpus->next) { for (cpus = node->cpus; cpus; cpus = cpus->next) {
if (cpus->value >= max_cpus) { if (cpus->value >= max_cpus) {
error_setg(errp, error_setg(errp,
@ -253,6 +259,7 @@ static void parse_numa_distance(NumaDistOptions *dist, Error **errp)
static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
{ {
NumaOptions *object = NULL; NumaOptions *object = NULL;
MachineState *ms = opaque;
Error *err = NULL; Error *err = NULL;
{ {
@ -267,7 +274,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
switch (object->type) { switch (object->type) {
case NUMA_OPTIONS_TYPE_NODE: case NUMA_OPTIONS_TYPE_NODE:
parse_numa_node(&object->u.node, opts, &err); parse_numa_node(ms, &object->u.node, opts, &err);
if (err) { if (err) {
goto end; goto end;
} }
@ -452,7 +459,7 @@ void parse_numa_opts(MachineState *ms)
numa_info[i].node_cpu = bitmap_new(max_cpus); numa_info[i].node_cpu = bitmap_new(max_cpus);
} }
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) { if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
exit(1); exit(1);
} }