[PATCH 4/7] storage_file_probe: Add support for probing qcow2's incompatible features

Peter Krempa pkrempa at redhat.com
Fri Dec 17 15:04:32 UTC 2021


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 at redhat.com>
---
 src/storage_file/storage_file_probe.c | 28 ++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c
index f403e50938..effd9aaa7d 100644
--- a/src/storage_file/storage_file_probe.c
+++ b/src/storage_file/storage_file_probe.c
@@ -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;
 }

-- 
2.31.1




More information about the libvir-list mailing list