[PATCH RFC 5/7] virfile: Introduce virFileBindMountDevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/lxc/lxc_container.c  | 20 +++-----------------
 src/util/virfile.c       | 16 ++++++++++++++++
 src/util/virfile.h       |  2 ++
 4 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9653247..c8dea1f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1556,6 +1556,7 @@ virDirRead;
 virFileAbsPath;
 virFileAccessibleAs;
 virFileActivateDirOverride;
+virFileBindMountDevice;
 virFileBuildPath;
 virFileClose;
 virFileDeleteTree;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 5357df4..5d7da8f 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1112,20 +1112,6 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
     return ret;
 }
 
-static int lxcContainerBindMountDevice(const char *src, const char *dst)
-{
-    if (virFileTouch(dst, 0666) < 0)
-        return -1;
-
-    if (mount(src, dst, "none", MS_BIND, NULL) < 0) {
-        virReportSystemError(errno, _("Failed to bind %s on to %s"), src,
-                             dst);
-        return -1;
-    }
-
-    return 0;
-}
-
 static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
 {
     size_t i;
@@ -1149,7 +1135,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
     }
 
     /* We have private devpts capability, so bind that */
-    if (lxcContainerBindMountDevice("/dev/pts/ptmx", "/dev/ptmx") < 0)
+    if (virFileBindMountDevice("/dev/pts/ptmx", "/dev/ptmx") < 0)
         return -1;
 
     for (i = 0; i < nttyPaths; i++) {
@@ -1157,7 +1143,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
         if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0)
             return -1;
 
-        if (lxcContainerBindMountDevice(ttyPaths[i], tty) < 0) {
+        if (virFileBindMountDevice(ttyPaths[i], tty) < 0) {
             return -1;
             VIR_FREE(tty);
         }
@@ -1165,7 +1151,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
         VIR_FREE(tty);
 
         if (i == 0 &&
-            lxcContainerBindMountDevice(ttyPaths[i], "/dev/console") < 0)
+            virFileBindMountDevice(ttyPaths[i], "/dev/console") < 0)
             return -1;
     }
     return 0;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index aa81ae3..0ddca01 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3601,3 +3601,19 @@ virFileSetupDevPTS(const char *path,
     VIR_FREE(devptmx);
     return ret;
 }
+
+
+int
+virFileBindMountDevice(const char *src, const char *dst)
+{
+    if (virFileTouch(dst, 0666) < 0)
+        return -1;
+
+    if (mount(src, dst, "none", MS_BIND, NULL) < 0) {
+        virReportSystemError(errno, _("Failed to bind %s on to %s"), src,
+                             dst);
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 2dab6e7..23a5afb 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -326,4 +326,6 @@ int virFileSetupDev(const char *path,
 int virFileSetupDevPTS(const char *path,
                        const char *mount_options,
                        char **ptmx_ret);
+
+int virFileBindMountDevice(const char *src, const char *dst);
 #endif /* __VIR_FILE_H */
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]