From 4495ec7d9b442753f2be946dd5d2fe512d0adaaa Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Thu, 25 Jan 2024 14:02:16 -0600 Subject: [PATCH] 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 Reviewed-by: Peter Krempa --- 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 f65dfe5b63..379ee3d5d1 100644 --- a/src/qemu/qemu_nbdkit.c +++ b/src/qemu/qemu_nbdkit.c @@ -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; }