OSDN Git Service

machine: Set the value of cpus to match maxcpus if it's omitted
authorYanan Wang <wangyanan55@huawei.com>
Wed, 29 Sep 2021 02:58:05 +0000 (10:58 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Oct 2021 13:27:56 +0000 (15:27 +0200)
commit7d8c5a39628820f6927b8b70c8f54872f5d1a196
tree0e2713d9bb3fc3c2e49f852c52c039aed0b7819c
parent9a52b508061163df4dae05e708cd2a9cd790ad04
machine: Set the value of cpus to match maxcpus if it's omitted

Currently we directly calculate the omitted cpus based on the given
incomplete collection of parameters. This makes some cmdlines like:
  -smp maxcpus=16
  -smp sockets=2,maxcpus=16
  -smp sockets=2,dies=2,maxcpus=16
  -smp sockets=2,cores=4,maxcpus=16
not work. We should probably set the value of cpus to match maxcpus
if it's omitted, which will make above configs start to work.

So the calculation logic of cpus/maxcpus after this patch will be:
When both maxcpus and cpus are omitted, maxcpus will be calculated
from the given parameters and cpus will be set equal to maxcpus.
When only one of maxcpus and cpus is given then the omitted one
will be set to its counterpart's value. Both maxcpus and cpus may
be specified, but maxcpus must be equal to or greater than cpus.

Note: change in this patch won't affect any existing working cmdlines
but allows more incomplete configs to be valid.

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-6-wangyanan55@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/core/machine.c
hw/i386/pc.c
qemu-options.hx