From: Peter Krempa Date: Mon, 29 Jul 2019 15:43:22 +0000 (+0200) Subject: util: storage: Allow checking whether virStorageFileCreate is supported X-Git-Tag: v5.7.0-rc1~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e776194ad2501c9dcba8b4d9f1272342cd7f7c41;p=thirdparty%2Flibvirt.git util: storage: Allow checking whether virStorageFileCreate is supported Add virStorageFileSupportsCreate which allows silent check whether virStorageFileCreate is implemented. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ff4ddd1c5c..83f40cefe6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2994,6 +2994,7 @@ virStorageFileReportBrokenChain; virStorageFileResize; virStorageFileStat; virStorageFileSupportsAccess; +virStorageFileSupportsCreate; virStorageFileSupportsSecurityDriver; virStorageFileUnlink; virStorageIsFile; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5882d470de..ba56f452e9 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -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) { diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 38ba901858..2882bacf3e 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -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,