]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_file_probe: Add support for probing qcow2's incompatible features
authorPeter Krempa <pkrempa@redhat.com>
Fri, 17 Dec 2021 09:21:04 +0000 (10:21 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Dec 2021 12:23:09 +0000 (13:23 +0100)
Add machinery for probing the incompatible feature flags field and
specifically extract whether the extended l2 feature (1 << 4) is
present.

For now we don't care abot the other features.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage_file/storage_file_probe.c

index f403e50938c5ea653d08b2ef89cf40f20ecc30e8..effd9aaa7d43df2a1742ba87f817f7e9906e838a 100644 (file)
@@ -350,6 +350,28 @@ static const virStorageFileFeature qcow2CompatibleFeatureArray[] = {
 G_STATIC_ASSERT(G_N_ELEMENTS(qcow2CompatibleFeatureArray) ==
        QCOW2_COMPATIBLE_FEATURE_LAST);
 
+/* qcow2 incompatible features in the order they appear on-disk */
+enum qcow2IncompatibleFeature {
+    QCOW2_INCOMPATIBLE_FEATURE_DIRTY = 0,
+    QCOW2_INCOMPATIBLE_FEATURE_CORRUPT,
+    QCOW2_INCOMPATIBLE_FEATURE_DATA_FILE,
+    QCOW2_INCOMPATIBLE_FEATURE_COMPRESSION,
+    QCOW2_INCOMPATIBLE_FEATURE_EXTL2,
+
+    QCOW2_INCOMPATIBLE_FEATURE_LAST
+};
+
+/* conversion to virStorageFileFeature */
+static const virStorageFileFeature qcow2IncompatibleFeatureArray[] = {
+    VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_DIRTY */
+    VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_CORRUPT */
+    VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_DATA_FILE */
+    VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_COMPRESSION */
+    VIR_STORAGE_FILE_FEATURE_EXTENDED_L2, /* QCOW2_INCOMPATIBLE_FEATURE_EXTL2 */
+};
+G_STATIC_ASSERT(G_N_ELEMENTS(qcow2IncompatibleFeatureArray) == QCOW2_INCOMPATIBLE_FEATURE_LAST);
+
+
 static int
 cowGetBackingStore(char **res,
                    int *format,
@@ -782,12 +804,16 @@ qcow2GetFeatures(virBitmap **features,
 
     *features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
 
-    /* todo: check for incompatible or autoclear features? */
     qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE),
                                  qcow2CompatibleFeatureArray,
                                  G_N_ELEMENTS(qcow2CompatibleFeatureArray),
                                  *features);
 
+    qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_INCOMPATIBLE),
+                                 qcow2IncompatibleFeatureArray,
+                                 G_N_ELEMENTS(qcow2IncompatibleFeatureArray),
+                                 *features);
+
     return 0;
 }