]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: Allow checking whether virStorageFileCreate is supported
authorPeter Krempa <pkrempa@redhat.com>
Mon, 29 Jul 2019 15:43:22 +0000 (17:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 14 Aug 2019 16:25:08 +0000 (18:25 +0200)
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>
src/libvirt_private.syms
src/util/virstoragefile.c
src/util/virstoragefile.h

index ff4ddd1c5c55872fc317b38076331978d3d7773a..83f40cefe6c9597b5a6e116a9ad7cb9425b11558 100644 (file)
@@ -2994,6 +2994,7 @@ virStorageFileReportBrokenChain;
 virStorageFileResize;
 virStorageFileStat;
 virStorageFileSupportsAccess;
+virStorageFileSupportsCreate;
 virStorageFileSupportsSecurityDriver;
 virStorageFileUnlink;
 virStorageIsFile;
index 5882d470dede763584f7ec18a9ec3423e5f0fc1e..ba56f452e90909ad8380ea90730c7071d8e4e89e 100644 (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)
 {
index 38ba9018589f1d0bbdb8db1dbf756818db85cba7..2882bacf3e11a1bc98881bf803f687d66c4fa996 100644 (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,