Received: from eggs.gnu.org ([2001:4830:134:3::10]:41466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDr7g-00061r-Ag for qemu-devel@nongnu.org; Wed, 21 Jan 2015 03:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDr7c-0005IP-5F for qemu-devel@nongnu.org; Wed, 21 Jan 2015 03:58:48 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:42613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDr7b-0005IB-HU for qemu-devel@nongnu.org; Wed, 21 Jan 2015 03:58:44 -0500 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Jan 2015 18:58:36 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 985B42BB003F for ; Wed, 21 Jan 2015 19:58:34 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0L8wXO541877548 for ; Wed, 21 Jan 2015 19:58:34 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0L8wXLx016201 for ; Wed, 21 Jan 2015 19:58:33 +1100 Date: Wed, 21 Jan 2015 14:28:18 +0530 From: Bharata B Rao Message-ID: <20150121085817.GB17897@in.ibm.com> References: <1421035354-14721-1-git-send-email-bharata@linux.vnet.ibm.com> <1421035354-14721-3-git-send-email-bharata@linux.vnet.ibm.com> <20150120111837.4b0b2335@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150120111837.4b0b2335@nial.brq.redhat.com> Subject: Re: [Qemu-devel] [PATCH v0 2/2] pc-dimm: Make pc_existing_dimms_capacity global Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org On Tue, Jan 20, 2015 at 11:18:37AM +0100, Igor Mammedov wrote: > On Mon, 12 Jan 2015 09:32:34 +0530 > Bharata B Rao wrote: > > > Move pc_existing_dimms_capacity() to pc-dimm.c since it would be needed > > by PowerPC memory hotplug code too. > > > > Signed-off-by: Bharata B Rao > > --- > > hw/i386/pc.c | 24 ------------------------ > > hw/mem/pc-dimm.c | 25 +++++++++++++++++++++++++ > > include/hw/mem/pc-dimm.h | 1 + > > 3 files changed, 26 insertions(+), 24 deletions(-) > > > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > index 125cf0a..2ec45a4 100644 > > --- a/hw/i386/pc.c > > +++ b/hw/i386/pc.c > > @@ -1552,30 +1552,6 @@ void qemu_register_pc_machine(QEMUMachine *m) > > g_free(name); > > } > > > > -static int pc_existing_dimms_capacity(Object *obj, void *opaque) > > -{ > > - Error *local_err = NULL; > > - uint64_t *size = opaque; > > - > > - if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { > > - DeviceState *dev = DEVICE(obj); > > - > > - if (dev->realized) { > > - (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP, > > - &local_err); > > - } > > - > > - if (local_err) { > > - qerror_report_err(local_err); > > - error_free(local_err); > > - return 1; > > - } > > - } > > - > > - object_child_foreach(obj, pc_existing_dimms_capacity, opaque); > > - return 0; > > -} > > - > > static void pc_dimm_plug(HotplugHandler *hotplug_dev, > > DeviceState *dev, Error **errp) > > { > > diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c > > index d431834..f02ce6e 100644 > > --- a/hw/mem/pc-dimm.c > > +++ b/hw/mem/pc-dimm.c > > @@ -22,6 +22,31 @@ > > #include "qemu/config-file.h" > > #include "qapi/visitor.h" > > #include "qemu/range.h" > > +#include "qapi/qmp/qerror.h" > > + > > +int pc_existing_dimms_capacity(Object *obj, void *opaque) > > +{ > since you are making it API, could you pass Error **errp argument > and deal with error in caller? > Along with it you can make function return void. I don't think that can be done because pc_existing_dimms_capacity() calls itself recursively via object_child_foreach() and hence its signature if fixed. > > > + Error *local_err = NULL; > > + uint64_t *size = opaque; > > + > > + if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { > > + DeviceState *dev = DEVICE(obj); > > + > > + if (dev->realized) { > > + (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP, > > + &local_err); > > + } > > + > > + if (local_err) { > > + qerror_report_err(local_err); > > + error_free(local_err); > > + return 1; > > + } > > + } > > + > > + object_child_foreach(obj, pc_existing_dimms_capacity, opaque); > > + return 0; > > +}