QCOW2 images now support 'extended_l2' which splits the default clusters
into 32 subcluster allocation units. This allows the allocation units to
be smaller without increasing the size of L2 table too much and thus also
the cache requirements for holding the full L2 table in memory.
Unfortunately it's incompatible with qemu versions older than 5.2 thus
can't be used as default.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/formatstorage.rst | 4 ++++
docs/schemas/storagecommon.rng | 5 +++++
src/conf/storage_source_conf.c | 1 +
src/conf/storage_source_conf.h | 1 +
src/storage/storage_util.c | 11 +++++++++++
tests/storagevolxml2argvdata/qcow2-clusterSize.argv | 2 +-
tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml | 3 +++
tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml | 4 ++++
8 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/docs/formatstorage.rst b/docs/formatstorage.rst
index ae700fef4d..838b00de75 100644
--- a/docs/formatstorage.rst
+++ b/docs/formatstorage.rst
@@ -646,6 +646,7 @@ host filesystem. It can contain the following child elements:
<clusterSize unit='KiB'>64</clusterSize>
<features>
<lazy_refcounts/>
+ <extended_l2/>
</features>
</target>
@@ -708,6 +709,9 @@ host filesystem. It can contain the following child elements:
- ``<lazy_refcounts/>`` - allow delayed reference counter updates.
:since:`Since 1.1.0`
+ - ``<extended_l2/>`` - enables subcluster allocation for qcow2 images. QCOW2
+ clusters are split into 32 subclusters decreasing the size of L2 cache
+ needed. It's recommended to increase ``clusterSize``.
Backing store elements
~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng
index 591a158209..10f1bc6a15 100644
--- a/docs/schemas/storagecommon.rng
+++ b/docs/schemas/storagecommon.rng
@@ -134,6 +134,11 @@
<empty/>
</element>
</optional>
+ <optional>
+ <element name="extended_l2">
+ <empty/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
index c0acee189a..d42f715f26 100644
--- a/src/conf/storage_source_conf.c
+++ b/src/conf/storage_source_conf.c
@@ -66,6 +66,7 @@ VIR_ENUM_IMPL(virStorageFileFormat,
VIR_ENUM_IMPL(virStorageFileFeature,
VIR_STORAGE_FILE_FEATURE_LAST,
"lazy_refcounts",
+ "extended_l2",
);
diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h
index 40db29c418..c4a026881c 100644
--- a/src/conf/storage_source_conf.h
+++ b/src/conf/storage_source_conf.h
@@ -86,6 +86,7 @@ VIR_ENUM_DECL(virStorageFileFormat);
typedef enum {
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS = 0,
+ VIR_STORAGE_FILE_FEATURE_EXTENDED_L2,
VIR_STORAGE_FILE_FEATURE_LAST
} virStorageFileFeature;
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index bfc3edb1fd..03874d6ca3 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -796,6 +796,17 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDef
*encinfo,
}
virBufferAddLit(&buf, "lazy_refcounts,");
}
+
+ if (virBitmapIsBitSet(info->features,
+ VIR_STORAGE_FILE_FEATURE_EXTENDED_L2)) {
+ if (STREQ_NULLABLE(info->compat, "0.10")) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("'extended_l2' not supported with compat
level %s"),
+ info->compat);
+ return -1;
+ }
+ virBufferAddLit(&buf, "extended_l2=on,");
+ }
}
virBufferTrim(&buf, ",");
diff --git a/tests/storagevolxml2argvdata/qcow2-clusterSize.argv
b/tests/storagevolxml2argvdata/qcow2-clusterSize.argv
index 8878a26818..c84fc8c47a 100644
--- a/tests/storagevolxml2argvdata/qcow2-clusterSize.argv
+++ b/tests/storagevolxml2argvdata/qcow2-clusterSize.argv
@@ -1,6 +1,6 @@
qemu-img \
create \
-f qcow2 \
--o compat=0.10,cluster_size=131072 \
+-o compat=1.1,cluster_size=131072,extended_l2=on \
/var/lib/libvirt/images/OtherDemo.img \
5242880K
diff --git a/tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml
b/tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml
index 22534982a1..2152a1f280 100644
--- a/tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml
+++ b/tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml
@@ -13,5 +13,8 @@
<label>unconfined_u:object_r:virt_image_t:s0</label>
</permissions>
<clusterSize unit='KiB'>128</clusterSize>
+ <features>
+ <extended_l2/>
+ </features>
</target>
</volume>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml
b/tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml
index 393a492536..40acb21ff8 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml
@@ -12,6 +12,10 @@
<group>0</group>
<label>unconfined_u:object_r:virt_image_t:s0</label>
</permissions>
+ <compat>1.1</compat>
<clusterSize unit='B'>131072</clusterSize>
+ <features>
+ <extended_l2/>
+ </features>
</target>
</volume>
--
2.31.1