From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id E155B1FF15F
	for <inbox@lore.proxmox.com>; Mon, 18 Nov 2024 14:31:17 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 05EF310C28;
	Mon, 18 Nov 2024 14:31:22 +0100 (CET)
Message-ID: <a919d4ff-22bd-413a-aa68-0d04c34a9d30@proxmox.com>
Date: Mon, 18 Nov 2024 14:31:18 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Dominik Csapak <d.csapak@proxmox.com>
References: <20241115151749.633407-1-d.csapak@proxmox.com>
 <20241115151749.633407-17-d.csapak@proxmox.com>
Content-Language: en-US
From: Fiona Ebner <f.ebner@proxmox.com>
In-Reply-To: <20241115151749.633407-17-d.csapak@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.054 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
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH qemu-server v6 4/6] api: create: implement
 extracting disks when needed for import-from
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Am 15.11.24 um 16:17 schrieb Dominik Csapak:
> @@ -416,6 +427,23 @@ my sub create_disks : prototype($$$$$$$$$$) {
>  		my ($source_storage, $source_volid) = PVE::Storage::parse_volume_id($source, 1);
>  
>  		if ($source_storage) { # PVE-managed volume
> +		    my ($vtype, undef, undef, undef, undef, undef, $fmt)
> +			= PVE::Storage::parse_volname($storecfg, $source);
> +		    my $needs_extraction = PVE::QemuServer::Helpers::needs_extraction($vtype, $fmt);
> +		    if ($needs_extraction) {
> +			print "extracting $source\n";
> +			my $extracted_volid
> +			     = PVE::GuestImport::extract_disk_from_import_file($source, $vmid);
> +			print "finished extracting to $extracted_volid\n";
> +			push @$vollist, $extracted_volid;
> +			$source = $extracted_volid;
> +
> +			my (undef, undef, undef, $parent)
> +			    = PVE::Storage::volume_size_info($storecfg, $source);
> +			die "importing from extracted images with backing file ($parent) not allowed\n"
> +			    if $parent;
> +		    }
> +
>  		    if ($live_import && $ds ne 'efidisk0') {
>  			my $path = PVE::Storage::path($storecfg, $source)
>  			    or die "failed to get a path for '$source'\n";

Below here is a $source = $path

> @@ -424,9 +452,11 @@ my sub create_disks : prototype($$$$$$$$$$) {
>  
>  			die "could not get file size of $source\n" if !$size;
>  			$live_import_mapping->{$ds} = {
> -			    path => $source,
> +			    path => $path,

So this doesn't change anything. It's nicer to read though :P

>  			    format => $source_format,
>  			};
> +			$live_import_mapping->{$ds}->{'delete-after-finish'} = $source

But here you already have $path assigned to $source rather than the
original volume ID. Doesn't vdisk_free() fail later then?

> +			    if $needs_extraction;
>  		    } else {
>  			my $dest_info = {
>  			    vmid => $vmid,
> @@ -438,8 +468,14 @@ my sub create_disks : prototype($$$$$$$$$$) {
>  			$dest_info->{efisize} = PVE::QemuServer::get_efivars_size($conf, $disk)
>  			    if $ds eq 'efidisk0';
>  
> -			($dst_volid, $size) = eval {
> -			    $import_from_volid->($storecfg, $source, $dest_info, $vollist);
> +			eval {
> +			    ($dst_volid, $size)
> +				= $import_from_volid->($storecfg, $source, $dest_info, $vollist);
> +
> +			    # remove extracted volumes after importing
> +			    PVE::Storage::vdisk_free($storecfg, $source) if $needs_extraction;
> +			    print "cleaned up extracted image $source\n";
> +			    @$vollist = grep { $_ ne $source } @$vollist;
>  			};
>  			die "cannot import from '$source' - $@" if $@;
>  		    }
> @@ -1964,7 +2000,6 @@ my $update_vm_api  = sub {
>  
>  		    assert_scsi_feature_compatibility($opt, $conf, $storecfg, $param->{$opt})
>  			if $opt =~ m/^scsi\d+$/;
> -
>  		    my (undef, $created_opts) = create_disks(
>  			$rpcenv,
>  			$authuser,

Unrelated hunk should not be here



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel