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');
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 {
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});
}
sub zfs_request {
my ($class, $scfg, $timeout, $method, @params) = @_;
- $timeout = PVE::RPCEnvironment::is_worker() ? 60*60 : 10
+ $timeout = PVE::RPCEnvironment->is_worker() ? 60*60 : 10
if !$timeout;
my $msg = '';
$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});
}
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);
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
description => "host group for comstar views",
type => 'string',
},
+ lio_tpg => {
+ description => "target portal group for Linux LIO targets",
+ type => 'string',
+ },
};
}
sparse => { optional => 1 },
comstar_hg => { optional => 1 },
comstar_tg => { optional => 1 },
+ lio_tpg => { optional => 1 },
content => { optional => 1 },
+ bwlimit => { optional => 1 },
};
}
sub clone_image {
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
- my $name = $class->SUPER::clone_image($scfg, $storeid, $volname, $vmid, $snap);
+ my $name = $class->SUPER::clone_image($scfg, $storeid, $volname, $vmid, $snap);
+
+ # get ZFS dataset name from PVE volname
+ my (undef, $clonedname) = $class->parse_volname($name);
- my $guid = $class->zfs_create_lu($scfg, $name);
- $class->zfs_add_lun_mapping_entry($scfg, $name, $guid);
+ my $guid = $class->zfs_create_lu($scfg, $clonedname);
+ $class->zfs_add_lun_mapping_entry($scfg, $clonedname, $guid);
return $name;
}
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);
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);
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");
$class->zfs_add_lun_mapping_entry($scfg, $volname);
}
+sub storage_can_replicate {
+ my ($class, $scfg, $storeid, $format) = @_;
+
+ return 0;
+}
+
sub volume_has_feature {
my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;