[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Devic
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device |
Date: |
Wed, 11 Dec 2013 17:29:06 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 |
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 <address@hidden>
> ---
> 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?
Perhaps you could initialize dc->hotpluggable to true, and return
"dc->hotplugable && device->parent_bus->allow_hotplug" from the property
getter? Or just set the class to true in the common superclasses of all
buses that support hotplug, but that's a bit harder.
Paolo
- [Qemu-devel] [PATCH 00/11 v2] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 01/11] qom: do not register interface "types" in the type table, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 02/11] qom: detect bad reentrance during object_class_foreach, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 03/11] define hotplug interface, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 04/11] qdev: add to BusState "hotplug-handler" link, Igor Mammedov, 2013/12/10
- [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/10
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/11
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Paolo Bonzini, 2013/12/11
- Re: [Qemu-devel] [PATCH 05/11] qdev: add "hotplugable" property to Device, Igor Mammedov, 2013/12/11
[Qemu-devel] [PATCH 06/11] hw/acpi: move typeinfo to the file end, Igor Mammedov, 2013/12/10
[Qemu-devel] [PATCH 07/11] qdev:pci: refactor PCIDevice to use generic "hotplugable" property, Igor Mammedov, 2013/12/10
[Qemu-devel] [PATCH 08/11] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API, Igor Mammedov, 2013/12/10
[Qemu-devel] [PATCH 09/11] pci/shpc: convert SHPC hotplug to use hotplug-handler API, Igor Mammedov, 2013/12/10