From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B73A71FF185 for ; Mon, 21 Jul 2025 14:11:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3FA13CF6E; Mon, 21 Jul 2025 14:11:36 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Mon, 21 Jul 2025 14:10:54 +0200 Message-ID: <20250721121124.77526-10-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250721121124.77526-1-f.ebner@proxmox.com> References: <20250721121124.77526-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753099880993 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server 9/9] use storage layer's resolve_format_hint() helper where appropriate X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" This also fixes an issue that the check_and_prepare_fleecing() helper would always try 'raw' (which might not even be supported) rather than the storage's default format. Signed-off-by: Fiona Ebner --- Dependency bump for pve-storage needed. src/PVE/QemuServer.pm | 28 ++++++++-------------------- src/PVE/VZDump/QemuServer.pm | 5 ++--- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index 60c390bd..f8fb472a 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -5337,8 +5337,7 @@ sub vm_migrate_alloc_nbd_disks { # order of precedence, filtered by whether storage supports it: # 1. explicit requested format # 2. default format of storage - my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); - $format = $defFormat if !$format || !grep { $format eq $_ } $validFormats->@*; + $format = PVE::Storage::resolve_format_hint($storecfg, $storeid, $format); my $size = $drive->{size} / 1024; my $newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, undef, $size); @@ -6452,11 +6451,8 @@ my $restore_allocate_devices = sub { my $storeid = $d->{storeid}; my $scfg = PVE::Storage::storage_config($storecfg, $storeid); - # test if requested format is supported - my ($defFormat, $validFormats) = - PVE::Storage::storage_default_format($storecfg, $storeid); - my $supported = grep { $_ eq $d->{format} } @$validFormats; - $d->{format} = $defFormat if !$supported; + # falls back to default format if requested format is not supported + $d->{format} = PVE::Storage::resolve_format_hint($storecfg, $storeid, $d->{format}); my $name; if ($d->{is_cloudinit}) { @@ -7959,21 +7955,13 @@ sub scsihw_infos { sub resolve_dst_disk_format { my ($storecfg, $storeid, $src_volid, $format) = @_; - my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); - - if (!$format) { - # if no target format is specified, use the source disk format as hint - if ($src_volid) { - $format = checked_volume_format($storecfg, $src_volid); - } else { - return $defFormat; - } + # if no target format is specified, use the source disk format as hint + if (!$format && $src_volid) { + $format = checked_volume_format($storecfg, $src_volid); } - # test if requested format is supported - else use default - my $supported = grep { $_ eq $format } @$validFormats; - $format = $defFormat if !$supported; - return $format; + # falls back to default format if requested format is not supported + return PVE::Storage::resolve_format_hint($storecfg, $storeid, $format); } sub generate_uuid { diff --git a/src/PVE/VZDump/QemuServer.pm b/src/PVE/VZDump/QemuServer.pm index eb85106c..5b94c369 100644 --- a/src/PVE/VZDump/QemuServer.pm +++ b/src/PVE/VZDump/QemuServer.pm @@ -698,9 +698,8 @@ my sub check_and_prepare_fleecing { if ($use_fleecing) { $self->query_block_node_sizes($vmid, $disks); - my ($default_format, $valid_formats) = - PVE::Storage::storage_default_format($self->{storecfg}, $fleecing_opts->{storage}); - my $format = scalar(grep { $_ eq 'qcow2' } $valid_formats->@*) ? 'qcow2' : 'raw'; + my $format = PVE::Storage::resolve_format_hint($self->{storecfg}, $fleecing_opts->{storage}, + 'qcow2'); allocate_fleecing_images( $self, -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel