mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
util: Replace virStorageSourceFree with virObjectUnref
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>
This commit is contained in:
parent
e1c01b2252
commit
44601a0e96
@ -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;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static void
|
||||
virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk)
|
||||
{
|
||||
VIR_FREE(disk->name);
|
||||
virStorageSourceFree(disk->src);
|
||||
virObjectUnref(disk->src);
|
||||
disk->src = NULL;
|
||||
}
|
||||
|
||||
|
@ -2910,7 +2910,6 @@ virStorageSourceChainHasManagedPR;
|
||||
virStorageSourceClear;
|
||||
virStorageSourceCopy;
|
||||
virStorageSourceFindByNodeName;
|
||||
virStorageSourceFree;
|
||||
virStorageSourceGetActualType;
|
||||
virStorageSourceGetSecurityLabelDef;
|
||||
virStorageSourceHasBacking;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -760,7 +760,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
|
||||
|
||||
qemuBlockStorageSourceDetachOneBlockdev(driver, vm, asyncJob,
|
||||
diskPriv->migrSource);
|
||||
virStorageSourceFree(diskPriv->migrSource);
|
||||
virObjectUnref(diskPriv->migrSource);
|
||||
diskPriv->migrSource = NULL;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user