[pve-devel] [PATCH container 4/5] run_with_loopdev: reuse existing loopdevs
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Feb 26 11:42:11 CET 2016
This will avoid triggering the MMP when mounting a
container locally outside lxc.
---
src/PVE/LXC.pm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index a823062..1ed3680 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2488,7 +2488,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+)$@) {
--
2.1.4
More information about the pve-devel
mailing list