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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-03-28 15:59:38 +01:00
parent 9237a81c13
commit 04c7fc0809

View File

@ -491,6 +491,9 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
if (rc == 0) if (rc == 0)
rc = qemuMonitorBlockdevTrayClose(priv->mon, diskPriv->qomName); rc = qemuMonitorBlockdevTrayClose(priv->mon, diskPriv->qomName);
if (rc < 0 && newbackend)
qemuBlockStorageSourceChainDetach(priv->mon, newbackend);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
goto cleanup; goto cleanup;