[PATCH 13/18] maint: Switch over from struct virStorageFileMetadata to virStorageSource

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

 



Replace the old structure with the new one. This change is a trivial
name change operation (along with change of the freeing function).
---
 src/conf/domain_conf.c                |  4 +--
 src/conf/domain_conf.h                |  2 +-
 src/qemu/qemu_domain.c                |  2 +-
 src/qemu/qemu_driver.c                | 16 +++++------
 src/storage/storage_backend_fs.c      |  4 +--
 src/storage/storage_backend_gluster.c |  4 +--
 src/util/virstoragefile.c             | 54 +++++++++++++++++------------------
 src/util/virstoragefile.h             | 32 ++++++++++-----------
 tests/virstoragetest.c                | 20 ++++++-------
 9 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 006aa96..695d7ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1190,7 +1190,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
     virStorageSourceClear(&def->src);
     VIR_FREE(def->serial);
     VIR_FREE(def->dst);
-    virStorageFileFreeMetadata(def->backingChain);
+    virStorageSourceFree(def->backingChain);
     VIR_FREE(def->mirror);
     VIR_FREE(def->wwn);
     VIR_FREE(def->vendor);
@@ -18553,7 +18553,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
 {
     int ret = -1;
     size_t depth = 0;
-    virStorageFileMetadata *tmp;
+    virStorageSourcePtr tmp;
     const char *path = virDomainDiskGetSource(disk);
     int type = virDomainDiskGetType(disk);

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2ff0bc4..56bb8bd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -605,7 +605,7 @@ struct _virDomainDiskDef {
     char *dst;
     int tray_status; /* enum virDomainDiskTray */
     int removable; /* enum virDomainFeatureState */
-    virStorageFileMetadataPtr backingChain;
+    virStorageSourcePtr backingChain;

     char *mirror;
     int mirrorFormat; /* enum virStorageFileFormat */
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1641eed..b6f9e6a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2410,7 +2410,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,

     if (disk->backingChain) {
         if (force) {
-            virStorageFileFreeMetadata(disk->backingChain);
+            virStorageSourceFree(disk->backingChain);
             disk->backingChain = NULL;
         } else {
             goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c242104..8005213 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10303,7 +10303,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
     int ret = -1;
     int fd = -1;
     off_t end;
-    virStorageFileMetadata *meta = NULL;
+    virStorageSourcePtr meta = NULL;
     virDomainDiskDefPtr disk = NULL;
     struct stat sb;
     int idx;
@@ -10450,7 +10450,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,

  cleanup:
     VIR_FREE(alias);
-    virStorageFileFreeMetadata(meta);
+    virStorageSourceFree(meta);
     VIR_FORCE_CLOSE(fd);

     /* If we failed to get data from a domain because it's inactive and
@@ -12022,7 +12022,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
      * temporarily modify the disk in place.  */
     char *origsrc = disk->src.path;
     int origformat = disk->src.format;
-    virStorageFileMetadataPtr origchain = disk->backingChain;
+    virStorageSourcePtr origchain = disk->backingChain;
     bool origreadonly = disk->readonly;
     int ret = -1;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -12735,7 +12735,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
      * recompute it.  Better would be storing the chain ourselves rather than
      * reprobing, but this requires modifying domain_conf and our XML to fully
      * track the chain across libvirtd restarts.  */
-    virStorageFileFreeMetadata(disk->backingChain);
+    virStorageSourceFree(disk->backingChain);
     disk->backingChain = NULL;

     if (virStorageFileInit(&snap->src) < 0)
@@ -14715,7 +14715,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
     bool resume = false;
     char *oldsrc = NULL;
     int oldformat;
-    virStorageFileMetadataPtr oldchain = NULL;
+    virStorageSourcePtr oldchain = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);

     /* Probe the status, if needed.  */
@@ -14810,7 +14810,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
          * fact that we aren't tracking the full chain ourselves; so
          * for now, we leak the access to the original.  */
         VIR_FREE(oldsrc);
-        virStorageFileFreeMetadata(oldchain);
+        virStorageSourceFree(oldchain);
         disk->mirror = NULL;
     } else {
         /* On failure, qemu abandons the mirror, and reverts back to
@@ -14823,7 +14823,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
          * success case, there's security labeling to worry about.  */
         disk->src.path = oldsrc;
         disk->src.format = oldformat;
-        virStorageFileFreeMetadata(disk->backingChain);
+        virStorageSourceFree(disk->backingChain);
         disk->backingChain = oldchain;
         VIR_FREE(disk->mirror);
     }
@@ -15297,7 +15297,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
     int idx;
     virDomainDiskDefPtr disk = NULL;
     const char *top_canon = NULL;
-    virStorageFileMetadataPtr top_meta = NULL;
+    virStorageSourcePtr top_meta = NULL;
     const char *top_parent = NULL;
     const char *base_canon = NULL;
     bool clean_access = false;
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index fa5eba1..36666f4 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -69,7 +69,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
 {
     int fd = -1;
     int ret = -1;
-    virStorageFileMetadata *meta = NULL;
+    virStorageSourcePtr meta = NULL;
     struct stat sb;
     char *header = NULL;
     ssize_t len = VIR_STORAGE_MAX_HEADER;
@@ -176,7 +176,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
     VIR_FORCE_CLOSE(fd);

  cleanup:
-    virStorageFileFreeMetadata(meta);
+    virStorageSourceFree(meta);
     VIR_FREE(header);
     return ret;

diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index e0a25df..5ab1e7e 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -243,7 +243,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     int ret = -1;
     virStorageVolDefPtr vol = NULL;
     glfs_fd_t *fd = NULL;
-    virStorageFileMetadata *meta = NULL;
+    virStorageSourcePtr meta = NULL;
     char *header = NULL;
     ssize_t len = VIR_STORAGE_MAX_HEADER;

@@ -324,7 +324,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     vol = NULL;
     ret = 0;
  cleanup:
-    virStorageFileFreeMetadata(meta);
+    virStorageSourceFree(meta);
     virStorageVolDefFree(vol);
     if (fd)
         glfs_close(fd);
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f519d82..e7dc6ae 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -795,7 +795,7 @@ qcow2GetFeatures(virBitmapPtr *features,
  * pre-populated in META*/
 static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
 ATTRIBUTE_NONNULL(4)
-virStorageFileGetMetadataInternal(virStorageFileMetadataPtr meta,
+virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
                                   char *buf,
                                   size_t len,
                                   int *backingFormat)
@@ -933,11 +933,11 @@ virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid)
 }


-static virStorageFileMetadataPtr
+static virStorageSourcePtr
 virStorageFileMetadataNew(const char *path,
                           int format)
 {
-    virStorageFileMetadataPtr ret = NULL;
+    virStorageSourcePtr ret = NULL;

     if (VIR_ALLOC(ret) < 0)
         return NULL;
@@ -956,7 +956,7 @@ virStorageFileMetadataNew(const char *path,
     return ret;

  error:
-    virStorageFileFreeMetadata(ret);
+    virStorageSourceFree(ret);
     return NULL;
 }

@@ -983,9 +983,9 @@ virStorageFileMetadataNew(const char *path,
  * backing store. Callers are advised against probing for the
  * backing store format in this case.
  *
- * Caller MUST free the result after use via virStorageFileFreeMetadata.
+ * Caller MUST free the result after use via virStorageSourceFree.
  */
-virStorageFileMetadataPtr
+virStorageSourcePtr
 virStorageFileGetMetadataFromBuf(const char *path,
                                  char *buf,
                                  size_t len,
@@ -993,19 +993,19 @@ virStorageFileGetMetadataFromBuf(const char *path,
                                  char **backing,
                                  int *backingFormat)
 {
-    virStorageFileMetadataPtr ret = NULL;
+    virStorageSourcePtr ret = NULL;

     if (!(ret = virStorageFileMetadataNew(path, format)))
         return NULL;

     if (virStorageFileGetMetadataInternal(ret, buf, len,
                                           backingFormat) < 0) {
-        virStorageFileFreeMetadata(ret);
+        virStorageSourceFree(ret);
         ret = NULL;
     }

     if (VIR_STRDUP(*backing, ret->backingStoreRaw) < 0) {
-        virStorageFileFreeMetadata(ret);
+        virStorageSourceFree(ret);
         ret = NULL;
     }

@@ -1015,7 +1015,7 @@ virStorageFileGetMetadataFromBuf(const char *path,

 /* Internal version that also supports a containing directory name.  */
 static int
-virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
+virStorageFileGetMetadataFromFDInternal(virStorageSourcePtr meta,
                                         int fd,
                                         int *backingFormat)
 {
@@ -1083,20 +1083,20 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
  * format, since a malicious guest can turn a raw file into any
  * other non-raw format at will.
  *
- * Caller MUST free the result after use via virStorageFileFreeMetadata.
+ * Caller MUST free the result after use via virStorageSourceFree.
  */
-virStorageFileMetadataPtr
+virStorageSourcePtr
 virStorageFileGetMetadataFromFD(const char *path,
                                 int fd,
                                 int format)
 {
-    virStorageFileMetadataPtr ret = NULL;
+    virStorageSourcePtr ret = NULL;

     if (!(ret = virStorageFileMetadataNew(path, format)))
         goto cleanup;

     if (virStorageFileGetMetadataFromFDInternal(ret, fd, NULL) < 0) {
-        virStorageFileFreeMetadata(ret);
+        virStorageSourceFree(ret);
         ret = NULL;
     }

@@ -1111,7 +1111,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
                                  const char *directory,
                                  int format, uid_t uid, gid_t gid,
                                  bool allow_probe, virHashTablePtr cycle,
-                                 virStorageFileMetadataPtr meta)
+                                 virStorageSourcePtr meta)
 {
     int fd;
     int ret = -1;
@@ -1182,7 +1182,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
                 return -1;
         }

-        virStorageFileMetadataPtr backing;
+        virStorageSourcePtr backing;

         if (backingFormat == VIR_STORAGE_FILE_AUTO && !allow_probe)
             backingFormat = VIR_STORAGE_FILE_RAW;
@@ -1195,7 +1195,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
                                              uid, gid, allow_probe,
                                              cycle, backing) < 0) {
             /* If we failed to get backing data, mark the chain broken */
-            virStorageFileFreeMetadata(backing);
+            virStorageSourceFree(backing);
         } else {
             meta->backingMeta = backing;
         }
@@ -1221,9 +1221,9 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
  * format, since a malicious guest can turn a raw file into any
  * other non-raw format at will.
  *
- * Caller MUST free result after use via virStorageFileFreeMetadata.
+ * Caller MUST free result after use via virStorageSourceFree.
  */
-virStorageFileMetadataPtr
+virStorageSourcePtr
 virStorageFileGetMetadata(const char *path, int format,
                           uid_t uid, gid_t gid,
                           bool allow_probe)
@@ -1232,8 +1232,8 @@ virStorageFileGetMetadata(const char *path, int format,
               path, format, (int)uid, (int)gid, allow_probe);

     virHashTablePtr cycle = virHashCreate(5, NULL);
-    virStorageFileMetadataPtr meta = NULL;
-    virStorageFileMetadataPtr ret = NULL;
+    virStorageSourcePtr meta = NULL;
+    virStorageSourcePtr ret = NULL;
     char *canonPath = NULL;
     char *directory = NULL;

@@ -1265,7 +1265,7 @@ virStorageFileGetMetadata(const char *path, int format,
     meta = NULL;

  cleanup:
-    virStorageFileFreeMetadata(meta);
+    virStorageSourceFree(meta);
     VIR_FREE(canonPath);
     VIR_FREE(directory);
     virHashFree(cycle);
@@ -1281,10 +1281,10 @@ virStorageFileGetMetadata(const char *path, int format,
  * error (allocation failure).
  */
 int
-virStorageFileChainGetBroken(virStorageFileMetadataPtr chain,
+virStorageFileChainGetBroken(virStorageSourcePtr chain,
                              char **brokenFile)
 {
-    virStorageFileMetadataPtr tmp;
+    virStorageSourcePtr tmp;

     *brokenFile = NULL;

@@ -1307,7 +1307,7 @@ virStorageFileChainGetBroken(virStorageFileMetadataPtr chain,


 /**
- * virStorageFileFreeMetadata:
+ * virStorageFileMetadataFree:
  *
  * Free pointers in passed structure and structure itself.
  */
@@ -1530,8 +1530,8 @@ int virStorageFileGetSCSIKey(const char *path,
  * independently freed.  Reports an error and returns NULL if NAME is
  * not found.  */
 const char *
-virStorageFileChainLookup(virStorageFileMetadataPtr chain,
-                          const char *name, virStorageFileMetadataPtr *meta,
+virStorageFileChainLookup(virStorageSourcePtr chain,
+                          const char *name, virStorageSourcePtr *meta,
                           const char **parent)
 {
     const char *start = chain->path;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 11e25eb..89fa1ee 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -298,28 +298,28 @@ int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid);
 int virStorageFileProbeFormatFromBuf(const char *path, char *buf,
                                      size_t buflen);

-virStorageFileMetadataPtr virStorageFileGetMetadata(const char *path,
-                                                    int format,
-                                                    uid_t uid, gid_t gid,
-                                                    bool allow_probe)
+virStorageSourcePtr virStorageFileGetMetadata(const char *path,
+                                              int format,
+                                              uid_t uid, gid_t gid,
+                                              bool allow_probe)
     ATTRIBUTE_NONNULL(1);
-virStorageFileMetadataPtr virStorageFileGetMetadataFromFD(const char *path,
-                                                          int fd,
-                                                          int format);
-virStorageFileMetadataPtr virStorageFileGetMetadataFromBuf(const char *path,
-                                                           char *buf,
-                                                           size_t len,
-                                                           int format,
-                                                           char **backing,
-                                                           int *backingFormat)
+virStorageSourcePtr virStorageFileGetMetadataFromFD(const char *path,
+                                                    int fd,
+                                                    int format);
+virStorageSourcePtr virStorageFileGetMetadataFromBuf(const char *path,
+                                                     char *buf,
+                                                     size_t len,
+                                                     int format,
+                                                     char **backing,
+                                                     int *backingFormat)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5)
     ATTRIBUTE_NONNULL(6);
-int virStorageFileChainGetBroken(virStorageFileMetadataPtr chain,
+int virStorageFileChainGetBroken(virStorageSourcePtr chain,
                                  char **broken_file);

-const char *virStorageFileChainLookup(virStorageFileMetadataPtr chain,
+const char *virStorageFileChainLookup(virStorageSourcePtr chain,
                                       const char *name,
-                                      virStorageFileMetadataPtr *meta,
+                                      virStorageSourcePtr *meta,
                                       const char **parent)
     ATTRIBUTE_NONNULL(1);

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 646c15e..90311af 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -266,8 +266,8 @@ testStorageChain(const void *args)
 {
     const struct testChainData *data = args;
     int ret = -1;
-    virStorageFileMetadataPtr meta;
-    virStorageFileMetadataPtr elt;
+    virStorageSourcePtr meta;
+    virStorageSourcePtr elt;
     size_t i = 0;
     char *broken = NULL;
     bool isAbs = !!(data->flags & ABS_START);
@@ -367,16 +367,16 @@ testStorageChain(const void *args)
     ret = 0;
  cleanup:
     VIR_FREE(broken);
-    virStorageFileFreeMetadata(meta);
+    virStorageSourceFree(meta);
     return ret;
 }

 struct testLookupData
 {
-    virStorageFileMetadataPtr chain;
+    virStorageSourcePtr chain;
     const char *name;
     const char *expResult;
-    virStorageFileMetadataPtr expMeta;
+    virStorageSourcePtr expMeta;
     const char *expParent;
 };

@@ -386,7 +386,7 @@ testStorageLookup(const void *args)
     const struct testLookupData *data = args;
     int ret = 0;
     const char *actualResult;
-    virStorageFileMetadataPtr actualMeta;
+    virStorageSourcePtr actualMeta;
     const char *actualParent;

     /* This function is documented as giving results within chain, but
@@ -444,7 +444,7 @@ mymain(void)
     int ret;
     virCommandPtr cmd = NULL;
     struct testChainData data;
-    virStorageFileMetadataPtr chain = NULL;
+    virStorageSourcePtr chain = NULL;

     /* Prep some files with qemu-img; if that is not found on PATH, or
      * if it lacks support for qcow2 and qed, skip this test.  */
@@ -866,7 +866,7 @@ mymain(void)
         ret = -1;

     /* Test behavior of chain lookups, relative backing from absolute start */
-    virStorageFileFreeMetadata(chain);
+    virStorageSourceFree(chain);
     chain = virStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2,
                                       -1, -1, false);
     if (!chain) {
@@ -896,7 +896,7 @@ mymain(void)
         ret = -1;

     /* Test behavior of chain lookups, relative backing */
-    virStorageFileFreeMetadata(chain);
+    virStorageSourceFree(chain);
     chain = virStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCOW2,
                                       -1, -1, false);
     if (!chain) {
@@ -922,7 +922,7 @@ mymain(void)

  cleanup:
     /* Final cleanup */
-    virStorageFileFreeMetadata(chain);
+    virStorageSourceFree(chain);
     testCleanupImages();
     virCommandFree(cmd);

-- 
1.9.1

--
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]