The aim of this patch is to move existing numa global have_numa_distance into NumaState.
Suggested-by: Igor Mammedov <imamm...@redhat.com> Suggested-by: Eduardo Habkost <ehabk...@redhat.com> Signed-off-by: Tao Xu <tao3...@intel.com> --- hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 1 + hw/i386/acpi-build.c | 2 +- include/hw/boards.h | 3 +++ include/sysemu/numa.h | 2 -- numa.c | 7 +++++-- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f9b72333a9..2a6dab6706 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -784,6 +784,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) GArray *tables_blob = tables->table_data; MachineState *ms = MACHINE(vms); int nb_numa_nodes = ms->numa_state->nb_numa_nodes; + bool have_numa_distance = ms->numa_state->have_numa_distance; table_offsets = g_array_new(false, true /* clear */, sizeof(uint32_t)); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 430189af1a..8a07f0442f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -197,6 +197,7 @@ static void create_fdt(VirtMachineState *vms) { MachineState *ms = MACHINE(vms); int nb_numa_nodes = ms->numa_state->nb_numa_nodes; + bool have_numa_distance = ms->numa_state->have_numa_distance; void *fdt = create_device_tree(&vms->fdt_size); if (!fdt) { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 416da318ae..d092eafd19 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2685,7 +2685,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); - if (have_numa_distance) { + if (machine->numa_state->have_numa_distance) { acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker); } diff --git a/include/hw/boards.h b/include/hw/boards.h index 2d4536b1a0..cd7fe0f933 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -235,6 +235,9 @@ typedef struct DeviceMemoryState { typedef struct NumaState { /* Number of NUMA nodes */ int nb_numa_nodes; + + /* Allow setting NUMA distance for different NUMA nodes */ + bool have_numa_distance; } NumaState; /** diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 6c753f9ccf..0d3920767a 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -6,8 +6,6 @@ #include "sysemu/hostmem.h" #include "hw/boards.h" -extern bool have_numa_distance; - struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; diff --git a/numa.c b/numa.c index ff40f6f04f..a6d9951145 100644 --- a/numa.c +++ b/numa.c @@ -52,7 +52,7 @@ static int have_memdevs = -1; static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. * For all nodes, nodeid < max_numa_nodeid */ -bool have_numa_distance; + NodeInfo numa_info[MAX_NODES]; @@ -143,6 +143,8 @@ static void parse_numa_distance(NumaDistOptions *dist, Error **errp) uint16_t src = dist->src; uint16_t dst = dist->dst; uint8_t val = dist->val; + MachineState *ms = MACHINE(qdev_get_machine()); + if (src >= MAX_NODES || dst >= MAX_NODES) { error_setg(errp, "Parameter '%s' expects an integer between 0 and %d", @@ -170,7 +172,7 @@ static void parse_numa_distance(NumaDistOptions *dist, Error **errp) } numa_info[src].distance[dst] = val; - have_numa_distance = true; + ms->numa_state->have_numa_distance = true; } static @@ -359,6 +361,7 @@ void numa_complete_configuration(MachineState *ms) int i; MachineClass *mc = MACHINE_GET_CLASS(ms); int nb_numa_nodes = ms->numa_state->nb_numa_nodes; + bool have_numa_distance = ms->numa_state->have_numa_distance; /* * If memory hotplug is enabled (slots > 0) but without '-numa' -- 2.17.1