]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Introduce 'extended_l2' feature for storage volume
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Dec 2021 15:05:09 +0000 (16:05 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Dec 2021 12:23:09 +0000 (13:23 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/formatstorage.rst
docs/schemas/storagecommon.rng
src/conf/storage_source_conf.c
src/conf/storage_source_conf.h
src/storage/storage_util.c
tests/storagevolxml2argvdata/qcow2-clusterSize.argv
tests/storagevolxml2xmlin/vol-qcow2-clusterSize.xml
tests/storagevolxml2xmlout/vol-qcow2-clusterSize.xml

index d7ca58788a3d91efd2ca21653af0c138dc1ad58d..ef15c0ac5c7aab830e117998edc4a3080dea87d7 100644 (file)
@@ -652,6 +652,7 @@ host filesystem. It can contain the following child elements:
      <clusterSize unit='KiB'>64</clusterSize>
      <features>
        <lazy_refcounts/>
+       <extended_l2/>
      </features>
    </target>
 
@@ -714,6 +715,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
 ~~~~~~~~~~~~~~~~~~~~~~
index 591a158209c7ba474993d0cebb39ea738c197b72..10f1bc6a15be49f9402da4f65608b79a88ca6c0a 100644 (file)
             <empty/>
           </element>
         </optional>
+        <optional>
+          <element name="extended_l2">
+            <empty/>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index c0acee189a1d915ff0728aa4d74cd879ce699261..d42f715f261033c035636a1b7d0b6935ebf1e1e9 100644 (file)
@@ -66,6 +66,7 @@ VIR_ENUM_IMPL(virStorageFileFormat,
 VIR_ENUM_IMPL(virStorageFileFeature,
               VIR_STORAGE_FILE_FEATURE_LAST,
               "lazy_refcounts",
+              "extended_l2",
 );
 
 
index 40db29c418b13ebc38293f3950de8243899dbadd..c4a026881c755787825ba4b56ac15a8c83f41203 100644 (file)
@@ -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;
index bfc3edb1fdbfde8e9b2fe465282bb775ce80be6e..03874d6ca3666b2a5d317ae2de83f39c89e8fb4f 100644 (file)
@@ -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, ",");
index 8878a26818cda3719f39adb20d46f451b85f3ccd..c84fc8c47a43f26d325a873e69af9d9733da2096 100644 (file)
@@ -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
index 22534982a1feb9861047e25af297c3bb81f312f7..2152a1f28091da038ee3a9c8ae4c7cbc3ad53558 100644 (file)
@@ -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>
index 393a4925364b10ce075632744b49427eefad5ed6..40acb21ff88e6ee23c9e10b9d3f80b92a1131cb1 100644 (file)
       <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>