[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] util: recognize SMB filesystems as shared



This should resolve:

  https://bugzilla.redhat.com/show_bug.cgi?id=1012085

libvirt previously recognized NFS, GFS2, OCFS2, and AFS filesystems as
"shared", and thus eligible for exceptions to certain rules/actions
about chowning image files before handing them off to a guest. This
patch widens the definition of "shared filesystem" to include the SMB
filesystem (sometimes called CIFS, or "Windows file sharing").
---
 src/util/virstoragefile.c | 9 ++++++++-
 src/util/virstoragefile.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 0b9cec3..ed43b2b 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1241,6 +1241,9 @@ cleanup:
 # ifndef AFS_FS_MAGIC
 #  define AFS_FS_MAGIC 0x6B414653
 # endif
+# ifndef SMB_SUPER_MAGIC
+#  define SMB_SUPER_MAGIC 0x517B
+# endif
 
 
 int virStorageFileIsSharedFSType(const char *path,
@@ -1304,6 +1307,9 @@ int virStorageFileIsSharedFSType(const char *path,
     if ((fstypes & VIR_STORAGE_FILE_SHFS_AFS) &&
         (sb.f_type == AFS_FS_MAGIC))
         return 1;
+    if ((fstypes & VIR_STORAGE_FILE_SHFS_SMB) &&
+        (sb.f_type == SMB_SUPER_MAGIC))
+        return 1;
 
     return 0;
 }
@@ -1322,7 +1328,8 @@ int virStorageFileIsSharedFS(const char *path)
                                         VIR_STORAGE_FILE_SHFS_NFS |
                                         VIR_STORAGE_FILE_SHFS_GFS2 |
                                         VIR_STORAGE_FILE_SHFS_OCFS |
-                                        VIR_STORAGE_FILE_SHFS_AFS);
+                                        VIR_STORAGE_FILE_SHFS_AFS |
+                                        VIR_STORAGE_FILE_SHFS_SMB);
 }
 
 int virStorageFileIsClusterFS(const char *path)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 1f89839..9c07212 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -112,6 +112,7 @@ enum {
     VIR_STORAGE_FILE_SHFS_GFS2 = (1 << 1),
     VIR_STORAGE_FILE_SHFS_OCFS = (1 << 2),
     VIR_STORAGE_FILE_SHFS_AFS = (1 << 3),
+    VIR_STORAGE_FILE_SHFS_SMB = (1 << 4),
 };
 
 int virStorageFileIsSharedFS(const char *path);
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]