From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
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 55893603ED
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 15:45:48 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 48D001BA0A
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 15:45:48 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (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 D12971BA00
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 15:45:47 +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 96ACC45DB9
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 15:45:47 +0200 (CEST)
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Mira Limbeck <m.limbeck@proxmox.com>
References: <20200928083631.30407-1-m.limbeck@proxmox.com>
 <20200928083631.30407-2-m.limbeck@proxmox.com>
 <8ff18626-3a98-8fdd-c551-da990a77faf2@proxmox.com>
 <4eedd179-1ac9-3150-8f35-9c18fd7ef656@proxmox.com>
 <1443552e-8e26-ae63-9b09-d9a68d54177b@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Message-ID: <a730e985-38fa-2abf-e39e-ed423d504884@proxmox.com>
Date: Fri, 16 Oct 2020 15:45:46 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101
 Thunderbird/82.0
MIME-Version: 1.0
In-Reply-To: <1443552e-8e26-ae63-9b09-d9a68d54177b@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.379 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -1.019 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 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 v2 qemu-server 2/2] fix clone_disk failing
 for nonexistent cloudinit disk
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>
X-List-Received-Date: Fri, 16 Oct 2020 13:45:48 -0000

On 06.10.20 13:10, Mira Limbeck wrote:
> On 10/6/20 10:56 AM, Mira Limbeck wrote:
>> On 10/5/20 5:35 PM, Thomas Lamprecht wrote:
>>> On 28.09.20 10:36, Mira Limbeck wrote:
>>>> @@ -6906,6 +6906,8 @@ sub clone_disk {
>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $size =3D PVE=
::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } elsif ($drivename eq 'efidisk0') {
>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $size =3D get=
_efivars_size($conf);
>>>> +=C2=A0=C2=A0=C2=A0 } else {
>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ($size) =3D PVE::Storage=
::volume_size_info($storecfg, $drive->{file}, 3);
>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $size /=3D 1024;
>>> doesn't this logs a "use of undefined value in division" or something=
 like that
>>> somewhere in the non-else case?
>> No, in the cloudinit case we set it to a constant. In the efidisk case=
 we call get_efivars_size() which dies if efivars is not a file, otherwis=
e we get a size (-s). And in the else case we also die if we can't get th=
e size. So size is set in every case before the first use.
> To clarify, the returned size in volume_size_info can be undefined, but=
 not the other 2 cases. Would a die be a good idea in case the volume_siz=
e_info call returns 'undef'?

could be, could be possible to assert that in vdisk_alloc, as there
it rather seems that it's assumed to never be undef; but I just checked
the base and ZFS Plugin, so..