The only thing that might need to be cleaned up after setup_snapshot_access() failed is dropping the cbw filter. Do so in the single branch it matters inside setup_snapshot_access() itself. This avoids the need that callers of setup_snapshot_access() use cleanup_snapshot_access() when the call failed.
Suggested-by: Wolfgang Bumiller <w.bumil...@proxmox.com> Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- pve-backup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pve-backup.c b/pve-backup.c index 32352fb5ec..2408f182bc 100644 --- a/pve-backup.c +++ b/pve-backup.c @@ -576,6 +576,9 @@ static int setup_snapshot_access(PVEBackupDevInfo *di, Error **errp) di->fleecing.snapshot_access = bdrv_open(NULL, NULL, snapshot_access_opts, BDRV_O_RDWR | BDRV_O_UNMAP, &local_err); if (!di->fleecing.snapshot_access) { + bdrv_cbw_drop(di->fleecing.cbw); + di->fleecing.cbw = NULL; + error_setg(errp, "setting up snapshot access for fleecing failed: %s", local_err ? error_get_pretty(local_err) : "unknown error"); return -1; @@ -629,7 +632,6 @@ static void create_backup_jobs_bh(void *opaque) { error_setg(errp, "%s - setting up snapshot access for fleecing failed: %s", di->device_name, local_err ? error_get_pretty(local_err) : "unknown error"); - cleanup_snapshot_access(di); bdrv_drained_end(di->bs); break; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel