mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdev: unplug blocker for devices
Add blocker to prevent hot-unplug of devices TYPE_VFIO_USER_SERVER, which is introduced shortly, attaches itself to a PCIDevice on which it depends. If the attached PCIDevice gets removed while the server in use, it could cause it crash. To prevent this, TYPE_VFIO_USER_SERVER adds an unplug blocker for the PCIDevice. Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> Signed-off-by: John G Johnson <john.g.johnson@oracle.com> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: c41ef80b7cc063314d629737bed2159e5713f2e0.1655151679.git.jag.raman@oracle.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
e2848bc574
commit
217c7f01ad
3 changed files with 57 additions and 0 deletions
|
@ -468,6 +468,28 @@ char *qdev_get_dev_path(DeviceState *dev)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void qdev_add_unplug_blocker(DeviceState *dev, Error *reason)
|
||||
{
|
||||
dev->unplug_blockers = g_slist_prepend(dev->unplug_blockers, reason);
|
||||
}
|
||||
|
||||
void qdev_del_unplug_blocker(DeviceState *dev, Error *reason)
|
||||
{
|
||||
dev->unplug_blockers = g_slist_remove(dev->unplug_blockers, reason);
|
||||
}
|
||||
|
||||
bool qdev_unplug_blocked(DeviceState *dev, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
|
||||
if (dev->unplug_blockers) {
|
||||
error_propagate(errp, error_copy(dev->unplug_blockers->data));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool device_get_realized(Object *obj, Error **errp)
|
||||
{
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
|
@ -704,6 +726,8 @@ static void device_finalize(Object *obj)
|
|||
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
|
||||
g_assert(!dev->unplug_blockers);
|
||||
|
||||
QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) {
|
||||
QLIST_REMOVE(ngl, node);
|
||||
qemu_free_irqs(ngl->in, ngl->num_in);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue