]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Replace virStorageSourceFree with virObjectUnref
authorPeter Krempa <pkrempa@redhat.com>
Fri, 15 Feb 2019 12:03:58 +0000 (13:03 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 18 Feb 2019 09:31:21 +0000 (10:31 +0100)
Now that virStorageSource is a subclass of virObject we can use
virObjectUnref and remove virStorageSourceFree which was a thin wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
12 files changed:
src/conf/domain_conf.c
src/conf/snapshot_conf.c
src/libvirt_private.syms
src/qemu/qemu_blockjob.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_migration.c
src/storage/storage_util.c
src/util/virstoragefile.c
src/util/virstoragefile.h
tests/virstoragetest.c

index e80c53e3576c6621136ee4efa584d764a3223640..661c9f710af03ed4555fa4ca83ae4528030a5a5c 100644 (file)
@@ -1903,10 +1903,10 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
     if (!def)
         return;
 
-    virStorageSourceFree(def->src);
+    virObjectUnref(def->src);
     VIR_FREE(def->serial);
     VIR_FREE(def->dst);
-    virStorageSourceFree(def->mirror);
+    virObjectUnref(def->mirror);
     VIR_FREE(def->wwn);
     VIR_FREE(def->driverName);
     VIR_FREE(def->vendor);
@@ -2115,7 +2115,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
     if (!def)
         return;
 
-    virStorageSourceFree(def->src);
+    virObjectUnref(def->src);
     VIR_FREE(def->dst);
     virDomainDeviceInfoClear(&def->info);
     VIR_FREE(def->virtio);
@@ -2696,7 +2696,7 @@ virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc
     if (!iscsisrc)
         return;
 
-    virStorageSourceFree(iscsisrc->src);
+    virObjectUnref(iscsisrc->src);
     iscsisrc->src = NULL;
 }
 
index 5127ebbdfdd0ee5a9e34ee37c38a9bf1268c1874..1afc7de30ccb0af019033c1aeb86ad1831721c47 100644 (file)
@@ -83,7 +83,7 @@ static void
 virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk)
 {
     VIR_FREE(disk->name);
-    virStorageSourceFree(disk->src);
+    virObjectUnref(disk->src);
     disk->src = NULL;
 }
 
index b6fec233f1d56278af727729d6a301901112ce83..b720acdc939d74f5d6c349eb893bc184b4f93b2c 100644 (file)
@@ -2910,7 +2910,6 @@ virStorageSourceChainHasManagedPR;
 virStorageSourceClear;
 virStorageSourceCopy;
 virStorageSourceFindByNodeName;
-virStorageSourceFree;
 virStorageSourceGetActualType;
 virStorageSourceGetSecurityLabelDef;
 virStorageSourceHasBacking;
index 0cbebab35992666fac13f2eea6ca4a95a7067b58..fa7e4c8625d2824311cdf216ece8a016e167dfe1 100644 (file)
@@ -258,13 +258,13 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver,
                     VIR_WARN("Unable to update persistent definition "
                              "on vm %s after block job",
                              vm->def->name);
-                    virStorageSourceFree(copy);
+                    virObjectUnref(copy);
                     copy = NULL;
                     persistDisk = NULL;
                 }
             }
             if (copy) {
-                virStorageSourceFree(persistDisk->src);
+                virObjectUnref(persistDisk->src);
                 persistDisk->src = copy;
             }
         }
@@ -275,12 +275,12 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver,
          * want to only revoke the non-shared portion of the chain); so for
          * now, we leak the access to the original.  */
         virDomainLockImageDetach(driver->lockManager, vm, disk->src);
-        virStorageSourceFree(disk->src);
+        virObjectUnref(disk->src);
         disk->src = disk->mirror;
     } else {
         if (disk->mirror) {
             virDomainLockImageDetach(driver->lockManager, vm, disk->mirror);
-            virStorageSourceFree(disk->mirror);
+            virObjectUnref(disk->mirror);
         }
     }
 
@@ -345,7 +345,7 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
     case VIR_DOMAIN_BLOCK_JOB_CANCELED:
         if (disk->mirror) {
             virDomainLockImageDetach(driver->lockManager, vm, disk->mirror);
-            virStorageSourceFree(disk->mirror);
+            virObjectUnref(disk->mirror);
             disk->mirror = NULL;
         }
         disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
