From 217c7f01adaf2853951d4725e3527ae70c45fbfc Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Mon, 13 Jun 2022 16:26:21 -0400 Subject: 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 Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi Message-id: c41ef80b7cc063314d629737bed2159e5713f2e0.1655151679.git.jag.raman@oracle.com Signed-off-by: Stefan Hajnoczi --- softmmu/qdev-monitor.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'softmmu/qdev-monitor.c') diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index bb5897f..4b0ef65 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -899,6 +899,10 @@ void qdev_unplug(DeviceState *dev, Error **errp) HotplugHandlerClass *hdc; Error *local_err = NULL; + if (qdev_unplug_blocked(dev, errp)) { + return; + } + if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) { error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); return; -- cgit v1.1