]> git.proxmox.com Git - pve-common.git/commitdiff
set 'snapshot-delete' lock when deleting snapshot
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 21 Dec 2016 09:54:17 +0000 (10:54 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 22 Dec 2016 11:34:41 +0000 (12:34 +0100)
unless we are in cleanup mode from a failed snapshot_create,
in which case the config already has a 'snapshot' lock.

this is necessary to prevent concurrent starting of or other
actions on the guest in the windows inbetween holding the
flock, e.g. when removing the volume snapshot (which can
take a bit of time).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/AbstractConfig.pm

index ac12fd12ec32290531d993447c6103f4ec65484a..23512d0ae924a7e90f0385936ba1b3a3b6149bdb 100644 (file)
@@ -468,6 +468,9 @@ sub snapshot_delete {
     my $snap;
     my $unused = [];
 
+    $class->set_lock($vmid, 'snapshot-delete')
+       if (!$drivehash); # doesn't already have a 'snapshot' lock
+
     my $unlink_parent = sub {
        my ($confref, $new_parent) = @_;
 
@@ -486,7 +489,6 @@ sub snapshot_delete {
        my $conf = $class->load_config($vmid);
 
        if (!$drivehash) {
-           $class->check_lock($conf);
            die "you can't delete a snapshot if vm is a template\n"
                if $class->is_template($conf);
        }
@@ -512,7 +514,7 @@ sub snapshot_delete {
            $snap->{snapstate} = 'delete';
        } else {
            delete $conf->{snapshots}->{$snapname};
-           delete $conf->{lock} if $drivehash;
+           delete $conf->{lock};
            foreach my $volid (@$unused) {
                $class->add_unused_volume($conf, $volid);
            }