storage_source: use virStorageSource prefix for all functions

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-01-21 16:46:14 +01:00
parent 5ac39c4ab0
commit 836e0a960b
14 changed files with 268 additions and 268 deletions

View File

@ -1686,30 +1686,30 @@ virStorageFileProbeGetMetadata;
# storage_file/storage_source.h
virStorageFileAccess;
virStorageFileChainLookup;
virStorageFileChown;
virStorageFileCreate;
virStorageFileDeinit;
virStorageFileGetBackingStoreStr;
virStorageFileGetMetadata;
virStorageFileGetMetadataFromBuf;
virStorageFileGetMetadataFromFD;
virStorageFileGetRelativeBackingPath;
virStorageFileGetUniqueIdentifier;
virStorageFileInit;
virStorageFileInitAs;
virStorageFileRead;
virStorageFileReportBrokenChain;
virStorageFileStat;
virStorageFileSupportsAccess;
virStorageFileSupportsBackingChainTraversal;
virStorageFileSupportsCreate;
virStorageFileSupportsSecurityDriver;
virStorageFileUnlink;
virStorageSourceAccess;
virStorageSourceChainLookup;
virStorageSourceChown;
virStorageSourceCreate;
virStorageSourceDeinit;
virStorageSourceGetBackingStoreStr;
virStorageSourceGetMetadata;
virStorageSourceGetMetadataFromBuf;
virStorageSourceGetMetadataFromFD;
virStorageSourceGetRelativeBackingPath;
virStorageSourceGetUniqueIdentifier;
virStorageSourceInit;
virStorageSourceInitAs;
virStorageSourceNewFromBacking;
virStorageSourceNewFromBackingAbsolute;
virStorageSourceParseRBDColonString;
virStorageSourceRead;
virStorageSourceReportBrokenChain;
virStorageSourceStat;
virStorageSourceSupportsAccess;
virStorageSourceSupportsBackingChainTraversal;
virStorageSourceSupportsCreate;
virStorageSourceSupportsSecurityDriver;
virStorageSourceUnlink;
virStorageSourceUpdateBackingSizes;
virStorageSourceUpdateCapacity;
virStorageSourceUpdatePhysicalSize;

View File

