maint: Switch over from struct virStorageFileMetadata to virStorageSource

Replace the old structure with the new one. This change is a trivial
name change operation (along with change of the freeing function).
This commit is contained in:
Peter Krempa 2014-04-17 16:05:16 +02:00
parent 0b5161d9c5
commit d64d9ff948
9 changed files with 69 additions and 70 deletions

View File

@ -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);
@ -18526,7 +18526,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
{
int ret = -1;
size_t depth = 0;
virStorageFileMetadata *tmp;
virStorageSourcePtr tmp;
const char *path = virDomainDiskGetSource(disk);
int type = virDomainDiskGetType(disk);

View File

@ -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 */

View File

@ -2410,7 +2410,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
if (disk->backingChain) {
if (force) {
virStorageFileFreeMetadata(disk->backingChain);
virStorageSourceFree(disk->backingChain);
disk->backingChain = NULL;
} else {
goto cleanup;

View File

@ -10292,7 +10292,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;
@ -10439,7 +10439,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
@ -12011,7 +12011,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);
@ -12724,7 +12724,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)
@ -14704,7 +14704,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. */
@ -14799,7 +14799,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
@ -14812,7 +14812,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);
}
@ -15286,7 +15286,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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
@ -961,7 +961,7 @@ virStorageFileMetadataNew(const char *path,
return ret;
error:
virStorageFileFreeMetadata(ret);
virStorageSourceFree(ret);
return NULL;
}
@ -988,9 +988,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,
@ -998,19 +998,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;
}
@ -1020,7 +1020,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)
{
@ -1089,20 +1089,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;
}
@ -1117,7 +1117,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;
@ -1170,7 +1170,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
}
if (ret == 0 && meta->backingStoreRaw) {
virStorageFileMetadataPtr backing;
virStorageSourcePtr backing;
if (virStorageIsFile(meta->backingStoreRaw)) {
if (virFindBackingFile(directory,
@ -1190,7 +1190,6 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
return -1;
}
if (backingFormat == VIR_STORAGE_FILE_AUTO && !allow_probe)
backingFormat = VIR_STORAGE_FILE_RAW;
else if (backingFormat == VIR_STORAGE_FILE_AUTO_SAFE)
@ -1202,7 +1201,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;
}
@ -1228,9 +1227,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)
@ -1239,8 +1238,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;
@ -1272,7 +1271,7 @@ virStorageFileGetMetadata(const char *path, int format,
meta = NULL;
cleanup:
virStorageFileFreeMetadata(meta);
virStorageSourceFree(meta);
VIR_FREE(canonPath);
VIR_FREE(directory);
virHashFree(cycle);
@ -1288,10 +1287,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;
@ -1314,7 +1313,7 @@ virStorageFileChainGetBroken(virStorageFileMetadataPtr chain,
/**
* virStorageFileFreeMetadata:
* virStorageFileMetadataFree:
*
* Free pointers in passed structure and structure itself.
*/
@ -1537,8 +1536,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;

View File

@ -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);

View File

@ -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);