99cbc7
From 92bca785f753f6bc80e2ebe612363a351f56e3d9 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <92bca785f753f6bc80e2ebe612363a351f56e3d9@dist-git>
99cbc7
From: Diego Michelotto <diego.michelotto@cnaf.infn.it>
99cbc7
Date: Tue, 21 May 2019 16:35:08 +0200
99cbc7
Subject: [PATCH] virfile: added GPFS as shared fs
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Added GPFS as shared file system recognized during live migration
99cbc7
security checks.
99cbc7
99cbc7
GPFS is 'IBM General Parallel File System' also called
99cbc7
'IBM Spectrum Scale'
99cbc7
99cbc7
BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1679528
99cbc7
99cbc7
Signed-off-by: Diego Michelotto <diego.michelotto@cnaf.infn.it>
99cbc7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
(cherry picked from commit d163b940a73a0d6b8277a4bccef2b60936933cf0)
99cbc7
https: //bugzilla.redhat.com/show_bug.cgi?id=1710728 [rhel-7.7]
99cbc7
Message-Id: <635dc075347096db1132d6d519aa8a5b1baca6aa.1558449212.git.pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/util/virfile.c            | 9 ++++++++-
99cbc7
 src/util/virfile.h            | 1 +
99cbc7
 tests/virfiledata/mounts3.txt | 1 +
99cbc7
 tests/virfilemock.c           | 5 +++++
99cbc7
 tests/virfiletest.c           | 1 +
99cbc7
 5 files changed, 16 insertions(+), 1 deletion(-)
99cbc7
99cbc7
diff --git a/src/util/virfile.c b/src/util/virfile.c
99cbc7
index 471d309062..e0564295dd 100644
99cbc7
--- a/src/util/virfile.c
99cbc7
+++ b/src/util/virfile.c
99cbc7
@@ -3540,6 +3540,9 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
99cbc7
 # ifndef CEPH_SUPER_MAGIC
99cbc7
 #  define CEPH_SUPER_MAGIC 0x00C36400
99cbc7
 # endif
99cbc7
+# ifndef GPFS_SUPER_MAGIC
99cbc7
+#  define GPFS_SUPER_MAGIC 0x47504653
99cbc7
+# endif
99cbc7
 
99cbc7
 # define PROC_MOUNTS "/proc/mounts"
99cbc7
 
99cbc7
@@ -3688,6 +3691,9 @@ virFileIsSharedFSType(const char *path,
99cbc7
     if ((fstypes & VIR_FILE_SHFS_CEPH) &&
99cbc7
         (f_type == CEPH_SUPER_MAGIC))
99cbc7
         return 1;
99cbc7
+    if ((fstypes & VIR_FILE_SHFS_GPFS) &&
99cbc7
+        (f_type == GPFS_SUPER_MAGIC))
99cbc7
+        return 1;
99cbc7
 
99cbc7
     return 0;
99cbc7
 }
99cbc7
@@ -3852,7 +3858,8 @@ int virFileIsSharedFS(const char *path)
99cbc7
                                  VIR_FILE_SHFS_AFS |
99cbc7
                                  VIR_FILE_SHFS_SMB |
99cbc7
                                  VIR_FILE_SHFS_CIFS |
99cbc7
-                                 VIR_FILE_SHFS_CEPH);
99cbc7
+                                 VIR_FILE_SHFS_CEPH |
99cbc7
+                                 VIR_FILE_SHFS_GPFS);
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
diff --git a/src/util/virfile.h b/src/util/virfile.h
99cbc7
index 1d16e96b59..51c221e069 100644
99cbc7
--- a/src/util/virfile.h
99cbc7
+++ b/src/util/virfile.h
99cbc7
@@ -206,6 +206,7 @@ enum {
99cbc7
     VIR_FILE_SHFS_SMB = (1 << 4),
99cbc7
     VIR_FILE_SHFS_CIFS = (1 << 5),
99cbc7
     VIR_FILE_SHFS_CEPH = (1 << 6),
99cbc7
+    VIR_FILE_SHFS_GPFS = (1 << 7),
99cbc7
 };
99cbc7
 
99cbc7
 int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL(1);
99cbc7
diff --git a/tests/virfiledata/mounts3.txt b/tests/virfiledata/mounts3.txt
99cbc7
index 68eded048c..4377e5d471 100644
99cbc7
--- a/tests/virfiledata/mounts3.txt
99cbc7
+++ b/tests/virfiledata/mounts3.txt
99cbc7
@@ -35,3 +35,4 @@ host:/gv0 /gluster fuse.glusterfs rw 0 0
99cbc7
 root@host:/tmp/mkdir /gluster/sshfs fuse.sshfs rw 0 0
99cbc7
 192.168.0.1:/ceph/data /ceph ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
99cbc7
 192.168.0.1,192.168.0.2,192.168.0.3:/ceph/data2 /ceph/multi ceph rw,noatime,name=cephfs,secret=<hidden>,acl,wsize=16777216 0 0
99cbc7
+gpfs_data /gpfs/data gpfs rw,relatime 0 0
99cbc7
diff --git a/tests/virfilemock.c b/tests/virfilemock.c
99cbc7
index eb5182df66..02f26433d4 100644
99cbc7
--- a/tests/virfilemock.c
99cbc7
+++ b/tests/virfilemock.c
99cbc7
@@ -91,6 +91,9 @@ setmntent(const char *filename, const char *type)
99cbc7
 #ifndef CEPH_SUPER_MAGIC
99cbc7
 # define CEPH_SUPER_MAGIC 0x00c36400
99cbc7
 #endif
99cbc7
+#ifndef GPFS_SUPER_MAGIC
99cbc7
+# define GPFS_SUPER_MAGIC 0x47504653
99cbc7
+#endif
99cbc7
 
99cbc7
 
99cbc7
 static int
99cbc7
@@ -139,6 +142,8 @@ statfs_mock(const char *mtab,
99cbc7
             ftype = FUSE_SUPER_MAGIC;
99cbc7
         } else if (STRPREFIX(mb.mnt_type, "ceph")) {
99cbc7
             ftype = CEPH_SUPER_MAGIC;
99cbc7
+        } else if (STRPREFIX(mb.mnt_type, "gpfs")) {
99cbc7
+            ftype = GPFS_SUPER_MAGIC;
99cbc7
         } else {
99cbc7
             /* Everything else is EXT4. We don't care really for other paths. */
99cbc7
             ftype = EXT4_SUPER_MAGIC;
99cbc7
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
99cbc7
index 972c07fdc5..5f17676c75 100644
99cbc7
--- a/tests/virfiletest.c
99cbc7
+++ b/tests/virfiletest.c
99cbc7
@@ -460,6 +460,7 @@ mymain(void)
99cbc7
     DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", true);
99cbc7
     DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/file", true);
99cbc7
     DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/multi/file", true);
99cbc7
+    DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gpfs/data", true);
99cbc7
 
99cbc7
     return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
99cbc7
 }
99cbc7
-- 
99cbc7
2.21.0
99cbc7