mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
storage_source: introduce virStorageSourceChainLookupBySource
Looks up disk storage source within storage source chain using storage source object instead of path to make it work with all disk types. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
90d9bc9d74
commit
a784d4076a
@ -1780,6 +1780,7 @@ virStorageFileProbeGetMetadata;
|
|||||||
# storage_file/storage_source.h
|
# storage_file/storage_source.h
|
||||||
virStorageSourceAccess;
|
virStorageSourceAccess;
|
||||||
virStorageSourceChainLookup;
|
virStorageSourceChainLookup;
|
||||||
|
virStorageSourceChainLookupBySource;
|
||||||
virStorageSourceChown;
|
virStorageSourceChown;
|
||||||
virStorageSourceCreate;
|
virStorageSourceCreate;
|
||||||
virStorageSourceDeinit;
|
virStorageSourceDeinit;
|
||||||
|
@ -322,6 +322,46 @@ virStorageSourceChainLookup(virStorageSource *chain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virStorageSourceChainLookupBySource:
|
||||||
|
* @chain: chain top to look in
|
||||||
|
* @base: storage source to look for in @chain
|
||||||
|
* @parent: Filled with parent virStorageSource of the returned value if non-NULL.
|
||||||
|
*
|
||||||
|
* Looks up a storage source definition corresponding to @base in @chain.
|
||||||
|
*
|
||||||
|
* Returns virStorageSource withing chain or NULL if not found.
|
||||||
|
*/
|
||||||
|
virStorageSource *
|
||||||
|
virStorageSourceChainLookupBySource(virStorageSource *chain,
|
||||||
|
virStorageSource *base,
|
||||||
|
virStorageSource **parent)
|
||||||
|
{
|
||||||
|
virStorageSource *prev = NULL;
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
*parent = NULL;
|
||||||
|
|
||||||
|
while (virStorageSourceIsBacking(chain)) {
|
||||||
|
if (virStorageSourceIsSameLocation(chain, base))
|
||||||
|
break;
|
||||||
|
|
||||||
|
prev = chain;
|
||||||
|
chain = chain->backingStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!virStorageSourceIsBacking(chain)) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("could not find base disk source in disk source chain"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
*parent = prev;
|
||||||
|
return chain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virStorageSource *
|
static virStorageSource *
|
||||||
virStorageSourceNewFromBackingRelative(virStorageSource *parent,
|
virStorageSourceNewFromBackingRelative(virStorageSource *parent,
|
||||||
const char *rel)
|
const char *rel)
|
||||||
|
@ -47,6 +47,12 @@ virStorageSourceChainLookup(virStorageSource *chain,
|
|||||||
virStorageSource **parent)
|
virStorageSource **parent)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
|
virStorageSource *
|
||||||
|
virStorageSourceChainLookupBySource(virStorageSource *chain,
|
||||||
|
virStorageSource *base,
|
||||||
|
virStorageSource **parent)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
int
|
int
|
||||||
virStorageSourceUpdatePhysicalSize(virStorageSource *src,
|
virStorageSourceUpdatePhysicalSize(virStorageSource *src,
|
||||||
int fd,
|
int fd,
|
||||||
|
Loading…
Reference in New Issue
Block a user