[PATCH for-11.0 3/6] qom: Declare GlobalProperty structure in 'qom/compat-properties.h'

Michael Tokarev posted 6 patches 1 week, 1 day ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, David Hildenbrand <david@kernel.org>, Igor Mammedov <imammedo@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
[PATCH for-11.0 3/6] qom: Declare GlobalProperty structure in 'qom/compat-properties.h'
Posted by Michael Tokarev 1 week, 1 day ago
From: Philippe Mathieu-Daudé <philmd@linaro.org>

While GlobalProperty is expected to only be used by QDev board
layer, it is used by the lower QOM API, so define it in the
qom/ namespace. This helps to build binary which use QOM but
don't need the QDev layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
---
 include/hw/core/boards.h          |  1 +
 include/hw/core/qdev-properties.h |  1 +
 include/hw/core/qdev.h            | 17 ----------------
 include/qom/compat-properties.h   | 32 +++++++++++++++++++++++++++++++
 qom/object.c                      |  2 +-
 5 files changed, 35 insertions(+), 18 deletions(-)
 create mode 100644 include/qom/compat-properties.h

diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h
index 0ac7e17ef7..3f9a7127ad 100644
--- a/include/hw/core/boards.h
+++ b/include/hw/core/boards.h
@@ -8,6 +8,7 @@
 #include "system/blockdev.h"
 #include "qapi/qapi-types-machine.h"
 #include "qemu/module.h"
+#include "qom/compat-properties.h"
 #include "qom/object.h"
 #include "hw/core/cpu.h"
 #include "hw/core/resettable.h"
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index d8745d4c65..17543957a6 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -1,6 +1,7 @@
 #ifndef QEMU_QDEV_PROPERTIES_H
 #define QEMU_QDEV_PROPERTIES_H
 
+#include "qom/compat-properties.h"
 #include "hw/core/qdev.h"
 
 /**
diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h
index 778617787c..337d69ea2c 100644
--- a/include/hw/core/qdev.h
+++ b/include/hw/core/qdev.h
@@ -404,23 +404,6 @@ struct BusState {
     ResettableState reset;
 };
 
-/**
- * typedef GlobalProperty - a global property type
- *
- * @used: Set to true if property was used when initializing a device.
- * @optional: If set to true, GlobalProperty will be skipped without errors
- *            if the property doesn't exist.
- *
- * An error is fatal for non-hotplugged devices, when the global is applied.
- */
-typedef struct GlobalProperty {
-    const char *driver;
-    const char *property;
-    const char *value;
-    bool used;
-    bool optional;
-} GlobalProperty;
-
 /*** Board API.  This should go away once we have a machine config file.  ***/
 
 /**
diff --git a/include/qom/compat-properties.h b/include/qom/compat-properties.h
new file mode 100644
index 0000000000..6e44aabc26
--- /dev/null
+++ b/include/qom/compat-properties.h
@@ -0,0 +1,32 @@
+/*
+ * QEMU Object Model
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_COMPAT_PROPERTIES_H
+#define QEMU_COMPAT_PROPERTIES_H
+
+/**
+ * typedef GlobalProperty - a global property type
+ *
+ * @used: Set to true if property was used when initializing a device.
+ * @optional: If set to true, GlobalProperty will be skipped without errors
+ *            if the property doesn't exist.
+ *
+ * An error is fatal for non-hotplugged devices, when the global is applied.
+ */
+typedef struct GlobalProperty {
+    const char *driver;
+    const char *property;
+    const char *value;
+    bool used;
+    bool optional;
+} GlobalProperty;
+
+#endif
diff --git a/qom/object.c b/qom/object.c
index ff8ede8a32..838b1d2b22 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -11,8 +11,8 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/core/qdev.h"
 #include "qapi/error.h"
+#include "qom/compat-properties.h"
 #include "qom/object.h"
 #include "qom/object_interfaces.h"
 #include "qemu/cutils.h"
-- 
2.47.3


Re: [PATCH for-11.0 3/6] qom: Declare GlobalProperty structure in 'qom/compat-properties.h'
Posted by Richard Henderson 1 week ago
On 4/3/26 20:43, Michael Tokarev wrote:
> From: Philippe Mathieu-Daudé<philmd@linaro.org>
> 
> While GlobalProperty is expected to only be used by QDev board
> layer, it is used by the lower QOM API, so define it in the
> qom/ namespace. This helps to build binary which use QOM but
> don't need the QDev layer.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> Reviewed-by: Michael Tokarev<mjt@tls.msk.ru>
> ---
>   include/hw/core/boards.h          |  1 +
>   include/hw/core/qdev-properties.h |  1 +
>   include/hw/core/qdev.h            | 17 ----------------
>   include/qom/compat-properties.h   | 32 +++++++++++++++++++++++++++++++
>   qom/object.c                      |  2 +-
>   5 files changed, 35 insertions(+), 18 deletions(-)
>   create mode 100644 include/qom/compat-properties.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~