If the local admin has explicitly declared that a certain
filesystem is to be considered shared, we should treat it as
such.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
Reviewed-by: Stefan Berger <stefanb(a)linux.ibm.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/virfile.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index e02ad0ef65..a8abd7d913 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3804,9 +3804,49 @@ virFileGetDefaultHugepage(virHugeTLBFS *fs,
return NULL;
}
+static bool
+virFileIsSharedFSOverride(const char *path,
+ char *const *overrides)
+{
+ g_autofree char *dirpath = NULL;
+ char *p = NULL;
+
+ if (!path || path[0] != '/' || !overrides)
+ return false;
+
+ if (g_strv_contains((const char *const *) overrides, path))
+ return true;
+
+ dirpath = g_strdup(path);
+
+ /* Continue until we've scanned the entire path */
+ while (p != dirpath) {
+
+ /* Find the last slash */
+ if ((p = strrchr(dirpath, '/')) == NULL)
+ break;
+
+ /* Truncate the path by overwriting the slash that we've just
+ * found with a null byte. If it is the very first slash in
+ * the path, we need to handle things slightly differently */
+ if (p == dirpath)
+ *(p+1) = '\0';
+ else
+ *p = '\0';
+
+ if (g_strv_contains((const char *const *) overrides, dirpath))
+ return true;
+ }
+
+ return false;
+}
+
int virFileIsSharedFS(const char *path,
- char *const *overrides G_GNUC_UNUSED)
+ char *const *overrides)
{
+ if (virFileIsSharedFSOverride(path, overrides))
+ return 1;
+
return virFileIsSharedFSType(path,
VIR_FILE_SHFS_NFS |
VIR_FILE_SHFS_GFS2 |
--
2.46.2