mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virStorageSourceGetBackingStoreStr: Return relative paths only
Rename the function to virStorageSourceFetchRelativeBackingPath and return relative paths only. The function is only used to restore the relative relationship between images so there's no need for it to be universal. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
489742e76d
commit
db4d7a37ca
@ -1691,7 +1691,7 @@ virStorageSourceChainLookup;
|
||||
virStorageSourceChown;
|
||||
virStorageSourceCreate;
|
||||
virStorageSourceDeinit;
|
||||
virStorageSourceGetBackingStoreStr;
|
||||
virStorageSourceFetchRelativeBackingPath;
|
||||
virStorageSourceGetMetadata;
|
||||
virStorageSourceGetMetadataFromBuf;
|
||||
virStorageSourceGetMetadataFromFD;
|
||||
|
@ -3420,7 +3420,6 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm,
|
||||
virStorageSourcePtr n;
|
||||
|
||||
for (n = src; virStorageSourceHasBacking(n); n = n->backingStore) {
|
||||
g_autofree char *backingStoreStr = NULL;
|
||||
int rc;
|
||||
|
||||
if (n->backingStore->relPath)
|
||||
@ -3432,15 +3431,12 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm,
|
||||
if (qemuDomainStorageFileInit(driver, vm, n, topsrc) < 0)
|
||||
return -1;
|
||||
|
||||
rc = virStorageSourceGetBackingStoreStr(n, &backingStoreStr);
|
||||
rc = virStorageSourceFetchRelativeBackingPath(n, &n->backingStore->relPath);
|
||||
|
||||
virStorageSourceDeinit(n);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (backingStoreStr && virStorageIsRelative(backingStoreStr))
|
||||
n->backingStore->relPath = g_steal_pointer(&backingStoreStr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1088,16 +1088,9 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm,
|
||||
dd->initialized = true;
|
||||
|
||||
if (reuse) {
|
||||
if (updateRelativeBacking) {
|
||||
g_autofree char *backingStoreStr = NULL;
|
||||
|
||||
if (virStorageSourceGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
|
||||
return -1;
|
||||
if (backingStoreStr != NULL) {
|
||||
if (virStorageIsRelative(backingStoreStr))
|
||||
dd->relPath = g_steal_pointer(&backingStoreStr);
|
||||
}
|
||||
}
|
||||
if (updateRelativeBacking &&
|
||||
virStorageSourceFetchRelativeBackingPath(dd->src, &dd->relPath) < 0)
|
||||
return -1;
|
||||
} 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) {
|
||||
|
@ -1881,24 +1881,26 @@ virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top,
|
||||
|
||||
|
||||
/**
|
||||
* virStorageSourceGetBackingStoreStr:
|
||||
* virStorageSourceFetchRelativeBackingPath:
|
||||
* @src: storage object
|
||||
* @relPath: filled with the relative path to the backing image of @src if
|
||||
* the metadata of @src refer to it as relative.
|
||||
*
|
||||
* Extracts the backing store string as stored in the storage volume described
|
||||
* by @src and returns it to the user. Caller is responsible for freeing it.
|
||||
* In case when the string can't be retrieved or does not exist NULL is
|
||||
* returned.
|
||||
* Fetches the backing store definition of @src by updating the metadata from
|
||||
* disk and fills 'relPath' if the backing store string is relative. The data
|
||||
* is used by virStorageSourceGetRelativeBackingPath to establish the relative
|
||||
* path between two images.
|
||||
*/
|
||||
int
|
||||
virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
|
||||
char **backing)
|
||||
virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src,
|
||||
char **relPath)
|
||||
{
|
||||
ssize_t headerLen;
|
||||
int rv;
|
||||
g_autofree char *buf = NULL;
|
||||
g_autoptr(virStorageSource) tmp = NULL;
|
||||
|
||||
*backing = NULL;
|
||||
g_clear_pointer(relPath, g_free);
|
||||
|
||||
/* exit if we can't load information about the current image */
|
||||
if (!virStorageSourceSupportsBackingChainTraversal(src))
|
||||
@ -1925,7 +1927,9 @@ virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
|
||||
if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
|
||||
return -1;
|
||||
|
||||
*backing = g_steal_pointer(&tmp->backingStoreRaw);
|
||||
if (virStorageIsRelative(tmp->backingStoreRaw))
|
||||
*relPath = g_steal_pointer(&tmp->backingStoreRaw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -138,8 +138,8 @@ virStorageSourceGetMetadata(virStorageSourcePtr src,
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
int
|
||||
virStorageSourceGetBackingStoreStr(virStorageSourcePtr src,
|
||||
char **backing)
|
||||
virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src,
|
||||
char **relPath)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user