[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 3/6] vl: support machine-initialized target in phase_until()
From: |
Damien Hedde |
Subject: |
[PATCH v5 3/6] vl: support machine-initialized target in phase_until() |
Date: |
Thu, 19 May 2022 17:33:59 +0200 |
phase_until() now supports the following transitions:
+ accel-created -> machine-initialized
+ machine-initialized -> machine-ready
As a consequence we can now support the use of qmp_exit_preconfig()
from phases _accel-created_ and _machine-initialized_.
This commit is a preparation to support cold plugging a device
using qapi (which will be introduced in a following commit). For this
we need fine grain control of the phase.
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v5: update due to refactor of previous commit
---
softmmu/vl.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 7f8d15b5b8..ea15e37973 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2698,8 +2698,9 @@ static void qemu_machine_creation_done(void)
void qmp_x_exit_preconfig(Error **errp)
{
- if (phase_check(PHASE_MACHINE_INITIALIZED)) {
- error_setg(errp, "The command is permitted only before machine
initialization");
+ if (phase_check(PHASE_MACHINE_READY)) {
+ error_setg(errp, "The command is permitted only before"
+ " machine is ready");
return;
}
phase_until(PHASE_MACHINE_READY, errp);
@@ -2707,9 +2708,6 @@ void qmp_x_exit_preconfig(Error **errp)
static void qemu_phase_ready(Error **errp)
{
- qemu_init_board();
- /* phase is now PHASE_MACHINE_INITIALIZED. */
- qemu_create_cli_devices();
cxl_fixed_memory_window_link_targets(errp);
qemu_machine_creation_done();
/* Phase is now PHASE_MACHINE_READY. */
@@ -2749,6 +2747,24 @@ bool phase_until(MachineInitPhase phase, Error **errp)
switch (cur_phase) {
case PHASE_ACCEL_CREATED:
+ qemu_init_board();
+ /* Phase is now PHASE_MACHINE_INITIALIZED. */
+ /*
+ * Handle CLI devices now in order leave this case in a state
+ * where we can cold plug devices with QMP. The following call
+ * handles the CLI options:
+ * + -fw_cfg (has side effects on device cold plug)
+ * + -device
+ */
+ qemu_create_cli_devices();
+ /*
+ * At this point all CLI options are handled apart:
+ * + -S (autostart)
+ * + -incoming
+ */
+ break;
+
+ case PHASE_MACHINE_INITIALIZED:
qemu_phase_ready(errp);
break;
--
2.36.1
- [PATCH v5 0/6] QAPI support for device cold-plug, Damien Hedde, 2022/05/19
- [PATCH v5 3/6] vl: support machine-initialized target in phase_until(),
Damien Hedde <=
- [PATCH v5 2/6] machine&vl: introduce phase_until() to handle phase transitions, Damien Hedde, 2022/05/19
- [PATCH v5 1/6] machine: add phase_get() and document phase_check()/advance(), Damien Hedde, 2022/05/19
- [PATCH v5 6/6] qapi/device_add: Allow execution in machine initialized phase, Damien Hedde, 2022/05/19
- [PATCH v5 4/6] qapi/device_add: compute is_hotplug flag, Damien Hedde, 2022/05/19
- [PATCH v5 5/6] RFC qapi/device_add: handle the rom_order_override when cold-plugging, Damien Hedde, 2022/05/19