From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 5C22D1FF16E
	for <inbox@lore.proxmox.com>; Mon, 17 Feb 2025 16:05:01 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 177362B806;
	Mon, 17 Feb 2025 16:04:51 +0100 (CET)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Mon, 17 Feb 2025 16:04:43 +0100
Message-Id: <20250217150444.142182-3-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250217150444.142182-1-f.ebner@proxmox.com>
References: <20250217150444.142182-1-f.ebner@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.047 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH manager 2/3] close #5291: ui: qemu: memory edit:
 support disabling KSM for specific VMs
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 www/manager6/qemu/HardwareView.js | 11 +++++++-
 www/manager6/qemu/MemoryEdit.js   | 43 ++++++++++++++++++++++++++-----
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index c6d193fc..815dfcc2 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -73,7 +73,7 @@ Ext.define('PVE.qemu.HardwareView', {
 		defaultValue: '512',
 		tdCls: 'pve-itype-icon-memory',
 		group: 2,
-		multiKey: ['memory', 'balloon', 'shares'],
+		multiKey: ['memory', 'balloon', 'shares', 'allow-ksm'],
 		renderer: function(value, metaData, record, ri, ci, store, pending) {
 		    var res = '';
 
@@ -92,6 +92,12 @@ Ext.define('PVE.qemu.HardwareView', {
 		    } else if (balloon === 0) {
 			res += ' [balloon=0]';
 		    }
+
+		    let allowKsm = me.getObjectValue('allow-ksm', undefined, pending);
+		    if (allowKsm !== undefined) {
+			res += ' [allow-ksm=' + allowKsm + ']';
+		    }
+
 		    return res;
 		},
 	    },
@@ -197,6 +203,9 @@ Ext.define('PVE.qemu.HardwareView', {
 	    numa: {
 		visible: false,
 	    },
+	    'allow-ksm': {
+		visible: false,
+	    },
 	    balloon: {
 		visible: false,
 	    },
diff --git a/www/manager6/qemu/MemoryEdit.js b/www/manager6/qemu/MemoryEdit.js
index 5e91dc9b..e7f1f688 100644
--- a/www/manager6/qemu/MemoryEdit.js
+++ b/www/manager6/qemu/MemoryEdit.js
@@ -32,23 +32,39 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
     },
 
     onGetValues: function(values) {
-	var me = this;
+	let res = {};
 
-	var res = {};
+	let deleteSet = new Set([]);
+
+	// properties that can be passed as-is
+	let propagate = ['allow-ksm', 'memory'];
+
+	propagate.forEach(function(prop) {
+	    if (values.delete?.split(',').includes(prop)) {
+		deleteSet.add(prop);
+	    }
+	    if (prop in values) {
+		res[prop] = values[prop];
+	    }
+	});
 
-	res.memory = values.memory;
 	res.balloon = values.balloon;
 
 	if (!values.ballooning) {
 	    res.balloon = 0;
-	    res.delete = 'shares';
+	    deleteSet.add('shares');
 	} else if (values.memory === values.balloon) {
 	    delete res.balloon;
-	    res.delete = 'balloon,shares';
+	    deleteSet.add('balloon');
+	    deleteSet.add('shares');
 	} else if (Ext.isDefined(values.shares) && values.shares !== "") {
 	    res.shares = values.shares;
 	} else {
-	    res.delete = "shares";
+	    deleteSet.add('shares');
+	}
+
+	if (deleteSet.size > 0) {
+	    res.delete = deleteSet.keys().toArray().join(',');
 	}
 
 	return res;
@@ -132,6 +148,20 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		    },
 		},
 	    },
+	    {
+		xtype: 'proxmoxcheckbox',
+		name: 'allow-ksm',
+		labelWidth: labelWidth,
+		fieldLabel: gettext('Allow KSM'),
+		checked: true,
+		uncheckedValue: '0',
+		defaultValue: '1',
+		deleteDefaultValue: true,
+		autoEl: {
+		    tag: 'div',
+		    'data-qtip': gettext('Allow the Kernel Samepage Merging daemon to merge memory pages of this VM.'),
+		},
+	    },
 	];
 
 	if (me.insideWizard) {
@@ -183,6 +213,7 @@ Ext.define('PVE.qemu.MemoryEdit', {
 		    shares: data.shares,
 		    memory: data.memory || '512',
 		    balloon: data.balloon > 0 ? data.balloon : data.memory || '512',
+		    'allow-ksm': data['allow-ksm'] ?? true,
 		};
 
 		ipanel.setValues(values);
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel