mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Clear all data allocated about backing store before reparsing
To avoid memory leak of the "backingStoreRaw" field when reparsing
backing chains a new function is being introduced by this patch that
shall be used to clear backing store information.
The memory leak was introduced in commit 8823272d41
.
This commit is contained in:
parent
cdebc2f74c
commit
b47668233e
@ -1865,6 +1865,7 @@ virStorageNetHostTransportTypeToString;
|
|||||||
virStorageNetProtocolTypeToString;
|
virStorageNetProtocolTypeToString;
|
||||||
virStorageSourceAuthClear;
|
virStorageSourceAuthClear;
|
||||||
virStorageSourceClear;
|
virStorageSourceClear;
|
||||||
|
virStorageSourceClearBackingStore;
|
||||||
virStorageSourceFree;
|
virStorageSourceFree;
|
||||||
virStorageSourceGetActualType;
|
virStorageSourceGetActualType;
|
||||||
virStorageSourcePoolDefFree;
|
virStorageSourcePoolDefFree;
|
||||||
|
@ -2421,12 +2421,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (disk->src.backingStore) {
|
if (disk->src.backingStore) {
|
||||||
if (force) {
|
if (force)
|
||||||
virStorageSourceFree(disk->src.backingStore);
|
virStorageSourceClearBackingStore(&disk->src);
|
||||||
disk->src.backingStore = NULL;
|
else
|
||||||
} else {
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
|
qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
|
||||||
|
@ -12734,8 +12734,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
|
|||||||
* recompute it. Better would be storing the chain ourselves rather than
|
* recompute it. Better would be storing the chain ourselves rather than
|
||||||
* reprobing, but this requires modifying domain_conf and our XML to fully
|
* reprobing, but this requires modifying domain_conf and our XML to fully
|
||||||
* track the chain across libvirtd restarts. */
|
* track the chain across libvirtd restarts. */
|
||||||
virStorageSourceFree(disk->src.backingStore);
|
virStorageSourceClearBackingStore(&disk->src);
|
||||||
disk->src.backingStore = NULL;
|
|
||||||
|
|
||||||
if (virStorageFileInit(&snap->src) < 0)
|
if (virStorageFileInit(&snap->src) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1726,6 +1726,29 @@ virStorageSourceGetActualType(virStorageSourcePtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virStorageSourceClearBackingStore:
|
||||||
|
*
|
||||||
|
* @src: disk source to clear
|
||||||
|
*
|
||||||
|
* Clears information about backing store of the current storage file.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virStorageSourceClearBackingStore(virStorageSourcePtr def)
|
||||||
|
{
|
||||||
|
if (!def)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VIR_FREE(def->relPath);
|
||||||
|
VIR_FREE(def->relDir);
|
||||||
|
VIR_FREE(def->backingStoreRaw);
|
||||||
|
|
||||||
|
/* recursively free backing chain */
|
||||||
|
virStorageSourceFree(def->backingStore);
|
||||||
|
def->backingStore = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virStorageSourceClear(virStorageSourcePtr def)
|
virStorageSourceClear(virStorageSourcePtr def)
|
||||||
{
|
{
|
||||||
@ -1755,12 +1778,7 @@ virStorageSourceClear(virStorageSourcePtr def)
|
|||||||
virStorageNetHostDefFree(def->nhosts, def->hosts);
|
virStorageNetHostDefFree(def->nhosts, def->hosts);
|
||||||
virStorageSourceAuthClear(def);
|
virStorageSourceAuthClear(def);
|
||||||
|
|
||||||
VIR_FREE(def->relPath);
|
virStorageSourceClearBackingStore(def);
|
||||||
VIR_FREE(def->relDir);
|
|
||||||
VIR_FREE(def->backingStoreRaw);
|
|
||||||
|
|
||||||
/* recursively free backing chain */
|
|
||||||
virStorageSourceFree(def->backingStore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,5 +316,6 @@ void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
|
|||||||
void virStorageSourceClear(virStorageSourcePtr def);
|
void virStorageSourceClear(virStorageSourcePtr def);
|
||||||
int virStorageSourceGetActualType(virStorageSourcePtr def);
|
int virStorageSourceGetActualType(virStorageSourcePtr def);
|
||||||
void virStorageSourceFree(virStorageSourcePtr def);
|
void virStorageSourceFree(virStorageSourcePtr def);
|
||||||
|
void virStorageSourceClearBackingStore(virStorageSourcePtr def);
|
||||||
|
|
||||||
#endif /* __VIR_STORAGE_FILE_H__ */
|
#endif /* __VIR_STORAGE_FILE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user