From f649f5a99c4b1cc630aa6dc198a048be9fc7f7f9 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Wed, 16 Jul 2025 08:31:48 +0200 Subject: [PATCH] plugin|lvmplugin: don't allow volume rename if external snapshots exist. Just to safe, as this is already check higher in the stack. Technically, it's possible to implement snapshot file renaming, and update backing_file info with "qemu-img rebase -u". Signed-off-by: Alexandre Derumier --- src/PVE/Storage/LVMPlugin.pm | 6 ++++++ src/PVE/Storage/Plugin.pm | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index 9aadbc2..8a61bc5 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -1233,6 +1233,12 @@ sub rename_volume { my ( undef, $source_image, $source_vmid, $base_name, $base_vmid, undef, $format, ) = $class->parse_volname($source_volname); + + if ($format eq 'qcow2') { + my $snapshots = $class->volume_snapshot_info($scfg, $storeid, $source_volname); + die "we can't rename volume if external snapshot exists" if $snapshots->{current}->{parent}; + } + $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format) if !$target_volname; diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 06d258e..8ea62e4 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -2175,6 +2175,11 @@ sub rename_volume { die "not implemented in storage plugin '$class'\n" if $class->can('api') && $class->api() < 10; die "no path found\n" if !$scfg->{path}; + if ($scfg->{'external-snapshots'}) { + my $snapshots = $class->volume_snapshot_info($scfg, $storeid, $source_volname); + die "we can't rename volume if external snapshot exists" if $snapshots->{current}->{parent}; + } + my ( undef, $source_image, $source_vmid, $base_name, $base_vmid, undef, $format, ) = $class->parse_volname($source_volname);