]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/LunCmd/Istgt.pm
fix prune-backups validation (again)
[pve-storage.git] / PVE / Storage / LunCmd / Istgt.pm
index b386b5d7b455c91907395947137629c3102c5015..2f758f908aafa7fa4e19b5a82b7244d77d949fb6 100644 (file)
@@ -6,8 +6,8 @@ package PVE::Storage::LunCmd::Istgt;
 
 use strict;
 use warnings;
+
 use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach);
-use Data::Dumper;
 
 my @CONFIG_FILES = (
     '/usr/local/etc/istgt/istgt.conf',  # FreeBSD, FreeNAS
@@ -241,7 +241,7 @@ my $make_lun = sub {
     my @options = ();
     my $lun = $get_lu_name->($target);
     if ($scfg->{nowritecache}) {
-        push @options, "WriteCache Disable";     
+        push @options, "WriteCache Disable";
     }
     my $conf = {
         lun => $lun,
@@ -284,9 +284,16 @@ my $parser = sub {
         } elsif ($lun) {
             next if (($_ =~ /^\s*#/) || ($_ =~ /^\s*$/));
             if ($_ =~ /^\s*(\w+)\s+(.+)\s*/) {
-                next if $2 =~ /^Option.*/;
-                $SETTINGS->{$lun}->{$1} = $2;
-                $SETTINGS->{$lun}->{$1} =~ s/^\s+|\s+$|"\s*//g;
+                my $arg1 = $1;
+                my $arg2 = $2;
+                $arg2 =~ s/^\s+|\s+$|"\s*//g;
+                if ($arg2 =~ /^Storage\s*(.+)/i) {
+                    $SETTINGS->{$lun}->{$arg1}->{storage} = $1;
+                } elsif ($arg2 =~ /^Option\s*(.+)/i) {
+                    push @{$SETTINGS->{$lun}->{$arg1}->{options}}, $1;
+                } else {
+                    $SETTINGS->{$lun}->{$arg1} = $arg2;
+                }
             } else {
                 die "$line: parse error [$_]";
             }
@@ -305,19 +312,23 @@ my $parser = sub {
             my $lu = ();
             while ((my $key, my $val) = each(%{$SETTINGS->{"LogicalUnit$i"}})) {
                 if ($key =~ /^LUN\d+/) {
-                    if ($val =~ /^Storage\s+([\w\/\-]+)\s+(\w+)/) {
-                        my $storage = $1;
-                        my $size = $parse_size->($2);
-                        my $conf = undef;
-                        if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
-                            $conf = {
-                                lun => $key,
-                                Storage => $storage,
-                                Size => $size,
-                            };
+                    $val->{storage} =~ /^([\w\/\-]+)\s+(\w+)/;
+                    my $storage = $1;
+                    my $size = $parse_size->($2);
+                    my $conf = undef;
+                    my @options = ();
+                    if ($val->{options}) {
+                        @options = @{$val->{options}};
+                    }
+                    if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
+                        $conf = {
+                            lun => $key,
+                            Storage => $storage,
+                            Size => $size,
+                            options => @options,
                         }
-                        push @$lu, $conf if $conf;
                     }
+                    push @$lu, $conf if $conf;
                     delete $SETTINGS->{"LogicalUnit$i"}->{$key};
                 }
             }
@@ -430,14 +441,14 @@ my $add_view = sub {
     my $cmdmap;
 
     if (@params && $params[0] eq 'restart') {
-        @params = ('restart', '1>&2', '>', '/dev/null');
+        @params = ('onerestart', '>&', '/dev/null');
         $cmdmap = {
             cmd => 'ssh',
             method => $DAEMON,
             params => \@params,
         };
     } else {
-        @params = ('-HUP', '$(cat '. "$SETTINGS->{pidfile})");
+        @params = ('-HUP', '`cat '. "$SETTINGS->{pidfile}`");
         $cmdmap = {
             cmd => 'ssh',
             method => 'kill',