qemu/Fix-smp.cores-value-and-Fix-divide-0-error.patch

44 lines
1.4 KiB
Diff
Raw Normal View History

From 08d0374d80ef321a421d4d9716c05006b469c78f Mon Sep 17 00:00:00 2001
From: lixianglai <lixianglai@loongson.cn>
Date: Wed, 24 May 2023 23:06:51 -0400
Subject: [PATCH] Fix smp.cores value and Fix divide 0 error
The smp.cores should use the default value passed from
qemu start command, and the argument is cores_per_socket.
The variable nb_numa_nodes may be 0, and a division by 0
error will occur later, and special treatment is done for
nb_numa_nodes here.
Signed-off-by: lixianglai <lixianglai@loongson.cn>
---
hw/loongarch/larch_3a.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/loongarch/larch_3a.c b/hw/loongarch/larch_3a.c
index fe786008ac..cef1a6f3d2 100644
--- a/hw/loongarch/larch_3a.c
+++ b/hw/loongarch/larch_3a.c
@@ -1221,7 +1221,6 @@ static void loongarch_build_smbios(LoongarchMachineState *lsms)
uint8_t *smbios_tables, *smbios_anchor;
size_t smbios_tables_len, smbios_anchor_len;
const char *product = "QEMU Virtual Machine";
- ms->smp.cores = 4;
if (!lsms->fw_cfg) {
return;
@@ -2005,6 +2004,10 @@ static int64_t ls3a_get_default_cpu_node_id(const MachineState *ms, int idx)
{
int nb_numa_nodes = ms->numa_state->num_nodes;
int smp_cores = ms->smp.cores;
+
+ if (nb_numa_nodes == 0) {
+ nb_numa_nodes = 1;
+ }
return idx / smp_cores % nb_numa_nodes;
}
--
2.41.0.windows.1