]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Add witness for checking storage volume use in security driver
authorPeter Krempa <pkrempa@redhat.com>
Wed, 9 Jul 2014 14:52:06 +0000 (16:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 24 Jul 2014 07:58:59 +0000 (09:58 +0200)
With my intended use of storage driver assist to chown files on remote
storage we will need a witness that will tell us whether the given
storage volume supports operations needed by the storage driver.

src/storage/storage_driver.c
src/storage/storage_driver.h

index efd79b9e00c1b5125b40e25d57a6272baea5a081..efbe5ffab5053efe510fb1b0a5ffdf6ac3668cd1 100644 (file)
@@ -2357,6 +2357,37 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
            backend->storageFileAccess;
 }
 
+
+/**
+ * virStorageFileSupportsSecurityDriver:
+ *
+ * @src: a storage file structure
+ *
+ * Check if a storage file supports operations needed by the security
+ * driver to perform labelling
+ */
+bool
+virStorageFileSupportsSecurityDriver(virStorageSourcePtr src)
+{
+    int actualType = virStorageSourceGetActualType(src);
+    virStorageFileBackendPtr backend;
+
+    if (!src)
+        return false;
+
+    if (src->drv) {
+        backend = src->drv->backend;
+    } else {
+        if (!(backend = virStorageFileBackendForTypeInternal(actualType,
+                                                             src->protocol,
+                                                             false)))
+            return false;
+    }
+
+    return !!backend->storageFileChown;
+}
+
+
 void
 virStorageFileDeinit(virStorageSourcePtr src)
 {
index eefd76682849877083cd88cbcf1a4768b2aac689..9592dd8f7c620016c016892a70ba2eaa902a553d 100644 (file)
@@ -45,6 +45,8 @@ const char *virStorageFileGetUniqueIdentifier(virStorageSourcePtr src);
 int virStorageFileAccess(virStorageSourcePtr src, int mode);
 int virStorageFileChown(virStorageSourcePtr src, uid_t uid, gid_t gid);
 
+bool virStorageFileSupportsSecurityDriver(virStorageSourcePtr src);
+
 int virStorageFileGetMetadata(virStorageSourcePtr src,
                               uid_t uid, gid_t gid,
                               bool allow_probe)