[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 35/41] hw/i386: Make x86_cpu_new() private in x86.c, (continued)
- [RFC 35/41] hw/i386: Make x86_cpu_new() private in x86.c, 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 11/41] hw/core/topo: Add virtual method to check topology child, Zhao Liu, 2023/11/30
- [RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device, Zhao Liu, 2023/11/30
- [RFC 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology, 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 33/41] hw/machine: Validate smp topology tree without -smp, Zhao Liu, 2023/11/30
- [RFC 39/41] hw/i386: Add the interface to search parent for QOM topology, 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 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30
- [RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal, Zhao Liu, 2023/11/30
- [RFC 22/41] hw/cpu/cluster: Convert cpu-cluster from general device to topology device, 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 14/41] PPC/ppc-core: Offload core-id to PPC specific core abstarction, 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 19/41] hw/cpu/cluster: Wrap TCG related ops and props into CONFIG_TCG, Zhao Liu, 2023/11/30
- [RFC 41/41] hw/i386: Cleanup non-QOM topology support, Zhao Liu, 2023/11/30
- [RFC 02/41] qdev: Allow qdev_device_add() to add specific category device, Zhao Liu, 2023/11/30