only affects LVM storages with 'saferemove 1' where the import fails at a rather
advanced stage. Previously in such cases, the renamed (by free_image) volume
del-vm-XYZ-disk-N would be left over.

Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---
 PVE/Storage/LVMPlugin.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index df49b76..b85fb89 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -670,8 +670,16 @@ sub volume_import {
        $class->volume_import_write($fh, $file);
     };
     if (my $err = $@) {
-       eval { $class->free_image($storeid, $scfg, $volname, 0) };
+       my $cleanup_worker = eval { $class->free_image($storeid, $scfg, 
$volname, 0) };
        warn $@ if $@;
+
+       if ($cleanup_worker) {
+           my $rpcenv = PVE::RPCEnvironment::get();
+           my $authuser = $rpcenv->get_user();
+
+           $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
+       }
+
        die $err;
     }
 
-- 
2.20.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to