aboutsummaryrefslogtreecommitdiff
path: root/qom/object.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-03-08 14:14:35 +0100
committerMarkus Armbruster <armbru@redhat.com>2019-03-11 22:53:44 +0100
commit617902af2c9203f4bb4112eb384870e248d42ad7 (patch)
treef738ec26eb13850a77abe77c32c201da79467370 /qom/object.c
parent1a3ec8c1564f51628cce10d435a2e22559ea29fd (diff)
qom: Move compat_props machinery from qdev to QOM
See the previous commit for rationale. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20190308131445.17502-3-armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r--qom/object.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index 05a8567041..e3206d6799 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -408,6 +408,45 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
}
}
+/*
+ * Global property defaults
+ * Slot 0: accelerator's global property defaults
+ * Slot 1: machine's global property defaults
+ * Each is a GPtrArray of of GlobalProperty.
+ * Applied in order, later entries override earlier ones.
+ */
+static GPtrArray *object_compat_props[2];
+
+/*
+ * Set machine's global property defaults to @compat_props.
+ * May be called at most once.
+ */
+void object_set_machine_compat_props(GPtrArray *compat_props)
+{
+ assert(!object_compat_props[1]);
+ object_compat_props[1] = compat_props;
+}
+
+/*
+ * Set accelerator's global property defaults to @compat_props.
+ * May be called at most once.
+ */
+void object_set_accelerator_compat_props(GPtrArray *compat_props)
+{
+ assert(!object_compat_props[0]);
+ object_compat_props[0] = compat_props;
+}
+
+void object_apply_compat_props(Object *obj)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(object_compat_props); i++) {
+ object_apply_global_props(obj, object_compat_props[i],
+ &error_abort);
+ }
+}
+
static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
{
Object *obj = data;