]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Treat failure to relabel stdin_path as non-fatal on NFS
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 29 Oct 2010 11:20:40 +0000 (12:20 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 2 Nov 2010 14:38:19 +0000 (14:38 +0000)
NFS does not support file labelling, so ignore this error
for stdin_path when on NFS.

* src/security/security_selinux.c: Ignore failures on labelling
  stdin_path on NFS
* src/util/storage_file.c, src/util/storage_file.h: Refine
  virStorageFileIsSharedFS() to allow it to check for a
  specific FS type.

src/libvirt_private.syms
src/security/security_selinux.c
src/util/storage_file.c
src/util/storage_file.h

index bd77a34ef90496a2617bba17e98fc34bc881211e..430c7c107fecb8be8153fd0cedddcaa35c1a7d02 100644 (file)
@@ -689,6 +689,7 @@ virStorageFileFormatTypeToString;
 virStorageFileGetMetadata;
 virStorageFileGetMetadataFromFD;
 virStorageFileIsSharedFS;
+virStorageFileIsSharedFSType;
 virStorageFileProbeFormat;
 virStorageFileProbeFormatFromFD;
 
index a9dd836e6f27c060eb59ee298e8b740445421ded..0612ce375f644ba28b2660b31b5b814bf948a8f4 100644 (file)
@@ -1023,9 +1023,12 @@ SELinuxSetSecurityAllLabel(virSecurityDriverPtr drv,
         SELinuxSetFilecon(vm->def->os.initrd, default_content_context) < 0)
         return -1;
 
-    if (stdin_path &&
-        SELinuxSetFilecon(stdin_path, default_content_context) < 0)
-        return -1;
+    if (stdin_path) {
+        if (SELinuxSetFilecon(stdin_path, default_content_context) < 0 &&
+            virStorageFileIsSharedFSType(stdin_path,
+                                         VIR_STORAGE_FILE_SHFS_NFS) != 1)
+            return -1;
+    }
 
     return 0;
 }
index 3cd5dbcf8de46673ae6b8b72da0d15f32d216809..e4f1eaa071de404e2f09e798163cca189c64c0d8 100644 (file)
@@ -804,7 +804,8 @@ virStorageFileGetMetadata(const char *path,
 # endif
 
 
-int virStorageFileIsSharedFS(const char *path)
+int virStorageFileIsSharedFSType(const char *path,
+                                 int fstypes)
 {
     char *dirpath, *p;
     struct statfs sb;
@@ -853,19 +854,36 @@ int virStorageFileIsSharedFS(const char *path)
     VIR_DEBUG("Check if path %s with FS magic %lld is shared",
               path, (long long int)sb.f_type);
 
-    if (sb.f_type == NFS_SUPER_MAGIC ||
-        sb.f_type == GFS2_MAGIC ||
-        sb.f_type == OCFS2_SUPER_MAGIC ||
-        sb.f_type == AFS_FS_MAGIC) {
+    if ((fstypes & VIR_STORAGE_FILE_SHFS_NFS) &&
+        (sb.f_type == NFS_SUPER_MAGIC))
+        return 1;
+
+    if ((fstypes & VIR_STORAGE_FILE_SHFS_GFS2) &&
+        (sb.f_type == GFS2_MAGIC))
+        return 1;
+    if ((fstypes & VIR_STORAGE_FILE_SHFS_OCFS) &&
+        (sb.f_type == OCFS2_SUPER_MAGIC))
+        return 1;
+    if ((fstypes & VIR_STORAGE_FILE_SHFS_AFS) &&
+        (sb.f_type == AFS_FS_MAGIC))
         return 1;
-    }
 
     return 0;
 }
 #else
-int virStorageFileIsSharedFS(const char *path ATTRIBUTE_UNUSED)
+int virStorageFileIsSharedFSType(const char *path ATTRIBUTE_UNUSED,
+                                 int fstypes ATTRIBUTE_UNUSED)
 {
     /* XXX implement me :-) */
     return 0;
 }
 #endif
+
+int virStorageFileIsSharedFS(const char *path)
+{
+    return virStorageFileIsSharedFSType(path,
+                                        VIR_STORAGE_FILE_SHFS_NFS |
+                                        VIR_STORAGE_FILE_SHFS_GFS2 |
+                                        VIR_STORAGE_FILE_SHFS_OCFS |
+                                        VIR_STORAGE_FILE_SHFS_AFS);
+}
index 6853182f78b52b8f135bf4b92f7a5e05becbc8e2..ba44111d99264cf89c9ff8515874c049fdc9eeab 100644 (file)
@@ -68,6 +68,15 @@ int virStorageFileGetMetadataFromFD(const char *path,
                                     int format,
                                     virStorageFileMetadata *meta);
 
+enum {
+    VIR_STORAGE_FILE_SHFS_NFS = (1 << 0),
+    VIR_STORAGE_FILE_SHFS_GFS2 = (1 << 1),
+    VIR_STORAGE_FILE_SHFS_OCFS = (1 << 2),
+    VIR_STORAGE_FILE_SHFS_AFS = (1 << 3),
+};
+
 int virStorageFileIsSharedFS(const char *path);
+int virStorageFileIsSharedFSType(const char *path,
+                                 int fstypes);
 
 #endif /* __VIR_STORAGE_FILE_H__ */