[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/20] spapr: Add a return value to spapr_nvdimm_validate()
From: |
David Gibson |
Subject: |
[PULL 13/20] spapr: Add a return value to spapr_nvdimm_validate() |
Date: |
Fri, 9 Oct 2020 21:19:44 +1100 |
From: Greg Kurz <groug@kaod.org>
As recommended in "qapi/error.h", return true on success and false on
failure. This allows to reduce error propagation overhead in the callers.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200914123505.612812-13-groug@kaod.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 4 +---
hw/ppc/spapr_nvdimm.c | 14 ++++++++------
include/hw/ppc/spapr_nvdimm.h | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index c6af456cfc..7f3a620d41 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3478,9 +3478,7 @@ static void spapr_memory_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
}
if (is_nvdimm) {
- spapr_nvdimm_validate(hotplug_dev, NVDIMM(dev), size, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!spapr_nvdimm_validate(hotplug_dev, NVDIMM(dev), size, errp)) {
return;
}
} else if (size % SPAPR_MEMORY_BLOCK_SIZE) {
diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c
index c06f903e5b..b3a489e9fe 100644
--- a/hw/ppc/spapr_nvdimm.c
+++ b/hw/ppc/spapr_nvdimm.c
@@ -33,7 +33,7 @@
#include "sysemu/sysemu.h"
#include "hw/ppc/spapr_numa.h"
-void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
+bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
uint64_t size, Error **errp)
{
const MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
@@ -45,7 +45,7 @@ void spapr_nvdimm_validate(HotplugHandler *hotplug_dev,
NVDIMMDevice *nvdimm,
if (!mc->nvdimm_supported) {
error_setg(errp, "NVDIMM hotplug not supported for this machine");
- return;
+ return false;
}
/*
@@ -59,20 +59,20 @@ void spapr_nvdimm_validate(HotplugHandler *hotplug_dev,
NVDIMMDevice *nvdimm,
*/
if (!ms->nvdimms_state->is_enabled && nvdimm_opt) {
error_setg(errp, "nvdimm device found but 'nvdimm=off' was set");
- return;
+ return false;
}
if (object_property_get_int(OBJECT(nvdimm), NVDIMM_LABEL_SIZE_PROP,
&error_abort) == 0) {
error_setg(errp, "PAPR requires NVDIMM devices to have label-size
set");
- return;
+ return false;
}
if (size % SPAPR_MINIMUM_SCM_BLOCK_SIZE) {
error_setg(errp, "PAPR requires NVDIMM memory size (excluding label)"
" to be a multiple of %" PRIu64 "MB",
SPAPR_MINIMUM_SCM_BLOCK_SIZE / MiB);
- return;
+ return false;
}
uuidstr = object_property_get_str(OBJECT(nvdimm), NVDIMM_UUID_PROP,
@@ -82,8 +82,10 @@ void spapr_nvdimm_validate(HotplugHandler *hotplug_dev,
NVDIMMDevice *nvdimm,
if (qemu_uuid_is_null(&uuid)) {
error_setg(errp, "NVDIMM device requires the uuid to be set");
- return;
+ return false;
}
+
+ return true;
}
diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h
index 3eb344e8e9..b834d82f55 100644
--- a/include/hw/ppc/spapr_nvdimm.h
+++ b/include/hw/ppc/spapr_nvdimm.h
@@ -28,7 +28,7 @@ QEMU_BUILD_BUG_ON(SPAPR_MINIMUM_SCM_BLOCK_SIZE %
SPAPR_MEMORY_BLOCK_SIZE);
int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
void *fdt, int *fdt_start_offset, Error **errp);
void spapr_dt_persistent_memory(SpaprMachineState *spapr, void *fdt);
-void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
+bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
uint64_t size, Error **errp);
void spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp);
void spapr_create_nvdimm_dr_connectors(SpaprMachineState *spapr);
--
2.26.2
- [PULL 03/20] ppc: Add a return value to ppc_set_compat() and ppc_set_compat_all(), (continued)
- [PULL 03/20] ppc: Add a return value to ppc_set_compat() and ppc_set_compat_all(), David Gibson, 2020/10/09
- [PULL 02/20] spapr: Fix error leak in spapr_realize_vcpu(), David Gibson, 2020/10/09
- [PULL 05/20] spapr: Simplify error handling in callers of ppc_set_compat(), David Gibson, 2020/10/09
- [PULL 06/20] spapr: Get rid of cas_check_pvr() error reporting, David Gibson, 2020/10/09
- [PULL 08/20] spapr: Simplify error handling in spapr_vio_busdev_realize(), David Gibson, 2020/10/09
- [PULL 10/20] spapr: Simplify error handling in prop_get_fdt(), David Gibson, 2020/10/09
- [PULL 20/20] specs/ppc-spapr-numa: update with new NUMA support, David Gibson, 2020/10/09
- [PULL 18/20] spapr_numa: change reference-points and maxdomain settings, David Gibson, 2020/10/09
- [PULL 07/20] spapr: Simplify error handling in do_client_architecture_support(), David Gibson, 2020/10/09
- [PULL 09/20] spapr: Add a return value to spapr_drc_attach(), David Gibson, 2020/10/09
- [PULL 13/20] spapr: Add a return value to spapr_nvdimm_validate(),
David Gibson <=
- [PULL 11/20] spapr: Add a return value to spapr_set_vcpu_id(), David Gibson, 2020/10/09
- [PULL 16/20] spapr: add spapr_machine_using_legacy_numa() helper, David Gibson, 2020/10/09
- [PULL 17/20] spapr_numa: forbid asymmetrical NUMA setups, David Gibson, 2020/10/09
- [PULL 12/20] spapr: Simplify error handling in spapr_cpu_core_realize(), David Gibson, 2020/10/09
- [PULL 14/20] spapr: Add a return value to spapr_check_pagesize(), David Gibson, 2020/10/09
- [PULL 15/20] ppc/pnv: Increase max firmware size, David Gibson, 2020/10/09
- [PULL 19/20] spapr_numa: consider user input when defining associativity, David Gibson, 2020/10/09
- Re: [PULL 00/20] ppc-for-5.2 queue 20201009, Peter Maydell, 2020/10/09