index a96a4f4049e6cea343d59a682a9b3c492c78ee56..a0af56695e9cd21c26f10cb723f00212e9f91a42 100644 (file)
@@ -1072,7 +1072,7 @@ qemuDomainDiskPrivateDispose(void *obj)
 {
     qemuDomainDiskPrivatePtr priv = obj;
 
-    virStorageSourceFree(priv->migrSource);
+    virObjectUnref(priv->migrSource);
     VIR_FREE(priv->qomName);
     VIR_FREE(priv->nodeCopyOnRead);
     virObjectUnref(priv->blockjob);
index 5a77afa1b46b0abfb3f8e00e9a01cec1df736e31..024ee5b62de026dbe414b00575047f988155e126 100644 (file)
@@ -15183,9 +15183,9 @@ qemuDomainSnapshotDiskDataFree(qemuDomainSnapshotDiskDataPtr data,
             if (data[i].prepared)
                 qemuDomainDiskChainElementRevoke(driver, vm, data[i].src);
 
-            virStorageSourceFree(data[i].src);
+            virObjectUnref(data[i].src);
         }
-        virStorageSourceFree(data[i].persistsrc);
+        virObjectUnref(data[i].persistsrc);
         VIR_FREE(data[i].relPath);
     }
 
@@ -17950,7 +17950,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
  cleanup:
     VIR_FREE(device);
     virObjectUnref(cfg);
-    virStorageSourceFree(mirror);
+    virObjectUnref(mirror);
     return ret;
 }
 
index 78c9a77f2d4aa0faf2904cfbdf0365ed824f0a19..00dbff6b2a736464f62e7decd563127081db00ac 100644 (file)
@@ -830,7 +830,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
     ignore_value(qemuHotplugPrepareDiskSourceAccess(driver, vm, oldsrc, true));
 
     /* media was changed, so we can remove the old media definition now */
-    virStorageSourceFree(oldsrc);
+    virObjectUnref(oldsrc);
     oldsrc = NULL;
     disk->src = newsrc;
 
index b10f55f80cd67f5033f8482342b3ddf3b947ec9c..362b79e567137490a939c1610665f093b1961a43 100644 (file)
@@ -760,7 +760,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
 
         qemuBlockStorageSourceDetachOneBlockdev(driver, vm, asyncJob,
                                                 diskPriv->migrSource);
-        virStorageSourceFree(diskPriv->migrSource);
+        virObjectUnref(diskPriv->migrSource);
         diskPriv->migrSource = NULL;
     }
 
index 1c5d4d14be9e46fb3f9a3a623e54c1bab8b90f1c..7a879b0f46fffba41f9ef419118b45e7f481f799 100644 (file)
@@ -3400,7 +3400,7 @@ storageBackendProbeTarget(virStorageSourcePtr target,
          * remote storage. To avoid trouble, just fake the backing store is RAW
          * and put the string from the metadata as the path of the target. */
         if (!virStorageSourceIsLocalStorage(target->backingStore)) {
-            virStorageSourceFree(target->backingStore);
+            virObjectUnref(target->backingStore);
 
             if (!(target->backingStore = virStorageSourceNew()))
                 return -1;
index f3f05c82ecbc94d8d9bf91fd56c1e6991e63577a..5927140a6662be95022e5180e747b2dbb99d470e 100644 (file)
@@ -1133,7 +1133,7 @@ virStorageFileMetadataNew(const char *path,
     return def;
 
  error:
-    virStorageSourceFree(def);
+    virObjectUnref(def);
     return NULL;
 }
 
@@ -1158,7 +1158,7 @@ virStorageFileMetadataNew(const char *path,
  * image didn't specify an explicit format for its backing store. Callers are
  * advised against probing for the backing store format in this case.
  *
- * Caller MUST free the result after use via virStorageSourceFree.
+ * Caller MUST free the result after use via virObjectUnref.
  */
 virStorageSourcePtr
 virStorageFileGetMetadataFromBuf(const char *path,
@@ -1178,7 +1178,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
 
     if (virStorageFileGetMetadataInternal(ret, buf, len,
                                           backingFormat) < 0) {
-        virStorageSourceFree(ret);
+        virObjectUnref(ret);
         return NULL;
     }
 
@@ -1197,7 +1197,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
  * 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 virStorageSourceFree.
+ * Caller MUST free the result after use via virObjectUnref.
  */
 virStorageSourcePtr
 virStorageFileGetMetadataFromFD(const char *path,
@@ -1257,7 +1257,7 @@ virStorageFileGetMetadataFromFD(const char *path,
     VIR_STEAL_PTR(ret, meta);
 
  cleanup:
-    virStorageSourceFree(meta);
+    virObjectUnref(meta);
     return ret;
 }
 
@@ -2336,7 +2336,7 @@ virStorageSourceCopy(const virStorageSource *src,
     return def;
 
  error:
-    virStorageSourceFree(def);
+    virObjectUnref(def);
     return NULL;
 }
 
@@ -2522,7 +2522,7 @@ virStorageSourceBackingStoreClear(virStorageSourcePtr def)
     VIR_FREE(def->backingStoreRaw);
 
     /* recursively free backing chain */
-    virStorageSourceFree(def->backingStore);
+    virObjectUnref(def->backingStore);
     def->backingStore = NULL;
 }
 
@@ -2599,13 +2599,6 @@ virStorageSourceNew(void)
 }
 
 
-void
-virStorageSourceFree(virStorageSourcePtr def)
-{
-    virObjectUnref(def);
-}
-
-
 static virStorageSourcePtr
 virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
                                        const char *rel)
@@ -2657,7 +2650,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
     return def;
 
  error:
-    virStorageSourceFree(def);
+    virObjectUnref(def);
     def = NULL;
     goto cleanup;
 }
@@ -3698,7 +3691,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
     return def;
 
  error:
-    virStorageSourceFree(def);
+    virObjectUnref(def);
     return NULL;
 }
 
