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