]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/ZFSPlugin.pm
fix prune-backups validation (again)
[pve-storage.git] / PVE / Storage / ZFSPlugin.pm
index f88fe947cb458ed5559802f6a435dcc281f50c79..5b84d85f2efca5f1d96fe003d47c21bd415857eb 100644 (file)
@@ -12,6 +12,7 @@ use base qw(PVE::Storage::ZFSPoolPlugin);
 use PVE::Storage::LunCmd::Comstar;
 use PVE::Storage::LunCmd::Istgt;
 use PVE::Storage::LunCmd::Iet;
+use PVE::Storage::LunCmd::LIO;
 
 
 my @ssh_opts = ('-o', 'BatchMode=yes');
@@ -31,7 +32,7 @@ my $lun_cmds = {
 my $zfs_unknown_scsi_provider = sub {
     my ($provider) = @_;
 
-    die "$provider: unknown iscsi provider. Available [comstar, istgt, iet]";
+    die "$provider: unknown iscsi provider. Available [comstar, istgt, iet, LIO]";
 };
 
 my $zfs_get_base = sub {
@@ -43,6 +44,8 @@ my $zfs_get_base = sub {
         return PVE::Storage::LunCmd::Istgt::get_base;
     } elsif ($scfg->{iscsiprovider} eq 'iet') {
         return PVE::Storage::LunCmd::Iet::get_base;
+    } elsif ($scfg->{iscsiprovider} eq 'LIO') {
+        return PVE::Storage::LunCmd::LIO::get_base;
     } else {
         $zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
     }
@@ -63,6 +66,8 @@ sub zfs_request {
             $msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
         } elsif ($scfg->{iscsiprovider} eq 'iet') {
             $msg = PVE::Storage::LunCmd::Iet::run_lun_command($scfg, $timeout, $method, @params);
+        } elsif ($scfg->{iscsiprovider} eq 'LIO') {
+            $msg = PVE::Storage::LunCmd::LIO::run_lun_command($scfg, $timeout, $method, @params);
         } else {
             $zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
         }
@@ -96,6 +101,8 @@ sub zfs_get_lu_name {
 
     my $base = $zfs_get_base->($scfg);
 
+    $zvol = ($class->parse_volname($zvol))[1];
+
     my $object = ($zvol =~ /^.+\/.+/) ? "$base/$zvol" : "$base/$scfg->{pool}/$zvol";
 
     my $lu_name = $class->zfs_request($scfg, undef, 'list_lu', $object);
@@ -152,7 +159,11 @@ sub zfs_get_lun_number {
 
     die "could not find lun_number for guid $guid" if !$guid;
 
-    return $class->zfs_request($scfg, undef, 'list_view', $guid);
+    if ($class->zfs_request($scfg, undef, 'list_view', $guid) =~ /^(\d+)$/) {
+       return $1;
+    }
+
+    die "lun_number for guid $guid is not a number";
 }
 
 # Configuration
@@ -188,6 +199,10 @@ sub properties {
            description => "host group for comstar views",
            type => 'string',
        },
+       lio_tpg => {
+           description => "target portal group for Linux LIO targets",
+           type => 'string',
+       },
     };
 }
 
@@ -204,6 +219,7 @@ sub options {
        sparse => { optional => 1 },
        comstar_hg => { optional => 1 },
        comstar_tg => { optional => 1 },
+       lio_tpg => { optional => 1 },
        content => { optional => 1 },
        bwlimit => { optional => 1 },
     };
@@ -277,12 +293,12 @@ sub alloc_image {
     
     die "unsupported format '$fmt'" if $fmt ne 'raw';
 
-    die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
+    die "illegal name '$name' - should be 'vm-$vmid-*'\n"
     if $name && $name !~ m/^vm-$vmid-/;
 
     my $volname = $name;
 
-    $volname = $class->zfs_find_free_diskname($storeid, $scfg, $vmid, $fmt) if !$volname;
+    $volname = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt) if !$volname;
     
     $class->zfs_create_zvol($scfg, $volname, $size);
  
@@ -311,7 +327,9 @@ sub free_image {
 
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
-    
+
+    $volname = ($class->parse_volname($volname))[1];
+
     my $new_size = $class->SUPER::volume_resize($scfg, $storeid, $volname, $size, $running);
 
     $class->zfs_resize_lu($scfg, $volname, $new_size);
@@ -322,12 +340,16 @@ sub volume_resize {
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
+    $volname = ($class->parse_volname($volname))[1];
+
     $class->zfs_request($scfg, undef, 'destroy', "$scfg->{pool}/$volname\@$snap");
 }
 
 sub volume_snapshot_rollback {
     my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
+    $volname = ($class->parse_volname($volname))[1];
+
     $class->zfs_delete_lu($scfg, $volname);
 
     $class->zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");