new file mode 100644
@@ -0,0 +1,31 @@
+# -*- Mode: Python -*-
+# vim: filetype=python
+#
+
+##
+# = VM initialization phase
+##
+
+##
+# @MachineInitPhase:
+#
+# Since 7.0
+##
+{ 'enum': 'MachineInitPhase',
+ 'prefix': 'PHASE',
+ 'data': [ 'no-machine', 'machine-created', 'accel-created',
+ 'machine-initialized', 'machine-ready' ] }
+
+##
+# @until-phase:
+#
+# Features:
+# @unstable: This command is experimental.
+#
+# Since 7.0
+#
+# Returns: nothing
+##
+{ 'command': 'until-phase', 'allow-preconfig': true,
+ 'data': { 'phase': 'MachineInitPhase' },
+ 'features': [ 'unstable' ] }
@@ -64,6 +64,7 @@
{ 'include': 'common.json' }
{ 'include': 'sockets.json' }
{ 'include': 'run-state.json' }
+{ 'include': 'phase.json' }
{ 'include': 'crypto.json' }
{ 'include': 'block.json' }
{ 'include': 'block-export.json' }
@@ -847,36 +847,4 @@ void device_listener_unregister(DeviceListener *listener);
*/
bool qdev_should_hide_device(const QDict *opts, bool from_json, Error **errp);
-typedef enum MachineInitPhase {
- /* current_machine is NULL. */
- PHASE_NO_MACHINE,
-
- /* current_machine is not NULL, but current_machine->accel is NULL. */
- PHASE_MACHINE_CREATED,
-
- /*
- * current_machine->accel is not NULL, but the machine properties have
- * not been validated and machine_class->init has not yet been called.
- */
- PHASE_ACCEL_CREATED,
-
- /*
- * machine_class->init has been called, thus creating any embedded
- * devices and validating machine properties. Devices created at
- * this time are considered to be cold-plugged.
- */
- PHASE_MACHINE_INITIALIZED,
-
- /*
- * QEMU is ready to start CPUs and devices created at this time
- * are considered to be hot-plugged. The monitor is not restricted
- * to "preconfig" commands.
- */
- PHASE_MACHINE_READY,
-} MachineInitPhase;
-
-extern bool phase_check(MachineInitPhase phase);
-extern MachineInitPhase phase_get(void);
-extern void phase_advance(MachineInitPhase phase);
-
#endif
@@ -21,6 +21,7 @@
#include "sysemu/hostmem.h"
#include "sysemu/hw_accel.h"
#include "sysemu/numa.h"
+#include "sysemu/phase.h"
#include "sysemu/runstate.h"
static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
@@ -24,6 +24,7 @@
#include "hw/sysbus.h"
#include "sysemu/cpus.h"
#include "sysemu/sysemu.h"
+#include "sysemu/phase.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
#include "sysemu/numa.h"
@@ -27,6 +27,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "qapi/qapi-types-phase.h"
#include "qapi/qapi-events-qdev.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
@@ -39,6 +40,7 @@
#include "hw/sysbus.h"
#include "hw/qdev-clock.h"
#include "migration/vmstate.h"
+#include "sysemu/phase.h"
#include "trace.h"
static bool qdev_hot_added = false;
@@ -38,6 +38,7 @@
#include "monitor/monitor.h"
#include "net/net.h"
#include "sysemu/numa.h"
+#include "sysemu/phase.h"
#include "sysemu/sysemu.h"
#include "hw/loader.h"
#include "qemu/error-report.h"
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "hw/usb.h"
#include "qemu/iov.h"
+#include "sysemu/phase.h"
#include "trace.h"
void usb_pick_speed(USBPort *port)
@@ -23,6 +23,7 @@
#include "qemu-common.h"
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio.h"
+#include "sysemu/phase.h"
#include "sysemu/kvm.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
@@ -37,6 +37,7 @@
#include "qemu/option.h"
#include "qemu/units.h"
#include "sysemu/block-backend.h"
+#include "sysemu/phase.h"
#include "sysemu/runstate.h"
#include "trace.h"
@@ -37,6 +37,7 @@
#include "qemu/qemu-print.h"
#include "qemu/option_int.h"
#include "sysemu/block-backend.h"
+#include "sysemu/phase.h"
#include "migration/misc.h"
#include "migration/migration.h"
#include "qemu/cutils.h"
@@ -37,6 +37,7 @@
#include "qemu/cutils.h"
#include "qemu/help_option.h"
#include "qemu/uuid.h"
+#include "sysemu/phase.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
#include "sysemu/runstate-action.h"
@@ -120,6 +121,7 @@
#include "qapi/qapi-commands-block-core.h"
#include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-phase.h"
#include "qapi/qapi-visit-qom.h"
#include "qapi/qapi-commands-ui.h"
#include "qapi/qmp/qdict.h"
@@ -1182,5 +1184,18 @@ void qemu_until_phase(MachineInitPhase phase)
case PHASE_MACHINE_READY:
break;
+
+ default:
+ assert(0);
}
}
+
+void qmp_until_phase(MachineInitPhase phase, Error **errp)
+{
+ if (phase < phase_get()) {
+ error_setg(errp, "too late");
+ return;
+ }
+
+ qemu_until_phase(phase);
+}
@@ -33,6 +33,7 @@
#include "qemu/option.h"
#include "qemu/timer.h"
#include "chardev/char.h"
+#include "sysemu/phase.h"
#include "trace.h"
#include "exec/memory.h"
#include "io/channel-file.h"
@@ -2591,6 +2591,7 @@ F: softmmu/cpu-timers.c
F: softmmu/icount.c
F: softmmu/runstate-action.c
F: qapi/run-state.json
+F: qapi/phase.json
Read, Copy, Update (RCU)
M: Paolo Bonzini <pbonzini@redhat.com>
@@ -41,6 +41,7 @@ qapi_all_modules = [
'misc',
'misc-target',
'net',
+ 'phase',
'pragma',
'qom',
'replay',
This is a straightforward QMP wrapper around qemu_until_phase(). Useless right now, because by the time you can execute QMP, we're already in phase @machine-ready, and all you can do with the command is "advance" to that same phase. Its error message is RFC-qwality. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- qapi/phase.json | 31 +++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + include/hw/qdev-core.h | 32 -------------------------------- hw/core/machine-qmp-cmds.c | 1 + hw/core/machine.c | 1 + hw/core/qdev.c | 2 ++ hw/pci/pci.c | 1 + hw/usb/core.c | 1 + hw/virtio/virtio-iommu.c | 1 + monitor/hmp.c | 1 + softmmu/qdev-monitor.c | 1 + softmmu/vl.c | 15 +++++++++++++++ ui/console.c | 1 + MAINTAINERS | 1 + qapi/meson.build | 1 + 15 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 qapi/phase.json