aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-10-21 06:49:31 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-12-10 12:15:11 -0500
commit3df8c4f31a60101c61d7f49ce0a3635690bed579 (patch)
tree568bf40f3354244a5cac19b2202c2509a409fa08 /hw
parent991c180d740c04c2f8c08c8783ad868fc832589f (diff)
vl: extract validation of -smp to machine.c
Once smp_parse is done, the validation operates on the MachineState. There is no reason for that code to be in vl.c. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/core/machine.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 9c41b94e0d..bd97fc2f1a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1077,6 +1077,29 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
return ret;
}
+bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
+{
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
+
+ mc->smp_parse(ms, opts);
+
+ /* 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);
+ return false;
+ } 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);
+ return false;
+ }
+ return true;
+}
+
void machine_run_board_init(MachineState *machine)
{
MachineClass *machine_class = MACHINE_GET_CLASS(machine);