[pve-devel] [PATCH qemu-server] api2: only add ide drives for non-legacy bootorders

Dominik Csapak d.csapak at proxmox.com
Thu Aug 5 13:53:01 CEST 2021


@bootorder only contains entries for non-legacy bootorder entries,
but the default one contains all cdroms anyway, and if the user
explicitely disabled cdroms, it is ok to not add them back
for the new cdrom drive.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
view with -w to see the actual change
 PVE/API2/Qemu.pm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 94cc0d2..ef0d877 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1358,12 +1358,15 @@ my $update_vm_api  = sub {
 
 		    &$create_disks($rpcenv, $authuser, $conf->{pending}, $arch, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
 
-		    # append new CD drives to bootorder to mark them bootable
-		    my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
-		    if (PVE::QemuServer::drive_is_cdrom($drive, 1) && !grep(/^$opt$/, @bootorder)) {
-			push @bootorder, $opt;
-			$conf->{pending}->{boot} = PVE::QemuServer::print_bootorder(\@bootorder);
-			$modified->{boot} = 1;
+		    # default legacy boot order implies all cdroms anyway
+		    if (@bootorder) {
+			# append new CD drives to bootorder to mark them bootable
+			my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
+			if (PVE::QemuServer::drive_is_cdrom($drive, 1) && !grep(/^$opt$/, @bootorder)) {
+			    push @bootorder, $opt;
+			    $conf->{pending}->{boot} = PVE::QemuServer::print_bootorder(\@bootorder);
+			    $modified->{boot} = 1;
+			}
 		    }
 		} elsif ($opt =~ m/^serial\d+/) {
 		    if ((!defined($conf->{$opt}) || $conf->{$opt} eq 'socket') && $param->{$opt} eq 'socket') {
-- 
2.30.2






More information about the pve-devel mailing list