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(a)redhat.com>
---
src/conf/domain_conf.c | 8 ++++----
src/conf/snapshot_conf.c | 2 +-
src/libvirt_private.syms | 1 -
src/qemu/qemu_blockjob.c | 10 +++++-----
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 6 +++---
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_migration.c | 2 +-
src/storage/storage_util.c | 2 +-
src/util/virstoragefile.c | 35 ++++++++++++++---------------------
src/util/virstoragefile.h | 1 -
tests/virstoragetest.c | 4 ++--
12 files changed, 33 insertions(+), 42 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 91ee35391b..38b30df82f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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;
}
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 5127ebbdfd..1afc7de30c 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -83,7 +83,7 @@ static void
virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk)
{
VIR_FREE(disk->name);
- virStorageSourceFree(disk->src);
+ virObjectUnref(disk->src);
disk->src = NULL;
}
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b6fec233f1..b720acdc93 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2910,7 +2910,6 @@ virStorageSourceChainHasManagedPR;
virStorageSourceClear;
virStorageSourceCopy;
virStorageSourceFindByNodeName;
-virStorageSourceFree;
virStorageSourceGetActualType;
virStorageSourceGetSecurityLabelDef;
virStorageSourceHasBacking;
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 0cbebab359..fa7e4c8625 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -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;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a96a4f4049..a0af56695e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5a77afa1b4..024ee5b62d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 78c9a77f2d..00dbff6b2a 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b10f55f80c..362b79e567 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -760,7 +760,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
qemuBlockStorageSourceDetachOneBlockdev(driver, vm, asyncJob,
diskPriv->migrSource);
- virStorageSourceFree(diskPriv->migrSource);
+ virObjectUnref(diskPriv->migrSource);
diskPriv->migrSource = NULL;
}
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 1c5d4d14be..7a879b0f46 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -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;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 56c6510c5e..9dd27b5ca6 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -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;
}
@@ -2598,13 +2598,6 @@ virStorageSourceNew(void)
}
-void
-virStorageSourceFree(virStorageSourcePtr def)
-{
- virObjectUnref(def);
-}
-
-
static virStorageSourcePtr
virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
const char *rel)
@@ -2656,7 +2649,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
return def;
error:
- virStorageSourceFree(def);
+ virObjectUnref(def);
def = NULL;
goto cleanup;
}
@@ -3697,7 +3690,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
return def;
error:
- virStorageSourceFree(def);
+ virObjectUnref(def);
return NULL;
}
@@ -3738,7 +3731,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent)
return def;
error:
- virStorageSourceFree(def);
+ virObjectUnref(def);
return NULL;
}
@@ -3919,7 +3912,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
ret = 0;
cleanup:
- virStorageSourceFree(meta);
+ virObjectUnref(meta);
return ret;
}
@@ -4943,7 +4936,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
if (virStorageSourceHasBacking(src))
src->backingStore->id = depth;
virStorageFileDeinit(src);
- virStorageSourceFree(backingStore);
+ virObjectUnref(backingStore);
return ret;
}
@@ -4966,7 +4959,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,
@@ -5050,7 +5043,7 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
ret = 0;
cleanup:
- virStorageSourceFree(tmp);
+ virObjectUnref(tmp);
return ret;
}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 17eea6dc6b..ba5181804c 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -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);
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 830d4fb08e..fb98903f02 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -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) {
--
2.20.1