5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2025-03-11 16:58:28 +03:00

storage: plugin: return 'raw' format when parsing non-image volumes

since `volume_size_info` passes the parsed format to `file_size_info`, which
prints a warning if the format is undef before falling back to auto-detection,
and these should always be treated as raw files anyway.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2024-12-10 11:43:35 +01:00
parent 93c1af6ba4
commit bfb3dff319
2 changed files with 18 additions and 14 deletions

View File

@ -650,19 +650,19 @@ sub parse_volname {
my (undef, $format, $isBase) = parse_name_dir($name); my (undef, $format, $isBase) = parse_name_dir($name);
return ('images', $name, $vmid, undef, undef, $isBase, $format); return ('images', $name, $vmid, undef, undef, $isBase, $format);
} elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!) { } elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!) {
return ('iso', $1); return ('iso', $1, undef, undef, undef, undef, 'raw');
} elsif ($volname =~ m!^vztmpl/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!) { } elsif ($volname =~ m!^vztmpl/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!) {
return ('vztmpl', $1); return ('vztmpl', $1, undef, undef, undef, undef, 'raw');
} elsif ($volname =~ m!^rootdir/(\d+)$!) { } elsif ($volname =~ m!^rootdir/(\d+)$!) {
return ('rootdir', $1, $1); return ('rootdir', $1, $1);
} elsif ($volname =~ m!^backup/([^/]+$PVE::Storage::BACKUP_EXT_RE_2)$!) { } elsif ($volname =~ m!^backup/([^/]+$PVE::Storage::BACKUP_EXT_RE_2)$!) {
my $fn = $1; my $fn = $1;
if ($fn =~ m/^vzdump-(openvz|lxc|qemu)-(\d+)-.+/) { if ($fn =~ m/^vzdump-(openvz|lxc|qemu)-(\d+)-.+/) {
return ('backup', $fn, $2); return ('backup', $fn, $2, undef, undef, undef, 'raw');
} }
return ('backup', $fn); return ('backup', $fn, undef, undef, undef, undef, 'raw');
} elsif ($volname =~ m!^snippets/([^/]+)$!) { } elsif ($volname =~ m!^snippets/([^/]+)$!) {
return ('snippets', $1); return ('snippets', $1, undef, undef, undef, undef, 'raw');
} elsif ($volname =~ m!^import/(${PVE::Storage::SAFE_CHAR_WITH_WHITESPACE_CLASS_RE}+\.ova\/${PVE::Storage::OVA_CONTENT_RE_1})$!) { } elsif ($volname =~ m!^import/(${PVE::Storage::SAFE_CHAR_WITH_WHITESPACE_CLASS_RE}+\.ova\/${PVE::Storage::OVA_CONTENT_RE_1})$!) {
my $packed_image = $1; my $packed_image = $1;
my $format = $2; my $format = $2;

View File

@ -29,12 +29,12 @@ my $tests = [
{ {
description => 'ISO image, iso', description => 'ISO image, iso',
volname => 'iso/some-installation-disk.iso', volname => 'iso/some-installation-disk.iso',
expected => ['iso', 'some-installation-disk.iso'], expected => ['iso', 'some-installation-disk.iso', undef, undef, undef, undef, 'raw'],
}, },
{ {
description => 'ISO image, img', description => 'ISO image, img',
volname => 'iso/some-other-installation-disk.img', volname => 'iso/some-other-installation-disk.img',
expected => ['iso', 'some-other-installation-disk.img'], expected => ['iso', 'some-other-installation-disk.img', undef, undef, undef, undef, 'raw'],
}, },
# #
# container templates # container templates
@ -42,17 +42,17 @@ my $tests = [
{ {
description => 'Container template tar.gz', description => 'Container template tar.gz',
volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.gz', volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.gz',
expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.gz'], expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.gz', undef, undef, undef, undef, 'raw'],
}, },
{ {
description => 'Container template tar.xz', description => 'Container template tar.xz',
volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.xz', volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.xz',
expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.xz'], expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.xz', undef, undef, undef, undef, 'raw'],
}, },
{ {
description => 'Container template tar.bz2', description => 'Container template tar.bz2',
volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.bz2', volname => 'vztmpl/debian-10.0-standard_10.0-1_amd64.tar.bz2',
expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.bz2'], expected => ['vztmpl', 'debian-10.0-standard_10.0-1_amd64.tar.bz2', undef, undef, undef, undef, 'raw'],
}, },
# #
# container rootdir # container rootdir
@ -70,7 +70,7 @@ my $tests = [
{ {
description => 'Backup archive, no virtualization type', description => 'Backup archive, no virtualization type',
volname => "backup/vzdump-none-$vmid-2020_03_30-21_39_30.tar", volname => "backup/vzdump-none-$vmid-2020_03_30-21_39_30.tar",
expected => ['backup', "vzdump-none-$vmid-2020_03_30-21_39_30.tar"], expected => ['backup', "vzdump-none-$vmid-2020_03_30-21_39_30.tar", undef, undef, undef, undef, 'raw'],
}, },
# #
# Snippets # Snippets
@ -78,12 +78,12 @@ my $tests = [
{ {
description => 'Snippets, yaml', description => 'Snippets, yaml',
volname => 'snippets/userconfig.yaml', volname => 'snippets/userconfig.yaml',
expected => ['snippets', 'userconfig.yaml'], expected => ['snippets', 'userconfig.yaml', undef, undef, undef, undef, 'raw'],
}, },
{ {
description => 'Snippets, perl', description => 'Snippets, perl',
volname => 'snippets/hookscript.pl', volname => 'snippets/hookscript.pl',
expected => ['snippets', 'hookscript.pl'], expected => ['snippets', 'hookscript.pl', undef, undef, undef, undef, 'raw'],
}, },
# #
# Import # Import
@ -229,7 +229,11 @@ foreach my $virt (keys %$bkp_suffix) {
expected => [ expected => [
'backup', 'backup',
"vzdump-$virt-$vmid-2020_03_30-21_12_40.$s", "vzdump-$virt-$vmid-2020_03_30-21_12_40.$s",
"$vmid" "$vmid",
undef,
undef,
undef,
'raw'
], ],
}, },
); );