mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qcow2GetFeatures: Extract population of features bitmap
Prepare for extraction of features from the 'incompatible features' group. This is done by moving the extraction loop into a new function called qcow2GetFeaturesProcessGroup. The new function also allows to ingore features we don't care about by passing VIR_STORAGE_FILE_FEATURE_LAST as the target flag. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
66566e84b8
commit
fe330b58c4
@ -344,7 +344,7 @@ enum qcow2CompatibleFeature {
|
||||
};
|
||||
|
||||
/* conversion to virStorageFileFeature */
|
||||
static const int qcow2CompatibleFeatureArray[] = {
|
||||
static const virStorageFileFeature qcow2CompatibleFeatureArray[] = {
|
||||
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS,
|
||||
};
|
||||
G_STATIC_ASSERT(G_N_ELEMENTS(qcow2CompatibleFeatureArray) ==
|
||||
@ -748,6 +748,22 @@ virStorageFileProbeFormatFromBuf(const char *path,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qcow2GetFeaturesProcessGroup(uint64_t bits,
|
||||
const virStorageFileFeature *featuremap,
|
||||
size_t nfeatures,
|
||||
virBitmap *features)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nfeatures; i++) {
|
||||
if ((bits & ((uint64_t) 1 << i)) &&
|
||||
featuremap[i] != VIR_STORAGE_FILE_FEATURE_LAST)
|
||||
ignore_value(virBitmapSetBit(features, featuremap[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qcow2GetFeatures(virBitmap **features,
|
||||
int format,
|
||||
@ -755,9 +771,6 @@ qcow2GetFeatures(virBitmap **features,
|
||||
ssize_t len)
|
||||
{
|
||||
int version = -1;
|
||||
virBitmap *feat = NULL;
|
||||
uint64_t bits;
|
||||
size_t i;
|
||||
|
||||
version = virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset);
|
||||
|
||||
@ -767,16 +780,14 @@ qcow2GetFeatures(virBitmap **features,
|
||||
if (len < QCOW2v3_HDR_SIZE)
|
||||
return -1;
|
||||
|
||||
feat = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
|
||||
*features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
|
||||
|
||||
/* todo: check for incompatible or autoclear features? */
|
||||
bits = virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE);
|
||||
for (i = 0; i < QCOW2_COMPATIBLE_FEATURE_LAST; i++) {
|
||||
if (bits & ((uint64_t) 1 << i))
|
||||
ignore_value(virBitmapSetBit(feat, qcow2CompatibleFeatureArray[i]));
|
||||
}
|
||||
qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE),
|
||||
qcow2CompatibleFeatureArray,
|
||||
G_N_ELEMENTS(qcow2CompatibleFeatureArray),
|
||||
*features);
|
||||
|
||||
*features = feat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user