[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 052/113] vl: extract validation of -smp to machine.c
From: |
Paolo Bonzini |
Subject: |
[PULL 052/113] vl: extract validation of -smp to machine.c |
Date: |
Wed, 2 Dec 2020 03:07:48 -0500 |
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>
---
hw/core/machine.c | 23 +++++++++++++++++++++++
include/hw/boards.h | 1 +
softmmu/vl.c | 20 ++------------------
3 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d0408049b5..cd298fac13 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1074,6 +1074,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 a49e3a6b44..4537cfb5c6 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;
--
2.26.2
- [PULL 033/113] sparc: remove bios_name, (continued)
- [PULL 033/113] sparc: remove bios_name, Paolo Bonzini, 2020/12/02
- [PULL 041/113] microblaze: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 043/113] moxie: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 042/113] mips: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 046/113] riscv: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 045/113] ppc: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 049/113] make ram_size local to vl.c, Paolo Bonzini, 2020/12/02
- [PULL 053/113] vl: remove bogus check, Paolo Bonzini, 2020/12/02
- [PULL 044/113] nios2: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 048/113] sparc64: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 052/113] vl: extract validation of -smp to machine.c,
Paolo Bonzini <=
- [PULL 063/113] vl: load plugins as late as possible, Paolo Bonzini, 2020/12/02
- [PULL 054/113] vl: split various early command line options to a separate function, Paolo Bonzini, 2020/12/02
- [PULL 058/113] vl: extract various command line validation snippets to a new function, Paolo Bonzini, 2020/12/02
- [PULL 039/113] i386: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 047/113] s390x: do not use ram_size global, Paolo Bonzini, 2020/12/02
- [PULL 055/113] vl: move various initialization routines out of qemu_init, Paolo Bonzini, 2020/12/02
- [PULL 062/113] vl: create "-net nic -net user" default earlier, Paolo Bonzini, 2020/12/02
- [PULL 057/113] vl: move prelaunch part of qemu_init to new functions, Paolo Bonzini, 2020/12/02
- [PULL 059/113] vl: preconfig and loadvm are mutually exclusive, Paolo Bonzini, 2020/12/02
- [PULL 050/113] hw/char/serial: Clean up unnecessary code, Paolo Bonzini, 2020/12/02