aboutsummaryrefslogtreecommitdiff
path: root/softmmu
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-11-12 09:38:36 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2020-12-15 12:51:52 -0500
commit2f181fbd5a9d456d1da291bea61d7e3ad10ec7d1 (patch)
treef6be4e559a9b9a95a2870caf0fc323e7ca6778e7 /softmmu
parent5a1ee6077b89ee9a803aaf8d1c98004701f63684 (diff)
machine: introduce MachineInitPhase
Generalize the qdev_hotplug variable to the different phases of machine initialization. We would like to allow different monitor commands depending on the phase. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r--softmmu/qdev-monitor.c24
-rw-r--r--softmmu/vl.c9
2 files changed, 17 insertions, 16 deletions
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 3f1e67267d..2c57e36c9a 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -245,7 +245,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
dc = DEVICE_CLASS(oc);
if (!dc->user_creatable ||
- (qdev_hotplug && !dc->hotpluggable)) {
+ (phase_check(PHASE_MACHINE_READY) && !dc->hotpluggable)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
"a pluggable device type");
return NULL;
@@ -627,7 +627,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
}
}
- if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
+ if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
}
@@ -641,15 +641,17 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
dev = qdev_new(driver);
/* Check whether the hotplug is allowed by the machine */
- if (qdev_hotplug && !qdev_hotplug_allowed(dev, errp)) {
- goto err_del_dev;
- }
+ if (phase_check(PHASE_MACHINE_READY)) {
+ if (!qdev_hotplug_allowed(dev, errp)) {
+ goto err_del_dev;
+ }
- if (!bus && qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) {
- /* No bus, no machine hotplug handler --> device is not hotpluggable */
- error_setg(errp, "Device '%s' can not be hotplugged on this machine",
- driver);
- goto err_del_dev;
+ if (!bus && !qdev_get_machine_hotplug_handler(dev)) {
+ /* No bus, no machine hotplug handler --> device is not hotpluggable */
+ error_setg(errp, "Device '%s' can not be hotplugged on this machine",
+ driver);
+ goto err_del_dev;
+ }
}
qdev_set_id(dev, qemu_opts_id(opts));
@@ -987,7 +989,7 @@ int qemu_global_option(const char *str)
bool qmp_command_available(const QmpCommand *cmd, Error **errp)
{
- if (!qdev_hotplug &&
+ if (!phase_check(PHASE_MACHINE_READY) &&
!(cmd->options & QCO_ALLOW_PRECONFIG)) {
error_setg(errp, "The command '%s' is permitted only after machine initialization has completed",
cmd->name);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 8e18c52f6e..4fece1b9db 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2406,10 +2406,6 @@ static void qemu_init_displays(void)
}
}
-/*
- * Called after leaving preconfig state. From here on runstate is
- * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE.
- */
static void qemu_init_board(void)
{
MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
@@ -2424,6 +2420,7 @@ static void qemu_init_board(void)
exit(1);
}
+ /* From here on we enter MACHINE_PHASE_INITIALIZED. */
machine_run_board_init(current_machine);
/*
@@ -2490,7 +2487,7 @@ static void qemu_machine_creation_done(void)
void qmp_x_exit_preconfig(Error **errp)
{
- if (qdev_hotplug) {
+ if (phase_check(PHASE_MACHINE_INITIALIZED)) {
error_setg(errp, "The command is permitted only before machine initialization");
return;
}
@@ -3469,12 +3466,14 @@ void qemu_init(int argc, char **argv, char **envp)
qemu_create_early_backends();
qemu_apply_machine_options();
+ phase_advance(PHASE_MACHINE_CREATED);
/*
* Note: uses machine properties such as kernel-irqchip, must run
* after machine_set_property().
*/
configure_accelerators(argv[0]);
+ phase_advance(PHASE_ACCEL_CREATED);
/*
* Beware, QOM objects created before this point miss global and