libvirt/0001-util-recognize-SMB-CIF...

82 lines
2.9 KiB
Diff

From 9265a89ae8e70495a989411b628429bcaf47c25e Mon Sep 17 00:00:00 2001
Message-Id: <9265a89ae8e70495a989411b628429bcaf47c25e.1384729615.git.crobinso@redhat.com>
From: Laine Stump <laine@laine.org>
Date: Thu, 26 Sep 2013 05:40:17 -0400
Subject: [PATCH 1/2] util: recognize SMB/CIFS 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 SMB and
CIFS filesystems (aka "Windows file sharing"); both of these use the
same protocol, but different drivers so there are different magic
numbers for each.
(cherry picked from commit e4e73337e5a5aa708bb356751404ab8ae6583f42)
---
src/util/virstoragefile.c | 16 +++++++++++++++-
src/util/virstoragefile.h | 2 ++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 532234e..60fdcf3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1085,6 +1085,12 @@ cleanup:
# ifndef AFS_FS_MAGIC
# define AFS_FS_MAGIC 0x6B414653
# endif
+# ifndef SMB_SUPER_MAGIC
+# define SMB_SUPER_MAGIC 0x517B
+# endif
+# ifndef CIFS_SUPER_MAGIC
+# define CIFS_SUPER_MAGIC 0xFF534D42
+# endif
int virStorageFileIsSharedFSType(const char *path,
@@ -1150,6 +1156,12 @@ 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;
+ if ((fstypes & VIR_STORAGE_FILE_SHFS_CIFS) &&
+ (sb.f_type == CIFS_SUPER_MAGIC))
+ return 1;
return 0;
}
@@ -1168,7 +1180,9 @@ 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 |
+ VIR_STORAGE_FILE_SHFS_CIFS);
}
int virStorageFileIsClusterFS(const char *path)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index ffe7a54..a93e664 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -96,6 +96,8 @@ 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),
+ VIR_STORAGE_FILE_SHFS_CIFS = (1 << 5),
};
int virStorageFileIsSharedFS(const char *path);
--
1.8.4.2