From: Peter Krempa Date: Thu, 28 Mar 2019 14:59:38 +0000 (+0100) Subject: qemu: hotplug: Remove rest of source backend if hotplug fails X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=04c7fc08099c03e6f55c9d5fe630b84847b069bc;p=libvirt.git qemu: hotplug: Remove rest of source backend if hotplug fails 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 Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 79548ddf73..08eb9c3d47 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;