From nobody Thu May 2 15:09:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548430553364928.4348342378192; Fri, 25 Jan 2019 07:35:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D01A52D7E8; Fri, 25 Jan 2019 15:35:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C509317D6B; Fri, 25 Jan 2019 15:35:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4A74E18033A0; Fri, 25 Jan 2019 15:35:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0PFZlXr022283 for ; Fri, 25 Jan 2019 10:35:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C70F17545; Fri, 25 Jan 2019 15:35:47 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id B371717189 for ; Fri, 25 Jan 2019 15:35:44 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 25 Jan 2019 16:35:42 +0100 Message-Id: <394371407e46b98bb5ee1f419a9a6f920a4fab9f.1548430532.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virfile: Detect ceph as shared FS X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 25 Jan 2019 15:35:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1665553 Ceph can be mounted just like any other filesystem and in fact is a shared and cluster filesystem. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/util/virfile.c | 9 ++++++++- src/util/virfile.h | 1 + src/util/virstoragefile.c | 3 ++- tests/virfiledata/mounts3.txt | 2 ++ tests/virfilemock.c | 5 +++++ tests/virfiletest.c | 1 + 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 263c92667c..271bf5e796 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3465,6 +3465,9 @@ int virFilePrintf(FILE *fp, const char *msg, ...) # ifndef FUSE_SUPER_MAGIC # define FUSE_SUPER_MAGIC 0x65735546 # endif +# ifndef CEPH_SUPER_MAGIC +# define CEPH_SUPER_MAGIC 0x00C36400 +# endif =20 # define PROC_MOUNTS "/proc/mounts" =20 @@ -3607,6 +3610,9 @@ virFileIsSharedFSType(const char *path, if ((fstypes & VIR_FILE_SHFS_CIFS) && (f_type =3D=3D CIFS_SUPER_MAGIC)) return 1; + if ((fstypes & VIR_FILE_SHFS_CEPH) && + (f_type =3D=3D CEPH_SUPER_MAGIC)) + return 1; =20 return 0; } @@ -3769,7 +3775,8 @@ int virFileIsSharedFS(const char *path) VIR_FILE_SHFS_OCFS | VIR_FILE_SHFS_AFS | VIR_FILE_SHFS_SMB | - VIR_FILE_SHFS_CIFS); + VIR_FILE_SHFS_CIFS | + VIR_FILE_SHFS_CEPH); } =20 =20 diff --git a/src/util/virfile.h b/src/util/virfile.h index 93484e5444..65432da13a 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -220,6 +220,7 @@ enum { VIR_FILE_SHFS_AFS =3D (1 << 3), VIR_FILE_SHFS_SMB =3D (1 << 4), VIR_FILE_SHFS_CIFS =3D (1 << 5), + VIR_FILE_SHFS_CEPH =3D (1 << 6), }; =20 int virFileIsSharedFSType(const char *path, int fstypes) ATTRIBUTE_NONNULL= (1); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index bd4b0274df..895c8f90de 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1359,7 +1359,8 @@ int virStorageFileIsClusterFS(const char *path) */ return virFileIsSharedFSType(path, VIR_FILE_SHFS_GFS2 | - VIR_FILE_SHFS_OCFS); + VIR_FILE_SHFS_OCFS | + VIR_FILE_SHFS_CEPH); } =20 #ifdef LVS diff --git a/tests/virfiledata/mounts3.txt b/tests/virfiledata/mounts3.txt index 134c6e8f81..68eded048c 100644 --- a/tests/virfiledata/mounts3.txt +++ b/tests/virfiledata/mounts3.txt @@ -33,3 +33,5 @@ host:/nfs /nfs nfs4 rw,relatime,vers=3D4.1,rsize=3D104857= 6,wsize=3D1048576,namlen=3D255, dev /nfs/blah devtmpfs rw,nosuid,relatime,size=3D10240k,nr_inodes=3D409306= 0,mode=3D755 0 0 host:/gv0 /gluster fuse.glusterfs rw 0 0 root@host:/tmp/mkdir /gluster/sshfs fuse.sshfs rw 0 0 +192.168.0.1:/ceph/data /ceph ceph rw,noatime,name=3Dcephfs,secret=3D,acl,wsize=3D16777216 0 0 +192.168.0.1,192.168.0.2,192.168.0.3:/ceph/data2 /ceph/multi ceph rw,noatim= e,name=3Dcephfs,secret=3D,acl,wsize=3D16777216 0 0 diff --git a/tests/virfilemock.c b/tests/virfilemock.c index fb6bd5e699..499135d773 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -86,6 +86,9 @@ setmntent(const char *filename, const char *type) #ifndef FUSE_SUPER_MAGIC # define FUSE_SUPER_MAGIC 0x65735546 #endif +#ifndef CEPH_SUPER_MAGIC +# define CEPH_SUPER_MAGIC 0x00c36400 +#endif =20 =20 static int @@ -132,6 +135,8 @@ statfs_mock(const char *mtab, ftype =3D CIFS_SUPER_MAGIC; } else if (STRPREFIX(mb.mnt_type, "fuse")) { ftype =3D FUSE_SUPER_MAGIC; + } else if (STRPREFIX(mb.mnt_type, "ceph")) { + ftype =3D CEPH_SUPER_MAGIC; } else { /* Everything else is EXT4. We don't care really for other pat= hs. */ ftype =3D EXT4_SUPER_MAGIC; diff --git a/tests/virfiletest.c b/tests/virfiletest.c index b1cb831bfd..6cc599a81b 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -455,6 +455,7 @@ mymain(void) DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/file", true); DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/sshfs/file", f= alse); DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", tr= ue); + DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/ceph/file", true); =20 return ret !=3D 0 ? EXIT_FAILURE : EXIT_SUCCESS; } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list