When starting nbdkit processes for the backing store of a disk, we were
returning an error if any backing store failed, but we were not cleaning
up processes that succeeded higher in the chain. Make sure that if we
return a failure status from qemuNbdkitStartStorageSource() that we roll
back any processes that had been started.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/qemu/qemu_nbdkit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
index 39f9c58a48..edbe2137d0 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -920,8 +920,11 @@ qemuNbdkitStartStorageSource(virQEMUDriver *driver,
return qemuNbdkitStartStorageSourceOne(driver, vm, src);
for (backing = src; backing != NULL; backing = backing->backingStore) {
- if (qemuNbdkitStartStorageSourceOne(driver, vm, backing) < 0)
+ if (qemuNbdkitStartStorageSourceOne(driver, vm, backing) < 0) {
+ /* roll back any previously-started sources */
+ qemuNbdkitStopStorageSource(src, vm, true);
return -1;
+ }
}
return 0;
--
2.43.0