From 7acee37a30206f61b72316d749862499d722ed05 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 13 May 2013 08:00:16 +0200 Subject: [PATCH] since wheezy, iscsiadm -m session throw an error code if no session exist. So we can't bring up the iscsi storage This patch is based on the patch submitted by Alexandre, but we only suppress error messages when there are no active sessions. Other errors still trigges an exceptions. --- PVE/Storage/ISCSIPlugin.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/PVE/Storage/ISCSIPlugin.pm b/PVE/Storage/ISCSIPlugin.pm index 8da7ec5..a445f85 100644 --- a/PVE/Storage/ISCSIPlugin.pm +++ b/PVE/Storage/ISCSIPlugin.pm @@ -41,16 +41,20 @@ sub iscsi_session_list { my $res = {}; - run_command($cmd, outfunc => sub { - my $line = shift; - - if ($line =~ m/^tcp:\s+\[(\S+)\]\s+\S+\s+(\S+)\s*$/) { - my ($session, $target) = ($1, $2); - # there can be several sessions per target (multipath) - push @{$res->{$target}}, $session; - - } - }); + eval { + run_command($cmd, errmsg => 'iscsi session scan failed', outfunc => sub { + my $line = shift; + + if ($line =~ m/^tcp:\s+\[(\S+)\]\s+\S+\s+(\S+)\s*$/) { + my ($session, $target) = ($1, $2); + # there can be several sessions per target (multipath) + push @{$res->{$target}}, $session; + } + }); + }; + if (my $err = $@) { + die $err if $err !~ m/: No active sessions.$/i; + } return $res; }