Skip to content

Commit

Permalink
migration: allow unplug during migration for failover devices
Browse files Browse the repository at this point in the history
In "b06424de62 migration: Disable hotplug/unplug during migration" we
added a check to disable unplug for all devices until we have figured
out what works. For failover primary devices qdev_unplug() is called
from the migration handler, i.e. during migration.

This patch adds a flag to DeviceState which is set to false for all
devices and makes an exception for PCI devices that are also
primary devices in a failover pair.

Signed-off-by: Jens Freimann <jfreimann@redhat.com>
Message-Id: <20191029114905.6856-8-jfreimann@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
jensfr authored and mstsirkin committed Oct 29, 2019
1 parent 70d0497 commit a1190ab
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions hw/core/qdev.c
Expand Up @@ -996,6 +996,7 @@ static void device_initfn(Object *obj)

dev->instance_id_alias = -1;
dev->realized = false;
dev->allow_unplug_during_migration = false;

object_property_add_bool(obj, "realized",
device_get_realized, device_set_realized, NULL);
Expand Down
1 change: 1 addition & 0 deletions hw/pci/pci.c
Expand Up @@ -2130,6 +2130,7 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
pci_qdev_unrealize(DEVICE(pci_dev), NULL);
return;
}
qdev->allow_unplug_during_migration = true;
}

/* rom loading */
Expand Down
1 change: 1 addition & 0 deletions include/hw/qdev-core.h
Expand Up @@ -156,6 +156,7 @@ struct DeviceState {
bool pending_deleted_event;
QemuOpts *opts;
int hotplugged;
bool allow_unplug_during_migration;
BusState *parent_bus;
QLIST_HEAD(, NamedGPIOList) gpios;
QLIST_HEAD(, BusState) child_bus;
Expand Down
2 changes: 1 addition & 1 deletion qdev-monitor.c
Expand Up @@ -851,7 +851,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)
return;
}

if (!migration_is_idle()) {
if (!migration_is_idle() && !dev->allow_unplug_during_migration) {
error_setg(errp, "device_del not allowed while migrating");
return;
}
Expand Down

0 comments on commit a1190ab

Please sign in to comment.