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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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