[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 05/41] qdev: Set device parent and id after setting properties
From: |
Zhao Liu |
Subject: |
[RFC 05/41] qdev: Set device parent and id after setting properties |
Date: |
Thu, 30 Nov 2023 22:41:27 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
The properties setting does not conflict with the creation of child<>
property.
Pre-setting the device's properties can help the device's parent
selection. Some topology devices (e.g., CPUs that support hotplug)
usually define topology sub indexes as properties, and the selection of
their parent needs to be based on these proteries.
Move qdev_set_id() after properties setting to help the next user-child
introduction.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
system/qdev-monitor.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 7ee33a50142a..107411bb50cc 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -700,14 +700,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
long *category,
}
}
- /*
- * set dev's parent and register its id.
- * If it fails it means the id is already taken.
- */
id = g_strdup(qdict_get_try_str(opts, "id"));
- if (!qdev_set_id(dev, id, errp)) {
- goto err_del_dev;
- }
/* set properties */
dev->opts = qdict_clone_shallow(opts);
@@ -721,6 +714,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
long *category,
goto err_del_dev;
}
+ /*
+ * set dev's parent and register its id.
+ * If it fails it means the id is already taken.
+ */
+ if (!qdev_set_id(dev, id, errp)) {
+ goto err_del_dev;
+ }
+
if (!qdev_realize(dev, bus, errp)) {
goto err_del_dev;
}
--
2.34.1
- [RFC 00/41] qom-topo: Abstract Everything about CPU Topology, Zhao Liu, 2023/11/30
- [RFC 01/41] qdev: Introduce new device category to cover basic topology device, Zhao Liu, 2023/11/30
- [RFC 02/41] qdev: Allow qdev_device_add() to add specific category device, Zhao Liu, 2023/11/30
- [RFC 03/41] system: Create base category devices from cli before board initialization, Zhao Liu, 2023/11/30
- [RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent, Zhao Liu, 2023/11/30
- [RFC 05/41] qdev: Set device parent and id after setting properties,
Zhao Liu <=
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, Zhao Liu, 2023/11/30
- [RFC 07/41] qdev: Introduce parent option in -device, Zhao Liu, 2023/11/30
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30
- [RFC 09/41] hw/core/topo: Support topology index for topology device, Zhao Liu, 2023/11/30
- [RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent, Zhao Liu, 2023/11/30
- [RFC 11/41] hw/core/topo: Add virtual method to check topology child, Zhao Liu, 2023/11/30
- [RFC 12/41] hw/core/topo: Add helpers to traverse the CPU topology tree, Zhao Liu, 2023/11/30
- [RFC 13/41] hw/core/cpu: Convert CPU from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 14/41] PPC/ppc-core: Offload core-id to PPC specific core abstarction, Zhao Liu, 2023/11/30
- [RFC 15/41] hw/cpu/core: Allow to configure plugged threads for cpu-core, Zhao Liu, 2023/11/30