On 11/20/19 8:31 AM, Wolfgang Bumiller wrote:
Signed-off-by: Wolfgang Bumiller <w.bumil...@proxmox.com>
---
Changes to v3:
   Changed the staging path from /run/pve/mountpoints to
   /var/lib/lxc/.pve-staged-mounts due to the lxc-start apparmor profile.

  src/PVE/LXC.pm | 30 +++++++++++++++++++++++++++++-
  1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 3ad807d..26c03f7 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -11,7 +11,7 @@ use File::Path;
  use File::Spec;
  use Cwd qw();
  use Fcntl qw(O_RDONLY O_NOFOLLOW O_DIRECTORY);
-use Errno qw(ELOOP ENOTDIR EROFS ECONNREFUSED ENOSYS);
+use Errno qw(ELOOP ENOTDIR EROFS ECONNREFUSED ENOSYS EEXIST);
  use IO::Socket::UNIX;
use PVE::Exception qw(raise_perm_exc);
@@ -1648,6 +1648,34 @@ sub __mountpoint_mount {
      die "unsupported storage";
  }
+# Create a directory in the mountpoint staging tempfs.
+sub get_staging_mount_path($) {
+    my ($opt) = @_;
+
+    my $target = get_staging_tempfs() . "/$opt";
+    if (!mkdir($target) && $! != EEXIST) {
+       die "failed to create directory $target: $!\n";
+    }
+
+    return $target;
+}
+
+# Mount /run/pve/mountpoints as tmpfs

Just FYI this comment is now wrong.

+sub get_staging_tempfs() {
+    # We choose a path in /var/lib/lxc/ here because the lxc-start apparmor 
profile restricts most
+    # mounts to that.
+    my $target = '/var/lib/lxc/.pve-staged-mounts';
+    if (!mkdir($target)) {
+       return $target if $! == EEXIST;
+       die "failed to create directory $target: $!\n";
+    }
+
+    PVE::Tools::mount("none", $target, 'tmpfs', 0, "size=8k,mode=755")
+       or die "failed to mount $target as tmpfs: $!\n";
+
+    return $target;
+}
+
  sub mkfs {
      my ($dev, $rootuid, $rootgid) = @_;

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to