[pve-devel] [PATCH 4/5] volid_path: don't format $path with loop:/

Alexandre Derumier aderumier at odiso.com
Fri Aug 21 17:10:18 CEST 2015


This is only used in lxc config and not a real path

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/LXC.pm         | 19 ++++++++++---------
 src/lxc-pve-mount-hook |  2 +-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index b90848b..9d2ea4f 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -999,6 +999,7 @@ sub update_lxc_config {
     my $shares = $conf->{cpuunits} || 1024;
     $raw .= "lxc.cgroup.cpu.shares = $shares\n";
 
+    
     PVE::LXC::foreach_mountpoint($conf, sub {
 	my ($ms, $mountpoint) = @_;
 
@@ -1006,7 +1007,12 @@ sub update_lxc_config {
 	my $volid = $mountpoint->{volume};
 	return if !$volid || $volid =~ m|^/dev/.+|;
 
-	my $path = volid_path ($volid, $ms, $storage_cfg);
+	my $path = volid_path ($volid, $storage_cfg);
+
+	my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
+	my $scfg = PVE::Storage::storage_config($storage_cfg, $storage);
+	$path = "loop:".$path if $scfg->{path};
+
 	$raw .= "lxc.rootfs = $path\n";
     });
 
@@ -1834,7 +1840,7 @@ sub check_ct_modify_config_perm {
 
 
 sub volid_path {
-    my ($volid, $ms, $storage_cfg, $loopdevs) = @_;
+    my ($volid, $storage_cfg, $loopdevs) = @_;
 
         my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
         my $scfg = PVE::Storage::storage_config($storage_cfg, $storage);
@@ -1850,12 +1856,7 @@ sub volid_path {
         } elsif ($format eq 'raw') {
 
             if ($scfg->{path}) {
-		if ($ms eq 'rootfs') {
-		    $path = "loop:$path\n" if $ms eq 'rootfs';
-		} elsif ($loopdevs) {
-		    $path = PVE::LXC::find_loopdev($loopdevs, $path) if $loopdevs;
-		}
-		
+		$path = PVE::LXC::find_loopdev($loopdevs, $path) if $loopdevs;
             } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'rbd') {
 		#do nothing
             } else {
@@ -1938,7 +1939,7 @@ sub mountpoint_mount {
 	    return;
 	}
 
-	my $path = PVE::LXC::volid_path($volid, $ms, $storage_cfg, $loopdevs);
+	my $path = PVE::LXC::volid_path($volid, $storage_cfg, $loopdevs);
 
 	if ($path !~ m|^/dev/.+|) {
 	    PVE::Tools::run_command(['mount', '-o', 'bind', $path, $mount_path]);
diff --git a/src/lxc-pve-mount-hook b/src/lxc-pve-mount-hook
index 0b99e68..2f8f286 100755
--- a/src/lxc-pve-mount-hook
+++ b/src/lxc-pve-mount-hook
@@ -101,7 +101,7 @@ __PACKAGE__->register_method ({
 	    my $volid = $mountpoint->{volume};
 	    return if !$volid || $volid =~ m|^/dev/.+|;
 
-	    my $path = PVE::LXC::volid_path($volid, $ms, $storage_cfg, $loopdevs);
+	    my $path = PVE::LXC::volid_path($volid, $storage_cfg, $loopdevs);
 
 	    if (-l $path) {
 		$path = readlink($path);
-- 
2.1.4




More information about the pve-devel mailing list