qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 5/9] qapi: Implement 'next-machine-phase' command


From: Mirela Grujic
Subject: [RFC PATCH 5/9] qapi: Implement 'next-machine-phase' command
Date: Thu, 13 May 2021 10:25:45 +0200

This command will be used to control via QMP the advancing of machine
through initialization phases. The feature is needed to enable the
machine configuration via QMP.

The command triggers QEMU to advance the machine to the next init phase,
i.e. to execute initialization steps required to enter the next phase.
The command is used in combination with -preconfig command line option.

Note: advancing the machine to the final phase has the same effect as
executing 'x-exit-preconfig' command.

Signed-off-by: Mirela Grujic <mirela.grujic@greensocs.com>
---
 qapi/machine.json          | 24 ++++++++++++++++++++++++
 include/sysemu/sysemu.h    |  3 +++
 hw/core/machine-qmp-cmds.c | 12 ++++++++++++
 softmmu/vl.c               |  3 +--
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 47bdbec817..968d67dd95 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1328,3 +1328,27 @@
 ##
 { 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus',
              'allow-preconfig': true }
+
+##
+# @next-machine-phase:
+#
+# Increment machine initialization phase
+#
+# Since: #FIXME
+#
+# Returns: If successful, nothing
+#
+# Notes: This command will trigger QEMU to execute initialization steps
+#        that are required to enter the next machine initialization phase.
+#        If by incrementing the initialization phase the machine reaches
+#        the final phase, the guest will start running immediately unless
+#        the -S option is used. The command is available only if the
+#        -preconfig command line option was passed.
+#
+# Example:
+#
+# -> { "execute": "next-machine-phase" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'next-machine-phase', 'allow-preconfig': true }
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 8fae667172..0df06d095d 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -2,6 +2,7 @@
 #define SYSEMU_H
 /* Misc. things related to the system emulator.  */
 
+#include "hw/qdev-core.h"
 #include "qemu/timer.h"
 #include "qemu/notify.h"
 #include "qemu/uuid.h"
@@ -20,6 +21,8 @@ void qemu_run_machine_init_done_notifiers(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
+void qemu_machine_enter_phase(MachineInitPhase target_phase, Error **errp);
+
 void configure_rtc(QemuOpts *opts);
 
 void qemu_init_subsystems(void);
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 23f837dadb..8aa743d59b 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -207,3 +207,15 @@ MachineInitPhaseStatus *qmp_query_machine_phase(Error 
**errp)
 
     return status;
 }
+
+void qmp_next_machine_phase(Error **errp)
+{
+    MachineInitPhase target_phase = phase_get() + 1;
+
+    if (target_phase >= MACHINE_INIT_PHASE__MAX) {
+        error_setg(errp, "Cannot increment machine init phase any further");
+        return;
+    }
+
+    qemu_machine_enter_phase(target_phase, errp);
+}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 88f504aff9..0f402806f5 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2578,8 +2578,7 @@ static void qemu_machine_creation_done(void)
     }
 }
 
-static void qemu_machine_enter_phase(MachineInitPhase target_phase,
-                                     Error **errp)
+void qemu_machine_enter_phase(MachineInitPhase target_phase, Error **errp)
 {
     /* target phases before initialization are not handled here */
     if (target_phase < MACHINE_INIT_PHASE_INITIALIZED) {
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]