Blame SOURCES/libvirt-util-storage-Allow-checking-whether-virStorageFileCreate-is-supported.patch

99cbc7
From 080e123711e8c31634567836c9ca1adf79bcf904 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <080e123711e8c31634567836c9ca1adf79bcf904@dist-git>
99cbc7
From: Peter Krempa <pkrempa@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:36:52 +0200
99cbc7
Subject: [PATCH] util: storage: Allow checking whether virStorageFileCreate is
99cbc7
 supported
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Add virStorageFileSupportsCreate which allows silent check whether
99cbc7
virStorageFileCreate is implemented.
99cbc7
99cbc7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit e776194ad2501c9dcba8b4d9f1272342cd7f7c41)
99cbc7
https: //bugzilla.redhat.com/show_bug.cgi?id=1724808
99cbc7
Message-Id: <e4d77e48d0f20da3d0254c95de9904d77cf971df.1565958905.git.pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/libvirt_private.syms  |  1 +
99cbc7
 src/util/virstoragefile.c | 20 ++++++++++++++++++++
99cbc7
 src/util/virstoragefile.h |  1 +
99cbc7
 3 files changed, 22 insertions(+)
99cbc7
99cbc7
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
99cbc7
index bf99930802..e696fa512c 100644
99cbc7
--- a/src/libvirt_private.syms
99cbc7
+++ b/src/libvirt_private.syms
99cbc7
@@ -2845,6 +2845,7 @@ virStorageFileReportBrokenChain;
99cbc7
 virStorageFileResize;
99cbc7
 virStorageFileStat;
99cbc7
 virStorageFileSupportsAccess;
99cbc7
+virStorageFileSupportsCreate;
99cbc7
 virStorageFileSupportsSecurityDriver;
99cbc7
 virStorageFileUnlink;
99cbc7
 virStorageIsFile;
99cbc7
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
99cbc7
index f320bc1928..faf21db567 100644
99cbc7
--- a/src/util/virstoragefile.c
99cbc7
+++ b/src/util/virstoragefile.c
99cbc7
@@ -4446,6 +4446,26 @@ virStorageFileSupportsAccess(const virStorageSource *src)
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
+/**
99cbc7
+ * virStorageFileSupportsCreate:
99cbc7
+ * @src: a storage file structure
99cbc7
+ *
99cbc7
+ * Check if the storage driver supports creating storage described by @src
99cbc7
+ * via virStorageFileCreate.
99cbc7
+ */
99cbc7
+int
99cbc7
+virStorageFileSupportsCreate(const virStorageSource *src)
99cbc7
+{
99cbc7
+    virStorageFileBackendPtr backend;
99cbc7
+    int rv;
99cbc7
+
99cbc7
+    if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1)
99cbc7
+        return rv;
99cbc7
+
99cbc7
+    return backend->storageFileCreate ? 1 : 0;
99cbc7
+}
99cbc7
+
99cbc7
+
99cbc7
 void
99cbc7
 virStorageFileDeinit(virStorageSourcePtr src)
99cbc7
 {
99cbc7
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
99cbc7
index 7d28dcfe65..b99afee437 100644
99cbc7
--- a/src/util/virstoragefile.h
99cbc7
+++ b/src/util/virstoragefile.h
99cbc7
@@ -505,6 +505,7 @@ int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid);
99cbc7
 
99cbc7
 int virStorageFileSupportsSecurityDriver(const virStorageSource *src);
99cbc7
 int virStorageFileSupportsAccess(const virStorageSource *src);
99cbc7
+int virStorageFileSupportsCreate(const virStorageSource *src);
99cbc7
 
99cbc7
 int virStorageFileGetMetadata(virStorageSourcePtr src,
99cbc7
                               uid_t uid, gid_t gid,
99cbc7
-- 
99cbc7
2.22.1
99cbc7