[libvirt] [PATCH 05/12] util: storage: Allow checking whether virStorageFileCreate is supported

Peter Krempa posted 12 patches 6 years, 6 months ago
[libvirt] [PATCH 05/12] util: storage: Allow checking whether virStorageFileCreate is supported
Posted by Peter Krempa 6 years, 6 months ago
Add virStorageFileSupportsCreate which allows silent check whether
virStorageFileCreate is implemented.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 20 ++++++++++++++++++++
 src/util/virstoragefile.h |  1 +
 3 files changed, 22 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cae8febf8d..b86868e954 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2995,6 +2995,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,
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 05/12] util: storage: Allow checking whether virStorageFileCreate is supported
Posted by Ján Tomko 6 years, 6 months ago
On Thu, Aug 08, 2019 at 06:00:35PM +0200, Peter Krempa wrote:
>Add virStorageFileSupportsCreate which allows silent check whether
>virStorageFileCreate is implemented.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/libvirt_private.syms  |  1 +
> src/util/virstoragefile.c | 20 ++++++++++++++++++++
> src/util/virstoragefile.h |  1 +
> 3 files changed, 22 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list