mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
storage: Extract common code to retrieve driver backend for support check
The 'file access' module of the storage driver has few feature checks to determine whether libvirt supports given storage driver method. The code to retrieve the driver struct needed for the check is the same so it can be extracted.
This commit is contained in:
parent
a1e3e8ddbd
commit
8c6b6684a8
@ -44,24 +44,30 @@ virStorageFileIsInitialized(const virStorageSource *src)
|
||||
}
|
||||
|
||||
|
||||
static virStorageFileBackendPtr
|
||||
virStorageFileGetBackendForSupportCheck(const virStorageSource *src)
|
||||
{
|
||||
int actualType;
|
||||
|
||||
if (!src)
|
||||
return NULL;
|
||||
|
||||
if (src->drv)
|
||||
return src->drv->backend;
|
||||
|
||||
actualType = virStorageSourceGetActualType(src);
|
||||
|
||||
return virStorageFileBackendForTypeInternal(actualType, src->protocol, false);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
|
||||
{
|
||||
int actualType;
|
||||
virStorageFileBackendPtr backend;
|
||||
|
||||
if (!src)
|
||||
if (!(backend = virStorageFileGetBackendForSupportCheck(src)))
|
||||
return false;
|
||||
actualType = virStorageSourceGetActualType(src);
|
||||
|
||||
if (src->drv) {
|
||||
backend = src->drv->backend;
|
||||
} else {
|
||||
if (!(backend = virStorageFileBackendForTypeInternal(actualType,
|
||||
src->protocol,
|
||||
false)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return backend->storageFileGetUniqueIdentifier &&
|
||||
backend->storageFileRead &&
|
||||
@ -80,21 +86,10 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
|
||||
bool
|
||||
virStorageFileSupportsSecurityDriver(const virStorageSource *src)
|
||||
{
|
||||
int actualType;
|
||||
virStorageFileBackendPtr backend;
|
||||
|
||||
if (!src)
|
||||
if (!(backend = virStorageFileGetBackendForSupportCheck(src)))
|
||||
return false;
|
||||
actualType = virStorageSourceGetActualType(src);
|
||||
|
||||
if (src->drv) {
|
||||
backend = src->drv->backend;
|
||||
} else {
|
||||
if (!(backend = virStorageFileBackendForTypeInternal(actualType,
|
||||
src->protocol,
|
||||
false)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!backend->storageFileChown;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user