machine: Improve the error reporting of smp parsing
commit52082d3ba4e81bf9df23d3cd5ddfb2a620e9b267
authorYanan Wang <wangyanan55@huawei.com>
Wed, 29 Sep 2021 02:58:06 +0000 (29 10:58 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Oct 2021 13:27:56 +0000 (1 15:27 +0200)
treebad5680e9394f1998f7cad3b6f0744b7582010ce
parent7d8c5a39628820f6927b8b70c8f54872f5d1a196
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>
hw/core/machine.c
hw/i386/pc.c