On 9/28/21 05:57, Yanan Wang wrote: > Put both sanity-check of the input SMP configuration and sanity-check > of the output SMP configuration uniformly in the generic parser. Then > machine_set_smp() will become cleaner, also all the invalid scenarios > can be tested only by calling the parser. > > Signed-off-by: Yanan Wang <wangyana...@huawei.com> > Reviewed-by: Andrew Jones <drjo...@redhat.com> > Reviewed-by: Pankaj Gupta <pankaj.gu...@ionos.com> > --- > hw/core/machine.c | 63 +++++++++++++++++++++++------------------------ > 1 file changed, 31 insertions(+), 32 deletions(-) > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index e2a48aa18c..637acd8d42 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -798,6 +798,20 @@ static void smp_parse(MachineState *ms, SMPConfiguration > *config, Error **errp) > unsigned threads = config->has_threads ? config->threads : 0; > unsigned maxcpus = config->has_maxcpus ? config->maxcpus : 0; > > + /* > + * Specified CPU topology parameters must be greater than zero, > + * explicit configuration like "cpus=0" is not allowed. > + */ > + if ((config->has_cpus && config->cpus == 0) || > + (config->has_sockets && config->sockets == 0) || > + (config->has_dies && config->dies == 0) || > + (config->has_cores && config->cores == 0) || > + (config->has_threads && config->threads == 0) || > + (config->has_maxcpus && config->maxcpus == 0)) { > + warn_report("Invalid CPU topology deprecated: "
Maybe: "Deprecated CPU topology: " or "Deprecated CPU topology (considered invalid): " > + "CPU topology parameters must be greater than zero"); > + }