[pve-devel] [PATCH pve-container 1/3] mountpoint_mount: optional $extra_opts

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Sep 25 12:18:01 CEST 2015


---
 src/PVE/LXC.pm | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index c01b401..c198eaf 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2057,7 +2057,7 @@ my $check_mount_path = sub {
 
 # use $rootdir = undef to just return the corresponding mount path
 sub mountpoint_mount {
-    my ($mountpoint, $rootdir, $storage_cfg, $snapname) = @_;
+    my ($mountpoint, $rootdir, $storage_cfg, $snapname, $extra_opts) = @_;
 
     my $volid = $mountpoint->{volume};
     my $mount = $mountpoint->{mp};
@@ -2078,6 +2078,7 @@ sub mountpoint_mount {
 
     die "unknown snapshot path for '$volid'" if !$storage && defined($snapname);
 
+    $extra_opts = [] if !$extra_opts;
     if ($storage) {
 
 	my $scfg = PVE::Storage::storage_config($storage_cfg, $storage);
@@ -2092,20 +2093,19 @@ sub mountpoint_mount {
 		    if ($scfg->{type} eq 'zfspool') {
 			my $path_arg = $path;
 			$path_arg =~ s!^/+!!;
-			PVE::Tools::run_command(['mount', '-o', 'ro', '-t', 'zfs', $path_arg, $mount_path]);
+			PVE::Tools::run_command(['mount', '-o', 'ro', '-t', 'zfs', @$extra_opts, $path_arg, $mount_path]);
 		    } else {
 			die "cannot mount subvol snapshots for storage type '$scfg->{type}'\n";
 		    }
 		} else {
-		    PVE::Tools::run_command(['mount', '-o', 'bind', $path, $mount_path]);
+		    PVE::Tools::run_command(['mount', '-o', 'bind', @$extra_opts, $path, $mount_path]);
 		}
 	    }
 	    return wantarray ? ($path, 0) : $path;
 	} elsif ($format eq 'raw') {
 	    my $use_loopdev = 0;
-	    my @extra_opts;
 	    if ($scfg->{path}) {
-		push @extra_opts, '-o', 'loop';
+		push @$extra_opts, '-o', 'loop';
 		$use_loopdev = 1;
 	    } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'lvm' || $scfg->{type} eq 'rbd') {
 		# do nothing
@@ -2114,9 +2114,9 @@ sub mountpoint_mount {
 	    }
 	    if ($mount_path) {
 		if ($isBase || defined($snapname)) {
-		    PVE::Tools::run_command(['mount', '-o', "ro", @extra_opts, $path, $mount_path]);
+		    PVE::Tools::run_command(['mount', '-o', "ro", @$extra_opts, $path, $mount_path]);
 		} else {
-		    PVE::Tools::run_command(['mount', @extra_opts, $path, $mount_path]);
+		    PVE::Tools::run_command(['mount', @$extra_opts, $path, $mount_path]);
 		}
 	    }
 	    return wantarray ? ($path, $use_loopdev) : $path;
@@ -2124,11 +2124,11 @@ sub mountpoint_mount {
 	    die "unsupported image format '$format'\n";
 	}
     } elsif ($volid =~ m|^/dev/.+|) {
-	PVE::Tools::run_command(['mount', $volid, $mount_path]) if $mount_path;
+	PVE::Tools::run_command(['mount', @$extra_opts, $volid, $mount_path]) if $mount_path;
 	return wantarray ? ($volid, 0) : $volid;
     } elsif ($volid !~ m|^/dev/.+| && $volid =~ m|^/.+| && -d $volid) {
 	&$check_mount_path($volid);
-	PVE::Tools::run_command(['mount', '-o', 'bind', $volid, $mount_path]) if $mount_path;
+	PVE::Tools::run_command(['mount', '-o', 'bind', @$extra_opts, $volid, $mount_path]) if $mount_path;
 	return wantarray ? ($volid, 0) : $volid;
     }
     
-- 
2.1.4




More information about the pve-devel mailing list