Fix QEMU crash caused when NUMA nodes exceed available CPUs
PATCH 1/1 Fix QEMU crash caused when NUMA nodes exceed available CPUs
command "qemu-system-riscv64 -machine virt
-m 2G -smp 1 -numa node,mem=1G -numa node,mem=1G" would trigger this problem.
This commit fixes the issue by adding parameter checks.
Signed-off-by Yin Wang <[email protected]>
--- hw/core/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/core/numa.c +7 -0
@@ -168,6 +168,13 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, numa_info[nodenr].present = true; max_numa_nodeid =MAX (max_numa_nodeid, nodenr +1 ); ms->numa_state->num_nodes++; +if (ms->smp.max_cpus < ms->numa_state->num_nodes) { +error_setg (errp, +"Number of NUMA nodes:(%d)" +" is larger than number of CPUs:(%d)" , + ms->numa_state->num_nodes, ms->smp.max_cpus); +return ; + } } static
Signature · 1 line
2.34.1
Quoted 4 lines · On Tue, 9 May 2023 14:44:52 +0800 Yin Wang <[email protected]> wrote:
command "qemu-system-riscv64 -machine virt
-m 2G -smp 1 -numa node,mem=1G -numa node,mem=1G" would trigger this problem.
This commit fixes the issue by adding parameter checks.
It seems wrong to apply this to all targets (that potentially excludes CPU-less nodes in some cases).
PS:
Crash backtrace should be mentioned in commit message.
Quoted 24 lines
Signed-off-by Yin Wang <[email protected]>--- hw/core/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/core/numa.c +7
-0@@ -168,6 +168,13 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, numa_info[nodenr].present = true; max_numa_nodeid =MAX (max_numa_nodeid, nodenr +1 ); ms->numa_state->num_nodes++; +if (ms->smp.max_cpus < ms->numa_state->num_nodes) { +error_setg (errp, +"Number of NUMA nodes:(%d)" +" is larger than number of CPUs:(%d)" , + ms->numa_state->num_nodes, ms->smp.max_cpus); +return ; + } } static