From e17a33794c340652aab5b8b84a6c4e8cc44c98d9 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Wed, 16 Jul 2025 08:31:53 +0200 Subject: [PATCH] storage: remove $running param from volume_snapshot not needed anymore after change in qemu-server Signed-off-by: Alexandre Derumier --- ApiChangeLog | 4 ---- src/PVE/Storage.pm | 4 ++-- src/PVE/Storage/ESXiPlugin.pm | 2 +- src/PVE/Storage/ISCSIDirectPlugin.pm | 2 +- src/PVE/Storage/LVMPlugin.pm | 11 +---------- src/PVE/Storage/LvmThinPlugin.pm | 2 +- src/PVE/Storage/PBSPlugin.pm | 2 +- src/PVE/Storage/Plugin.pm | 16 ++++++---------- src/PVE/Storage/RBDPlugin.pm | 2 +- src/PVE/Storage/ZFSPoolPlugin.pm | 2 +- 10 files changed, 15 insertions(+), 32 deletions(-) diff --git a/ApiChangeLog b/ApiChangeLog index 68e94fd..58996a9 100644 --- a/ApiChangeLog +++ b/ApiChangeLog @@ -22,10 +22,6 @@ Future changes should be documented in here. Feel free to request allowing more drivers or options on the pve-devel mailing list based on your needs. -* Add `running` parameter to `volume_snapshot()` - The parameter *can* be used if some extra actions need to be done at the storage - layer when the snapshot has already be done at qemu level when the vm is running. - * Introduce rename_snapshot() plugin method This method allow to rename a vm disk snapshot name to a different snapshot name. diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index b3ca094..893b611 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -449,13 +449,13 @@ sub volume_rollback_is_possible { } sub volume_snapshot { - my ($cfg, $volid, $snap, $running) = @_; + my ($cfg, $volid, $snap) = @_; my ($storeid, $volname) = parse_volume_id($volid, 1); if ($storeid) { my $scfg = storage_config($cfg, $storeid); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); - return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running); + return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap); } elsif ($volid =~ m|^(/.+)$| && -e $volid) { die "snapshot file/device '$volid' is not possible\n"; } else { diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 66ef289..eeb6a48 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -561,7 +561,7 @@ sub volume_size_info { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; die "creating snapshots is not supported for $class\n"; } diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm index 93cfd3c..62e9026 100644 --- a/src/PVE/Storage/ISCSIDirectPlugin.pm +++ b/src/PVE/Storage/ISCSIDirectPlugin.pm @@ -232,7 +232,7 @@ sub volume_resize { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; die "volume snapshot is not possible on iscsi device\n"; } diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 1f5a5f1..35e1732 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -959,21 +959,12 @@ sub volume_size_info { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; my ($vmid, $format) = ($class->parse_volname($volname))[2, 6]; die "can't snapshot '$format' volume\n" if $format ne 'qcow2'; - if ($running) { - #rename with blockdev-reopen is done at qemu level when running - eval { alloc_snap_image($class, $storeid, $scfg, $volname, $snap) }; - if ($@) { - die "can't allocate new volume $volname: $@\n"; - } - return; - } - $class->activate_volume($storeid, $scfg, $volname); #rename current volume to snap volume diff --git a/src/PVE/Storage/LvmThinPlugin.pm b/src/PVE/Storage/LvmThinPlugin.pm index 13c0275..6f8a92e 100644 --- a/src/PVE/Storage/LvmThinPlugin.pm +++ b/src/PVE/Storage/LvmThinPlugin.pm @@ -353,7 +353,7 @@ sub create_base { # sub volume_resize {} reuse code from parent class sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; my $vg = $scfg->{vgname}; my $snapvol = "snap_${volname}_$snap"; diff --git a/src/PVE/Storage/PBSPlugin.pm b/src/PVE/Storage/PBSPlugin.pm index 45edc46..00170f5 100644 --- a/src/PVE/Storage/PBSPlugin.pm +++ b/src/PVE/Storage/PBSPlugin.pm @@ -966,7 +966,7 @@ sub volume_resize { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; die "volume snapshot is not possible on pbs device"; } diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 439e4c3..2e16c59 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1272,7 +1272,7 @@ sub volume_resize { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; if ($scfg->{'external-snapshots'}) { @@ -1280,18 +1280,14 @@ sub volume_snapshot { my $vmid = ($class->parse_volname($volname))[2]; - if (!$running) { - #rename volume unless qemu has already done it for us - $class->rename_snapshot($scfg, $storeid, $volname, 'current', $snap); - } + #rename volume unless qemu has already done it for us + $class->rename_snapshot($scfg, $storeid, $volname, 'current', $snap); + eval { alloc_backed_image($class, $storeid, $scfg, $volname, $snap) }; if ($@) { warn "$@ \n"; - #if running, the revert is done by qemu with blockdev-reopen - if (!$running) { - eval { $class->rename_snapshot($scfg, $storeid, $volname, $snap, 'current'); }; - warn $@ if $@; - } + eval { $class->rename_snapshot($scfg, $storeid, $volname, $snap, 'current'); }; + warn $@ if $@; die "can't allocate new volume $volname with $snap backing image\n"; } diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm index 01866f1..2201900 100644 --- a/src/PVE/Storage/RBDPlugin.pm +++ b/src/PVE/Storage/RBDPlugin.pm @@ -868,7 +868,7 @@ sub volume_resize { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; my ($vtype, $name, $vmid) = $class->parse_volname($volname); diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm index 28d4795..cdf5868 100644 --- a/src/PVE/Storage/ZFSPoolPlugin.pm +++ b/src/PVE/Storage/ZFSPoolPlugin.pm @@ -480,7 +480,7 @@ sub volume_size_info { } sub volume_snapshot { - my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; + my ($class, $scfg, $storeid, $volname, $snap) = @_; my $vname = ($class->parse_volname($volname))[1];