]> git.proxmox.com Git - pve-container.git/commitdiff
run_with_loopdev: reuse existing loopdevs
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 29 Feb 2016 08:44:18 +0000 (09:44 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 29 Feb 2016 09:48:12 +0000 (10:48 +0100)
This will avoid triggering the MMP when mounting a
container locally outside lxc.

src/PVE/LXC.pm

index 0f8cff35b5646599c1a7f16333cbbcbecbd9eb53..f5cc1f26b3d626be80fe643a9573ac7f2d13cc92 100644 (file)
@@ -2396,7 +2396,15 @@ sub query_loopdev {
 # Returns the loop device.
 sub run_with_loopdev {
     my ($func, $file) = @_;
-    my $device;
+    my $device = query_loopdev($file);
+    # Try to reuse an existing device
+    if ($device) {
+       # We assume that whoever setup the loop device is responsible for
+       # detaching it.
+       &$func($device);
+       return $device;
+    }
+
     my $parser = sub {
        my $line = shift;
        if ($line =~ m@^(/dev/loop\d+)$@) {