@@ -3739,7 +3732,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent)
     return def;
 
  error:
-    virStorageSourceFree(def);
+    virObjectUnref(def);
     return NULL;
 }
 
@@ -3920,7 +3913,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
     ret = 0;
 
  cleanup:
-    virStorageSourceFree(meta);
+    virObjectUnref(meta);
     return ret;
 }
 
@@ -4944,7 +4937,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
     if (virStorageSourceHasBacking(src))
         src->backingStore->id = depth;
     virStorageFileDeinit(src);
-    virStorageSourceFree(backingStore);
+    virObjectUnref(backingStore);
     return ret;
 }
 
@@ -4967,7 +4960,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
  * If @report_broken is true, the whole function fails with a possibly sane
  * error instead of just returning a broken chain.
  *
- * Caller MUST free result after use via virStorageSourceFree.
+ * Caller MUST free result after use via virObjectUnref.
  */
 int
 virStorageFileGetMetadata(virStorageSourcePtr src,
@@ -5051,7 +5044,7 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
     ret = 0;
 
  cleanup:
-    virStorageSourceFree(tmp);
+    virObjectUnref(tmp);
 
     return ret;
 }
index 17eea6dc6be2f64ebd4c62e840ae6ca72bad0892..ba5181804cdb1819738891d99cbf972c3c6e1ced 100644 (file)
@@ -434,7 +434,6 @@ bool virStorageSourceIsLocalStorage(const virStorageSource *src);
 bool virStorageSourceIsEmpty(virStorageSourcePtr src);
 bool virStorageSourceIsBlockLocal(const virStorageSource *src);
 virStorageSourcePtr virStorageSourceNew(void);
-void virStorageSourceFree(virStorageSourcePtr def);
 void virStorageSourceBackingStoreClear(virStorageSourcePtr def);
 int virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src,
                                        int fd, struct stat const *sb);
index 830d4fb08e6f27cd23880e0a9c195acf2456ef3e..fb98903f02222d1bcaf0fb92622acce8c3a2b780 100644 (file)
@@ -1084,7 +1084,7 @@ mymain(void)
         ret = -1;
 
     /* Test behavior of chain lookups, relative backing from absolute start */
-    virStorageSourceFree(chain);
+    virObjectUnref(chain);
     chain = testStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2, -1, -1);
     if (!chain) {
         ret = -1;
@@ -1130,7 +1130,7 @@ mymain(void)
         ret = -1;
 
     /* Test behavior of chain lookups, relative backing */
-    virStorageSourceFree(chain);
+    virObjectUnref(chain);
     chain = testStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCOW2,
                                        -1, -1);
     if (!chain) {