提交 8c6b6684 编写于 作者: P Peter Krempa

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.
上级 a1e3e8dd
...@@ -44,24 +44,30 @@ virStorageFileIsInitialized(const virStorageSource *src) ...@@ -44,24 +44,30 @@ virStorageFileIsInitialized(const virStorageSource *src)
} }
static bool static virStorageFileBackendPtr
virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) virStorageFileGetBackendForSupportCheck(const virStorageSource *src)
{ {
int actualType; int actualType;
virStorageFileBackendPtr backend;
if (!src) if (!src)
return false; return NULL;
if (src->drv)
return src->drv->backend;
actualType = virStorageSourceGetActualType(src); actualType = virStorageSourceGetActualType(src);
if (src->drv) { return virStorageFileBackendForTypeInternal(actualType, src->protocol, false);
backend = src->drv->backend; }
} else {
if (!(backend = virStorageFileBackendForTypeInternal(actualType,
src->protocol, static bool
false))) virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
return false; {
} virStorageFileBackendPtr backend;
if (!(backend = virStorageFileGetBackendForSupportCheck(src)))
return false;
return backend->storageFileGetUniqueIdentifier && return backend->storageFileGetUniqueIdentifier &&
backend->storageFileRead && backend->storageFileRead &&
...@@ -80,21 +86,10 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) ...@@ -80,21 +86,10 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
bool bool
virStorageFileSupportsSecurityDriver(const virStorageSource *src) virStorageFileSupportsSecurityDriver(const virStorageSource *src)
{ {
int actualType;
virStorageFileBackendPtr backend; virStorageFileBackendPtr backend;
if (!src) if (!(backend = virStorageFileGetBackendForSupportCheck(src)))
return false; 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; return !!backend->storageFileChown;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册