public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] ui: qemu wizard: use better boot order for second cd drive
@ 2023-11-21  8:35 Dominik Csapak
  2023-11-21 13:37 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-11-21  8:35 UTC (permalink / raw)
  To: pve-devel

in the case we add a second cd drive (for windows), we don't want the
backend logic to only include the first one, since we cannot know
which is bootable and which is (probably) the virtio iso.

so instead, emulate the backend logic for the wizard but include both cd
drives in that case, otherwise let the backend decide like before

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
this is a follow up to "ui: vm wizard: allow second iso for windows vms":
https://lists.proxmox.com/pipermail/pve-devel/2023-November/060546.html

 www/manager6/qemu/CreateWizard.js | 49 ++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 443e42c6..375f0c66 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -26,6 +26,41 @@ Ext.define('PVE.qemu.CreateWizard', {
 
     subject: gettext('Virtual Machine'),
 
+    // fot the special case that we have 2 cdrom drives
+    //
+    // emulates part of the backend bootorder logic, but includes all
+    // cdrom drives since we don't know which one the user put in a bootable iso
+    // and hardcodes the known values (ide0/2, net0)
+    calculateBootOrder: function(values) {
+	// user selected windows + second cdrom
+	if (values.ide0 && values.ide0.match(/media=cdrom/)) {
+	    let disk;
+	    PVE.Utils.forEachBus(['ide', 'scsi', 'virtio', 'sata'], (type, id) => {
+		let confId = type + id;
+		if (!values[confId]) {
+		    return undefined;
+		}
+		if (values[confId].match(/media=cdrom/)) {
+		    return undefined;
+		}
+		disk = confId;
+		return false; // abort loop
+	    });
+
+	    let order = [];
+	    if (disk) {
+		order.push(disk);
+	    }
+	    order.push('ide0', 'ide2');
+	    if (values.net0) {
+		order.push('net0');
+	    }
+
+	    return `order=${order.join(';')}`;
+	}
+	return undefined;
+    },
+
     items: [
 	{
 	    xtype: 'inputpanel',
@@ -228,8 +263,15 @@ Ext.define('PVE.qemu.CreateWizard', {
 	    ],
 	    listeners: {
 		show: function(panel) {
-		    var kv = this.up('window').getValues();
+		    let wizard = this.up('window');
+		    var kv = wizard.getValues();
 		    var data = [];
+
+		    let boot = wizard.calculateBootOrder(kv);
+		    if (boot) {
+			kv.boot = boot;
+		    }
+
 		    Ext.Object.each(kv, function(key, value) {
 			if (key === 'delete') { // ignore
 			    return;
@@ -254,6 +296,11 @@ Ext.define('PVE.qemu.CreateWizard', {
 		var nodename = kv.nodename;
 		delete kv.nodename;
 
+		let boot = wizard.calculateBootOrder(kv);
+		if (boot) {
+		    kv.boot = boot;
+		}
+
 		Proxmox.Utils.API2Request({
 		    url: '/nodes/' + nodename + '/qemu',
 		    waitMsgTarget: wizard,
-- 
2.30.2





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

* [pve-devel] applied: [PATCH manager] ui: qemu wizard: use better boot order for second cd drive
  2023-11-21  8:35 [pve-devel] [PATCH manager] ui: qemu wizard: use better boot order for second cd drive Dominik Csapak
@ 2023-11-21 13:37 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-11-21 13:37 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

Am 21/11/2023 um 09:35 schrieb Dominik Csapak:
> in the case we add a second cd drive (for windows), we don't want the
> backend logic to only include the first one, since we cannot know
> which is bootable and which is (probably) the virtio iso.
> 
> so instead, emulate the backend logic for the wizard but include both cd
> drives in that case, otherwise let the backend decide like before
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> this is a follow up to "ui: vm wizard: allow second iso for windows vms":
> https://lists.proxmox.com/pipermail/pve-devel/2023-November/060546.html
> 
>  www/manager6/qemu/CreateWizard.js | 49 ++++++++++++++++++++++++++++++-
>  1 file changed, 48 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




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

end of thread, other threads:[~2023-11-21 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21  8:35 [pve-devel] [PATCH manager] ui: qemu wizard: use better boot order for second cd drive Dominik Csapak
2023-11-21 13:37 ` [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