]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qdev-monitor: Forbid repeated device_del
authorJulia Suvorova <jusual@redhat.com>
Thu, 20 Feb 2020 16:55:56 +0000 (17:55 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 25 Feb 2020 08:18:01 +0000 (09:18 +0100)
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 <jusual@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200220165556.39388-1-jusual@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qdev-monitor.c

index 8ce71a206b70475b82386117c271a7841f9aa1a6..8a2a9538cd47a280694c372633b2be2b20a19e9c 100644 (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);
     }
 }