Skip to contentSkip to conversation

qdev-monitor: Forbid repeated device_del

PATCH Applied Julia Suvorova 3 participants 3 messages Feb 20, 2020 – Feb 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 qdev-monitor.c | 6 ++++++
 1 file changed, 6 insertions(+)
qdev-monitor.c +6 -0
index 8ce71a206b..8a2a9538cd 100644
@@ -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);
     }
 }
Signature · 1 line
2.24.1
#2 lore raw
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Julia Suvorova

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.

Quoted 7 lines
Quoted 4 lines
---
 qdev-monitor.c | 6 ++++++
 1 file changed, 6 insertions(+)

Queued, thanks.

Paolo