[pve-devel] [PATCH v2 qemu-server 4/7] fix #3010: add 'bootorder' parameter for better control of boot devices

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Oct 16 16:53:24 CEST 2020


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

Seeing just now, never declare a variable conditionally, this is dangerous 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 something
you're not aware off but like to use. Please stop doing so, as this led us already
once to a long bug hunt, which I'd like to avoid again.


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






More information about the pve-devel mailing list