qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
	peter.crosthwaite@xilinx.com, ehabkost@redhat.com,
	mst@redhat.com, marcel.a@redhat.com, qemu-devel@nongnu.org,
	blauwirbel@gmail.com, alex.williamson@redhat.com,
	kraxel@redhat.com, anthony@codemonkey.ws, dkoch@verizon.co,
	afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device
Date: Wed, 11 Dec 2013 17:57:26 +0100	[thread overview]
Message-ID: <20131211175726.1f22957d@thinkpad> (raw)
In-Reply-To: <52A892D2.5090908@redhat.com>

On Wed, 11 Dec 2013 17:29:06 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Il 11/12/2013 02:01, Igor Mammedov ha scritto:
> > Currently it's possible to make PCIDevice not hotplugable 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 "hotplugable" readonly property, to make
> > it possible to get it via QOM interface.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  hw/core/qdev.c         |    8 ++++++++
> >  include/hw/qdev-core.h |    3 +++
> >  2 files changed, 11 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > index 25c2d2c..1b1a684 100644
> > --- a/hw/core/qdev.c
> > +++ b/hw/core/qdev.c
> > @@ -719,6 +719,12 @@ static void device_set_realized(Object *obj, bool value, Error **err)
> >      dev->realized = value;
> >  }
> >  
> > +static bool device_get_hotplugable(Object *obj, Error **err)
> > +{
> > +    DeviceClass *dc = DEVICE_GET_CLASS(obj);
> > +    return dc->hotplugable;
> > +}
> > +
> >  static void device_initfn(Object *obj)
> >  {
> >      DeviceState *dev = DEVICE(obj);
> > @@ -736,6 +742,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, "hotplugable",
> > +                             device_get_hotplugable, NULL, NULL);
> >  
> >      class = object_get_class(OBJECT(dev));
> >      do {
> > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 684a5da..5d4a9c8 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.
> > + * @hotplugable: booleean indicating if #DeviceClass is hotplugable, available
> > + * as readonly "hotplugable" 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 hotplugable;
> >  
> >      /* callbacks */
> >      void (*reset)(DeviceState *dev);
> > 
> 
> Does this patch break SCSI and virtio-serial hotplug?
Ouch,
this  patch doesn't but 
"[PATCH 07/11] qdev:pci: refactor PCIDevice to use generic "hotplugable"
property" does. See 2 hunks in hw/core/qdev.c

> 
> Perhaps you could initialize dc->hotpluggable to true, and return
that's probably the easiest way, since before series all devices were
considered hotplugable from qdev POV, so it makes sense to make DeviceClass
hotplugable by default to avoid unexpected regressions.

> "dc->hotplugable && device->parent_bus->allow_hotplug" from the property
> getter? 
sure, since there is no bus-less hotlpug it won't hurt.
I'll respin amended patch as reply to this thread if it's ok.

> Or just set the class to true in the common superclasses of all
> buses that support hotplug, but that's a bit harder.
perhaps exercise for the later.

> 
> Paolo


-- 
Regards,
  Igor

  reply	other threads:[~2013-12-11 17:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11  1:01 [Qemu-devel] [PATCH 00/11 v2] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 01/11] qom: do not register interface "types" in the type table Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_class_foreach Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 03/11] define hotplug interface Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 04/11] qdev: add to BusState "hotplug-handler" link Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device Igor Mammedov
2013-12-11 16:29   ` Paolo Bonzini
2013-12-11 16:57     ` Igor Mammedov [this message]
2013-12-11 17:02       ` Paolo Bonzini
2013-12-11 17:41         ` Igor Mammedov
2013-12-11 17:43     ` [Qemu-devel] [PATCH 5/11 v3 FIXED] " Igor Mammedov
2013-12-11 19:57       ` Markus Armbruster
2013-12-12 15:45         ` Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 06/11] hw/acpi: move typeinfo to the file end Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 07/11] qdev:pci: refactor PCIDevice to use generic "hotplugable" property Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 08/11] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 09/11] pci/shpc: convert SHPC " Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 10/11] pci/pcie: convert PCIE " Igor Mammedov
2013-12-11  1:01 ` [Qemu-devel] [PATCH 11/11] hw/pci: switch to a generic hotplug handling for PCIDevice 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=20131211175726.1f22957d@thinkpad \
    --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).