[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 02/41] qdev: Allow qdev_device_add() to add specific category device, Zhao Liu, 2023/11/30
- [RFC 05/41] qdev: Set device parent and id after setting properties,
Zhao Liu <=
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30
- [RFC 18/41] hw/cpu/cluster: Rename CPUClusterState to CPUCluster, Zhao Liu, 2023/11/30
- [RFC 29/41] hw/core/slot: Statistics topology information in CPU slot, Zhao Liu, 2023/11/30
- [RFC 31/41] hw/machine: Plug cpu-slot into machine to maintain topology tree, Zhao Liu, 2023/11/30
- [RFC 32/41] hw/machine: Build smp topology tree from -smp, 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 17/41] hw/cpu/core: Convert cpu-core from general device to topology 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 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