fix #6587: lvm plugin: snapshot info: fix parsing snapshot name
Volume names are allowed to contain underscores, so it is impossible to determine the snapshot name from just the volume name, e.g: snap_vm-100-disk_with_underscore_here_s_some_more.qcow2 Therefore, pass along the short volume name too and match against it. Note that none of the variables from the result of parse_volname() were actually used previously. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Tested-by: Max R. Carrara <m.carrara@proxmox.com> Reviewed-by: Max R. Carrara <m.carrara@proxmox.com> Link: https://lore.proxmox.com/20250730162117.160498-3-f.ebner@proxmox.com
This commit is contained in:
committed by
Thomas Lamprecht
parent
819dafe516
commit
db2025f5ba
@ -470,9 +470,11 @@ my sub get_snap_name {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my sub parse_snap_name {
|
my sub parse_snap_name {
|
||||||
my ($name) = @_;
|
my ($name, $short_volname) = @_;
|
||||||
|
|
||||||
if ($name =~ m/^snap_\S+_(.*)\.qcow2$/) {
|
$short_volname =~ s/\.(qcow2)$//;
|
||||||
|
|
||||||
|
if ($name =~ m/^snap_\Q$short_volname\E_(.*)\.qcow2$/) {
|
||||||
return $1;
|
return $1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -799,11 +801,13 @@ sub status {
|
|||||||
sub volume_snapshot_info {
|
sub volume_snapshot_info {
|
||||||
my ($class, $scfg, $storeid, $volname) = @_;
|
my ($class, $scfg, $storeid, $volname) = @_;
|
||||||
|
|
||||||
|
my $short_volname = ($class->parse_volname($volname))[1];
|
||||||
|
|
||||||
my $get_snapname_from_path = sub {
|
my $get_snapname_from_path = sub {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
|
||||||
my $name = basename($path);
|
my $name = basename($path);
|
||||||
if (my $snapname = parse_snap_name($name)) {
|
if (my $snapname = parse_snap_name($name, $short_volname)) {
|
||||||
return $snapname;
|
return $snapname;
|
||||||
} elsif ($name eq $volname) {
|
} elsif ($name eq $volname) {
|
||||||
return 'current';
|
return 'current';
|
||||||
@ -812,8 +816,6 @@ sub volume_snapshot_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
my $path = $class->filesystem_path($scfg, $volname);
|
my $path = $class->filesystem_path($scfg, $volname);
|
||||||
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
|
|
||||||
$class->parse_volname($volname);
|
|
||||||
|
|
||||||
my $json = PVE::Storage::Common::qemu_img_info($path, undef, 10, 1);
|
my $json = PVE::Storage::Common::qemu_img_info($path, undef, 10, 1);
|
||||||
die "failed to query file information with qemu-img\n" if !$json;
|
die "failed to query file information with qemu-img\n" if !$json;
|
||||||
|
|||||||
Reference in New Issue
Block a user