Re: [PATCH 14/30] storagefile: Parse qcow2 external data file

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

 





On 10/7/19 6:49 PM, Cole Robinson wrote:
This is tracked as a qcow2 extension, like backing store format

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---

Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>


  src/util/virstoragefile.c | 22 ++++++++++++++++++++--
  1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 621cc56e87..7e32d7619e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -202,6 +202,7 @@ qedGetBackingStore(char **, int *, const char *, size_t);
#define QCOW2_HDR_EXTENSION_END 0
  #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA
+#define QCOW2_HDR_EXTENSION_DATA_FILE 0x44415441
#define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE)
  #define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE+8)
@@ -429,7 +430,8 @@ cowGetBackingStore(char **res,
  static int
  qcow2GetExtensions(const char *buf,
                     size_t buf_size,
-                   int *backingFormat)
+                   int *backingFormat,
+                   char **externalDataStoreRaw)
  {
      size_t offset;
      size_t extension_start;
@@ -508,6 +510,9 @@ qcow2GetExtensions(const char *buf,
case QCOW2_HDR_EXTENSION_BACKING_FORMAT: {
              VIR_AUTOFREE(char *) tmp = NULL;
+            if (!backingFormat)
+                break;
+
              if (VIR_ALLOC_N(tmp, len + 1) < 0)
                  return -1;
              memcpy(tmp, buf + offset, len);
@@ -516,6 +521,19 @@ qcow2GetExtensions(const char *buf,
              *backingFormat = virStorageFileFormatTypeFromString(tmp);
              if (*backingFormat <= VIR_STORAGE_FILE_NONE)
                  return -1;
+            break;
+        }
+
+        case QCOW2_HDR_EXTENSION_DATA_FILE: {
+            if (!externalDataStoreRaw)
+                break;
+
+            if (VIR_ALLOC_N(*externalDataStoreRaw, len + 1) < 0)
+                return -1;
+            memcpy(*externalDataStoreRaw, buf + offset, len);
+            (*externalDataStoreRaw)[len] = '\0';
+            VIR_DEBUG("parsed externalDataStoreRaw='%s'", *externalDataStoreRaw);
+            break;
          }
          }
@@ -566,7 +584,7 @@ qcowXGetBackingStore(char **res,
      memcpy(*res, buf + offset, size);
      (*res)[size] = '\0';
- if (qcow2GetExtensions(buf, buf_size, format) < 0)
+    if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0)
          return BACKING_STORE_INVALID;
return BACKING_STORE_OK;

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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