On Tue, 9 May 2023 14:44:52 +0800
Yin Wang <yin.wang@intel.com> 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.
>
> Signed-off-by: Yin Wang <yin.wang@intel.com>
> ---
> hw/core/numa.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/core/numa.c b/hw/core/numa.c
> index d8d36b16d8..ff249369be 100644
> --- a/hw/core/numa.c
> +++ b/hw/core/numa.c
> @@ -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