From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 storage 2/2] zfs over iscsi: on-add hook: dynamically determine base path
Date: Thu, 5 Jun 2025 13:11:09 +0200 [thread overview]
Message-ID: <20250605111109.52712-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250605111109.52712-1-f.ebner@proxmox.com>
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>
---
No changes in v3.
src/PVE/Storage/ZFSPlugin.pm | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/PVE/Storage/ZFSPlugin.pm b/src/PVE/Storage/ZFSPlugin.pm
index d0d330c..ed7adad 100644
--- a/src/PVE/Storage/ZFSPlugin.pm
+++ b/src/PVE/Storage/ZFSPlugin.pm
@@ -3,9 +3,10 @@ package PVE::Storage::ZFSPlugin;
use strict;
use warnings;
use IO::File;
-use POSIX;
+use POSIX qw(ENOENT);
use PVE::Tools qw(run_command);
use PVE::Storage::ZFSPoolPlugin;
+use PVE::RESTEnvironment qw(log_warn);
use PVE::RPCEnvironment;
use base qw(PVE::Storage::ZFSPoolPlugin);
@@ -246,9 +247,26 @@ sub on_add_hook {
$base_path = PVE::Storage::LunCmd::Istgt::get_base($scfg);
} elsif ($scfg->{iscsiprovider} eq 'iet' || $scfg->{iscsiprovider} eq 'LIO') {
# Provider implementations hard-code '/dev/', which does not work for distributions like
- # Debian 12. Keep that implementation as-is for backwards compatibility, but use
- # '/dev/zvol' here.
- $base_path = '/dev/zvol';
+ # Debian 12. Keep that implementation as-is for backwards compatibility, but use custom
+ # logic here.
+ 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 {
$zfs_unknown_scsi_provider->($scfg->{iscsiprovider});
}
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2025-06-05 11:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 11:11 [pve-devel] [PATCH v3 storage 1/2] fix #5071: zfs over iscsi: add 'zfs-base-path' configuration option Fiona Ebner
2025-06-05 11:11 ` Fiona Ebner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250605111109.52712-2-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal