mirror of
https://github.com/mii443/qemu.git
synced 2025-12-03 11:08:25 +00:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user