]> git.proxmox.com Git - pve-container.git/commitdiff
factor query_loopdev into PVE::LXC
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 20 Nov 2015 13:04:26 +0000 (14:04 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Nov 2015 10:59:56 +0000 (11:59 +0100)
src/PVE/API2/LXC.pm
src/PVE/LXC.pm

index a2bf32f934ba315a1e4849d8c2eb40c3a86d7f71..4502c592526ca9b504431ccf52cf8eaced55ecdc 100644 (file)
@@ -1006,20 +1006,6 @@ __PACKAGE__->register_method({
 
        my $storage_cfg = cfs_read_file("storage.cfg");
 
-       my $query_loopdev = sub {
-           my ($path) = @_;
-           my $found;
-           my $parser = sub {
-               my $line = shift;
-               if ($line =~ m@^(/dev/loop\d+):@) {
-                   $found = $1;
-               }
-           };
-           my $cmd = ['losetup', '--associated', $path];
-           PVE::Tools::run_command($cmd, outfunc => $parser);
-           return $found;
-       };
-
        my $code = sub {
 
            my $conf = PVE::LXC::load_config($vmid);
@@ -1071,7 +1057,7 @@ __PACKAGE__->register_method({
 
                        $mp->{mp} = '/';
                        my $use_loopdev = (PVE::LXC::mountpoint_mount_path($mp, $storage_cfg))[1];
-                       $path = &$query_loopdev($path) if $use_loopdev;
+                       $path = PVE::LXC::query_loopdev($path) if $use_loopdev;
                        die "internal error: CT running but mountpoint not attached to a loop device"
                            if !$path;
                        PVE::Tools::run_command(['losetup', '--set-capacity', $path]) if $use_loopdev;
index 6775fe3fdd8f93c909aa15f9fe496656c3acf8e1..52f1077102496547eb4b0fcc5e3cec6edf6519c1 100644 (file)
@@ -2109,6 +2109,20 @@ my $check_mount_path = sub {
     }
 };
 
+sub query_loopdev {
+    my ($path) = @_;
+    my $found;
+    my $parser = sub {
+       my $line = shift;
+       if ($line =~ m@^(/dev/loop\d+):@) {
+           $found = $1;
+       }
+    };
+    my $cmd = ['losetup', '--associated', $path];
+    PVE::Tools::run_command($cmd, outfunc => $parser);
+    return $found;
+}
+
 # use $rootdir = undef to just return the corresponding mount path
 sub mountpoint_mount {
     my ($mountpoint, $rootdir, $storage_cfg, $snapname) = @_;