From: Erik Fastermann <e.fastermann@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Erik Fastermann <e.fastermann@proxmox.com>
Subject: [PATCH pve-manager v3 5/6] partially fix #1989: ui: qemu: disk: add qcow2 cache size config
Date: Fri, 16 Oct 2026 14:26:01 +0200 [thread overview]
Message-ID: <20261016122602.183911-6-e.fastermann@proxmox.com> (raw)
In-Reply-To: <20261016122602.183911-1-e.fastermann@proxmox.com>
Add the option to control the size of the qcow2 cache in the VM disk
create and edit dialogs. This can provide significant 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 <e.fastermann@proxmox.com>
---
www/manager6/Parser.js | 2 +-
www/manager6/qemu/HDEdit.js | 81 +++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index 36df8e9d..cc9c6e9d 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..3592890f 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,
+ qcow2CacheSizeBasedOnDisk: false,
},
},
@@ -54,6 +56,15 @@ Ext.define('PVE.qemu.HDInputPanel', {
vm.set('isSCSISingle', value === 'virtio-scsi-single');
},
},
+ 'field[name=diskformat]': {
+ change: 'onDiskFormatChange',
+ // afterrender is needed for setting the initial value
+ afterrender: 'onDiskFormatChange',
+ },
+ },
+
+ onDiskFormatChange: function (field) {
+ this.getViewModel().set('isQcow2', field.getValue() === 'qcow2');
},
init: function (view) {
@@ -88,6 +99,24 @@ Ext.define('PVE.qemu.HDInputPanel', {
me.drive.format = values.diskformat;
}
+ if (me.drive?.format === 'qcow2' || me.drive?.file?.endsWith('.qcow2')) {
+ if (values.qcow2CacheSize) {
+ me.drive['qcow2-cache-size'] = values.qcow2CacheSize;
+ } else {
+ delete me.drive['qcow2-cache-size'];
+ }
+ }
+
+ PVE.Utils.propertyStringSet(
+ me.drive,
+ values.qcow2CacheSizeBasedOnDisk,
+ 'qcow2-cache-size-based-on-disk',
+ );
+ if (values.qcow2CacheSizeBasedOnDisk) {
+ delete me.drive['qcow2-l2-cache-size'];
+ delete me.drive['qcow2-refcount-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');
@@ -156,6 +185,10 @@ Ext.define('PVE.qemu.HDInputPanel', {
values.iothread = PVE.Parser.parseBoolean(drive.iothread);
values.readOnly = PVE.Parser.parseBoolean(drive.ro);
values.aio = drive.aio || '__default__';
+ values.qcow2CacheSizeBasedOnDisk = PVE.Parser.parseBoolean(
+ drive['qcow2-cache-size-based-on-disk'],
+ );
+ values.qcow2CacheSize = drive['qcow2-cache-size'];
values.mbps_rd = drive.mbps_rd;
values.mbps_wr = drive.mbps_wr;
@@ -167,6 +200,11 @@ 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'),
+ );
},
setNodename: function (nodename) {
@@ -355,6 +393,49 @@ Ext.define('PVE.qemu.HDInputPanel', {
disabled: '{!isVirtIO && !isSCSI}',
},
},
+ {
+ xtype: 'numberfield',
+ name: 'qcow2CacheSize',
+ minValue: 1,
+ maxValue: 10 * 1024,
+ allowDecimals: false,
+ fieldLabel: gettext('qcow2 cache') + ' (MiB)',
+ emptyText: gettext('Default cache size'),
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext(
+ 'Total size of the qcow2 cache in MiB. A larger cache can' +
+ ' improve I/O performance on large images. Leave empty to' +
+ ' use the QEMU default (up to 32 MiB L2 cache and 256 KiB' +
+ ' refcount cache with the default disk settings).',
+ ),
+ },
+ bind: {
+ disabled: '{!isQcow2 || qcow2CacheSizeBasedOnDisk}',
+ },
+ listeners: {
+ disable: (field) => field.setValue(null),
+ },
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'qcow2CacheSizeBasedOnDisk',
+ defaultValue: 0,
+ fieldLabel: gettext('qcow2 cache based on disk'),
+ clearOnDisable: true,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext(
+ 'Automatically size the qcow2 cache to cover the whole disk.' +
+ ' Uses roughly 160 KiB of memory per GiB of disk with' +
+ ' the default disk settings.',
+ ),
+ },
+ bind: {
+ value: '{qcow2CacheSizeBasedOnDisk}',
+ disabled: '{!isQcow2}',
+ },
+ },
);
advancedColumn2.push(
--
2.47.3
next prev parent reply other threads:[~2026-10-16 12:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 12:25 [PATCH docs/manager/qemu-server v3 0/6] partially fix #1989: add QEMU qcow2 cache options Erik Fastermann
2026-10-16 12:25 ` [PATCH qemu-server v3 1/6] re-tidy source code Erik Fastermann
2026-10-16 12:25 ` [PATCH qemu-server v3 2/6] drive: fix conversion of bps throttle limits to mbps Erik Fastermann
2026-10-16 12:25 ` [PATCH qemu-server v3 3/6] api: report why drive options are rejected Erik Fastermann
2026-10-16 12:26 ` [PATCH qemu-server v3 4/6] partially fix #1989: disk: add qcow2 cache options Erik Fastermann
2026-10-16 12:26 ` Erik Fastermann [this message]
2026-10-16 12:26 ` [PATCH pve-docs v3 6/6] partially fix #1989: qm: document qcow2 cache size config Erik Fastermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261016122602.183911-6-e.fastermann@proxmox.com \
--to=e.fastermann@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.