From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 918401FF14C for ; Fri, 29 May 2026 14:58:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 78D93AB14; Fri, 29 May 2026 14:58:29 +0200 (CEST) From: Erik Fastermann To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager 3/3] fix #1989: qemu: disk: add cache size config Date: Fri, 29 May 2026 14:58:08 +0200 Message-ID: <20260529125808.204983-4-e.fastermann@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260529125808.204983-1-e.fastermann@proxmox.com> References: <20260529125808.204983-1-e.fastermann@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.021 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: IG4B4SVN5ONJ5V7DMDUF6XFG3LDIMMEJ X-Message-ID-Hash: IG4B4SVN5ONJ5V7DMDUF6XFG3LDIMMEJ X-MailFrom: efastermann@ruth.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Erik Fastermann X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add the option to control the size of the qcow2 L2/refcount cache in the vm disk create and edit dialogs. This enables huge performance gains in some vm configurations. For a detailed explanation see the QEMU docs [0]. Currently only the cache-size is configurable in the frontend, either directly or based on the size of the disk. [0] https://gitlab.com/qemu-project/qemu/-/blob/master/docs/qcow2-cache.txt Signed-off-by: Erik Fastermann --- www/manager6/Parser.js | 2 +- www/manager6/qemu/HDEdit.js | 70 +++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js index 36df8e9d..90467316 100644 --- a/www/manager6/Parser.js +++ b/www/manager6/Parser.js @@ -207,7 +207,7 @@ Ext.define('PVE.Parser', { if (!p || p.match(/^\s*$/)) { return undefined; // continue } - let match = p.match(/^([a-z_]+)=(\S+)$/); + let match = p.match(/^([0-9a-z_]+)=(\S+)$/); if (!match) { if (!p.match(/[=]/)) { res.file = p; diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js index 1bb2bfda..401b8032 100644 --- a/www/manager6/qemu/HDEdit.js +++ b/www/manager6/qemu/HDEdit.js @@ -18,6 +18,8 @@ Ext.define('PVE.qemu.HDInputPanel', { isSCSI: false, isVirtIO: false, isSCSISingle: false, + isQcow2: false, + cacheSizeBasedOnDisk: false, }, }, @@ -54,6 +56,22 @@ Ext.define('PVE.qemu.HDInputPanel', { vm.set('isSCSISingle', value === 'virtio-scsi-single'); }, }, + 'field[name=diskformat]': { + change: function (f, value) { + this.getViewModel().set('isQcow2', value === 'qcow2'); + }, + afterrender: function (f) { + this.getViewModel().set('isQcow2', f.getValue() === 'qcow2'); + }, + }, + 'field[name=cacheSizeBasedOnDisk]': { + change: function (f, value) { + this.getViewModel().set('cacheSizeBasedOnDisk', value); + }, + afterrender: function (f) { + this.getViewModel().set('cacheSizeBasedOnDisk', f.getValue()); + }, + }, }, init: function (view) { @@ -88,6 +106,16 @@ Ext.define('PVE.qemu.HDInputPanel', { me.drive.format = values.diskformat; } + if (me.drive?.format === 'qcow2' || me.drive?.file?.endsWith('.qcow2')) { + if (values.cacheSizeBasedOnDisk) { + me.drive.cache_size = 'based-on-disk'; + } else if (values.cacheSize) { + me.drive.cache_size = values.cacheSize; + } else { + delete me.drive.cache_size; + } + } + PVE.Utils.propertyStringSet(me.drive, !values.backup, 'backup', '0'); PVE.Utils.propertyStringSet(me.drive, values.noreplicate, 'replicate', 'no'); PVE.Utils.propertyStringSet(me.drive, values.discard, 'discard', 'on'); @@ -157,6 +185,14 @@ Ext.define('PVE.qemu.HDInputPanel', { values.readOnly = PVE.Parser.parseBoolean(drive.ro); values.aio = drive.aio || '__default__'; + if (drive.cache_size === 'based-on-disk') { + values.cacheSizeBasedOnDisk = true; + values.cacheSize = undefined; + } else { + values.cacheSizeBasedOnDisk = false; + values.cacheSize = drive.cache_size; + } + values.mbps_rd = drive.mbps_rd; values.mbps_wr = drive.mbps_wr; values.iops_rd = drive.iops_rd; @@ -167,6 +203,12 @@ Ext.define('PVE.qemu.HDInputPanel', { values.iops_wr_max = drive.iops_wr_max; me.setValues(values); + + me.getViewModel().set( + 'isQcow2', + values.diskformat === 'qcow2' || values.hdimage?.endsWith('.qcow2'), + ); + this.getViewModel().set('cacheSizeBasedOnDisk', values.cacheSizeBasedOnDisk); }, setNodename: function (nodename) { @@ -355,6 +397,34 @@ Ext.define('PVE.qemu.HDInputPanel', { disabled: '{!isVirtIO && !isSCSI}', }, }, + { + xtype: 'numberfield', + name: 'cacheSize', + minValue: 1, + step: 1024 * 1024, + fieldLabel: gettext('Cache size'), + emptyText: gettext('Default cache size'), + bind: { + disabled: '{!isQcow2 || cacheSizeBasedOnDisk}', + }, + listeners: { + disable: function (field) { + console.log(field); + field.setValue(null); + }, + }, + }, + { + xtype: 'proxmoxcheckbox', + name: 'cacheSizeBasedOnDisk', + reference: 'cacheSizeBasedOnDisk', + defaultValue: 0, + fieldLabel: gettext('Cache size based on disk'), + clearOnDisable: true, + bind: { + disabled: '{!isQcow2}', + }, + }, ); advancedColumn2.push( -- 2.47.3