aboutsummaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-06-17 17:53:05 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-06-25 16:13:50 +0200
commitabc2f51144242e819fd7af69d3e7c199cc9d7004 (patch)
tree25e547677cbc4c8e93dcbcc43d2bf729dfa91381 /hw/core
parent593d3c51481bc40433474bd2b922217e819f1f68 (diff)
downloadqemu-abc2f51144242e819fd7af69d3e7c199cc9d7004.zip
qemu-abc2f51144242e819fd7af69d3e7c199cc9d7004.tar.gz
qemu-abc2f51144242e819fd7af69d3e7c199cc9d7004.tar.bz2
machine: add error propagation to mc->smp_parse
Clean up the smp_parse functions to use Error** instead of exiting. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20210617155308.928754-9-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/machine.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 1016ec9..5a9c97c 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -739,7 +739,7 @@ void machine_set_cpu_numa_node(MachineState *machine,
}
}
-static void smp_parse(MachineState *ms, QemuOpts *opts)
+static void smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
{
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
@@ -766,28 +766,28 @@ static void smp_parse(MachineState *ms, QemuOpts *opts)
threads = cpus / (cores * sockets);
threads = threads > 0 ? threads : 1;
} else if (sockets * cores * threads < cpus) {
- error_report("cpu topology: "
- "sockets (%u) * cores (%u) * threads (%u) < "
- "smp_cpus (%u)",
- sockets, cores, threads, cpus);
- exit(1);
+ error_setg(errp, "cpu topology: "
+ "sockets (%u) * cores (%u) * threads (%u) < "
+ "smp_cpus (%u)",
+ sockets, cores, threads, cpus);
+ return;
}
ms->smp.max_cpus =
qemu_opt_get_number(opts, "maxcpus", cpus);
if (ms->smp.max_cpus < cpus) {
- error_report("maxcpus must be equal to or greater than smp");
- exit(1);
+ error_setg(errp, "maxcpus must be equal to or greater than smp");
+ return;
}
if (sockets * cores * threads != ms->smp.max_cpus) {
- error_report("Invalid CPU topology: "
- "sockets (%u) * cores (%u) * threads (%u) "
- "!= maxcpus (%u)",
- sockets, cores, threads,
- ms->smp.max_cpus);
- exit(1);
+ error_setg(errp, "Invalid CPU topology: "
+ "sockets (%u) * cores (%u) * threads (%u) "
+ "!= maxcpus (%u)",
+ sockets, cores, threads,
+ ms->smp.max_cpus);
+ return;
}
ms->smp.cpus = cpus;
@@ -1126,9 +1126,13 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
+ ERRP_GUARD();
if (opts) {
- mc->smp_parse(ms, opts);
+ mc->smp_parse(ms, opts, errp);
+ if (*errp) {
+ return false;
+ }
}
/* sanity-check smp_cpus and max_cpus against mc */