[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 03/16] qapi: Implement x-machine-init QMP command
From: |
Damien Hedde |
Subject: |
[RFC PATCH v2 03/16] qapi: Implement x-machine-init QMP command |
Date: |
Wed, 22 Sep 2021 18:13:52 +0200 |
From: Mirela Grujic <mirela.grujic@greensocs.com>
The x-machine-init QMP command is available only if the -preconfig option
is used and the current machine initialization phase is accel-created.
The command triggers QEMU to enter machine initialized phase and wait
for the QMP configuration. In future commits, we will add the possiblity
to create devices at this point.
To exit the initialized phase use the x-exit-preconfig QMP command.
Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>
---
qapi/machine.json | 23 +++++++++++++++++++++++
softmmu/vl.c | 19 +++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 969d37fb03..56330c0e8e 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1368,3 +1368,26 @@
##
{ 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus',
'allow-preconfig': true }
+
+##
+# @x-machine-init:
+#
+# Enter machine initialized phase
+#
+# Since: 6.2
+#
+# Returns: If successful, nothing
+#
+# Notes: This command will trigger QEMU to execute initialization steps
+# that are required to enter the machine initialized phase. The command
+# is available only if the -preconfig command line option was passed and
+# if the machine is currently in the accel-created phase. To exit the
+# machine initialized phase use the x-exit-preconfig command.
+#
+# Example:
+#
+# -> { "execute": "x-machine-init" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'x-machine-init', 'allow-preconfig': true }
diff --git a/softmmu/vl.c b/softmmu/vl.c
index d2552ba8ac..84c5132ad7 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -123,6 +123,7 @@
#include "qapi/qapi-visit-qom.h"
#include "qapi/qapi-commands-ui.h"
#include "qapi/qmp/qdict.h"
+#include "qapi/qapi-commands-machine.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/iothread.h"
#include "qemu/guest-random.h"
@@ -2610,10 +2611,16 @@ static void qemu_init_displays(void)
}
}
-static void qemu_init_board(void)
+void qmp_x_machine_init(Error **errp)
{
MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+ if (phase_check(MACHINE_INIT_PHASE_INITIALIZED)) {
+ error_setg(errp, "The command is permitted only before "
+ "the machine is initialized");
+ return;
+ }
+
if (machine_class->default_ram_id && current_machine->ram_size &&
numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
create_default_memdev(current_machine, mem_path);
@@ -2692,12 +2699,16 @@ static void qemu_machine_creation_done(void)
void qmp_x_exit_preconfig(Error **errp)
{
- if (phase_check(MACHINE_INIT_PHASE_INITIALIZED)) {
- error_setg(errp, "The command is permitted only before machine
initialization");
+ if (phase_check(MACHINE_INIT_PHASE_READY)) {
+ error_setg(errp, "The command is permitted only before "
+ "the machine is ready");
return;
}
- qemu_init_board();
+ if (!phase_check(MACHINE_INIT_PHASE_INITIALIZED)) {
+ qmp_x_machine_init(errp);
+ }
+
qemu_create_cli_devices();
qemu_machine_creation_done();
--
2.33.0
- [RFC PATCH v2 00/16] Initial support for machine creation via QMP, Damien Hedde, 2021/09/22
- [RFC PATCH v2 01/16] rename MachineInitPhase enum constants for QAPI compatibility, Damien Hedde, 2021/09/22
- [RFC PATCH v2 07/16] hw/core/machine: add machine_class_is_dynamic_sysbus_dev_allowed, Damien Hedde, 2021/09/22
- [RFC PATCH v2 03/16] qapi: Implement x-machine-init QMP command,
Damien Hedde <=
- [RFC PATCH v2 09/16] hw/core/machine: Remove the dynamic sysbus devices type check, Damien Hedde, 2021/09/22
- [RFC PATCH v2 04/16] softmmu/qdev-monitor: add error handling in qdev_set_id, Damien Hedde, 2021/09/22
- [RFC PATCH v2 06/16] qapi: Allow device_add to execute in machine initialized phase, Damien Hedde, 2021/09/22
- [RFC PATCH v2 05/16] qdev-monitor: prevent conflicts between qmp/device_add and cli/-device, Damien Hedde, 2021/09/22
- [RFC PATCH v2 08/16] qdev-monitor: Check sysbus device type before creating it, Damien Hedde, 2021/09/22
- [RFC PATCH v2 11/16] softmmu/memory: add memory_region_try_add_subregion function, Damien Hedde, 2021/09/22
- [RFC PATCH v2 14/16] docs/system: add doc about the initialized machine phase and an example, Damien Hedde, 2021/09/22
- [RFC PATCH v2 12/16] add x-sysbus-mmio-map qmp command, Damien Hedde, 2021/09/22