util: storage: Allow checking whether virStorageFileCreate is supported

Add virStorageFileSupportsCreate which allows silent check whether
virStorageFileCreate is implemented.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-07-29 17:43:22 +02:00
parent d30e0d3abc
commit e776194ad2
3 changed files with 22 additions and 0 deletions

View File

@ -2994,6 +2994,7 @@ virStorageFileReportBrokenChain;
virStorageFileResize;
virStorageFileStat;
virStorageFileSupportsAccess;
virStorageFileSupportsCreate;
virStorageFileSupportsSecurityDriver;
virStorageFileUnlink;
virStorageIsFile;

View File

@ -4505,6 +4505,26 @@ virStorageFileSupportsAccess(const virStorageSource *src)
}
/**
* virStorageFileSupportsCreate:
* @src: a storage file structure
*
* Check if the storage driver supports creating storage described by @src
* via virStorageFileCreate.
*/
int
virStorageFileSupportsCreate(const virStorageSource *src)
{
virStorageFileBackendPtr backend;
int rv;
if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
return rv;
return backend->storageFileCreate ? 1 : 0;
}
void
virStorageFileDeinit(virStorageSourcePtr src)
{

View File

@ -532,6 +532,7 @@ int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid);
int virStorageFileSupportsSecurityDriver(const virStorageSource *src);
int virStorageFileSupportsAccess(const virStorageSource *src);
int virStorageFileSupportsCreate(const virStorageSource *src);
int virStorageFileGetMetadata(virStorageSourcePtr src,
uid_t uid, gid_t gid,