]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_file_probe: Move setting of 'compat' attribute to qcow2GetFeatures
authorPeter Krempa <pkrempa@redhat.com>
Wed, 28 May 2025 16:13:39 +0000 (18:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2025 11:11:03 +0000 (13:11 +0200)
Since the 'compat' field is set based on qcow2 features it belongs to
the qcow2 code rather than to the main metadata probing function.

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

index 73751c7a2f9652f06c7274c31abc718ab7e3b721..9fcc052ea3ad732c8dd86db04a05010f8704d097 100644 (file)
@@ -579,6 +579,7 @@ qcow2GetFeatures(virStorageSource *meta,
     int version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION);
 
     g_clear_pointer(&meta->features, virBitmapFree);
+    g_clear_pointer(&meta->compat, g_free);
 
     if (version == 2)
         return 0;
@@ -587,6 +588,7 @@ qcow2GetFeatures(virStorageSource *meta,
         return -1;
 
     meta->features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);
+    meta->compat = g_strdup("1.1");
 
     qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE),
                                  qcow2CompatibleFeatureArray,
@@ -997,10 +999,6 @@ virStorageFileProbeGetMetadata(virStorageSource *meta,
                                                buf, len);
     }
 
-    VIR_FREE(meta->compat);
-    if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features)
-        meta->compat = g_strdup("1.1");
-
     return 0;
 }