From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB4mE-0005JG-Ng for qemu-devel@nongnu.org; Wed, 05 Feb 2014 10:52:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB4m7-0005GP-3d for qemu-devel@nongnu.org; Wed, 05 Feb 2014 10:52:38 -0500 Received: from cantor2.suse.de ([195.135.220.15]:37316 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB4m6-0005FA-QI for qemu-devel@nongnu.org; Wed, 05 Feb 2014 10:52:31 -0500 Message-ID: <52F25E3B.3050009@suse.de> Date: Wed, 05 Feb 2014 16:52:27 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1391614612-21107-1-git-send-email-imammedo@redhat.com> <1391614612-21107-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1391614612-21107-3-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 2/9] qdev: add to BusState "hotplug-handler" link List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, stefanha@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, marcel.a@redhat.com, armbru@redhat.com, blauwirbel@gmail.com, alex.williamson@redhat.com, kraxel@redhat.com, aliguori@amazon.com, pbonzini@redhat.com Am 05.02.2014 16:36, schrieb Igor Mammedov: > It will allow to reuse field with different BUSes, > reducing code duplication. Field is intended for > replacing 'hotplug_qdev' field in PCIBus and also > will allow to avoid adding equivalent field to > DimmBus with possiblitity to refactor other BUSes > to use it instead of custom field. > In addition once all users of allow_hotplug field > are converted to new API, link could replace > allow_hotplug field in qdev hotplug code. >=20 > Signed-off-by: Igor Mammedov > --- > hw/core/qdev.c | 4 ++++ > include/hw/qdev-core.h | 12 ++++++++++++ > 2 files changed, 16 insertions(+), 0 deletions(-) >=20 > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 82a9123..c9f0c33 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -32,6 +32,7 @@ > #include "qapi/visitor.h" > #include "qapi/qmp/qjson.h" > #include "monitor/monitor.h" > +#include "hw/hotplug.h" > =20 > int qdev_hotplug =3D 0; > static bool qdev_hot_added =3D false; > @@ -870,6 +871,9 @@ static void qbus_initfn(Object *obj) > BusState *bus =3D BUS(obj); > =20 > QTAILQ_INIT(&bus->children); > + object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, > + TYPE_HOTPLUG_HANDLER, > + (Object **)&bus->hotplug_handler, NULL); Will/should the user ever change that property? If not, we could drop this hunk and change the inline link-setting below to just do it the C way. Otherwise it should probably be using &error_abort instead of NULL. Regards, Andreas > } > =20 > static char *default_bus_get_fw_dev_path(DeviceState *dev) > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h > index 2c4f140..41ec533 100644 > --- a/include/hw/qdev-core.h > +++ b/include/hw/qdev-core.h > @@ -8,6 +8,7 @@ > #include "qom/object.h" > #include "hw/irq.h" > #include "qapi/error.h" > +#include "hw/hotplug.h" > =20 > enum { > DEV_NVECTORS_UNSPECIFIED =3D -1, > @@ -180,14 +181,18 @@ typedef struct BusChild { > QTAILQ_ENTRY(BusChild) sibling; > } BusChild; > =20 > +#define QDEV_HOTPLUG_HANDLER_PROPERTY "hotplug-handler" > + > /** > * BusState: > + * @hotplug_device: link to a hotplug device associated with bus. > */ > struct BusState { > Object obj; > DeviceState *parent; > const char *name; > int allow_hotplug; > + HotplugHandler *hotplug_handler; > int max_index; > QTAILQ_HEAD(ChildrenHead, BusChild) children; > QLIST_ENTRY(BusState) sibling; > @@ -321,4 +326,11 @@ extern int qdev_hotplug; > =20 > char *qdev_get_dev_path(DeviceState *dev); > =20 > +static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState= *handler, > + Error **errp) > +{ > + object_property_set_link(OBJECT(bus), OBJECT(handler), > + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); > + bus->allow_hotplug =3D 1; > +} > #endif >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg