resolve destination disk format helper: use volume format from storage layer

Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2024-12-06 17:25:47 +01:00 committed by Fabian Grünbichler
parent 9cefe5d7bf
commit 1f961e51a8

View File

@ -8421,10 +8421,10 @@ sub clone_disk {
$newvolid = PVE::Storage::vdisk_clone($storecfg, $drive->{file}, $newvmid, $snapname); $newvolid = PVE::Storage::vdisk_clone($storecfg, $drive->{file}, $newvmid, $snapname);
push @$newvollist, $newvolid; push @$newvollist, $newvolid;
} else { } else {
my ($src_storeid, $volname) = PVE::Storage::parse_volume_id($drive->{file}); my ($src_storeid) = PVE::Storage::parse_volume_id($drive->{file});
my $storeid = $storage || $src_storeid; my $storeid = $storage || $src_storeid;
my $dst_format = resolve_dst_disk_format($storecfg, $storeid, $volname, $format); my $dst_format = resolve_dst_disk_format($storecfg, $storeid, $drive->{file}, $format);
my $name = undef; my $name = undef;
my $size = undef; my $size = undef;
@ -8615,15 +8615,15 @@ sub scsihw_infos {
} }
sub resolve_dst_disk_format { sub resolve_dst_disk_format {
my ($storecfg, $storeid, $src_volname, $format) = @_; my ($storecfg, $storeid, $src_volid, $format) = @_;
my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);
if (!$format) { if (!$format) {
# if no target format is specified, use the source disk format as hint # if no target format is specified, use the source disk format as hint
if ($src_volname) { if ($src_volid) {
my $scfg = PVE::Storage::storage_config($storecfg, $storeid); my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
$format = qemu_img_format($scfg, $src_volname); $format = checked_volume_format($storecfg, $src_volid);
} else { } else {
return $defFormat; return $defFormat;
} }