[pve-devel] [PATCH storage 1/1] storage: iscsi: Fix LunCmd for Comstar on Oracle Solaris 11
David Hedbor
neotron at gmail.com
Wed May 15 17:19:10 CEST 2019
Fix #2213: ZFS over iSCSI doesn't work with Solaris 11.3
Signed-off-by: David Hedbor <neotron at gmail.com>
---
PVE/Storage/LunCmd/Comstar.pm | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/PVE/Storage/LunCmd/Comstar.pm b/PVE/Storage/LunCmd/Comstar.pm
index 527e4ba..ca5938e 100644
--- a/PVE/Storage/LunCmd/Comstar.pm
+++ b/PVE/Storage/LunCmd/Comstar.pm
@@ -1,4 +1,5 @@
package PVE::Storage::LunCmd::Comstar;
+use PVE::SafeSyslog;
use strict;
use warnings;
@@ -31,13 +32,26 @@ my $get_lun_cmd_map = sub {
return $cmdmap->{$method};
};
+sub get_initiator_name {
+ my $initiator;
+
+ my $fh = IO::File->new('/etc/iscsi/initiatorname.iscsi') || return undef;
+ while (defined(my $line = <$fh>)) {
+ next if $line !~ m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/;
+ $initiator = $1;
+ last;
+ }
+ $fh->close();
+
+ return $initiator;
+}
+
sub get_base {
return '/dev/zvol/rdsk';
}
sub run_lun_command {
my ($scfg, $timeout, $method, @params) = @_;
-
my $msg = '';
my $luncmd;
my $target;
@@ -62,7 +76,7 @@ sub run_lun_command {
} elsif ($method eq 'modify_lu') {
@params = ('-s', @params);
} elsif ($method eq 'list_view') {
- @params = ('-l', @params);
+ @params = ('-l', @params, '-v');
} elsif ($method eq 'list_lu') {
$guid = $params[0];
@params = undef;
@@ -90,8 +104,16 @@ sub run_lun_command {
if ($method eq 'list_view') {
my @lines = split /\n/, $msg;
$msg = undef;
- foreach my $line (@lines) {
- if ($line =~ /^\s*LUN\s*:\s*(\d+)$/) {
+ my $initiator = undef;
+ foreach my $line (@lines) {
+ if(defined $initiator) {
+ if ($line =~ /^\s*Lun\s*:\s*(\d+)\s*for\s*\Q${initiator}/) {
+ $msg = $1;
+ last;
+ }
+ } elsif ($line =~ /^\s*LUN\s*:\s*Auto$/) {
+ $initiator = get_initiator_name();
+ } elsif ($line =~ /^\s*LUN\s*:\s*(\d+)$/) {
$msg = $1;
last;
}
@@ -112,4 +134,3 @@ sub run_lun_command {
return $msg;
}
-
--
2.11.0
More information about the pve-devel
mailing list