@@ -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 }
@@ -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();