From: Peter Krempa Date: Fri, 17 Dec 2021 09:21:04 +0000 (+0100) Subject: storage_file_probe: Add support for probing qcow2's incompatible features X-Git-Tag: v8.0.0-rc1~106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58f5597a770aa5ca03f86cff24b1a008c7f08f91;p=thirdparty%2Flibvirt.git storage_file_probe: Add support for probing qcow2's incompatible features 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 Reviewed-by: Ján Tomko --- 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; }