[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 05/14] qapi/device_add: handle the rom_order_override when col
From: |
Damien Hedde |
Subject: |
[PATCH v4 05/14] qapi/device_add: handle the rom_order_override when cold-plugging |
Date: |
Wed, 23 Feb 2022 10:06:57 +0100 |
rom_set_order_override() and rom_reset_order_override() were called
in qemu_create_cli_devices() to set the rom_order_override value
once and for all when creating the devices added on CLI.
Unfortunately this won't work with qapi commands.
Move the calls inside device_add so that it will be done in every
case:
+ CLI option: -device
+ QAPI command: device_add
rom_[set|reset]_order_override() are implemented in hw/core/loader.c
They either do nothing or call fw_cfg_[set|reset]_order_override().
The later functions are implemented in hw/nvram/fw_cfg.c and only
change an integer value of a "global" variable.
In consequence, there are no complex side effects involved and we can
safely move them from outside the -device option loop to the inner
function.
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
softmmu/qdev-monitor.c | 11 +++++++++++
softmmu/vl.c | 2 --
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 47a89aee20..9ec3e0ebff 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -43,6 +43,7 @@
#include "hw/qdev-properties.h"
#include "hw/clock.h"
#include "hw/boards.h"
+#include "hw/loader.h"
/*
* Aliases were a bad idea from the start. Let's keep them
@@ -671,6 +672,10 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
return NULL;
}
+ if (!is_hotplug) {
+ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
+ }
+
/* create device */
dev = qdev_new(driver);
@@ -712,6 +717,9 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
if (!qdev_realize(DEVICE(dev), bus, errp)) {
goto err_del_dev;
}
+ if (!is_hotplug) {
+ rom_reset_order_override();
+ }
return dev;
err_del_dev:
@@ -719,6 +727,9 @@ err_del_dev:
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
}
+ if (!is_hotplug) {
+ rom_reset_order_override();
+ }
return NULL;
}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 50337d68b9..b91ae1b8ae 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2680,7 +2680,6 @@ static void qemu_create_cli_devices(void)
}
/* 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);
QTAILQ_FOREACH(opt, &device_opts, next) {
@@ -2697,7 +2696,6 @@ static void qemu_create_cli_devices(void)
object_unref(OBJECT(dev));
loc_pop(&opt->loc);
}
- rom_reset_order_override();
}
static void qemu_machine_creation_done(void)
--
2.35.1
- [PATCH v4 00/14] Initial support for machine creation via QMP, Damien Hedde, 2022/02/23
- [PATCH v4 05/14] qapi/device_add: handle the rom_order_override when cold-plugging,
Damien Hedde <=
- [PATCH v4 10/14] none-machine: allow several cpus, Damien Hedde, 2022/02/23
- [PATCH v4 08/14] none-machine: add 'ram-addr' property, Damien Hedde, 2022/02/23
- [PATCH v4 02/14] machine&vl: introduce phase_until() to handle phase transitions, Damien Hedde, 2022/02/23
- [PATCH v4 06/14] qapi/device_add: Allow execution in machine initialized phase, Damien Hedde, 2022/02/23
- [PATCH v4 07/14] none-machine: add the NoneMachineState structure, Damien Hedde, 2022/02/23
- [PATCH v4 01/14] machine: add phase_get() and document phase_check()/advance(), Damien Hedde, 2022/02/23
- [PATCH v4 03/14] vl: support machine-initialized target in phase_until(), Damien Hedde, 2022/02/23
- [PATCH v4 12/14] add sysbus-mmio-map qapi command, Damien Hedde, 2022/02/23
- [PATCH v4 04/14] qapi/device_add: compute is_hotplug flag, Damien Hedde, 2022/02/23
- [PATCH v4 09/14] none-machine: allow cold plugging sysbus devices, Damien Hedde, 2022/02/23