summaryrefslogtreecommitdiffstats
path: root/hw/i386/pc.c
diff options
context:
space:
mode:
authorYanan Wang2021-09-29 04:58:06 +0200
committerPaolo Bonzini2021-10-01 15:27:56 +0200
commit52082d3ba4e81bf9df23d3cd5ddfb2a620e9b267 (patch)
treebad5680e9394f1998f7cad3b6f0744b7582010ce /hw/i386/pc.c
parentmachine: Set the value of cpus to match maxcpus if it's omitted (diff)
downloadqemu-52082d3ba4e81bf9df23d3cd5ddfb2a620e9b267.tar.gz
qemu-52082d3ba4e81bf9df23d3cd5ddfb2a620e9b267.tar.xz
qemu-52082d3ba4e81bf9df23d3cd5ddfb2a620e9b267.zip
machine: Improve the error reporting of smp parsing
We have two requirements for a valid SMP configuration: the product of "sockets * cores * threads" must represent all the possible cpus, i.e., max_cpus, and then must include the initially present cpus, i.e., smp_cpus. So we only need to ensure 1) "sockets * cores * threads == maxcpus" at first and then ensure 2) "maxcpus >= cpus". With a reasonable order of the sanity check, we can simplify the error reporting code. When reporting an error message we also report the exact value of each topology member to make users easily see what's going on. Signed-off-by: Yanan Wang <wangyanan55@huawei.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210929025816.21076-7-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r--hw/i386/pc.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f24a1d72ad..9216ad163d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -749,25 +749,21 @@ static void pc_smp_parse(MachineState *ms, SMPConfiguration *config, Error **err
maxcpus = maxcpus > 0 ? maxcpus : sockets * dies * cores * threads;
cpus = cpus > 0 ? cpus : maxcpus;
- if (sockets * dies * cores * threads < cpus) {
- error_setg(errp, "cpu topology: "
- "sockets (%u) * dies (%u) * cores (%u) * threads (%u) < "
- "smp_cpus (%u)",
- sockets, dies, cores, threads, cpus);
+ if (sockets * dies * cores * threads != maxcpus) {
+ error_setg(errp, "Invalid CPU topology: "
+ "product of the hierarchy must match maxcpus: "
+ "sockets (%u) * dies (%u) * cores (%u) * threads (%u) "
+ "!= maxcpus (%u)",
+ sockets, dies, cores, threads, maxcpus);
return;
}
if (maxcpus < cpus) {
- error_setg(errp, "maxcpus must be equal to or greater than smp");
- return;
- }
-
- if (sockets * dies * cores * threads != maxcpus) {
- error_setg(errp, "Invalid CPU topology deprecated: "
+ error_setg(errp, "Invalid CPU topology: "
+ "maxcpus must be equal to or greater than smp: "
"sockets (%u) * dies (%u) * cores (%u) * threads (%u) "
- "!= maxcpus (%u)",
- sockets, dies, cores, threads,
- maxcpus);
+ "== maxcpus (%u) < smp_cpus (%u)",
+ sockets, dies, cores, threads, maxcpus, cpus);
return;
}