[PATCH 05/15] storage file: add getDataFile function to FileTypeInfo

Nikolai Barybin via Devel posted 15 patches 2 days, 17 hours ago
[PATCH 05/15] storage file: add getDataFile function to FileTypeInfo
Posted by Nikolai Barybin via Devel 2 days, 17 hours ago
Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com>
---
 src/storage_file/storage_file_probe.c | 34 ++++++++++++++-------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c
index 243927d50a..ad14350edc 100644
--- a/src/storage_file/storage_file_probe.c
+++ b/src/storage_file/storage_file_probe.c
@@ -93,6 +93,7 @@ struct FileTypeInfo {
                                          size_t buf_size);
     int (*getBackingStore)(char **res, int *format,
                            const char *buf, size_t buf_size);
+    int (*getDataFile)(char **res, virBitmap *features, char *buf, size_t buf_size);
     int (*getFeatures)(virBitmap **features, int format,
                        char *buf, ssize_t len);
 };
@@ -238,18 +239,18 @@ static struct FileEncryptionInfo const qcow2EncryptionInfo[] = {
 
 static struct FileTypeInfo const fileTypeInfo[] = {
     [VIR_STORAGE_FILE_NONE] = { 0, NULL, LV_LITTLE_ENDIAN,
-                                -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL },
+                                -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL, NULL },
     [VIR_STORAGE_FILE_RAW] = { 0, NULL, LV_LITTLE_ENDIAN,
                                -1, 0, {0}, 0, 0, 0,
                                luksEncryptionInfo,
-                               NULL, NULL, NULL },
+                               NULL, NULL, NULL, NULL },
     [VIR_STORAGE_FILE_DIR] = { 0, NULL, LV_LITTLE_ENDIAN,
-                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL },
+                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL, NULL },
     [VIR_STORAGE_FILE_BOCHS] = {
         /*"Bochs Virtual HD Image", */ /* Untested */
         0, NULL,
         LV_LITTLE_ENDIAN, 64, 4, {0x20000},
-        32+16+16+4+4+4+4+4, 8, 1, NULL, NULL, NULL, NULL
+        32+16+16+4+4+4+4+4, 8, 1, NULL, NULL, NULL, NULL, NULL
     },
     [VIR_STORAGE_FILE_CLOOP] = {
         /* #!/bin/sh
@@ -258,7 +259,7 @@ static struct FileTypeInfo const fileTypeInfo[] = {
         */ /* Untested */
         0, NULL,
         LV_LITTLE_ENDIAN, -1, 0, {0},
-        -1, 0, 0, NULL, NULL, NULL, NULL
+        -1, 0, 0, NULL, NULL, NULL, NULL, NULL
     },
     [VIR_STORAGE_FILE_DMG] = {
         /* XXX QEMU says there's no magic for dmg,
@@ -266,45 +267,45 @@ static struct FileTypeInfo const fileTypeInfo[] = {
          * would have to match) but then disables that check. */
         0, NULL,
         0, -1, 0, {0},
-        -1, 0, 0, NULL, NULL, NULL, NULL
+        -1, 0, 0, NULL, NULL, NULL, NULL, NULL
     },
     [VIR_STORAGE_FILE_ISO] = {
         32769, "CD001",
         LV_LITTLE_ENDIAN, -2, 0, {0},
-        -1, 0, 0, NULL, NULL, NULL, NULL
+        -1, 0, 0, NULL, NULL, NULL, NULL, NULL
     },
     [VIR_STORAGE_FILE_VPC] = {
         0, "conectix",
         LV_BIG_ENDIAN, 12, 4, {0x10000},
-        8 + 4 + 4 + 8 + 4 + 4 + 2 + 2 + 4, 8, 1, NULL, NULL, NULL, NULL
+        8 + 4 + 4 + 8 + 4 + 4 + 2 + 2 + 4, 8, 1, NULL, NULL, NULL, NULL, NULL
     },
     /* TODO: add getBackingStore function */
     [VIR_STORAGE_FILE_VDI] = {
         64, "\x7f\x10\xda\xbe",
         LV_LITTLE_ENDIAN, 68, 4, {0x00010001},
-        64 + 5 * 4 + 256 + 7 * 4, 8, 1, NULL, NULL, NULL, NULL},
+        64 + 5 * 4 + 256 + 7 * 4, 8, 1, NULL, NULL, NULL, NULL, NULL},
 
     /* Not direct file formats, but used for various drivers */
     [VIR_STORAGE_FILE_FAT] = { 0, NULL, LV_LITTLE_ENDIAN,
-                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL },
+                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL, NULL },
     [VIR_STORAGE_FILE_VHD] = { 0, NULL, LV_LITTLE_ENDIAN,
-                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL },
+                               -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL, NULL },
     [VIR_STORAGE_FILE_PLOOP] = { 0, "WithouFreSpacExt", LV_LITTLE_ENDIAN,
                                  -2, 0, {0}, PLOOP_IMAGE_SIZE_OFFSET, 8,
-                                 PLOOP_SIZE_MULTIPLIER, NULL, NULL, NULL, NULL },
+                                 PLOOP_SIZE_MULTIPLIER, NULL, NULL, NULL, NULL, NULL },
 
     /* All formats with a backing store probe below here */
     [VIR_STORAGE_FILE_COW] = {
         0, "OOOM",
         LV_BIG_ENDIAN, 4, 4, {2},
-        4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL
+        4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL, NULL
     },
     [VIR_STORAGE_FILE_QCOW] = {
         0, "QFI",
         LV_BIG_ENDIAN, 4, 4, {1},
         QCOWX_HDR_IMAGE_SIZE, 8, 1,
         qcow1EncryptionInfo,
-        NULL, qcowXGetBackingStore, NULL
+        NULL, qcowXGetBackingStore, NULL, NULL
     },
     [VIR_STORAGE_FILE_QCOW2] = {
         0, "QFI",
@@ -313,18 +314,19 @@ static struct FileTypeInfo const fileTypeInfo[] = {
         qcow2EncryptionInfo,
         qcow2GetClusterSize,
         qcowXGetBackingStore,
+        NULL,
         qcow2GetFeatures
     },
     [VIR_STORAGE_FILE_QED] = {
         /* https://wiki.qemu.org/Features/QED */
         0, "QED",
         LV_LITTLE_ENDIAN, -2, 0, {0},
-        QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, qedGetBackingStore, NULL
+        QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, qedGetBackingStore, NULL, NULL
     },
     [VIR_STORAGE_FILE_VMDK] = {
         0, "KDMV",
         LV_LITTLE_ENDIAN, 4, 4, {1, 2, 3},
-        4+4+4, 8, 512, NULL, NULL, vmdk4GetBackingStore, NULL
+        4+4+4, 8, 512, NULL, NULL, vmdk4GetBackingStore, NULL, NULL
     },
 };
 G_STATIC_ASSERT(G_N_ELEMENTS(fileTypeInfo) == VIR_STORAGE_FILE_LAST);
-- 
2.43.5
Re: [PATCH 05/15] storage file: add getDataFile function to FileTypeInfo
Posted by Peter Krempa 1 day, 19 hours ago
On Wed, Nov 20, 2024 at 18:48:40 +0300, Nikolai Barybin via Devel wrote:
> Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com>
> ---
>  src/storage_file/storage_file_probe.c | 34 ++++++++++++++-------------
>  1 file changed, 18 insertions(+), 16 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>