[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 37/40] machine: add smp compound property
From: |
Peter Maydell |
Subject: |
Re: [PULL 37/40] machine: add smp compound property |
Date: |
Tue, 13 Jul 2021 11:53:00 +0100 |
On Tue, 6 Jul 2021 at 11:39, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Make -smp syntactic sugar for a compound property "-machine
> smp.{cores,threads,cpu,...}". machine_smp_parse is replaced by the
> setter for the property.
>
> numa-test will now cover the new syntax, while other tests
> still use -smp.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Hi; Coverity reports a bug in this function (CID 1458083):
> +static void machine_set_smp(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + MachineClass *mc = MACHINE_GET_CLASS(obj);
> + MachineState *ms = MACHINE(obj);
> + SMPConfiguration *config;
> + ERRP_GUARD();
ERRP_GUARD() ensures that 'errp' is never NULL...
> +
> + if (!visit_type_SMPConfiguration(v, name, &config, errp)) {
> + return;
> + }
> +
> + mc->smp_parse(ms, config, errp);
> + if (errp) {
> + goto out_free;
...so this condition is always true, and we always take the goto...
> + }
...and the sanity-checks below here are dead code.
> +
> + /* sanity-check smp_cpus and max_cpus against mc */
> + if (ms->smp.cpus < mc->min_cpus) {
> + error_setg(errp, "Invalid SMP CPUs %d. The min CPUs "
> + "supported by machine '%s' is %d",
> + ms->smp.cpus,
> + mc->name, mc->min_cpus);
> + } else if (ms->smp.max_cpus > mc->max_cpus) {
> + error_setg(errp, "Invalid SMP CPUs %d. The max CPUs "
> + "supported by machine '%s' is %d",
> + current_machine->smp.max_cpus,
> + mc->name, mc->max_cpus);
> + }
> +
> +out_free:
> + qapi_free_SMPConfiguration(config);
> +}
With ERRP_GUARD(), the test you want for "is there an error?"
is "if (*errp) {..."
thanks
-- PMM
- Re: [PULL 36/40] vl: switch -M parsing to keyval, (continued)
[PULL 38/40] qemu-option: remove now-dead code, Paolo Bonzini, 2021/07/06
[PULL 37/40] machine: add smp compound property, Paolo Bonzini, 2021/07/06
[PULL 32/40] configure: convert compiler tests to meson, part 6, Paolo Bonzini, 2021/07/06
[PULL 39/40] Set icon for QEMU binary on Mac OS, Paolo Bonzini, 2021/07/06
Re: [PULL 00/40] Misc patches for 2021-07-06, Peter Maydell, 2021/07/06