machine: Minor refactor/fix for the smp parsers
authorYanan Wang <wangyanan55@huawei.com>
Wed, 29 Sep 2021 02:58:03 +0000 (10:58 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Oct 2021 13:27:56 +0000 (15:27 +0200)
commit5d8b5a505571b7927095015c805646f78fc56578
tree2b2ff9cb3780cb5b99e54e1ba7a297c823d8bf71
parentc2511b1632e109130df524121dfb7d2413216d3c
machine: Minor refactor/fix for the smp parsers

To pave the way for the functional improvement in later patches,
make some refactor/cleanup for the smp parsers, including using
local maxcpus instead of ms->smp.max_cpus in the calculation,
defaulting dies to 0 initially like other members, cleanup the
sanity check for dies.

We actually also fix a hidden defect by avoiding directly using
the provided *zero value* in the calculation, which could cause
a segment fault (e.g. using dies=0 in the calculation).

Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20210929025816.21076-4-wangyanan55@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/core/machine.c
hw/i386/pc.c