file size info: prepare to make format parameter mandatory
In almost all cases, there already is an expected format. Allow setting a special value 'auto-detect' to opt-in to automatic format detection by 'qemu-img' for the exceptions. Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
9612844ff3
commit
936fbe3f35
@ -354,7 +354,7 @@ ovf:Item[rasd:InstanceID='%s']/rasd:ResourceType", $controller_id);
|
||||
}
|
||||
|
||||
if (!$isOva) {
|
||||
my $size = PVE::Storage::file_size_info($backing_file_path);
|
||||
my $size = PVE::Storage::file_size_info($backing_file_path, undef, 'auto-detect');
|
||||
die "error parsing $backing_file_path, cannot determine file size\n"
|
||||
if !$size;
|
||||
|
||||
|
||||
@ -2223,7 +2223,7 @@ sub assert_iso_content {
|
||||
my ($path) = @_;
|
||||
|
||||
# check for things like backing image
|
||||
file_size_info($path, undef, undef, 1);
|
||||
file_size_info($path, undef, 'auto-detect', 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -959,10 +959,15 @@ my @checked_qemu_img_formats = qw(raw cow qcow qcow2 qed vmdk cloop);
|
||||
# - backing files (qcow2/vmdk)
|
||||
# - external data files (qcow2)
|
||||
#
|
||||
# Set $file_format to force qemu-img to treat the image as being a specific format.
|
||||
# Set $file_format to force qemu-img to treat the image as being a specific format. Use the value
|
||||
# 'auto-detect' for auto-detection. The parameter is planned to become mandatory with Proxmox VE 9.
|
||||
sub file_size_info {
|
||||
my ($filename, $timeout, $file_format, $untrusted) = @_;
|
||||
|
||||
# TODO PVE 9 make $file_format mandatory
|
||||
warn "file_size_info: detected call without \$file_format parameter\n"
|
||||
if !defined($file_format);
|
||||
|
||||
# compat for old parameter order
|
||||
# TODO PVE 9 remove
|
||||
if (defined($file_format) && ($file_format eq '1' || $file_format eq '0')) {
|
||||
@ -972,6 +977,8 @@ sub file_size_info {
|
||||
$file_format = undef;
|
||||
}
|
||||
|
||||
$file_format = undef if $file_format && $file_format eq 'auto-detect';
|
||||
|
||||
my $st = File::stat::stat($filename);
|
||||
|
||||
if (!defined($st)) {
|
||||
|
||||
Reference in New Issue
Block a user