[pve-devel] [PATCH pve-container] First beta of FreeNAS storage plugin

Michael Rasmussen mir at datanom.net
Mon Jun 12 03:19:46 CEST 2017


Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
 src/PVE/API2/LXC.pm | 9 +++++++++
 src/PVE/LXC.pm      | 6 +++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index d9ad5ff..9cf22de 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1476,11 +1476,20 @@ __PACKAGE__->register_method({
 			};
 			warn "Failed to update the container's filesystem: $@\n" if $@;
 		    } else {
+		    # Some storage backends only exposes disks when VM is running
+		    # and e2fsck and resize2fs requires access to the disk to work
+		    my $scfg = PVE::Storage::storage_config($storage_cfg, $storeid);
+		    if ($scfg->{type} eq 'freenas') {
+		    	PVE::Storage::activate_volumes($storage_cfg, [$volid]);
+		    }
 			eval {
 			    PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
 			    PVE::Tools::run_command(['resize2fs', $path]);
 			};
 			warn "Failed to update the container's filesystem: $@\n" if $@;
+		    if ($scfg->{type} eq 'freenas') {
+		    	PVE::Storage::deactivate_volumes($storage_cfg, [$volid]);
+		    }
 		    }
 		}
 	    };
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 32b0318..e269e72 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1268,7 +1268,8 @@ sub mountpoint_mount {
 		$mounted_dev = run_with_loopdev($domount, $path);
 		$use_loopdev = 1;
 	    } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'lvm' ||
-		     $scfg->{type} eq 'rbd' || $scfg->{type} eq 'lvmthin') {
+		     $scfg->{type} eq 'rbd' || $scfg->{type} eq 'lvmthin' ||
+             $scfg->{type} eq 'freenas') {
 		$mounted_dev = $path;
 		&$domount($path);
 	    } else {
@@ -1387,6 +1388,9 @@ sub create_disks {
 		    die "krbd option must be enabled on storage type '$scfg->{type}'\n" if !$scfg->{krbd};
 		    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
 		    format_disk($storecfg, $volid, $rootuid, $rootgid);
+        } elsif ($scfg->{type} eq 'freenas') {
+            $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
+            format_disk($storecfg, $volid, $rootuid, $rootgid);
 		} else {
 		    die "unable to create containers on storage type '$scfg->{type}'\n";
 		}
-- 
2.1.4


----

This mail was virus scanned and spam checked before delivery.
This mail is also DKIM signed. See header dkim-signature.




More information about the pve-devel mailing list