[PATCH 10/15] storage_file_probe: Move logic from qcow2GetClusterSize to qcow2GetImageSpecific

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Krempa <pkrempa@xxxxxxxxxx>

Move the cluster size parser into the image specific code for qcow2,
which will later allow us to remove the callback for cluster size which
is not used by any other format.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/storage_file/storage_file_probe.c | 31 ++++++++-------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c
index ce8ba4b884..21a1013102 100644
--- a/src/storage_file/storage_file_probe.c
+++ b/src/storage_file/storage_file_probe.c
@@ -114,9 +114,6 @@ static int
 qcow2GetImageSpecific(virStorageSource *meta,
                       const char *buf,
                       size_t buf_size);
-static unsigned long long
-qcow2GetClusterSize(const char *buf,
-                    size_t buf_size);
 static int qcow2GetDataFile(char **, virBitmap *, char *, size_t);
 static int qcow2GetFeatures(virBitmap **features, int format,
                             char *buf, ssize_t len);
@@ -329,7 +326,7 @@ static struct FileTypeInfo const fileTypeInfo[] = {
         LV_BIG_ENDIAN, 4, 4, {2, 3},
         QCOWX_HDR_IMAGE_SIZE, 8, 1,
         qcow2EncryptionInfo,
-        qcow2GetClusterSize,
+        NULL,
         NULL,
         qcow2GetDataFile,
         qcow2GetFeatures,
@@ -532,24 +529,6 @@ qcow2GetExtensions(const char *buf,
 }


-static unsigned long long
-qcow2GetClusterSize(const char *buf,
-                    size_t buf_size)
-{
-    int clusterBits = 0;
-
-    if ((QCOWX_HDR_CLUSTER_BITS_OFFSET + 4) > buf_size)
-        return 0;
-
-    clusterBits = virReadBufInt32BE(buf + QCOWX_HDR_CLUSTER_BITS_OFFSET);
-
-    if (clusterBits > 0)
-        return 1ULL << clusterBits;
-
-    return 0;
-}
-
-
 static int
 qcowXGetBackingStore(virStorageSource *meta,
                      const char *buf,
@@ -601,6 +580,14 @@ qcow2GetImageSpecific(virStorageSource *meta,
 {
     int format;

+    meta->clusterSize = 0;
+    if (buf_size > (QCOWX_HDR_CLUSTER_BITS_OFFSET + 4)) {
+        int clusterBits = virReadBufInt32BE(buf + QCOWX_HDR_CLUSTER_BITS_OFFSET);
+
+        if (clusterBits > 0)
+            meta->clusterSize = 1ULL << clusterBits;
+    }
+
     if (qcowXGetBackingStore(meta, buf, buf_size) < 0)
         return -1;

-- 
2.49.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux