]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storagefile: Check version to determine if qcow2 or not
authorCole Robinson <crobinso@redhat.com>
Fri, 4 Oct 2019 22:12:14 +0000 (18:12 -0400)
committerCole Robinson <crobinso@redhat.com>
Fri, 11 Oct 2019 17:41:21 +0000 (13:41 -0400)
Rather than require a boolean to be passed in

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
src/util/virstoragefile.c

index 905e70b1a94ebc7f76a631985eae061b59678330..9bf4c1178b83d05d798d43121dec912915b16d7c 100644 (file)
@@ -486,7 +486,7 @@ qcowXGetBackingStore(char **res,
                      int *format,
                      const char *buf,
                      size_t buf_size,
-                     bool isQCow2)
+                     bool isQCow2 ATTRIBUTE_UNUSED)
 {
     unsigned long long offset;
     unsigned int size;
@@ -548,8 +548,11 @@ qcowXGetBackingStore(char **res,
      * for qcow2 v3 images, the length of the header
      * is stored at QCOW2v3_HDR_SIZE
      */
-    if (isQCow2) {
-        version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION);
+
+    version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION);
+    if (version >= 2) {
+        /* QCow1 doesn't have the extensions capability
+         * used to store backing format */
         if (version == 2)
             start = QCOW2_HDR_TOTAL_SIZE;
         else
@@ -569,8 +572,6 @@ qcow1GetBackingStore(char **res,
                      const char *buf,
                      size_t buf_size)
 {
-    /* QCow1 doesn't have the extensions capability
-     * used to store backing format */
     return qcowXGetBackingStore(res, format, buf, buf_size, false);
 }