diff mbox series

[v7,22/28] qdev: make a separate helper function to apply compat properties

Message ID 20181221090410.27250-23-marcandre.lureau@redhat.com
State New
Headers show
Series Generalize machine compatibility properties | expand

Commit Message

Marc-André Lureau Dec. 21, 2018, 9:04 a.m. UTC
This will allow to apply compat properties on other objects than QDev easily.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h | 2 ++
 hw/core/qdev.c         | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Igor Mammedov Dec. 21, 2018, 2:38 p.m. UTC | #1
On Fri, 21 Dec 2018 13:04:04 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> This will allow to apply compat properties on other objects than QDev easily.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

[...]
Cornelia Huck Dec. 21, 2018, 3:25 p.m. UTC | #2
On Fri, 21 Dec 2018 13:04:04 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> This will allow to apply compat properties on other objects than QDev easily.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/qdev-core.h | 2 ++
>  hw/core/qdev.c         | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
diff mbox series

Patch

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 84e612f473..5989fb6565 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -422,6 +422,8 @@  const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
 
+void object_apply_compat_props(Object *obj);
+
 /* FIXME: make this a link<> */
 void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
 
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d510340bac..3769a2bccb 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -970,7 +970,7 @@  static void device_initfn(Object *obj)
     QLIST_INIT(&dev->gpios);
 }
 
-static void device_post_init(Object *obj)
+void object_apply_compat_props(Object *obj)
 {
     if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
         MachineState *m = MACHINE(qdev_get_machine());
@@ -982,7 +982,11 @@  static void device_post_init(Object *obj)
         }
         object_apply_global_props(obj, mc->compat_props, &error_abort);
     }
+}
 
+static void device_post_init(Object *obj)
+{
+    object_apply_compat_props(obj);
     qdev_prop_set_globals(DEVICE(obj));
 }