qdev: make a separate helper function to apply compat properties
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Sat, 1 Dec 2018 21:23:27 +0000 (01:23 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 7 Jan 2019 12:18:42 +0000 (16:18 +0400)
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: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
hw/core/qdev.c
include/hw/qdev-core.h

index d510340bac5795c654b77bef53af7bc171ae59d5..3769a2bccb93404b8a630f89132182156895f84b 100644 (file)
@@ -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));
 }
 
index 84e612f473e6e1f24056173fcecb14487d7fef35..5989fb6565526ce348fbf297e0aa9098c571f660 100644 (file)
@@ -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);