@ -135,7 +135,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm,
}
if (dd->created) {
if (virStorageFileUnlink(dd->store) < 0)
if (virStorageSourceUnlink(dd->store) < 0)
VIR_WARN("Unable to remove just-created %s", NULLSTR(dd->store->path));
}
@ -144,7 +144,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm,
}
if (dd->initialized)
virStorageFileDeinit(dd->store);
virStorageSourceDeinit(dd->store);
if (dd->blockjob)
qemuBlockJobStartupFinalize(vm, dd->blockjob);
@ -429,7 +429,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm,
if (!reuse_external &&
dd->store->type == VIR_STORAGE_TYPE_FILE &&
virStorageFileSupportsCreate(dd->store)) {
virStorageSourceSupportsCreate(dd->store)) {
if (virFileExists(dd->store->path)) {
virReportError(VIR_ERR_INVALID_ARG,
@ -443,7 +443,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm,
dd->initialized = true;
if (virStorageFileCreate(dd->store) < 0) {
if (virStorageSourceCreate(dd->store) < 0) {
virReportSystemError(errno,
_("failed to create image file '%s'"),
NULLSTR(dd->store->path));

View File

@ -3426,15 +3426,15 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm,
if (n->backingStore->relPath)
break;
if (!virStorageFileSupportsBackingChainTraversal(n))
if (!virStorageSourceSupportsBackingChainTraversal(n))
continue;
if (qemuDomainStorageFileInit(driver, vm, n, topsrc) < 0)
return -1;
rc = virStorageFileGetBackingStoreStr(n, &backingStoreStr);
rc = virStorageSourceGetBackingStoreStr(n, &backingStoreStr);
virStorageFileDeinit(n);
virStorageSourceDeinit(n);
if (rc < 0)
return rc;

View File

@ -7160,7 +7160,7 @@ qemuDomainStorageFileInit(virQEMUDriverPtr driver,
qemuDomainGetImageIds(cfg, vm, src, parent, &uid, &gid);
if (virStorageFileInitAs(src, uid, gid) < 0)
if (virStorageSourceInitAs(src, uid, gid) < 0)
return -1;
return 0;
@ -7298,7 +7298,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
if (!virFileExists(disksrc->path)) {
if (report_broken)
virStorageFileReportBrokenChain(errno, disksrc, disksrc);
virStorageSourceReportBrokenChain(errno, disksrc, disksrc);
return -1;
}
@ -7322,7 +7322,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
/* skip to the end of the chain if there is any */
while (virStorageSourceHasBacking(src)) {
if (report_broken) {
int rv = virStorageFileSupportsAccess(src);
int rv = virStorageSourceSupportsAccess(src);
if (rv < 0)
return -1;
@ -7331,13 +7331,13 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
if (qemuDomainStorageFileInit(driver, vm, src, disksrc) < 0)
return -1;
if (virStorageFileAccess(src, F_OK) < 0) {
virStorageFileReportBrokenChain(errno, src, disksrc);
virStorageFileDeinit(src);
if (virStorageSourceAccess(src, F_OK) < 0) {
virStorageSourceReportBrokenChain(errno, src, disksrc);
virStorageSourceDeinit(src);
return -1;
}
virStorageFileDeinit(src);
virStorageSourceDeinit(src);
}
}
src = src->backingStore;
@ -7354,7 +7354,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
qemuDomainGetImageIds(cfg, vm, src, disksrc, &uid, &gid);
if (virStorageFileGetMetadata(src, uid, gid, report_broken) < 0)
if (virStorageSourceGetMetadata(src, uid, gid, report_broken) < 0)
return -1;
for (n = src->backingStore; virStorageSourceIsBacking(n); n = n->backingStore) {

View File

@ -253,20 +253,20 @@ qemuSecurityChownCallback(const virStorageSource *src,
return 0;
}
if ((rv = virStorageFileSupportsSecurityDriver(src)) <= 0)
if ((rv = virStorageSourceSupportsSecurityDriver(src)) <= 0)
return rv;
if (!(cpy = virStorageSourceCopy(src, false)))
return -1;
/* src file init reports errors, return -2 on failure */
if (virStorageFileInit(cpy) < 0)
if (virStorageSourceInit(cpy) < 0)
return -2;
ret = virStorageFileChown(cpy, uid, gid);
ret = virStorageSourceChown(cpy, uid, gid);
save_errno = errno;
virStorageFileDeinit(cpy);
virStorageSourceDeinit(cpy);
errno = save_errno;
return ret;
@ -10620,7 +10620,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) < 0)
goto cleanup;
if ((nread = virStorageFileRead(disk->src, offset, size, &tmpbuf)) < 0) {
if ((nread = virStorageSourceRead(disk->src, offset, size, &tmpbuf)) < 0) {
if (nread == -2) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("storage file reading is not supported for "
@ -10644,7 +10644,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
cleanup:
if (disk)
virStorageFileDeinit(disk->src);
virStorageSourceDeinit(disk->src);
virDomainObjEndAPI(&vm);
return ret;
}
@ -10776,14 +10776,14 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver,
return -1;
}
} else {
if (skipInaccessible && virStorageFileSupportsBackingChainTraversal(src) <= 0)
if (skipInaccessible && virStorageSourceSupportsBackingChainTraversal(src) <= 0)
return 0;
if (virStorageFileInitAs(src, cfg->user, cfg->group) < 0)
if (virStorageSourceInitAs(src, cfg->user, cfg->group) < 0)
return -1;
if (virStorageFileStat(src, ret_sb) < 0) {
virStorageFileDeinit(src);
if (virStorageSourceStat(src, ret_sb) < 0) {
virStorageSourceDeinit(src);
virReportSystemError(errno, _("failed to stat remote file '%s'"),
NULLSTR(src->path));
return -1;
@ -10808,7 +10808,7 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src,
if (virStorageSourceIsLocalStorage(src))
VIR_FORCE_CLOSE(*fd);
else
virStorageFileDeinit(src);
virStorageSourceDeinit(src);
}
@ -10908,7 +10908,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
goto cleanup;
}
} else {
if ((len = virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, &buf)) < 0)
if ((len = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, &buf)) < 0)
goto cleanup;
}
@ -14449,7 +14449,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
if (base &&
(virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 ||
!(baseSource = virStorageFileChainLookup(disk->src, disk->src,
!(baseSource = virStorageSourceChainLookup(disk->src, disk->src,
base, baseIndex, NULL))))
goto endjob;
@ -14466,7 +14466,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
qemuBlockUpdateRelativeBacking(vm, disk->src, disk->src) < 0)
goto endjob;
if (virStorageFileGetRelativeBackingPath(disk->src->backingStore,
if (virStorageSourceGetRelativeBackingPath(disk->src->backingStore,
baseSource,
&backingPath) < 0)
goto endjob;
@ -14839,7 +14839,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSourcePtr mirror,
if (!virStorageSourceIsLocalStorage(mirror))
return 0;
if (virStorageFileAccess(mirror, F_OK) < 0) {
if (virStorageSourceAccess(mirror, F_OK) < 0) {
if (errno != ENOENT) {
virReportSystemError(errno, "%s",
_("unable to verify existence of "
@ -14854,7 +14854,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSourcePtr mirror,
return -1;
}
} else {
if (virStorageFileStat(mirror, &st) < 0) {
if (virStorageSourceStat(mirror, &st) < 0) {
virReportSystemError(errno,
_("unable to stat block copy target '%s'"),
mirror->path);
@ -15058,9 +15058,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
goto endjob;
}
supports_access = virStorageFileSupportsAccess(mirror) == 1;
supports_create = virStorageFileSupportsCreate(mirror) == 1;
supports_detect = virStorageFileSupportsBackingChainTraversal(mirror) == 1;
supports_access = virStorageSourceSupportsAccess(mirror) == 1;
supports_create = virStorageSourceSupportsCreate(mirror) == 1;
supports_detect = virStorageSourceSupportsBackingChainTraversal(mirror) == 1;
if (supports_access || supports_create || supports_detect) {
if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0)
@ -15104,7 +15104,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
* required so that libvirt can properly label the image for access by qemu */
if (!existing) {
if (supports_create) {
if (virStorageFileCreate(mirror) < 0) {
if (virStorageSourceCreate(mirror) < 0) {
virReportSystemError(errno, "%s", _("failed to create copy target"));
goto endjob;
}
@ -15247,7 +15247,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
/* Update vm in place to match changes. */
need_unlink = false;
virStorageFileDeinit(mirror);
virStorageSourceDeinit(mirror);
disk->mirror = g_steal_pointer(&mirror);
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
qemuBlockJobStarted(job, vm);
@ -15266,9 +15266,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
if (need_revoke)
qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror);
}
if (need_unlink && virStorageFileUnlink(mirror) < 0)
if (need_unlink && virStorageSourceUnlink(mirror) < 0)
VIR_WARN("%s", _("unable to remove just-created copy target"));
virStorageFileDeinit(mirror);
virStorageSourceDeinit(mirror);
qemuDomainObjEndJob(driver, vm);
qemuBlockJobStartupFinalize(vm, job);
@ -15541,7 +15541,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (!top || STREQ(top, disk->dst))
topSource = disk->src;
else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
!(topSource = virStorageFileChainLookup(disk->src, NULL,
!(topSource = virStorageSourceChainLookup(disk->src, NULL,
top, topIndex,
&top_parent)))
goto endjob;
@ -15576,7 +15576,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW))
baseSource = topSource->backingStore;
else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 ||
!(baseSource = virStorageFileChainLookup(disk->src, topSource,
!(baseSource = virStorageSourceChainLookup(disk->src, topSource,
base, baseIndex, NULL)))
goto endjob;
@ -15611,7 +15611,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0)
goto endjob;
if (virStorageFileGetRelativeBackingPath(topSource, baseSource,
if (virStorageSourceGetRelativeBackingPath(topSource, baseSource,
&backingPath) < 0)
goto endjob;

View File

@ -4375,8 +4375,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
VIR_DEBUG("Removing transient overlay '%s' of disk '%s'",
disk->src->path, disk->dst);
if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) >= 0) {
virStorageFileUnlink(disk->src);
virStorageFileDeinit(disk->src);
virStorageSourceUnlink(disk->src);
virStorageSourceDeinit(disk->src);
}
}

View File

@ -7887,8 +7887,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
VIR_DEBUG("Removing transient overlay '%s' of disk '%s'",
disk->src->path, disk->dst);
if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) >= 0) {
virStorageFileUnlink(disk->src);
virStorageFileDeinit(disk->src);
virStorageSourceUnlink(disk->src);
virStorageSourceDeinit(disk->src);
}
}
}

View File

@ -567,13 +567,13 @@ qemuSnapshotPrepareDiskExternal(virDomainObjPtr vm,
}
if (virStorageSourceIsLocalStorage(snapdisk->src)) {
if (virStorageFileInit(snapdisk->src) < 0)
if (virStorageSourceInit(snapdisk->src) < 0)
return -1;
rc = virStorageFileStat(snapdisk->src, &st);
rc = virStorageSourceStat(snapdisk->src, &st);
err = errno;
virStorageFileDeinit(snapdisk->src);
virStorageSourceDeinit(snapdisk->src);
if (rc < 0) {
if (err != ENOENT) {
@ -867,13 +867,13 @@ qemuSnapshotDiskCleanup(qemuSnapshotDiskDataPtr data,
}
if (data[i].created &&
virStorageFileUnlink(data[i].src) < 0) {
virStorageSourceUnlink(data[i].src) < 0) {
VIR_WARN("Unable to remove just-created %s",
NULLSTR(data[i].src->path));
}
if (data[i].initialized)
virStorageFileDeinit(data[i].src);
virStorageSourceDeinit(data[i].src);
if (data[i].prepared)
qemuDomainStorageSourceAccessRevoke(driver, vm, data[i].src);
@ -1072,13 +1072,13 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm,
return -1;
}
supportsCreate = virStorageFileSupportsCreate(dd->src);
supportsCreate = virStorageSourceSupportsCreate(dd->src);
/* relative backing store paths need to be updated so that relative
* block commit still works. With blockdev we must update it when doing
* commit anyways so it's skipped here */
if (!blockdev &&
virStorageFileSupportsBackingChainTraversal(dd->src))
virStorageSourceSupportsBackingChainTraversal(dd->src))
updateRelativeBacking = true;
if (supportsCreate || updateRelativeBacking) {
@ -1091,7 +1091,7 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm,
if (updateRelativeBacking) {
g_autofree char *backingStoreStr = NULL;
if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
if (virStorageSourceGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
return -1;
if (backingStoreStr != NULL) {
if (virStorageIsRelative(backingStoreStr))
@ -1101,7 +1101,7 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm,
} else {
/* pre-create the image file so that we can label it before handing it to qemu */
if (supportsCreate && dd->src->type != VIR_STORAGE_TYPE_BLOCK) {
if (virStorageFileCreate(dd->src) < 0) {
if (virStorageSourceCreate(dd->src) < 0) {
virReportSystemError(errno, _("failed to create image file '%s'"),
NULLSTR(dd->src->path));
return -1;
@ -1251,7 +1251,7 @@ qemuSnapshotDiskUpdateSource(virDomainObjPtr vm,
/* storage driver access won'd be needed */
if (dd->initialized)
virStorageFileDeinit(dd->src);
virStorageSourceDeinit(dd->src);
if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) < 0)
VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name);

View File

@ -939,7 +939,7 @@ get_files(vahControl * ctl)
* so that the open could be re-tried as that user:group.
*/
if (!virStorageSourceHasBacking(disk->src))
virStorageFileGetMetadata(disk->src, -1, -1, false);
virStorageSourceGetMetadata(disk->src, -1, -1, false);
/* XXX should handle open errors more careful than just ignoring them.
*/

View File

@ -272,7 +272,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
&header)) < 0)
goto cleanup;
if (!(meta = virStorageFileGetMetadataFromBuf(name, header, len,
if (!(meta = virStorageSourceGetMetadataFromBuf(name, header, len,
VIR_STORAGE_FILE_AUTO)))
goto cleanup;

View File

@ -3427,7 +3427,7 @@ storageBackendProbeTarget(virStorageSourcePtr target,
}
}
if (!(meta = virStorageFileGetMetadataFromFD(target->path,
if (!(meta = virStorageSourceGetMetadataFromFD(target->path,
fd,
VIR_STORAGE_FILE_AUTO)))
return -1;

View File

@ -46,7 +46,7 @@ VIR_LOG_INIT("storage_source");
static virStorageSourcePtr
virStorageFileMetadataNew(const char *path,
virStorageSourceMetadataNew(const char *path,
int format)
{
g_autoptr(virStorageSource) def = virStorageSourceNew();
@ -61,7 +61,7 @@ virStorageFileMetadataNew(const char *path,
/**
* virStorageFileGetMetadataFromBuf:
* virStorageSourceGetMetadataFromBuf:
* @path: name of file, for error messages
* @buf: header bytes from @path
* @len: length of @buf
@ -83,14 +83,14 @@ virStorageFileMetadataNew(const char *path,
* Caller MUST free the result after use via virObjectUnref.
*/
virStorageSourcePtr
virStorageFileGetMetadataFromBuf(const char *path,
virStorageSourceGetMetadataFromBuf(const char *path,
char *buf,
size_t len,
int format)
{
virStorageSourcePtr ret = NULL;
if (!(ret = virStorageFileMetadataNew(path, format)))
if (!(ret = virStorageSourceMetadataNew(path, format)))
return NULL;
if (virStorageFileProbeGetMetadata(ret, buf, len) < 0) {
@ -103,7 +103,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
/**
* virStorageFileGetMetadataFromFD:
* virStorageSourceGetMetadataFromFD:
*
* Extract metadata about the storage volume with the specified
* image format. If image format is VIR_STORAGE_FILE_AUTO, it
@ -116,7 +116,7 @@ virStorageFileGetMetadataFromBuf(const char *path,
* Caller MUST free the result after use via virObjectUnref.
*/
virStorageSourcePtr
virStorageFileGetMetadataFromFD(const char *path,
virStorageSourceGetMetadataFromFD(const char *path,
int fd,
int format)
@ -132,7 +132,7 @@ virStorageFileGetMetadataFromFD(const char *path,
return NULL;
}
if (!(meta = virStorageFileMetadataNew(path, format)))
if (!(meta = virStorageSourceMetadataNew(path, format)))
return NULL;
if (S_ISDIR(sb.st_mode)) {
@ -177,7 +177,7 @@ virStorageFileGetMetadataFromFD(const char *path,
* found.
*/
virStorageSourcePtr
virStorageFileChainLookup(virStorageSourcePtr chain,
virStorageSourceChainLookup(virStorageSourcePtr chain,
virStorageSourcePtr startFrom,
const char *name,
unsigned int idx,
@ -1794,7 +1794,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
if (format == VIR_STORAGE_FILE_RAW && !src->encryption) {
src->capacity = src->physical;
} else if ((meta = virStorageFileGetMetadataFromBuf(src->path, buf,
} else if ((meta = virStorageSourceGetMetadataFromBuf(src->path, buf,
len, format))) {
src->capacity = meta->capacity ? meta->capacity : src->physical;
if (src->encryption && meta->encryption)
@ -1811,7 +1811,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
/**
* virStorageFileRemoveLastPathComponent:
* virStorageSourceRemoveLastPathComponent:
*
* @path: Path string to remove the last component from
*
@ -1820,7 +1820,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
* responsible to free the returned string.
*/
static char *
virStorageFileRemoveLastPathComponent(const char *path)
virStorageSourceRemoveLastPathComponent(const char *path)
{
char *ret;
@ -1833,7 +1833,7 @@ virStorageFileRemoveLastPathComponent(const char *path)
/*
* virStorageFileGetRelativeBackingPath:
* virStorageSourceGetRelativeBackingPath:
*
* Resolve relative path to be written to the overlay of @top image when
* collapsing the backing chain between @top and @base.
@ -1841,7 +1841,7 @@ virStorageFileRemoveLastPathComponent(const char *path)
* Returns 0 on success; 1 if backing chain isn't relative and -1 on error.
*/
int
virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top,
virStorageSourcePtr base,
char **relpath)
{
@ -1855,7 +1855,7 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
if (!next->relPath)
return 1;
if (!(tmp = virStorageFileRemoveLastPathComponent(path)))
if (!(tmp = virStorageSourceRemoveLastPathComponent(path)))
return -1;
VIR_FREE(path);
@ -1881,14 +1881,14 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
static bool
virStorageFileIsInitialized(const virStorageSource *src)
virStorageSourceIsInitialized(const virStorageSource *src)
{
return src && src->drv;
}
/**
* virStorageFileGetBackendForSupportCheck:
* virStorageSourceGetBackendForSupportCheck:
* @src: storage source to check support for
* @backend: pointer to the storage backend for @src if it's supported
*
@ -1896,7 +1896,7 @@ virStorageFileIsInitialized(const virStorageSource *src)
* 1 if it is supported and -1 on error with an error reported.
*/
static int
virStorageFileGetBackendForSupportCheck(const virStorageSource *src,
virStorageSourceGetBackendForSupportCheck(const virStorageSource *src,
virStorageFileBackendPtr *backend)
{
int actualType;
@ -1926,12 +1926,12 @@ virStorageFileGetBackendForSupportCheck(const virStorageSource *src,
int
virStorageFileSupportsBackingChainTraversal(const virStorageSource *src)
virStorageSourceSupportsBackingChainTraversal(const virStorageSource *src)
{
virStorageFileBackendPtr backend;
int rv;
if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
if ((rv = virStorageSourceGetBackendForSupportCheck(src, &backend)) < 1)
return rv;
return backend->storageFileGetUniqueIdentifier &&
@ -1941,7 +1941,7 @@ virStorageFileSupportsBackingChainTraversal(const virStorageSource *src)
/**
* virStorageFileSupportsSecurityDriver:
* virStorageSourceSupportsSecurityDriver:
*
* @src: a storage file structure
*
@ -1949,12 +1949,12 @@ virStorageFileSupportsBackingChainTraversal(const virStorageSource *src)
* driver to perform labelling
*/
int
virStorageFileSupportsSecurityDriver(const virStorageSource *src)
virStorageSourceSupportsSecurityDriver(const virStorageSource *src)
{
virStorageFileBackendPtr backend;
int rv;
if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
if ((rv = virStorageSourceGetBackendForSupportCheck(src, &backend)) < 1)
return rv;
return backend->storageFileChown ? 1 : 0;
@ -1962,7 +1962,7 @@ virStorageFileSupportsSecurityDriver(const virStorageSource *src)
/**
* virStorageFileSupportsAccess:
* virStorageSourceSupportsAccess:
*
* @src: a storage file structure
*
@ -1970,12 +1970,12 @@ virStorageFileSupportsSecurityDriver(const virStorageSource *src)
* for the given vm.
*/
int
virStorageFileSupportsAccess(const virStorageSource *src)
virStorageSourceSupportsAccess(const virStorageSource *src)
{
virStorageFileBackendPtr backend;
int rv;
if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
if ((rv = virStorageSourceGetBackendForSupportCheck(src, &backend)) < 1)
return rv;
return backend->storageFileAccess ? 1 : 0;
@ -1983,19 +1983,19 @@ virStorageFileSupportsAccess(const virStorageSource *src)
/**
* virStorageFileSupportsCreate:
* virStorageSourceSupportsCreate:
* @src: a storage file structure
*
* Check if the storage driver supports creating storage described by @src
* via virStorageFileCreate.
* via virStorageSourceCreate.
*/
int
virStorageFileSupportsCreate(const virStorageSource *src)
virStorageSourceSupportsCreate(const virStorageSource *src)
{
virStorageFileBackendPtr backend;
int rv;
if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
if ((rv = virStorageSourceGetBackendForSupportCheck(src, &backend)) < 1)
return rv;
return backend->storageFileCreate ? 1 : 0;
@ -2003,11 +2003,11 @@ virStorageFileSupportsCreate(const virStorageSource *src)
void
virStorageFileDeinit(virStorageSourcePtr src)
virStorageSourceDeinit(virStorageSourcePtr src)
{
virStorageDriverDataPtr drv = NULL;
if (!virStorageFileIsInitialized(src))
if (!virStorageSourceIsInitialized(src))
return;
drv = src->drv;
@ -2021,7 +2021,7 @@ virStorageFileDeinit(virStorageSourcePtr src)
/**
* virStorageFileInitAs:
* virStorageSourceInitAs:
*
* @src: storage source definition
* @uid: uid used to access the file, or -1 for current uid
@ -2034,7 +2034,7 @@ virStorageFileDeinit(virStorageSourcePtr src)
* initialization failed. Libvirt error is reported.
*/
int
virStorageFileInitAs(virStorageSourcePtr src,
virStorageSourceInitAs(virStorageSourcePtr src,
uid_t uid, gid_t gid)
{
int actualType = virStorageSourceGetActualType(src);
@ -2071,20 +2071,20 @@ virStorageFileInitAs(virStorageSourcePtr src,
/**
* virStorageFileInit:
* virStorageSourceInit:
*
* See virStorageFileInitAs. The file is initialized to be accessed by the
* See virStorageSourceInitAs. The file is initialized to be accessed by the
* current user.
*/
int
virStorageFileInit(virStorageSourcePtr src)
virStorageSourceInit(virStorageSourcePtr src)
{
return virStorageFileInitAs(src, -1, -1);
return virStorageSourceInitAs(src, -1, -1);
}
/**
* virStorageFileCreate: Creates an empty storage file via storage driver
* virStorageSourceCreate: Creates an empty storage file via storage driver
*
* @src: file structure pointing to the file
*
@ -2092,12 +2092,12 @@ virStorageFileInit(virStorageSourcePtr src)
* -1 on other failure. Errno is set in case of failure.
*/
int
virStorageFileCreate(virStorageSourcePtr src)
virStorageSourceCreate(virStorageSourcePtr src)
{
virStorageDriverDataPtr drv = NULL;
int ret;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
errno = ENOSYS;
return -2;
}
@ -2119,7 +2119,7 @@ virStorageFileCreate(virStorageSourcePtr src)
/**
* virStorageFileUnlink: Unlink storage file via storage driver
* virStorageSourceUnlink: Unlink storage file via storage driver
*
* @src: file structure pointing to the file
*
@ -2129,12 +2129,12 @@ virStorageFileCreate(virStorageSourcePtr src)
* -1 on other failure. Errno is set in case of failure.
*/
int
virStorageFileUnlink(virStorageSourcePtr src)
virStorageSourceUnlink(virStorageSourcePtr src)
{
virStorageDriverDataPtr drv = NULL;
int ret;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
errno = ENOSYS;
return -2;
}
@ -2156,7 +2156,7 @@ virStorageFileUnlink(virStorageSourcePtr src)
/**
* virStorageFileStat: returns stat struct of a file via storage driver
* virStorageSourceStat: returns stat struct of a file via storage driver
*
* @src: file structure pointing to the file
* @stat: stat structure to return data
@ -2165,13 +2165,13 @@ virStorageFileUnlink(virStorageSourcePtr src)
* -1 on other failure. Errno is set in case of failure.
*/
int
virStorageFileStat(virStorageSourcePtr src,
virStorageSourceStat(virStorageSourcePtr src,
struct stat *st)
{
virStorageDriverDataPtr drv = NULL;
int ret;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
errno = ENOSYS;
return -2;
}
@ -2193,7 +2193,7 @@ virStorageFileStat(virStorageSourcePtr src,
/**
* virStorageFileRead: read bytes from a file into a buffer
* virStorageSourceRead: read bytes from a file into a buffer
*
* @src: file structure pointing to the file
* @offset: number of bytes to skip in the storage file
@ -2205,7 +2205,7 @@ virStorageFileStat(virStorageSourcePtr src,
* Libvirt error is reported on failure.
*/
ssize_t
virStorageFileRead(virStorageSourcePtr src,
virStorageSourceRead(virStorageSourcePtr src,
size_t offset,
size_t len,
char **buf)
@ -2213,7 +2213,7 @@ virStorageFileRead(virStorageSourcePtr src,
virStorageDriverDataPtr drv = NULL;
ssize_t ret;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("storage file backend not initialized"));
return -1;
@ -2234,7 +2234,7 @@ virStorageFileRead(virStorageSourcePtr src,
/*
* virStorageFileGetUniqueIdentifier: Get a unique string describing the volume
* virStorageSourceGetUniqueIdentifier: Get a unique string describing the volume
*
* @src: file structure pointing to the file
*
@ -2242,11 +2242,11 @@ virStorageFileRead(virStorageSourcePtr src,
* The string shall not be freed and is valid until the storage file is
* deinitialized. Returns NULL on error and sets a libvirt error code */
const char *
virStorageFileGetUniqueIdentifier(virStorageSourcePtr src)
virStorageSourceGetUniqueIdentifier(virStorageSourcePtr src)
{
virStorageDriverDataPtr drv = NULL;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("storage file backend not initialized"));
return NULL;
@ -2268,7 +2268,7 @@ virStorageFileGetUniqueIdentifier(virStorageSourcePtr src)
/**
* virStorageFileAccess: Check accessibility of a storage file
* virStorageSourceAccess: Check accessibility of a storage file
*
* @src: storage file to check access permissions
* @mode: accessibility check options (see man 2 access)
@ -2278,12 +2278,12 @@ virStorageFileGetUniqueIdentifier(virStorageSourcePtr src)
* by libvirt storage backend.
*/
int
virStorageFileAccess(virStorageSourcePtr src,
virStorageSourceAccess(virStorageSourcePtr src,
int mode)
{
virStorageDriverDataPtr drv = NULL;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
errno = ENOSYS;
return -2;
}
@ -2300,7 +2300,7 @@ virStorageFileAccess(virStorageSourcePtr src,
/**
* virStorageFileChown: Change owner of a storage file
* virStorageSourceChown: Change owner of a storage file
*
* @src: storage file to change owner of
* @uid: new owner id
@ -2311,13 +2311,13 @@ virStorageFileAccess(virStorageSourcePtr src,
* by libvirt storage backend.
*/
int
virStorageFileChown(const virStorageSource *src,
virStorageSourceChown(const virStorageSource *src,
uid_t uid,
gid_t gid)
{
virStorageDriverDataPtr drv = NULL;
if (!virStorageFileIsInitialized(src)) {
if (!virStorageSourceIsInitialized(src)) {
errno = ENOSYS;
return -2;
}
@ -2337,7 +2337,7 @@ virStorageFileChown(const virStorageSource *src,
/**
* virStorageFileReportBrokenChain:
* virStorageSourceReportBrokenChain:
*
* @errcode: errno when accessing @src
* @src: inaccessible file in the backing chain of @parent
@ -2347,7 +2347,7 @@ virStorageFileChown(const virStorageSource *src,
* for @parent.
*/
void
virStorageFileReportBrokenChain(int errcode,
virStorageSourceReportBrokenChain(int errcode,
virStorageSourcePtr src,
virStorageSourcePtr parent)
{
@ -2383,7 +2383,7 @@ virStorageFileReportBrokenChain(int errcode,
static int
virStorageFileGetMetadataRecurseReadHeader(virStorageSourcePtr src,
virStorageSourceGetMetadataRecurseReadHeader(virStorageSourcePtr src,
virStorageSourcePtr parent,
uid_t uid,
gid_t gid,
@ -2395,15 +2395,15 @@ virStorageFileGetMetadataRecurseReadHeader(virStorageSourcePtr src,
const char *uniqueName;
ssize_t len;
if (virStorageFileInitAs(src, uid, gid) < 0)
if (virStorageSourceInitAs(src, uid, gid) < 0)
return -1;
if (virStorageFileAccess(src, F_OK) < 0) {
virStorageFileReportBrokenChain(errno, src, parent);
if (virStorageSourceAccess(src, F_OK) < 0) {
virStorageSourceReportBrokenChain(errno, src, parent);
goto cleanup;
}
if (!(uniqueName = virStorageFileGetUniqueIdentifier(src)))
if (!(uniqueName = virStorageSourceGetUniqueIdentifier(src)))
goto cleanup;
if (virHashHasEntry(cycle, uniqueName)) {
@ -2416,21 +2416,21 @@ virStorageFileGetMetadataRecurseReadHeader(virStorageSourcePtr src,
if (virHashAddEntry(cycle, uniqueName, NULL) < 0)
goto cleanup;
if ((len = virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, buf)) < 0)
if ((len = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, buf)) < 0)
goto cleanup;
*headerLen = len;
ret = 0;
cleanup:
virStorageFileDeinit(src);
virStorageSourceDeinit(src);
return ret;
}
/* Recursive workhorse for virStorageFileGetMetadata. */
/* Recursive workhorse for virStorageSourceGetMetadata. */
static int
virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
virStorageSourceGetMetadataRecurse(virStorageSourcePtr src,
virStorageSourcePtr parent,
uid_t uid, gid_t gid,
bool report_broken,
@ -2451,7 +2451,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
src->format = VIR_STORAGE_FILE_AUTO;
/* exit if we can't load information about the current image */
rv = virStorageFileSupportsBackingChainTraversal(src);
rv = virStorageSourceSupportsBackingChainTraversal(src);
if (rv <= 0) {
if (orig_format == VIR_STORAGE_FILE_AUTO)
return -2;
@ -2459,7 +2459,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
return rv;
}
if (virStorageFileGetMetadataRecurseReadHeader(src, parent, uid, gid,
if (virStorageSourceGetMetadataRecurseReadHeader(src, parent, uid, gid,
&buf, &headerLen, cycle) < 0)
return -1;
@ -2484,7 +2484,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
if (rv == 1)
return 0;
if ((rv = virStorageFileGetMetadataRecurse(backingStore, parent,
if ((rv = virStorageSourceGetMetadataRecurse(backingStore, parent,
uid, gid,
report_broken,
cycle, depth + 1)) < 0) {
@ -2513,7 +2513,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
/**
* virStorageFileGetMetadata:
* virStorageSourceGetMetadata:
*
* Extract metadata about the storage volume with the specified
* image format. If image format is VIR_STORAGE_FILE_AUTO, it
@ -2534,7 +2534,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
* Caller MUST free result after use via virObjectUnref.
*/
int
virStorageFileGetMetadata(virStorageSourcePtr src,
virStorageSourceGetMetadata(virStorageSourcePtr src,
uid_t uid, gid_t gid,
bool report_broken)
{
@ -2556,7 +2556,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
src->format = VIR_STORAGE_FILE_RAW;
}
ret = virStorageFileGetMetadataRecurse(src, src, uid, gid,
ret = virStorageSourceGetMetadataRecurse(src, src, uid, gid,
report_broken, cycle, 1);
virHashFree(cycle);
@ -2565,7 +2565,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
/**
* virStorageFileGetBackingStoreStr:
* virStorageSourceGetBackingStoreStr:
* @src: storage object
*
* Extracts the backing store string as stored in the storage volume described
@ -2574,7 +2574,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
* returned.
*/
int
virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
char **backing)
{
ssize_t headerLen;
@ -2585,18 +2585,18 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
*backing = NULL;
/* exit if we can't load information about the current image */
if (!virStorageFileSupportsBackingChainTraversal(src))
if (!virStorageSourceSupportsBackingChainTraversal(src))
return 0;
rv = virStorageFileAccess(src, F_OK);
rv = virStorageSourceAccess(src, F_OK);
if (rv == -2)
return 0;
if (rv < 0) {
virStorageFileReportBrokenChain(errno, src, src);
virStorageSourceReportBrokenChain(errno, src, src);
return -1;
}
if ((headerLen = virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER,
if ((headerLen = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER,
&buf)) < 0) {
if (headerLen == -2)
return 0;

View File

@ -28,19 +28,19 @@
#endif
virStorageSourcePtr
virStorageFileGetMetadataFromFD(const char *path,
virStorageSourceGetMetadataFromFD(const char *path,
int fd,
int format);
virStorageSourcePtr
virStorageFileGetMetadataFromBuf(const char *path,
virStorageSourceGetMetadataFromBuf(const char *path,
char *buf,
size_t len,
int format)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
virStorageSourcePtr
virStorageFileChainLookup(virStorageSourcePtr chain,
virStorageSourceChainLookup(virStorageSourcePtr chain,
virStorageSourcePtr startFrom,
const char *name,
unsigned int idx,
@ -72,7 +72,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int
virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top,
virStorageSourcePtr base,
char **relpath)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
@ -82,67 +82,67 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
virStorageSourcePtr *src);
int
virStorageFileInit(virStorageSourcePtr src);
virStorageSourceInit(virStorageSourcePtr src);
int
virStorageFileInitAs(virStorageSourcePtr src,
virStorageSourceInitAs(virStorageSourcePtr src,
uid_t uid, gid_t gid);
void
virStorageFileDeinit(virStorageSourcePtr src);
virStorageSourceDeinit(virStorageSourcePtr src);
int
virStorageFileCreate(virStorageSourcePtr src);
virStorageSourceCreate(virStorageSourcePtr src);
int
virStorageFileUnlink(virStorageSourcePtr src);
virStorageSourceUnlink(virStorageSourcePtr src);
int
virStorageFileStat(virStorageSourcePtr src,
virStorageSourceStat(virStorageSourcePtr src,
struct stat *st);
ssize_t
virStorageFileRead(virStorageSourcePtr src,
virStorageSourceRead(virStorageSourcePtr src,
size_t offset,
size_t len,
char **buf);
const char *
virStorageFileGetUniqueIdentifier(virStorageSourcePtr src);
virStorageSourceGetUniqueIdentifier(virStorageSourcePtr src);
int
virStorageFileAccess(virStorageSourcePtr src,
virStorageSourceAccess(virStorageSourcePtr src,
int mode);
int
virStorageFileChown(const virStorageSource *src,
virStorageSourceChown(const virStorageSource *src,
uid_t uid,
gid_t gid);
int
virStorageFileSupportsSecurityDriver(const virStorageSource *src);
virStorageSourceSupportsSecurityDriver(const virStorageSource *src);
int
virStorageFileSupportsAccess(const virStorageSource *src);
virStorageSourceSupportsAccess(const virStorageSource *src);
int
virStorageFileSupportsCreate(const virStorageSource *src);
virStorageSourceSupportsCreate(const virStorageSource *src);
int
virStorageFileSupportsBackingChainTraversal(const virStorageSource *src);
virStorageSourceSupportsBackingChainTraversal(const virStorageSource *src);
int
virStorageFileGetMetadata(virStorageSourcePtr src,
virStorageSourceGetMetadata(virStorageSourcePtr src,
uid_t uid, gid_t gid,
bool report_broken)
ATTRIBUTE_NONNULL(1);
int
virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
char **backing)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void
virStorageFileReportBrokenChain(int errcode,
virStorageSourceReportBrokenChain(int errcode,
virStorageSourcePtr src,
virStorageSourcePtr parent);

View File

@ -101,7 +101,7 @@ testStorageFileGetMetadata(const char *path,
def->path = g_strdup(path);
if (virStorageFileGetMetadata(def, uid, gid, true) < 0)
if (virStorageSourceGetMetadata(def, uid, gid, true) < 0)
return NULL;
return g_steal_pointer(&def);
@ -366,7 +366,7 @@ testStorageLookup(const void *args)
}
/* Test twice to ensure optional parameter doesn't cause NULL deref. */
result = virStorageFileChainLookup(data->chain, data->from,
result = virStorageSourceChainLookup(data->chain, data->from,
idx ? NULL : data->name,
idx, NULL);
@ -395,7 +395,7 @@ testStorageLookup(const void *args)
ret = -1;
}
result = virStorageFileChainLookup(data->chain, data->from,
result = virStorageSourceChainLookup(data->chain, data->from,
data->name, idx, &actualParent);
if (!data->expResult)
virResetLastError();
@ -552,7 +552,7 @@ testPathRelative(const void *args)
const struct testPathRelativeBacking *data = args;
g_autofree char *actual = NULL;
if (virStorageFileGetRelativeBackingPath(data->top,
if (virStorageSourceGetRelativeBackingPath(data->top,
data->base,
&actual) < 0) {
fprintf(stderr, "relative backing path resolution failed\n");