sub qemu_volume_snapshot {
my ($vmid, $deviceid, $storecfg, $volid, $snap) = @_;
- my $conf = PVE::QemuServer::load_config($vmid);
-
- die "you can't take a snapshot if it's a template" if is_template($conf);
-
my $running = check_running($vmid);
return if !PVE::Storage::volume_snapshot($storecfg, $volid, $snap, $running);
sub qemu_volume_snapshot_delete {
my ($vmid, $deviceid, $storecfg, $volid, $snap) = @_;
- my $conf = PVE::QemuServer::load_config($vmid);
-
- die "you can't delete a snapshot if vm is a template" if is_template($conf);
-
my $running = check_running($vmid);
return if !PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap, $running);
my $conf = load_config($vmid);
+ die "you can't take a snapshot if it's a template"
+ if is_template($conf);
+
check_lock($conf);
$conf->{lock} = 'snapshot';
my $conf = load_config($vmid);
- check_lock($conf) if !$drivehash;
+ if (!$drivehash) {
+ check_lock($conf);
+ die "you can't delete a snapshot if vm is a template"
+ if is_template($conf);
+ }
$snap = $conf->{snapshots}->{$snapname};