spapr/xive: Simplify error handling in kvmppc_xive_connect()

Now that all these functions return a negative errno on failure, check
that and get rid of the local_err boilerplate.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <159707851537.1489912.1030839306195472651.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Greg Kurz 2020-08-10 18:55:15 +02:00 committed by David Gibson
parent 2a8100cb61
commit 6cdc0e2063

View file

@ -723,12 +723,12 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
{ {
SpaprXive *xive = SPAPR_XIVE(intc); SpaprXive *xive = SPAPR_XIVE(intc);
XiveSource *xsrc = &xive->source; XiveSource *xsrc = &xive->source;
Error *local_err = NULL;
size_t esb_len = xive_source_esb_len(xsrc); size_t esb_len = xive_source_esb_len(xsrc);
size_t tima_len = 4ull << TM_SHIFT; size_t tima_len = 4ull << TM_SHIFT;
CPUState *cs; CPUState *cs;
int fd; int fd;
void *addr; void *addr;
int ret;
/* /*
* The KVM XIVE device already in use. This is the case when * The KVM XIVE device already in use. This is the case when
@ -754,9 +754,10 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
/* Tell KVM about the # of VCPUs we may have */ /* Tell KVM about the # of VCPUs we may have */
if (kvm_device_check_attr(xive->fd, KVM_DEV_XIVE_GRP_CTRL, if (kvm_device_check_attr(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
KVM_DEV_XIVE_NR_SERVERS)) { KVM_DEV_XIVE_NR_SERVERS)) {
if (kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL, ret = kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true, KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true,
&local_err)) { errp);
if (ret < 0) {
goto fail; goto fail;
} }
} }
@ -764,8 +765,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
/* /*
* 1. Source ESB pages - KVM mapping * 1. Source ESB pages - KVM mapping
*/ */
addr = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, addr = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, errp);
&local_err);
if (addr == MAP_FAILED) { if (addr == MAP_FAILED) {
goto fail; goto fail;
} }
@ -783,8 +783,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
/* /*
* 3. TIMA pages - KVM mapping * 3. TIMA pages - KVM mapping
*/ */
addr = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, addr = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, errp);
&local_err);
if (addr == MAP_FAILED) { if (addr == MAP_FAILED) {
goto fail; goto fail;
} }
@ -802,15 +801,15 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
CPU_FOREACH(cs) { CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs); PowerPCCPU *cpu = POWERPC_CPU(cs);
kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err); ret = kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp);
if (local_err) { if (ret < 0) {
goto fail; goto fail;
} }
} }
/* Update the KVM sources */ /* Update the KVM sources */
kvmppc_xive_source_reset(xsrc, &local_err); ret = kvmppc_xive_source_reset(xsrc, errp);
if (local_err) { if (ret < 0) {
goto fail; goto fail;
} }
@ -820,7 +819,6 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
return 0; return 0;
fail: fail:
error_propagate(errp, local_err);
kvmppc_xive_disconnect(intc); kvmppc_xive_disconnect(intc);
return -1; return -1;
} }