Blame SOURCES/kvm-qdev-Loosen-coupling-between-compat-and-other-global.patch

383d26
From a3a904263d8b2c2cb91be8f9dfb048239fc2b1e2 Mon Sep 17 00:00:00 2001
383d26
From: Markus Armbruster <armbru@redhat.com>
383d26
Date: Fri, 17 May 2019 06:51:07 +0200
383d26
Subject: [PATCH 40/53] qdev: Loosen coupling between compat and other global
383d26
 properties
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Markus Armbruster <armbru@redhat.com>
383d26
Message-id: <20190517065120.12028-19-armbru@redhat.com>
383d26
Patchwork-id: 88002
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 18/31] qdev: Loosen coupling between compat and other global properties
383d26
Bugzilla: 1624009
383d26
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
383d26
The (upstream) patch after next creates global properties before
383d26
compat properties rather than after.  That's fine upstream, because
383d26
compat properties have been divorced from global properties there, in
383d26
merge commit 31ed41889e6.  Downstream, changing creation order that
383d26
way would break overriding compat properties with -global.
383d26
383d26
Since backporting the upstream work is rather invasive, this commit
383d26
loosens the coupling between the two just enough to permit the
383d26
reordering: collect accelerator and machine compat properties in
383d26
separate lists @accel_compat_props and @machine_compat_props rather
383d26
than stuffing them all into @global_props, and apply the three lists
383d26
order @accel_compat_props, @machine_compat_props, @global_props.  This
383d26
matches the order before the patch, thus no functional change.
383d26
383d26
Signed-off-by: Markus Armbruster <armbru@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 accel/accel.c                |  2 +-
383d26
 hw/core/machine.c            |  2 +-
383d26
 hw/core/qdev-properties.c    | 34 +++++++++++++++++++++++++++-------
383d26
 include/hw/qdev-properties.h |  9 +++------
383d26
 4 files changed, 32 insertions(+), 15 deletions(-)
383d26
383d26
diff --git a/accel/accel.c b/accel/accel.c
383d26
index 5f3d73f..124f957 100644
383d26
--- a/accel/accel.c
383d26
+++ b/accel/accel.c
383d26
@@ -123,7 +123,7 @@ void configure_accelerator(MachineState *ms)
383d26
 void accel_register_compat_props(AccelState *accel)
383d26
 {
383d26
     AccelClass *class = ACCEL_GET_CLASS(accel);
383d26
-    register_compat_props_array(class->global_props);
383d26
+    register_accel_compat_props(class->global_props);
383d26
 }
383d26
 
383d26
 static void register_accel_types(void)
383d26
diff --git a/hw/core/machine.c b/hw/core/machine.c
383d26
index 2040177..b4804e9 100644
383d26
--- a/hw/core/machine.c
383d26
+++ b/hw/core/machine.c
383d26
@@ -853,7 +853,7 @@ void machine_register_compat_props(MachineState *machine)
383d26
         p = g_array_index(mc->compat_props, GlobalProperty *, i);
383d26
         /* Machine compat_props must never cause errors: */
383d26
         p->errp = &error_abort;
383d26
-        qdev_prop_register_global(p);
383d26
+        register_machine_compat_prop(p);
383d26
     }
383d26
 }
383d26
 
383d26
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
383d26
index f3a83a3..5fd6d11 100644
383d26
--- a/hw/core/qdev-properties.c
383d26
+++ b/hw/core/qdev-properties.c
383d26
@@ -1174,6 +1174,14 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
383d26
     *ptr = value;
383d26
 }
383d26
 
383d26
+static GList *machine_compat_props;
383d26
+static GList *accel_compat_props;
383d26
+
383d26
+void register_machine_compat_prop(GlobalProperty *prop)
383d26
+{
383d26
+    machine_compat_props = g_list_append(machine_compat_props, prop);
383d26
+}
383d26
+
383d26
 static GList *global_props;
383d26
 
383d26
 void qdev_prop_register_global(GlobalProperty *prop)
383d26
@@ -1195,10 +1203,17 @@ void register_compat_prop(const char *driver,
383d26
     qdev_prop_register_global(p);
383d26
 }
383d26
 
383d26
-void register_compat_props_array(GlobalProperty *prop)
383d26
+void register_accel_compat_props(GlobalProperty *props)
383d26
 {
383d26
-    for (; prop && prop->driver; prop++) {
383d26
-        register_compat_prop(prop->driver, prop->property, prop->value);
383d26
+    GlobalProperty *p, *prop;
383d26
+
383d26
+    for (p = props; p && p->driver; p++) {
383d26
+        prop = g_new0(GlobalProperty, 1);
383d26
+        prop->errp = &error_abort;
383d26
+        prop->driver = p->driver;
383d26
+        prop->property = p->property;
383d26
+        prop->value = p->value;
383d26
+        accel_compat_props = g_list_append(accel_compat_props, prop);
383d26
     }
383d26
 }
383d26
 
383d26
@@ -1245,11 +1260,9 @@ int qdev_prop_check_globals(void)
383d26
     return ret;
383d26
 }
383d26
 
383d26
-void qdev_prop_set_globals(DeviceState *dev)
383d26
+static void qdev_prop_set_globals_1(DeviceState *dev, GList *l)
383d26
 {
383d26
-    GList *l;
383d26
-
383d26
-    for (l = global_props; l; l = l->next) {
383d26
+    for (; l; l = l->next) {
383d26
         GlobalProperty *prop = l->data;
383d26
         Error *err = NULL;
383d26
 
383d26
@@ -1271,6 +1284,13 @@ void qdev_prop_set_globals(DeviceState *dev)
383d26
     }
383d26
 }
383d26
 
383d26
+void qdev_prop_set_globals(DeviceState *dev)
383d26
+{
383d26
+    qdev_prop_set_globals_1(dev, accel_compat_props);
383d26
+    qdev_prop_set_globals_1(dev, machine_compat_props);
383d26
+    qdev_prop_set_globals_1(dev, global_props);
383d26
+}
383d26
+
383d26
 /* --- 64bit unsigned int 'size' type --- */
383d26
 
383d26
 static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
383d26
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
383d26
index b2ad8e9..19ad0ae 100644
383d26
--- a/include/hw/qdev-properties.h
383d26
+++ b/include/hw/qdev-properties.h
383d26
@@ -280,12 +280,9 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
383d26
  */
383d26
 void register_compat_prop(const char *driver, const char *property,
383d26
                           const char *value);
383d26
-/*
383d26
- * register_compat_props_array(): using register_compat_prop(), which
383d26
- * only registers internal global properties (which has lower priority
383d26
- * than user-provided global properties)
383d26
- */
383d26
-void register_compat_props_array(GlobalProperty *prop);
383d26
+
383d26
+void register_accel_compat_props(GlobalProperty *props);
383d26
+void register_machine_compat_prop(GlobalProperty *prop);
383d26
 
383d26
 /**
383d26
  * qdev_property_add_static:
383d26
-- 
383d26
1.8.3.1
383d26