[libvirt] [PATCH 10/10] qemu: hotplug: Remove rest of source backend if hotplug fails

Peter Krempa pkrempa at redhat.com
Mon Jun 24 15:38:55 UTC 2019


When changing media using blockdev-add we need to remove the leftovers
if we didn't succeed plugging in the full chain or closing the tray.
Otherwise the data structures will be freed and thus the backing chain
members will never be unplugged.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_hotplug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a1296d55d4..29d703e514 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -491,6 +491,9 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
     if (rc == 0)
         rc = qemuMonitorBlockdevTrayClose(priv->mon, diskPriv->qomName);

+    if (rc < 0 && newbackend)
+        qemuBlockStorageSourceChainDetach(priv->mon, newbackend);
+
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
         goto cleanup;

-- 
2.21.0




More information about the libvir-list mailing list