All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL v4 32/62] qom: Restrict compat properties API to system emulation
Date: Fri, 24 Apr 2026 21:25:35 +0200	[thread overview]
Message-ID: <20260424192543.22614-4-philmd@linaro.org> (raw)
In-Reply-To: <20260424192543.22614-1-philmd@linaro.org>

Move compat properties API definitions to their own file
unit, compile it only when system emulation is configured.
Add a pair of stubs for user emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-6-philmd@linaro.org>
---
 MAINTAINERS                   |  1 +
 qom/compat-properties.c       | 76 +++++++++++++++++++++++++++++++++++
 qom/object.c                  | 60 ---------------------------
 stubs/qom-compat-properties.c | 14 +++++++
 qom/meson.build               |  3 ++
 stubs/meson.build             |  1 +
 6 files changed, 95 insertions(+), 60 deletions(-)
 create mode 100644 qom/compat-properties.c
 create mode 100644 stubs/qom-compat-properties.c

diff --git a/MAINTAINERS b/MAINTAINERS
index facc4b499a9..45d258f64fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3533,6 +3533,7 @@ F: qapi/qom.json
 F: scripts/coccinelle/qom-parent-type.cocci
 F: scripts/qom-cast-macro-clean-cocci-gen.py
 F: qom/
+F: stubs/qom-compat-properties.c
 F: tests/unit/check-qom-interface.c
 F: tests/unit/check-qom-proplist.c
 F: tests/qtest/qom-test.c
diff --git a/qom/compat-properties.c b/qom/compat-properties.c
new file mode 100644
index 00000000000..2110754155a
--- /dev/null
+++ b/qom/compat-properties.c
@@ -0,0 +1,76 @@
+/*
+ * QEMU Object Model
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qom/compat-properties.h"
+#include "qom/qom-qobject.h"
+#include "hw/core/qdev.h"
+
+/*
+ * Global property defaults
+ * Slot 0: accelerator's global property defaults
+ * Slot 1: machine's global property defaults
+ * Slot 2: global properties from legacy command line option
+ * Each is a GPtrArray of GlobalProperty.
+ * Applied in order, later entries override earlier ones.
+ */
+static GPtrArray *object_compat_props[3];
+
+/*
+ * Retrieve @GPtrArray for global property defined with options
+ * other than "-global".  These are generally used for syntactic
+ * sugar and legacy command line options.
+ */
+void object_register_sugar_prop(const char *driver, const char *prop,
+                                const char *value, bool optional)
+{
+    GlobalProperty *g;
+    if (!object_compat_props[2]) {
+        object_compat_props[2] = g_ptr_array_new();
+    }
+    g = g_new0(GlobalProperty, 1);
+    g->driver = g_strdup(driver);
+    g->property = g_strdup(prop);
+    g->value = g_strdup(value);
+    g->optional = optional;
+    g_ptr_array_add(object_compat_props[2], g);
+}
+
+/*
+ * 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],
+                                  i == 2 ? &error_fatal : &error_abort);
+    }
+}
diff --git a/qom/object.c b/qom/object.c
index d6500bcbbf4..f981e270440 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -480,66 +480,6 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props,
     return true;
 }
 
-/*
- * Global property defaults
- * Slot 0: accelerator's global property defaults
- * Slot 1: machine's global property defaults
- * Slot 2: global properties from legacy command line option
- * Each is a GPtrArray of GlobalProperty.
- * Applied in order, later entries override earlier ones.
- */
-static GPtrArray *object_compat_props[3];
-
-/*
- * Retrieve @GPtrArray for global property defined with options
- * other than "-global".  These are generally used for syntactic
- * sugar and legacy command line options.
- */
-void object_register_sugar_prop(const char *driver, const char *prop,
-                                const char *value, bool optional)
-{
-    GlobalProperty *g;
-    if (!object_compat_props[2]) {
-        object_compat_props[2] = g_ptr_array_new();
-    }
-    g = g_new0(GlobalProperty, 1);
-    g->driver = g_strdup(driver);
-    g->property = g_strdup(prop);
-    g->value = g_strdup(value);
-    g->optional = optional;
-    g_ptr_array_add(object_compat_props[2], g);
-}
-
-/*
- * 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],
-                                  i == 2 ? &error_fatal : &error_abort);
-    }
-}
-
 static void object_class_property_init_all(Object *obj)
 {
     ObjectPropertyIterator iter;
diff --git a/stubs/qom-compat-properties.c b/stubs/qom-compat-properties.c
new file mode 100644
index 00000000000..2c955677bed
--- /dev/null
+++ b/stubs/qom-compat-properties.c
@@ -0,0 +1,14 @@
+/*
+ * QEMU Object Model (compat properties stubs for user emulation)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qom/compat-properties.h"
+
+void object_apply_compat_props(Object *obj)
+{
+}
diff --git a/qom/meson.build b/qom/meson.build
index 81922434309..bd6f4aadd78 100644
--- a/qom/meson.build
+++ b/qom/meson.build
@@ -5,6 +5,9 @@ qom_ss.add(files(
   'object_interfaces.c',
   'qom-qobject.c',
 ))
+if have_system
+  qom_ss.add(files('compat-properties.c'))
+endif
 
 qmp_ss.add(files('qom-qmp-cmds.c'))
 system_ss.add(files('qom-hmp-cmds.c'))
diff --git a/stubs/meson.build b/stubs/meson.build
index 7189ff63ed5..f33b1d2a089 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -54,6 +54,7 @@ if have_user
   # Symbols that are used by hw/core.
   stub_ss.add(files('cpu-synchronize-state.c'))
   stub_ss.add(files('cpu-destroy-address-spaces.c'))
+  stub_ss.add(files('qom-compat-properties.c'))
 
   # Stubs for QAPI events.  Those can always be included in the build, but
   # they are not built at all for --disable-system builds.
-- 
2.53.0



  parent reply	other threads:[~2026-04-24 19:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 19:25 [PULL v4 00/62] Misc HW patches for 2026-04-22 Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 02/62] hw/core/cpu: Expose CPUState::start_powered_off docstring Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 28/62] hw: add compat machines for 11.1 Philippe Mathieu-Daudé
2026-04-24 19:25 ` Philippe Mathieu-Daudé [this message]
2026-04-24 19:25 ` [PULL v4 48/62] hw/cxl: Define cxl_fmws_get_all_sorted() stub Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 49/62] hw/arm/virt: Do not select Kconfig symbol PCI_EXPRESS Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 50/62] hw/usb/hcd-ehci: Remove unused EHCIfstn structure and dead code Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 51/62] hw/usb/hcd-ehci.h: Fix coding style issues reported by checkpatch Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 52/62] hw/usb/hcd-ehci.c: " Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 53/62] hw/usb/hcd-ehci.c: Replace fprintf(stderr, ...) with qemu_log_mask(LOG_GUEST_ERROR) Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 54/62] hw/usb/hcd-ehci: Replace DPRINTF debug logs with trace events Philippe Mathieu-Daudé
2026-04-24 19:25 ` [PULL v4 55/62] hw/usb/hcd-ehci: Introduce common properties macro for sysbus and pci Philippe Mathieu-Daudé
2026-04-25 16:59 ` [PULL v4 00/62] Misc HW patches for 2026-04-22 Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260424192543.22614-4-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.