aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/core/machine.c23
-rw-r--r--include/hw/boards.h1
-rw-r--r--softmmu/vl.c20
3 files changed, 26 insertions, 18 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);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index f94f4ad5d8..3a1968d035 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -26,6 +26,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE)
extern MachineState *current_machine;
void machine_run_board_init(MachineState *machine);
+bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp);
bool machine_usb(MachineState *machine);
int machine_phandle_start(MachineState *machine);
bool machine_dump_guest_core(MachineState *machine);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3819a4abf2..69d54b27b9 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3976,24 +3976,8 @@ void qemu_init(int argc, char **argv, char **envp)
exit(0);
}
- machine_class->smp_parse(current_machine,
- qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
-
- /* sanity-check smp_cpus and max_cpus against machine_class */
- if (current_machine->smp.cpus < machine_class->min_cpus) {
- error_report("Invalid SMP CPUs %d. The min CPUs "
- "supported by machine '%s' is %d",
- current_machine->smp.cpus,
- machine_class->name, machine_class->min_cpus);
- exit(1);
- }
- if (current_machine->smp.max_cpus > machine_class->max_cpus) {
- error_report("Invalid SMP CPUs %d. The max CPUs "
- "supported by machine '%s' is %d",
- current_machine->smp.max_cpus,
- machine_class->name, machine_class->max_cpus);
- exit(1);
- }
+ machine_smp_parse(current_machine,
+ qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal);
if (mem_prealloc) {
char *val;