When cancelling the move disk operation for containers the partly
finished destination and thus useless files now get removed.

Co-developed-by: Wolfgang Bumiller <w.bumil...@proxmox.com>
Signed-off-by: Dominic Jäger <d.jae...@proxmox.com>
---
After a quick offline feedback there is now a v2
v2: System call is not a single string anymore 

 src/PVE/LXC.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 62b6b8c..4922fb0 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2024,8 +2024,13 @@ my $copy_volume = sub {
                                 "--bwlimit=$bwlimit", "$src/", $dest]);
     };
     my $err = $@;
+
+    # Wait for rsync's children to release dest so that
+    # consequent file operations (umount, remove) are possible
+    while ((system {"fuser"} "fuser",  "-s", $dest) == 0) {sleep 1};
+
     foreach my $mount (reverse @mounted) {
-       eval { PVE::Tools::run_command(['/bin/umount', '--lazy', $mount], 
errfunc => sub{})};
+       eval { PVE::Tools::run_command(['/bin/umount', $mount], errfunc => 
sub{})};
        warn "Can't umount $mount\n" if $@;
     }
 
-- 
2.11.0

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

Reply via email to