[pve-devel] [PATCH] ZFSPoolPlugin: Added the ability to use nested ZVOLs
Adrian Costin
adrian at goat.fish
Thu Feb 12 20:27:02 CET 2015
- Moved the zpool_import method of zfs_request() to it's own pool_request function
- activate_storage() is now using "zfs list" to check if the zpool is imported
- pool import only the configured pool, not all the accessible pools
Signed-off-by: Adrian Costin <adrian at goat.fish>
---
PVE/Storage/ZFSPoolPlugin.pm | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 5cbd1b2..3fc2978 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -149,16 +149,27 @@ sub zfs_request {
$timeout = 5 if !$timeout;
- my $cmd = [];
+ my $cmd = ['zfs', $method, @params];
- if ($method eq 'zpool_list') {
- push @$cmd, 'zpool', 'list';
- } else {
- push @$cmd, 'zfs', $method;
- }
+ my $msg = '';
+
+ my $output = sub {
+ my $line = shift;
+ $msg .= "$line\n";
+ };
+
+ run_command($cmd, outfunc => $output, timeout => $timeout);
+
+ return $msg;
+}
+
+sub zpool_request {
+ my ($class, $scfg, $timeout, $method, @params) = @_;
+
+ $timeout = 5 if !$timeout;
+
+ my $cmd = ['zpool', $method, @params];
- push @$cmd, @params;
-
my $msg = '';
my $output = sub {
@@ -428,12 +439,16 @@ sub volume_rollback_is_possible {
sub activate_storage {
my ($class, $storeid, $scfg, $cache) = @_;
- my @param = ('-o', 'name', '-H');
+ my @param = ('-o', 'name', '-H', $scfg->{'pool'});
+
+ my $text = zfs_request($class, $scfg, undef, 'list', @param);
- my $text = zfs_request($class, $scfg, undef, 'zpool_list', @param);
-
if ($text !~ $scfg->{pool}) {
- run_command("zpool import -d /dev/disk/by-id/ -a");
+ my ($pool_name) = $scfg->{pool} =~ /([^\/]+)/;
+
+ my @import_params = ('-d', '/dev/disk/by-id/', $pool_name);
+
+ zpool_request($class, $scfg, undef, 'import', @import_params);
}
return 1;
}
--
1.9.3 (Apple Git-50)
More information about the pve-devel
mailing list