zfs over iscsi: on-add hook: dynamically determine base path
This reduces the potential breakage from commit "fix #5071: zfs over iscsi: add 'zfs-base-path' configuration option". Only setups where '/dev/zvol' exists, but is not a valid base, will still be affected. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Tested-by: Christoph Heiss <c.heiss@proxmox.com> Link: https://lore.proxmox.com/20250605111109.52712-2-f.ebner@proxmox.com
This commit is contained in:
committed by
Thomas Lamprecht
parent
d181d0b1ee
commit
4fb733a9ac
@ -3,9 +3,10 @@ package PVE::Storage::ZFSPlugin;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use IO::File;
|
use IO::File;
|
||||||
use POSIX;
|
use POSIX qw(ENOENT);
|
||||||
use PVE::Tools qw(run_command);
|
use PVE::Tools qw(run_command);
|
||||||
use PVE::Storage::ZFSPoolPlugin;
|
use PVE::Storage::ZFSPoolPlugin;
|
||||||
|
use PVE::RESTEnvironment qw(log_warn);
|
||||||
use PVE::RPCEnvironment;
|
use PVE::RPCEnvironment;
|
||||||
|
|
||||||
use base qw(PVE::Storage::ZFSPoolPlugin);
|
use base qw(PVE::Storage::ZFSPoolPlugin);
|
||||||
@ -246,9 +247,26 @@ sub on_add_hook {
|
|||||||
$base_path = PVE::Storage::LunCmd::Istgt::get_base($scfg);
|
$base_path = PVE::Storage::LunCmd::Istgt::get_base($scfg);
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'iet' || $scfg->{iscsiprovider} eq 'LIO') {
|
} elsif ($scfg->{iscsiprovider} eq 'iet' || $scfg->{iscsiprovider} eq 'LIO') {
|
||||||
# Provider implementations hard-code '/dev/', which does not work for distributions like
|
# Provider implementations hard-code '/dev/', which does not work for distributions like
|
||||||
# Debian 12. Keep that implementation as-is for backwards compatibility, but use
|
# Debian 12. Keep that implementation as-is for backwards compatibility, but use custom
|
||||||
# '/dev/zvol' here.
|
# logic here.
|
||||||
$base_path = '/dev/zvol';
|
my $target = 'root@' . $scfg->{portal};
|
||||||
|
my $cmd = [@ssh_cmd, '-i', "$id_rsa_path/$scfg->{portal}_id_rsa", $target];
|
||||||
|
push $cmd->@*, 'ls', '/dev/zvol';
|
||||||
|
|
||||||
|
my $rc = eval { run_command($cmd, timeout => 10, noerr => 1, quiet => 1) };
|
||||||
|
my $err = $@;
|
||||||
|
if (defined($rc) && $rc == 0) {
|
||||||
|
$base_path = '/dev/zvol';
|
||||||
|
} elsif (defined($rc) && $rc == ENOENT) {
|
||||||
|
$base_path = '/dev';
|
||||||
|
} else {
|
||||||
|
my $message = $err ? $err : "remote command failed";
|
||||||
|
chomp($message);
|
||||||
|
$message .= " ($rc)" if defined($rc);
|
||||||
|
$message .= " - check 'zfs-base-path' setting manually!";
|
||||||
|
log_warn($message);
|
||||||
|
$base_path = '/dev/zvol';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
|
$zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user