qemu: roll back if not all nbdkit backends are successful

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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jonathon Jongsma 2024-01-25 14:02:16 -06:00
parent 7a03785d88
commit 4495ec7d9b

View File

@ -914,8 +914,11 @@ qemuNbdkitStartStorageSource(virQEMUDriver *driver,
virStorageSource *backing;
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, chain);
return -1;
}
if (!chain)
break;
}