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 7DBB01FF15F for ; Mon, 18 Nov 2024 14:36:12 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A8DE810DAF; Mon, 18 Nov 2024 14:36:15 +0100 (CET) Message-ID: <1d6afa95-972b-4c66-a55f-5b22e2486352@proxmox.com> Date: Mon, 18 Nov 2024 14:36:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Fiona Ebner , Proxmox VE development discussion References: <20241115151749.633407-1-d.csapak@proxmox.com> <20241115151749.633407-17-d.csapak@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On 11/18/24 14:31, Fiona Ebner wrote: > 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? yep, i noticed that 5 minutes ago ;) i'll change it so that source does not get overwritten and we save the volid to delete instead of the path > >> + 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