public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] api: always add new CD drives to bootorder
@ 2021-07-05  9:14 Stefan Reiter
  2021-07-23  9:05 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Reiter @ 2021-07-05  9:14 UTC (permalink / raw)
  To: pve-devel

Attaching an ISO image to a VM is usually/often done for two reasons:
* booting an installer image
* supplying additional drivers to an installer (e.g. virtio)

Both of these cases (the latter at least with SeaBIOS and the Windows
installer) require the disk to be marked as bootable.

For this reason, enable the bootable flag for all new CDROM drives
attached to a VM by adding it to the bootorder list. It is appended to
the end, as otherwise it would cause new drives to boot before already
existing boot targets, which would be a more grave (and IMO bad)
behaviour change.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 PVE/API2/Qemu.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 1e540f5..b750db0 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1357,6 +1357,14 @@ my $update_vm_api  = sub {
 			if defined($conf->{pending}->{$opt});
 
 		    &$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)) {
+			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') {
 			$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.HWType']);
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-23  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05  9:14 [pve-devel] [PATCH qemu-server] api: always add new CD drives to bootorder Stefan Reiter
2021-07-23  9:05 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal