plugin: extend snapshot name parsing to legacy volnames
otherwise a volume like `100/oldstyle-100-disk-0.qcow2` can be snapshotted, but the snapshot file is treated as a volume instead of a snapshot afterwards. this also avoids issues with volnames with `vm-` in their names, similar to the LVM fix for underscores. Co-authored-by: Shannon Sterz <s.sterz@proxmox.com> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Tested-by: Shannon Sterz <s.sterz@proxmox.com> Link: https://lore.proxmox.com/20250731111519.931104-4-f.gruenbichler@proxmox.com
This commit is contained in:
committed by
Thomas Lamprecht
parent
59a54b3d5f
commit
6dbeba59da
@ -702,9 +702,9 @@ sub cluster_lock_storage {
|
||||
}
|
||||
|
||||
my sub parse_snap_name {
|
||||
my ($name) = @_;
|
||||
my ($filename, $volname) = @_;
|
||||
|
||||
if ($name =~ m/^snap-(.*)-vm(.*)$/) {
|
||||
if ($filename =~ m/^snap-(.*)-\Q$volname\E$/) {
|
||||
return $1;
|
||||
}
|
||||
}
|
||||
@ -715,7 +715,7 @@ sub parse_name_dir {
|
||||
if ($name =~ m!^((vm-|base-|subvol-)(\d+)-[^/\s]+\.(raw|qcow2|vmdk|subvol))$!) {
|
||||
my $isbase = $2 eq 'base-' ? $2 : undef;
|
||||
return ($1, $4, $isbase); # (name, format, isBase)
|
||||
} elsif (parse_snap_name($name)) {
|
||||
} elsif ($name =~ m!^snap-.*\.qcow2$!) {
|
||||
die "'$name' is a snapshot filename, not a volume!\n";
|
||||
} elsif ($name =~ m!^((base-)?[^/\s]+\.(raw|qcow2|vmdk|subvol))$!) {
|
||||
warn "this volume name `$name` is deprecated, please use (base-/vm-/subvol-)-NNN- as prefix\n";
|
||||
@ -1753,7 +1753,7 @@ sub volume_snapshot_info {
|
||||
|
||||
my $name = basename($path);
|
||||
|
||||
if (my $snapname = parse_snap_name($name)) {
|
||||
if (my $snapname = parse_snap_name($name, basename($volname))) {
|
||||
return $snapname;
|
||||
} elsif ($name eq basename($volname)) {
|
||||
return 'current';
|
||||
|
||||
Reference in New Issue
Block a user