[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 03/41] system: Create base category devices from cli before board i
From: |
Zhao Liu |
Subject: |
[RFC 03/41] system: Create base category devices from cli before board initialization |
Date: |
Thu, 30 Nov 2023 22:41:25 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
Topology devices are required to complete CPU topology building before
*_init_cpus() in MachineClass.init().
Add a qemu_create_cli_base_devices() before board initialization to
help create and realize topology devices from cli early.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
system/vl.c | 51 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/system/vl.c b/system/vl.c
index 0be155b530b4..65add2fb2460 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1197,8 +1197,9 @@ static int device_help_func(void *opaque, QemuOpts *opts,
Error **errp)
static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
DeviceState *dev;
+ long *category = opaque;
- dev = qdev_device_add(opts, NULL, errp);
+ dev = qdev_device_add(opts, category, errp);
if (!dev && *errp) {
error_report_err(*errp);
return -1;
@@ -2617,25 +2618,13 @@ static void qemu_init_board(void)
realtime_init();
}
-static void qemu_create_cli_devices(void)
+static void qemu_create_cli_devices(long *category)
{
DeviceOption *opt;
- soundhw_init();
-
- qemu_opts_foreach(qemu_find_opts("fw_cfg"),
- parse_fw_cfg, fw_cfg_find(), &error_fatal);
-
- /* init USB devices */
- if (machine_usb(current_machine)) {
- if (foreach_device_config(DEV_USB, usb_parse) < 0)
- exit(1);
- }
-
- /* init generic devices */
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
qemu_opts_foreach(qemu_find_opts("device"),
- device_init_func, NULL, &error_fatal);
+ device_init_func, category, &error_fatal);
QTAILQ_FOREACH(opt, &device_opts, next) {
DeviceState *dev;
loc_push_restore(&opt->loc);
@@ -2646,13 +2635,40 @@ static void qemu_create_cli_devices(void)
* from the start, so call qdev_device_add_from_qdict() directly for
* now.
*/
- dev = qdev_device_add_from_qdict(opt->opts, NULL, true, &error_fatal);
+ dev = qdev_device_add_from_qdict(opt->opts, category,
+ true, &error_fatal);
object_unref(OBJECT(dev));
loc_pop(&opt->loc);
}
rom_reset_order_override();
}
+static void qemu_create_cli_base_devices(void)
+{
+ long category = DEVICE_CATEGORY_CPU_DEF;
+
+ qemu_opts_foreach(qemu_find_opts("fw_cfg"),
+ parse_fw_cfg, fw_cfg_find(), &error_fatal);
+
+ /* init CPU topology devices which don't support hotplug. */
+ qemu_create_cli_devices(&category);
+}
+
+static void qemu_create_cli_periphery_devices(void)
+{
+ soundhw_init();
+
+ /* init USB devices */
+ if (machine_usb(current_machine)) {
+ if (foreach_device_config(DEV_USB, usb_parse) < 0) {
+ exit(1);
+ }
+ }
+
+ /* init generic devices */
+ qemu_create_cli_devices(NULL);
+}
+
static void qemu_machine_creation_done(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
@@ -2701,8 +2717,9 @@ void qmp_x_exit_preconfig(Error **errp)
return;
}
+ qemu_create_cli_base_devices();
qemu_init_board();
- qemu_create_cli_devices();
+ qemu_create_cli_periphery_devices();
qemu_machine_creation_done();
if (loadvm) {
--
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 <=
- [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, 2023/11/30
- [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