[pve-devel] [PATCH 4/4] remove tests for /dev/xxx and use get_vm_volumes

Alexandre Derumier aderumier at odiso.com
Mon Aug 24 10:13:21 CEST 2015


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

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 8a84284..5196fff 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1258,17 +1258,8 @@ sub vm_stop_cleanup {
     eval {
 	if (!$keepActive) {
 
-	    my $vollist = [];
-	    my $loopdevlist = [];
-
-	    PVE::LXC::foreach_mountpoint($conf, sub {
-		my ($ms, $mountpoint) = @_;
-
-		my $volid = $mountpoint->{volume};
-		return if !$volid || $volid =~ m|^/dev/.+|;
-		push @$vollist, $volid;
-		push @$loopdevlist, $volid if $ms ne 'rootfs';
-	    });
+            my $vollist = get_vm_volumes($conf);
+            my $loopdevlist = get_vm_volumes($conf, 'rootfs');
 
 	    PVE::LXC::dettach_loops($storage_cfg, $loopdevlist);
 	    PVE::Storage::deactivate_volumes($storage_cfg, $vollist);
diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
index 8ff4672..764cd2b 100755
--- a/src/lxc-pve-prestart-hook
+++ b/src/lxc-pve-prestart-hook
@@ -78,17 +78,8 @@ __PACKAGE__->register_method ({
 
 	my $storage_cfg = PVE::Storage::config();
 
-	my $vollist = [];
-	my $loopdevlist = [];
-
-	PVE::LXC::foreach_mountpoint($conf, sub {
-	    my ($ms, $mountpoint) = @_;
-
-	    my $volid = $mountpoint->{volume};
-	    return if !$volid || $volid =~ m|^/dev/.+|;
-	    push @$vollist, $volid;
-	    push @$loopdevlist, $volid if $ms ne 'rootfs';
-	});
+	my $vollist = PVE::LXC::get_vm_volumes($conf);
+	my $loopdevlist = PVE::LXC::get_vm_volumes($conf, 'rootfs');
 
 	PVE::Storage::activate_volumes($storage_cfg, $vollist);
 	PVE::LXC::attach_loops($storage_cfg, $loopdevlist);
-- 
2.1.4




More information about the pve-devel mailing list