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 5E9A460488
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 16:53:26 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 5469D1C228
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 16:53:26 +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) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 44E6F1C21B
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 16:53:25 +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 165BC45DB4
 for <pve-devel@lists.proxmox.com>; Fri, 16 Oct 2020 16:53:25 +0200 (CEST)
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Stefan Reiter <s.reiter@proxmox.com>
References: <20201006133218.25403-1-s.reiter@proxmox.com>
 <20201006133218.25403-5-s.reiter@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Message-ID: <9e9dff0a-bb1c-0a4c-94af-7536fd11b168@proxmox.com>
Date: Fri, 16 Oct 2020 16:53:24 +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: <20201006133218.25403-5-s.reiter@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.378 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 4/7] fix #3010: add
 'bootorder' parameter for better control of boot devices
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 14:53:26 -0000

On 06.10.20 15:32, Stefan Reiter wrote:
> @@ -3213,17 +3210,30 @@ sub config_to_command {
>  	push @$devices, '-device', $kbd if defined($kbd);
>      }
> =20
> +    my $bootorder =3D {};
> +    my $boot =3D parse_property_string($boot_fmt, $conf->{boot}) if $c=
onf->{boot};

Seeing just now, never declare a variable conditionally, this is dangerou=
s in perl,
like a lot! If the check above fails, the variable will operate with the =
value it was
last set too, and not be undef.

You added this pattern also when doing the RNG stuff, so it's clearly som=
ething
you're not aware off but like to use. Please stop doing so, as this led u=
s already
once to a long bug hunt, which I'd like to avoid again.


> +    if (!defined($boot) || $boot->{legacy}) {
> +	$bootorder =3D bootorder_from_legacy($conf, $boot);
> +    } elsif ($boot->{order}) {
> +	# start at 100 to allow user to insert devices before us with -args
> +	my $i =3D 100;
> +	for my $dev (PVE::Tools::split_list($boot->{order})) {
> +	    $bootorder->{$dev} =3D $i++;
> +	}
> +    }
> +