From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 10E7DDA76 for ; Mon, 17 Jul 2023 16:00:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DDA4EE230 for ; Mon, 17 Jul 2023 16:00:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 17 Jul 2023 16:00:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 22188428BB for ; Mon, 17 Jul 2023 16:00:27 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Mon, 17 Jul 2023 16:00:20 +0200 Message-Id: <20230717140020.74568-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230717140020.74568-1-f.ebner@proxmox.com> References: <20230717140020.74568-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.045 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH qemu-server 2/2] migration: alloc nbd disks: fix fall-back for remote live migration 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: , X-List-Received-Date: Mon, 17 Jul 2023 14:00:28 -0000 While the comment sated > # order of precedence, filtered by whether storage supports it: > # 1. explicit requested format > # 2. format of current volume > # 3. default format of storage the code did not fall back to the default format in the case of remote migration, because the format was already set and the code used > $format //= $defFormat; This made remote migration from dir with qcow2 to e.g. LVM-thin fail. Move extracting the format from the volume name to the call side for local migration. This allows the logic here to be much simpler. Reported-by: Thomas Lamprecht Suggested-by: Fabian Grünbichler Signed-off-by: Fiona Ebner --- PVE/API2/Qemu.pm | 1 - PVE/QemuServer.pm | 32 +++++++++----------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 59307133..9c3f7216 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -5634,7 +5634,6 @@ __PACKAGE__->register_method({ 'disk' => [ undef, $storeid, - undef, $drive, 0, $format, diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index a692e32e..4767bad4 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5554,9 +5554,11 @@ sub vm_migrate_get_nbd_disks { my $scfg = PVE::Storage::storage_config($storecfg, $storeid); return if $scfg->{shared}; + my $format = qemu_img_format($scfg, $volname); + # replicated disks re-use existing state via bitmap my $use_existing = $replicated_volumes->{$volid} ? 1 : 0; - $local_volumes->{$ds} = [$volid, $storeid, $volname, $drive, $use_existing]; + $local_volumes->{$ds} = [$volid, $storeid, $drive, $use_existing, $format]; }); return $local_volumes; } @@ -5567,7 +5569,7 @@ sub vm_migrate_alloc_nbd_disks { my $nbd = {}; foreach my $opt (sort keys %$source_volumes) { - my ($volid, $storeid, $volname, $drive, $use_existing, $format) = @{$source_volumes->{$opt}}; + my ($volid, $storeid, $drive, $use_existing, $format) = @{$source_volumes->{$opt}}; if ($use_existing) { $nbd->{$opt}->{drivestr} = print_drive($drive); @@ -5576,29 +5578,13 @@ sub vm_migrate_alloc_nbd_disks { next; } - # storage mapping + volname = regular migration - # storage mapping + format = remote migration + $storeid = PVE::JSONSchema::map_id($storagemap, $storeid); + # order of precedence, filtered by whether storage supports it: # 1. explicit requested format - # 2. format of current volume - # 3. default format of storage - if (!$storagemap->{identity}) { - my $source_scfg = PVE::Storage::storage_config($storecfg, $storeid); - $storeid = PVE::JSONSchema::map_id($storagemap, $storeid); - my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); - if (!$format || !grep { $format eq $_ } @$validFormats) { - if ($volname) { - my $fileFormat = qemu_img_format($source_scfg, $volname); - $format = $fileFormat - if grep { $fileFormat eq $_ } @$validFormats; - } - $format //= $defFormat; - } - } else { - # can't happen for remote migration, so $volname is always defined - my $scfg = PVE::Storage::storage_config($storecfg, $storeid); - $format = qemu_img_format($scfg, $volname); - } + # 2. default format of storage + my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid); + $format = $defFormat if !$format || !grep { $format eq $_ } $validFormats->@*; my $size = $drive->{size} / 1024; my $newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, undef, $size); -- 2.39.2