[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 3/5] qapi: Implement x-machine-init QMP command
From: |
Damien Hedde |
Subject: |
[RFC PATCH v3 3/5] qapi: Implement x-machine-init QMP command |
Date: |
Wed, 17 Nov 2021 15:47:01 +0100 |
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 the next commit, we will add the
possibility to create devices at this point. To exit the initialized
phase, use the existing x-exit-preconfig QMP command.
As part of preconfig mode, the command has the 'unstable' feature.
Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
Cc: Alistair Francis <alistair.francis@wdc.com>
v3:
+ add 'unstable' feature
+ bump the target version to 7.0
+ fix the entrance check (and drop alistair ack-by). In previous
version we were only checking we were not too early, we now check
we are not too late too.
---
qapi/machine.json | 27 +++++++++++++++++++++++++++
softmmu/vl.c | 19 +++++++++++++++----
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 8e9a8afb1d..39c2397629 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1617,3 +1617,30 @@
{ 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus',
'features' : ['unstable'],
'allow-preconfig': true }
+
+##
+# @x-machine-init:
+#
+# Enter machine initialized phase
+#
+# Features:
+# @unstable: This command is part of the experimental preconfig mode.
+#
+# Since: 7.0
+#
+# Returns: 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.
+#
+# Example:
+#
+# -> { "execute": "x-machine-init" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'x-machine-init',
+ 'features' : ['unstable'],
+ 'allow-preconfig': true }
diff --git a/softmmu/vl.c b/softmmu/vl.c
index df19b911e6..a3bbe7b249 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"
@@ -2636,10 +2637,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_get() != MACHINE_INIT_PHASE_ACCEL_CREATED) {
+ error_setg(errp, "The command is permitted only when "
+ "the machine is in accel-created phase");
+ 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);
@@ -2732,12 +2739,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 v3 0/5] QMP support for cold-plugging devices, Damien Hedde, 2021/11/17
- [RFC PATCH v3 1/5] rename MachineInitPhase enum constants for QAPI compatibility, Damien Hedde, 2021/11/17
- [RFC PATCH v3 2/5] qapi: Implement query-machine-phase QMP command, Damien Hedde, 2021/11/17
- [RFC PATCH v3 3/5] qapi: Implement x-machine-init QMP command,
Damien Hedde <=
- [RFC PATCH v3 4/5] qapi: Allow device_add to execute in machine initialized phase, Damien Hedde, 2021/11/17
- [RFC PATCH v3 5/5] docs/system: improve doc about preconfig, Damien Hedde, 2021/11/17
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Markus Armbruster, 2021/11/20
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Damien Hedde, 2021/11/23
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Markus Armbruster, 2021/11/24
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Daniel P . Berrangé, 2021/11/24
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Markus Armbruster, 2021/11/24
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Damien Hedde, 2021/11/25
- Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Daniel P . Berrangé, 2021/11/25
Re: [RFC PATCH v3 0/5] QMP support for cold-plugging devices, Dr. David Alan Gilbert, 2021/11/29