qdev-monitor: Forbid repeated device_del

Device unplug can be done asynchronously. Thus, sending the second
device_del before the previous unplug is complete may lead to
unexpected results. On PCIe devices, this cancels the hot-unplug
process.

Signed-off-by: Julia Suvorova <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
This commit is contained in:
Julia Suvorova authored and Paolo Bonzini committed 2020-02-25 09:18:01 +01:00
1 parent 037fb5eb39
commit cce8944cc9
1 file changed
+6
+6
View File
@@ -887,6 +887,12 @@ void qmp_device_del(const char *id, Error **errp)
{
DeviceState *dev = find_device_state(id, errp);
if (dev != NULL) {
if (dev->pending_deleted_event) {
error_setg(errp, "Device %s is already in the "
"process of unplug", id);
return;
}
qdev_unplug(dev, errp);
}
}