machine: move common smp_parse code to caller
Most of smp_parse and pc_smp_parse is guarded by an "if (opts)" conditional, and the rest is common to both function. Move the conditional and the common code to the caller, machine_smp_parse. Move the replay_add_blocker call after all errors are checked for. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20210617155308.928754-8-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
67872eb8ed
commit
593d3c5148
@ -741,7 +741,6 @@ void machine_set_cpu_numa_node(MachineState *machine,
|
|||||||
|
|
||||||
static void smp_parse(MachineState *ms, QemuOpts *opts)
|
static void smp_parse(MachineState *ms, QemuOpts *opts)
|
||||||
{
|
{
|
||||||
if (opts) {
|
|
||||||
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
|
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
|
||||||
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
|
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
|
||||||
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
|
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
|
||||||
@ -797,13 +796,6 @@ static void smp_parse(MachineState *ms, QemuOpts *opts)
|
|||||||
ms->smp.sockets = sockets;
|
ms->smp.sockets = sockets;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms->smp.cpus > 1) {
|
|
||||||
Error *blocker = NULL;
|
|
||||||
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
|
|
||||||
replay_add_blocker(blocker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void machine_class_init(ObjectClass *oc, void *data)
|
static void machine_class_init(ObjectClass *oc, void *data)
|
||||||
{
|
{
|
||||||
MachineClass *mc = MACHINE_CLASS(oc);
|
MachineClass *mc = MACHINE_CLASS(oc);
|
||||||
@ -1135,7 +1127,9 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
|
|||||||
{
|
{
|
||||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||||
|
|
||||||
|
if (opts) {
|
||||||
mc->smp_parse(ms, opts);
|
mc->smp_parse(ms, opts);
|
||||||
|
}
|
||||||
|
|
||||||
/* sanity-check smp_cpus and max_cpus against mc */
|
/* sanity-check smp_cpus and max_cpus against mc */
|
||||||
if (ms->smp.cpus < mc->min_cpus) {
|
if (ms->smp.cpus < mc->min_cpus) {
|
||||||
@ -1151,6 +1145,12 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
|
|||||||
mc->name, mc->max_cpus);
|
mc->name, mc->max_cpus);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ms->smp.cpus > 1) {
|
||||||
|
Error *blocker = NULL;
|
||||||
|
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
|
||||||
|
replay_add_blocker(blocker);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
|
|||||||
*/
|
*/
|
||||||
void pc_smp_parse(MachineState *ms, QemuOpts *opts)
|
void pc_smp_parse(MachineState *ms, QemuOpts *opts)
|
||||||
{
|
{
|
||||||
if (opts) {
|
|
||||||
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
|
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
|
||||||
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
|
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
|
||||||
unsigned dies = qemu_opt_get_number(opts, "dies", 1);
|
unsigned dies = qemu_opt_get_number(opts, "dies", 1);
|
||||||
@ -770,13 +769,6 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts)
|
|||||||
ms->smp.dies = dies;
|
ms->smp.dies = dies;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms->smp.cpus > 1) {
|
|
||||||
Error *blocker = NULL;
|
|
||||||
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
|
|
||||||
replay_add_blocker(blocker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void pc_machine_done(Notifier *notifier, void *data)
|
void pc_machine_done(Notifier *notifier, void *data)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user