[pve-devel] [PATCH manager v2 03/10] Do not use 'autoselect' as a boolean when preselecting a bus

Emmanuel Kasper e.kasper at proxmox.com
Tue Sep 12 14:44:42 CEST 2017


The bus selector is displayed when we add a Hard Disk or CD Drive.
When it is displayed, we *always* preselect the next available
slot on the controller of our choice.
So this test is not needed.

We keep the test on the string value of 'autoselect' to select
a bus position when adding a CD Drive.
---
 www/manager6/form/ControllerSelector.js | 53 ++++++++++++++++-----------------
 www/manager6/qemu/HDEdit.js             |  2 +-
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/www/manager6/form/ControllerSelector.js b/www/manager6/form/ControllerSelector.js
index 002134ef..045e7d0d 100644
--- a/www/manager6/form/ControllerSelector.js
+++ b/www/manager6/form/ControllerSelector.js
@@ -58,37 +58,36 @@ Ext.define('PVE.form.ControllerSelector', {
 	var me = this;
 
 	me.vmconfig = Ext.apply({}, vmconfig);
-	if (autoSelect) {
-	    var clist = ['ide', 'virtio', 'scsi', 'sata'];
-	    if (autoSelect === 'cdrom') {
-		clist = ['ide', 'scsi', 'sata'];
-		if (!Ext.isDefined(me.vmconfig.ide2)) {
-		    me.down('field[name=controller]').setValue('ide');
-		    me.down('field[name=deviceid]').setValue(2);
-		    return;
-		}
-	    } else  {
-		// in most cases we want to add a disk to the same controller
-		// we previously used
-		clist = me.sortByPreviousUsage(me.vmconfig, clist);
+
+	var clist = ['ide', 'virtio', 'scsi', 'sata'];
+	if (autoSelect === 'cdrom') {
+	    clist = ['ide', 'scsi', 'sata'];
+	    if (!Ext.isDefined(me.vmconfig.ide2)) {
+		me.down('field[name=controller]').setValue('ide');
+		me.down('field[name=deviceid]').setValue(2);
+		return;
 	    }
+	} else  {
+	    // in most cases we want to add a disk to the same controller
+	    // we previously used
+	    clist = me.sortByPreviousUsage(me.vmconfig, clist);
+	}
 
-	    Ext.Array.each(clist, function(controller) {
-		var confid, i;
-		if ((controller === 'virtio' && me.noVirtIO) ||
+	Ext.Array.each(clist, function(controller) {
+	    var confid, i;
+	    if ((controller === 'virtio' && me.noVirtIO) ||
 		    (controller === 'scsi' && me.noScsi)) {
-		    return; //continue
-		}
-		me.down('field[name=controller]').setValue(controller);
-		for (i = 0; i <= PVE.form.ControllerSelector.maxIds[controller]; i++) {
-		    confid = controller + i.toString();
-		    if (!Ext.isDefined(me.vmconfig[confid])) {
-			me.down('field[name=deviceid]').setValue(i);
-			return false; // break
-		    }
+		return; //continue
+	    }
+	    me.down('field[name=controller]').setValue(controller);
+	    for (i = 0; i <= PVE.form.ControllerSelector.maxIds[controller]; i++) {
+		confid = controller + i.toString();
+		if (!Ext.isDefined(me.vmconfig[confid])) {
+		    me.down('field[name=deviceid]').setValue(i);
+		    return false; // break
 		}
-	    });
-	}
+	    }
+	});
 	me.down('field[name=deviceid]').validate();
     },
 
diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js
index 464aa49c..2874bfa8 100644
--- a/www/manager6/qemu/HDEdit.js
+++ b/www/manager6/qemu/HDEdit.js
@@ -136,7 +136,7 @@ Ext.define('PVE.qemu.HDInputPanel', {
 	me.vmconfig = vmconfig;
 
 	if (me.bussel) {
-	    me.bussel.setVMConfig(vmconfig, true);
+	    me.bussel.setVMConfig(vmconfig);
 	}
 	if (me.unusedDisks) {
 	    var disklist = [];
-- 
2.11.0





More information about the pve-devel mailing list