From: Igor Mammedov <imammedo@redhat.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
marcel.a@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
"Blue Swirl" <blauwirbel@gmail.com>,
alex.williamson@redhat.com, "Gerd Hoffmann" <kraxel@redhat.com>,
"Anthony Liguori" <anthony@codemonkey.ws>,
"Paolo Bonzini" <pbonzini@redhat.com>,
dkoch@verizon.co, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotpluggable" property to Device
Date: Mon, 16 Dec 2013 16:37:53 +0100 [thread overview]
Message-ID: <20131216163753.02e43ba2@nial.usersys.redhat.com> (raw)
In-Reply-To: <CAEgOgz7r3OOim+wNUqV+xSC2saRq=OS_6ss=W+jmW3o3Kff5cQ@mail.gmail.com>
On Sat, 14 Dec 2013 17:10:35 +1000
Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote:
> On Fri, Dec 13, 2013 at 10:44 PM, Igor Mammedov <imammedo@redhat.com> wrote:
> > Currently it's possible to make PCIDevice not hotpluggable by using
> > no_hotplug field of PCIDeviceClass. However it limits this
> > only to PCI devices and prevents from generalizing hotplug code.
> >
> > So add similar field to DeviceClass so it could be reused with other
> > Devices and would allow to replace PCI specific hotplug callbacks
> > with generic implementation.
> >
> > In addition expose field as "hotpluggable" readonly property, to make
> > it possible to get it via QOM interface.
> >
> > Make DeviceClass hotpluggable by default as it was assumed before.
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > v4:
> > * s/hotplugable/hotpluggable/
> >
> > v3:
> > * make DeviceClass hotpluggable by default
> > Since PCIDevice still uses internal no_hotlpug checks it shouldn't
> > reggress. And follow up patch that converts PCIDevices to use
> > "hotpluggable" property will take care about not hotpluggable PCI
> > devices explicitly setting "hotpluggable" to false in their class_init().
> >
> > * move generic hotplug checks from
> > "7/11 qdev:pci: refactor PCIDevice to use generic "hotplugable" property"
> > to this patch
> > ---
> > hw/core/qdev.c | 29 +++++++++++++++++++++++++++++
> > include/hw/qdev-core.h | 3 +++
> > 2 files changed, 32 insertions(+)
> >
> > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > index 25c2d2c..9418fea 100644
> > --- a/hw/core/qdev.c
> > +++ b/hw/core/qdev.c
> > @@ -215,6 +215,12 @@ void qdev_unplug(DeviceState *dev, Error **errp)
> > }
> > assert(dc->unplug != NULL);
> >
> > + if (!dc->hotpluggable) {
> > + error_set(errp, QERR_DEVICE_NO_HOTPLUG,
> > + object_get_typename(OBJECT(dev)));
> > + return;
> > + }
> > +
> > qdev_hot_removed = true;
> >
> > if (dc->unplug(dev) < 0) {
> > @@ -679,6 +685,11 @@ static void device_set_realized(Object *obj, bool value, Error **err)
> > DeviceClass *dc = DEVICE_GET_CLASS(dev);
> > Error *local_err = NULL;
> >
> > + if (dev->hotplugged && !dc->hotpluggable) {
> > + error_set(err, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
> > + return;
> > + }
> > +
> > if (value && !dev->realized) {
> > if (!obj->parent && local_err == NULL) {
> > static int unattached_count;
> > @@ -719,6 +730,14 @@ static void device_set_realized(Object *obj, bool value, Error **err)
> > dev->realized = value;
> > }
> >
> > +static bool device_get_hotpluggable(Object *obj, Error **err)
> > +{
> > + DeviceClass *dc = DEVICE_GET_CLASS(obj);
> > + DeviceState *dev = DEVICE(obj);
> > +
> > + return dc->hotpluggable && dev->parent_bus->allow_hotplug;
> > +}
> > +
> > static void device_initfn(Object *obj)
> > {
> > DeviceState *dev = DEVICE(obj);
> > @@ -736,6 +755,8 @@ static void device_initfn(Object *obj)
> >
> > object_property_add_bool(obj, "realized",
> > device_get_realized, device_set_realized, NULL);
> > + object_property_add_bool(obj, "hotpluggable",
> > + device_get_hotpluggable, NULL, NULL);
> >
> > class = object_get_class(OBJECT(dev));
> > do {
> > @@ -784,6 +805,14 @@ static void device_class_base_init(ObjectClass *class, void *data)
> > * so do not propagate them to the subclasses.
> > */
> > klass->props = NULL;
> > +
> > + /* by default all devices were considered as hotpluggable,
> > + * so with intent to check it in generic qdev_unplug() /
> > + * device_set_realized() functions make every device
> > + * hotpluggable. Devices that shouldn't be hoplugable,
> > + * should override it in their class_init()
> > + */
> > + klass->hotpluggable = true;
> > }
> >
> > static void device_unparent(Object *obj)
> > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 684a5da..04bbef4 100644
> > --- a/include/hw/qdev-core.h
> > +++ b/include/hw/qdev-core.h
> > @@ -50,6 +50,8 @@ struct VMStateDescription;
> > * is changed to %true. Deprecated, new types inheriting directly from
> > * TYPE_DEVICE should use @realize instead, new leaf types should consult
> > * their respective parent type.
> > + * @hotpluggable: booleean indicating if #DeviceClass is hotpluggable, available
>
> "boolean". Although the fact that its bool is implicit just by saying:
>
> "@hotpluggable: indicates if #DeviceClass is hotpluggable ...
sure
>
> Regards,
> Peter
>
> > + * as readonly "hotpluggable" property of #DeviceState instance
> > *
> > * # Realization #
> > * Devices are constructed in two stages,
> > @@ -99,6 +101,7 @@ typedef struct DeviceClass {
> > const char *desc;
> > Property *props;
> > int no_user;
> > + bool hotpluggable;
> >
> > /* callbacks */
> > void (*reset)(DeviceState *dev);
> > --
> > 1.8.3.1
> >
> >
next prev parent reply other threads:[~2013-12-16 15:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 12:44 [Qemu-devel] [PATCH 00/11 v3] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 01/11] qom: do not register interface "types" in the type table Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_class_foreach Igor Mammedov
2013-12-14 6:53 ` Peter Crosthwaite
2013-12-15 17:44 ` Andreas Färber
2013-12-13 12:44 ` [Qemu-devel] [PATCH 03/11] define hotplug interface Igor Mammedov
2013-12-14 7:03 ` Peter Crosthwaite
2013-12-16 15:37 ` Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 04/11] qdev: add to BusState "hotplug-handler" link Igor Mammedov
2013-12-14 7:05 ` Peter Crosthwaite
2013-12-16 15:26 ` Igor Mammedov
2013-12-16 15:53 ` Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 05/11] qdev: add "hotpluggable" property to Device Igor Mammedov
2013-12-14 7:10 ` Peter Crosthwaite
2013-12-16 15:37 ` Igor Mammedov [this message]
2013-12-16 23:22 ` Anthony Liguori
2013-12-13 12:44 ` [Qemu-devel] [PATCH 06/11] hw/acpi: move typeinfo to the file end Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 07/11] qdev:pci: refactor PCIDevice to use generic "hotpluggable" property Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 08/11] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 09/11] pci/shpc: convert SHPC " Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 10/11] pci/pcie: convert PCIE " Igor Mammedov
2013-12-13 12:44 ` [Qemu-devel] [PATCH 11/11] hw/pci: switch to a generic hotplug handling for PCIDevice Igor Mammedov
2013-12-16 23:26 ` [Qemu-devel] [PATCH 00/11 v3] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API Anthony Liguori
2013-12-16 23:34 ` Peter Crosthwaite
2013-12-17 11:58 ` Igor Mammedov
2013-12-17 12:38 ` Paolo Bonzini
2013-12-17 19:38 ` Anthony Liguori
2013-12-18 10:36 ` Paolo Bonzini
2013-12-18 15:48 ` Igor Mammedov
2013-12-18 15:59 ` Paolo Bonzini
2013-12-18 16:32 ` Igor Mammedov
2013-12-18 16:26 ` Michael S. Tsirkin
2013-12-18 16:34 ` Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131216163753.02e43ba2@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=alex.williamson@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=blauwirbel@gmail.com \
--cc=dkoch@verizon.co \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).