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 659B961405 for ; Fri, 4 Feb 2022 12:39:45 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5B5BB3124E for ; Fri, 4 Feb 2022 12:39:45 +0100 (CET) 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 id 8D5A431244 for ; Fri, 4 Feb 2022 12:39:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 566F444BDB for ; Fri, 4 Feb 2022 12:39:44 +0100 (CET) Message-ID: <44f54e46-fa19-b43f-3e09-bd5ad32eb694@proxmox.com> Date: Fri, 4 Feb 2022 12:38:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: pve-devel@lists.proxmox.com, =?UTF-8?Q?Fabian_Gr=c3=bcnbichler?= References: <20220203124143.1931377-1-f.gruenbichler@proxmox.com> <20220203124143.1931377-23-f.gruenbichler@proxmox.com> From: Fabian Ebner In-Reply-To: <20220203124143.1931377-23-f.gruenbichler@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.138 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) 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: Re: [pve-devel] [PATCH v4 storage 4/4] add volume_import/export_start helpers 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: Fri, 04 Feb 2022 11:39:45 -0000 Am 03.02.22 um 13:41 schrieb Fabian Grünbichler: > diff --git a/PVE/Storage.pm b/PVE/Storage.pm > index 837df1b..682dd38 100755 > --- a/PVE/Storage.pm > +++ b/PVE/Storage.pm > @@ -1833,6 +1833,72 @@ sub volume_imported_message { > } > } > > +# $format and $volname are requests and might be overruled depending on $opts > +# $opts: > +# - with_snapshots: passed to `pvesm import` and used to select import format > +# - allow_rename: passed to `pvesm import` > +# - export_formats: used to select common transport format > +# - unix: unix socket path > +sub volume_import_start { > + my ($cfg, $storeid, $volname, $format, $vmid, $opts) = @_; > + > + my $with_snapshots = $opts->{'with_snapshots'} ? 1 : 0; > + > + $volname = $volname_for_storage->($cfg, $storeid, $volname, $vmid, $format); > + > + my $volid = "$storeid:$volname"; > + > + if (!defined($opts->{snapshot})) { > + $opts->{migration_snapshot} = storage_migrate_snapshot($cfg, $storeid); > + $opts->{snapshot} = '__migration__' if $opts->{migration_snapshot}; > + } Don't we actually need to have the exporting side tell us whether it's using a migration snapshot or not? In practice, not many combinations are affected, but e.g. lvm-thin -> btrfs doesn't work, because the importing side thinks it needs a common format with snapshot (but the exporting side wouldn't actually use a snapshot). > + > + # find common import/export format, like volume_transfer_formats > + my @import_formats = PVE::Storage::volume_import_formats($cfg, $volid, $opts->{migration_snapshot}, undef, $with_snapshots); Found while testing: here you need to pass in $opts->{snapshot}. While plugins are unlikely to base the decision based on the snapshot name, our plugins use definedness of that parameter and $opts->{migration_snapshot} can be ''. Nit: the 'PVE::Storage::' prefix is not necessary. > + my @export_formats = PVE::Tools::split_list($opts->{export_formats}); > + my %import_hash = map { $_ => 1 } @import_formats; > + my @common = grep { $import_hash{$_} } @export_formats; > + die "no matching import/export format found for storage '$storeid'\n" > + if !@common; > + $format = $common[0];