all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v6 storage 10/42] iscsi: add an option to manage storage LUNs with multipath
Date: Wed, 18 Nov 2026 07:52:27 +0100	[thread overview]
Message-ID: <20261118065302.3033937-11-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261118065302.3033937-1-t.lamprecht@proxmox.com>

With the 'managed-multipath' option, an iSCSI storage names its
volumes after the multipath map of the LUN (dm-uuid-mpath-<wwid>), as
the scsi-<wwid> name can resolve to a single path while the map has
not assembled yet. Adding the LUNs to the multipath allow-list of the
nodes follows separately.

Activating such a volume waits up to ten seconds for the map, if the
node sees the LUN. The status update neither waits nor asks
multipathd, as it has more storages to query and looks again a few
seconds later. An LVM storage on top only accepts a map or a partition
of one as base volume, and does not wait for a partition.

The option is not named 'multipath': third-party storage plugins
define a property of that name already. The storage layer leaves out
a third-party plugin that declares a property of another plugin, and
the next write of the storage configuration drops its storages.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                       |   1 +
 src/PVE/Multipath.pm                   |  36 ++++++++
 src/PVE/Multipath/Identity.pm          |  44 ++++++++++
 src/PVE/Storage.pm                     |   2 +-
 src/PVE/Storage/ISCSIPlugin.pm         |  48 ++++++++++-
 src/PVE/Storage/LVMPlugin.pm           |  10 ++-
 src/test/Makefile                      |   8 +-
 src/test/plugin_properties_test.pm     |   1 +
 src/test/run_iscsi_activation_tests.pl | 109 +++++++++++++++++++++++++
 src/test/run_lun_identity_tests.pl     |  57 +++++++++++++
 src/test/run_multipath_tests.pl        |  12 +++
 src/test/run_test_lvm_base_volume.pl   |  12 ++-
 12 files changed, 332 insertions(+), 8 deletions(-)
 create mode 100644 src/PVE/Multipath/Identity.pm
 create mode 100755 src/test/run_iscsi_activation_tests.pl
 create mode 100755 src/test/run_lun_identity_tests.pl

diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index 597ad7a1..53347442 100644
--- a/src/PVE/Makefile
+++ b/src/PVE/Makefile
@@ -7,6 +7,7 @@ install:
 	install -D -m 0644 ISCSI/Topology.pm ${DESTDIR}${PERLDIR}/PVE/ISCSI/Topology.pm
 	install -D -m 0644 Multipath.pm ${DESTDIR}${PERLDIR}/PVE/Multipath.pm
 	install -D -m 0644 Multipath/Config.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Config.pm
+	install -D -m 0644 Multipath/Identity.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Identity.pm
 	install -D -m 0644 CephConfig.pm ${DESTDIR}${PERLDIR}/PVE/CephConfig.pm
 	install -D -m 0644 GuestImport.pm ${DESTDIR}${PERLDIR}/PVE/GuestImport.pm
 	make -C Storage install
diff --git a/src/PVE/Multipath.pm b/src/PVE/Multipath.pm
index 84c4901e..1caadee1 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -8,6 +8,7 @@ use JSON qw(decode_json);
 use PVE::Tools qw(run_command file_read_firstline dir_glob_foreach);
 
 use PVE::Diskmanage;
+use PVE::Multipath::Config;
 
 my $MULTIPATH = '/sbin/multipath';
 my $MULTIPATHD = '/sbin/multipathd';
@@ -117,6 +118,31 @@ sub parse_maps_json($json) {
     return \@maps;
 }
 
+sub parse_path_identities($text) {
+    my @lines = grep { length } split(/\n/, $text // '');
+    return {} if @lines == 1 && $lines[0] eq 'ok';
+    my $res = {};
+    for my $line (@lines) {
+        my ($dev, $wwid) = split(/\|/, $line, 2);
+        return undef if !defined($wwid);
+        next if $dev !~ /^sd[a-z]+$/ || $wwid !~ $PVE::Multipath::Config::WWID_RE;
+        $res->{$dev} = { wwid => $wwid };
+    }
+    return $res;
+}
+
+sub query_path_identities() {
+    assert_supported();
+    my $text = '';
+    run_command(
+        [$MULTIPATHD, 'show', 'paths', 'raw', 'format', '%d|%w'],
+        timeout => 5,
+        outfunc => sub($line) { $text .= "$line\n" },
+        errfunc => sub($line) { },
+    );
+    return parse_path_identities($text) // die "multipathd returned an invalid path list\n";
+}
+
 sub get_maps() {
     assert_supported();
     my $json = '';
@@ -133,4 +159,14 @@ sub get_maps() {
     return $maps;
 }
 
+sub wait_for_map($wwid, $timeout = 10) {
+    my $link = "/dev/disk/by-id/dm-uuid-mpath-$wwid";
+    my $deadline = time() + ($timeout // 10);
+    while (1) {
+        return 1 if -b $link;
+        return undef if time() >= $deadline;
+        sleep(1);
+    }
+}
+
 1;
diff --git a/src/PVE/Multipath/Identity.pm b/src/PVE/Multipath/Identity.pm
new file mode 100644
index 00000000..bc40c67b
--- /dev/null
+++ b/src/PVE/Multipath/Identity.pm
@@ -0,0 +1,44 @@
+package PVE::Multipath::Identity;
+
+use v5.36;
+
+use PVE::Tools qw(dir_glob_foreach file_get_contents file_read_firstline);
+
+use PVE::ISCSI::Topology;
+use PVE::Multipath;
+use PVE::Multipath::Config;
+
+our $SYSFS = '/sys';
+our $UDEV_DATA = '/run/udev/data';
+
+sub collect(%param) {
+    my $devices = PVE::ISCSI::Topology::device_map($SYSFS);
+    my $daemon = eval { PVE::Multipath::query_path_identities() };
+    my %paths;
+    dir_glob_foreach(
+        $SYSFS . '/class/block',
+        'sd[a-z]+',
+        sub($dev, @) {
+            my $session = $devices->{$dev};
+            return if !$param{all} && (!$session || !$param{targets}->{ $session->{target} });
+            my $wwid = $daemon ? $daemon->{$dev}->{wwid} : undef;
+            # multipathd does not list every disk, for example not the ones it has blacklisted
+            if (!defined($wwid)) {
+                my $devt = file_read_firstline("$SYSFS/class/block/$dev/dev") // return;
+                my $data = eval { file_get_contents("$UDEV_DATA/b$devt") } // '';
+                ($wwid) = $data =~ m/^E:ID_SERIAL=(.+)$/m;
+            }
+            return if !defined($wwid) || $wwid !~ $PVE::Multipath::Config::WWID_RE;
+            $paths{$dev} = { wwid => $wwid };
+        },
+    );
+    return {
+        paths => \%paths,
+    };
+}
+
+sub path_wwid($ids, $name) {
+    return $ids->{paths}->{$name}->{wwid};
+}
+
+1;
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index faf325fb..1e9c670a 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -1586,7 +1586,7 @@ sub storage_info {
         push @$slist, $storeid;
     }
 
-    my $cache = {};
+    my $cache = { status_only => 1 };
 
     foreach my $storeid (keys %$ids) {
         my $scfg = $ids->{$storeid};
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 3b9f748d..2209891a 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -10,6 +10,7 @@ use IO::File;
 
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Multipath;
+use PVE::Multipath::Identity;
 use PVE::Storage::Plugin;
 use PVE::ISCSI::Topology;
 use PVE::Tools
@@ -292,11 +293,15 @@ sub load_stable_scsi_paths {
     return $stable_paths;
 }
 
+# The LUNs of the iSCSI sessions, { target => { volname => info } }. With $map_names a LUN is named
+# after its multipath map, see PVE::Multipath::Identity, and only the LUNs of $target are listed.
 sub iscsi_device_list {
+    my ($map_names, $target) = @_;
 
     my $res = {};
 
     my $stable_paths = load_stable_scsi_paths();
+    my $ids = $map_names ? PVE::Multipath::Identity::collect(targets => { $target => 1 }) : undef;
 
     my $device_map = PVE::ISCSI::Topology::device_map($SYSFS);
 
@@ -304,6 +309,8 @@ sub iscsi_device_list {
         my $info = $device_map->{$bdev};
         my ($channel, $id, $lun) = $info->@{qw(channel id lun)};
 
+        my $path_dev = $bdev;
+
         #check multipath
         if (-d "$SYSFS/block/$bdev/holders") {
             my $multipathdev = dir_glob_regex("$SYSFS/block/$bdev/holders", '[A-Za-z]\S*');
@@ -311,6 +318,15 @@ sub iscsi_device_list {
         }
 
         my $blockdev = $stable_paths->{$bdev};
+        # scsi-<wwid> can name a member before assembly; dm-uuid-mpath-<wwid> only names the map.
+        # Managed volumes keep the map name even while assembly is pending.
+        if ($map_names) {
+            my $wwid =
+                $info->{target} eq $target
+                ? PVE::Multipath::Identity::path_wwid($ids, $path_dev)
+                : undef;
+            $blockdev = defined($wwid) ? "dm-uuid-mpath-$wwid" : undef;
+        }
         next if !$blockdev;
 
         my $size = file_read_firstline("$SYSFS/block/$bdev/size");
@@ -362,6 +378,12 @@ sub properties {
             type => 'string',
             format => 'pve-storage-portal-dns',
         },
+        'managed-multipath' => {
+            title => "Multipath",
+            description => "Manage multipath access to the storage's LUNs and include them in"
+                . " the cluster-wide path-health monitoring.",
+            type => 'boolean',
+        },
     };
 }
 
@@ -373,6 +395,7 @@ sub options {
         disable => { optional => 1 },
         content => { optional => 1 },
         bwlimit => { optional => 1 },
+        'managed-multipath' => { optional => 1 },
     };
 }
 
@@ -443,13 +466,15 @@ sub list_images {
 
     my $res = [];
 
-    $cache->{iscsi_devices} = iscsi_device_list() if !$cache->{iscsi_devices};
+    my $cache_key =
+        $scfg->{'managed-multipath'} ? "iscsi_devices_mpath:$scfg->{target}" : 'iscsi_devices';
+    $cache->{$cache_key} //= iscsi_device_list($scfg->{'managed-multipath'}, $scfg->{target});
 
     # we have no owner for iscsi devices
 
     my $target = $scfg->{target};
 
-    if (my $dat = $cache->{iscsi_devices}->{$target}) {
+    if (my $dat = $cache->{$cache_key}->{$target}) {
 
         foreach my $volname (keys %$dat) {
 
@@ -620,6 +645,25 @@ $resolve_virtual_devices = sub {
 sub activate_volume {
     my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
+    if ($scfg->{'managed-multipath'}) {
+        my ($wwid) = $volname =~ m/\.dm-uuid-mpath-(\S+)$/;
+        if (defined($wwid) && !-b "/dev/disk/by-id/dm-uuid-mpath-$wwid") {
+            # A status pass has more storages to query and looks again in a few seconds anyway. So
+            # it neither waits for the map nor asks multipathd for the paths of the LUN.
+            if ($cache && $cache->{status_only}) {
+                die "multipath map for WWID '$wwid' is not assembled"
+                    . " - check the multipath status of this node\n";
+            }
+            # Activation can race map assembly at login or boot. Only wait for a LUN that is there.
+            my $ids = PVE::Multipath::Identity::collect(targets => { $scfg->{target} => 1 });
+            die "LUN with WWID '$wwid' is not visible on this node\n"
+                if !grep { $_->{wwid} eq $wwid } values $ids->{paths}->%*;
+            PVE::Multipath::wait_for_map($wwid)
+                or die "multipath map for WWID '$wwid' did not assemble in time"
+                . " - check the multipath status of this node\n";
+        }
+    }
+
     my $path = $class->filesystem_path($scfg, $volname, $snapname);
     my $real_path = Cwd::realpath($path);
     die "failed to get realpath for '$path': $!\n" if !$real_path;
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 3cdab9e4..16a3d65f 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -17,6 +17,7 @@ use PVE::Exception qw(raise_param_exc);
 use PVE::Format qw(render_bytes render_duration);
 use PVE::INotify;
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::Multipath;
 use PVE::RESTEnvironment qw(log_warn);
 use PVE::Tools qw(run_command file_read_firstline trim);
 
@@ -1101,11 +1102,18 @@ sub on_add_hook {
         die "unsupported base type '$basecfg->{type}'"
             if $basecfg->{type} ne 'iscsi';
 
+        # Managed multipath requires the coalesced map or a partition of it, never a transient
+        # single-path PV.
+        my ($uuid) = $volname =~ m/\.dm-uuid-(\S+)$/;
+        die "base volume '$volname' is no multipath volume of storage '$baseid'\n"
+            if $basecfg->{'managed-multipath'} && !PVE::Multipath::parse_dm_uuid($uuid);
+
         my $path = PVE::Storage::path($cfg, $base);
 
         PVE::Storage::activate_storage($cfg, $baseid);
 
-        # Activating the base volume verifies that it belongs to its target.
+        # the base's activate_volume checks target membership and, with managed multipath, waits
+        # for the map to assemble before the VG is created on it, but not for a partition of one
         PVE::Storage::activate_volumes($cfg, [$base]);
 
         # a failing hook does not remove a volume group it created, so check the device first
diff --git a/src/test/Makefile b/src/test/Makefile
index a267c7ba..904f2b29 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries
+test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries test_lun_identity
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -40,7 +40,8 @@ test_volume_access: run_volume_access_tests.pl
 test_remote_command: run_remote_command_tests.pl
 	./run_remote_command_tests.pl
 
-test_iscsi: run_iscsi_discovery_tests.pl run_iscsi_rescan_tests.pl run_iscsi_device_list_tests.pl run_iscsi_session_tests.pl run_iscsi_volume_tests.pl
+test_iscsi: run_iscsi_activation_tests.pl run_iscsi_discovery_tests.pl run_iscsi_rescan_tests.pl run_iscsi_device_list_tests.pl run_iscsi_session_tests.pl run_iscsi_volume_tests.pl
+	./run_iscsi_activation_tests.pl
 	./run_iscsi_discovery_tests.pl
 	./run_iscsi_rescan_tests.pl
 	./run_iscsi_device_list_tests.pl
@@ -58,3 +59,6 @@ test_multipath: run_multipath_tests.pl
 
 test_san_libraries: run_san_library_tests.pl
 	./run_san_library_tests.pl
+
+test_lun_identity: run_lun_identity_tests.pl
+	./run_lun_identity_tests.pl
diff --git a/src/test/plugin_properties_test.pm b/src/test/plugin_properties_test.pm
index d8e336d1..80d36dc8 100644
--- a/src/test/plugin_properties_test.pm
+++ b/src/test/plugin_properties_test.pm
@@ -36,6 +36,7 @@ my $available = {
     keyring => 'string',
     krbd => 'boolean',
     lio_tpg => 'string',
+    'managed-multipath' => 'boolean',
     'master-pubkey' => 'string',
     'max-protected-backups' => 'integer minimum=-1',
     mkdir => 'boolean',
diff --git a/src/test/run_iscsi_activation_tests.pl b/src/test/run_iscsi_activation_tests.pl
new file mode 100755
index 00000000..a19193de
--- /dev/null
+++ b/src/test/run_iscsi_activation_tests.pl
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::MockModule;
+use Test::More;
+
+use lib ('.', '..');
+use PVE::Storage::ISCSIPlugin;
+
+my $plugin = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
+my $identity = Test::MockModule->new('PVE::Multipath::Identity');
+my $mp = Test::MockModule->new('PVE::Multipath');
+my $cwd = Test::MockModule->new('Cwd');
+my ($resolved, $waits, $ready, $visible) = (undef, 0, 0, undef);
+$identity->mock(
+    collect => sub {
+        die "unexpected identity query\n" if !defined($visible);
+        return { paths => { map { $_ => { wwid => '3600a' } } @$visible } };
+    },
+);
+$mp->mock(
+    wait_for_map => sub {
+        $waits++;
+        is($_[0], '3600a', 'map name supplies the WWID');
+        return $ready;
+    },
+);
+$cwd->mock(realpath => sub { $resolved });
+$plugin->mock(
+    filesystem_path => sub { '/dev/disk/by-id/test' },
+    file_read_firstline => sub { 'iqn.test' },
+    run_command => sub {
+        my ($cmd, %opts) = @_;
+        is($cmd->[0], 'udevadm', 'normal activation validates target membership');
+        $opts{outfunc}->('/devices/platform/host1/session1/target1:0:0/1:0:0:1/block/sda');
+    },
+);
+
+for my $multipath (0, 1) {
+    for my $case ([undef, qr/failed to get realpath/], ['/dev/null', qr/not a block device/]) {
+        $resolved = $case->[0];
+        my $warnings = '';
+        local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+        eval {
+            PVE::Storage::ISCSIPlugin->activate_volume(
+                'san',
+                { target => 'iqn.test', 'managed-multipath' => $multipath },
+                '0.0.1.scsi-legacy',
+            );
+        };
+        like($@, $case->[1], "plain name uses normal validation with multipath=$multipath");
+        is($warnings, '', 'no compatibility warning');
+        is($waits, 0, 'no wait for a plain name');
+    }
+}
+
+my $scfg = { target => 'iqn.test', 'managed-multipath' => 1 };
+$visible = [];
+eval { PVE::Storage::ISCSIPlugin->activate_volume('san', $scfg, '0.0.1.dm-uuid-mpath-3600a') };
+like($@, qr/is not visible on this node/, 'no wait for a LUN without a path on the node');
+is($waits, 0, 'absent LUN fails at once');
+
+$visible = ['sda', 'sdb'];
+eval { PVE::Storage::ISCSIPlugin->activate_volume('san', $scfg, '0.0.1.dm-uuid-mpath-3600a') };
+like($@, qr/did not assemble in time/, 'map-named timeout is fatal');
+is($waits, 1, 'map-named volume waits once');
+
+eval {
+    PVE::Storage::ISCSIPlugin->activate_volume(
+        'san', $scfg, '0.0.1.dm-uuid-mpath-3600a', undef, {},
+    );
+};
+like($@, qr/did not assemble in time/, 'an activation with a cache waits as well');
+$waits = 1;
+
+# the mocked identity query dies without a list of visible paths
+$visible = undef;
+eval {
+    PVE::Storage::ISCSIPlugin->activate_volume(
+        'san',
+        $scfg,
+        '0.0.1.dm-uuid-mpath-3600a',
+        undef,
+        { status_only => 1 },
+    );
+};
+like($@, qr/is not assembled/, 'a status pass fails for a missing map');
+is($waits, 1, 'without a wait and without asking for the paths of the LUN');
+$visible = ['sda', 'sdb'];
+
+$ready = 1;
+$resolved = undef;
+eval { PVE::Storage::ISCSIPlugin->activate_volume('san', $scfg, '0.0.1.dm-uuid-mpath-3600a') };
+like($@, qr/failed to get realpath/, 'map link is resolved after waiting');
+is($waits, 2, 'one additional wait');
+
+SKIP: {
+    my ($blockdev) = grep { -b $_ } map { s!^/sys/block/!/dev/!r } glob('/sys/block/*');
+    skip 'block device metadata required for successful activation', 3 if !$blockdev;
+    $resolved = $blockdev;
+    my $before = $waits;
+    eval { PVE::Storage::ISCSIPlugin->activate_volume('san', $scfg, '0.0.1.scsi-legacy') };
+    is($@, '', 'plain name activates through the normal target check');
+    is($waits, $before, 'successful plain activation also has no map wait');
+}
+
+done_testing();
diff --git a/src/test/run_lun_identity_tests.pl b/src/test/run_lun_identity_tests.pl
new file mode 100755
index 00000000..b4913ea9
--- /dev/null
+++ b/src/test/run_lun_identity_tests.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use lib qw(..);
+use Test::More;
+use Test::MockModule;
+use PVE::Multipath::Identity;
+
+my $mp = Test::MockModule->new('PVE::Multipath');
+my $id = Test::MockModule->new('PVE::Multipath::Identity');
+my $topology = Test::MockModule->new('PVE::ISCSI::Topology');
+$topology->mock(sessions => sub { {} });
+$id->mock(
+    dir_glob_foreach => sub { $_[2]->($_) for qw(sda sdb sdc) },
+    file_read_firstline => sub { '8:0' },
+    file_get_contents => sub { "E:ID_SERIAL=3600udev\n" },
+);
+my $answer = "sda|3600daemon\nsdb|[undef]\n";
+$mp->mock(
+    query_path_identities => sub {
+        return PVE::Multipath::parse_path_identities($answer) if $answer;
+        die "unavailable\n";
+    },
+);
+my $ids = PVE::Multipath::Identity::collect(all => 1);
+is(
+    PVE::Multipath::Identity::path_wwid($ids, 'sda'),
+    '3600daemon',
+    'daemon identity is authoritative',
+);
+is(
+    PVE::Multipath::Identity::path_wwid($ids, 'sdb'),
+    '3600udev',
+    'udev identity for a path whose WWID the daemon does not know',
+);
+is(
+    PVE::Multipath::Identity::path_wwid($ids, 'sdc'),
+    '3600udev',
+    'udev identity for a path the daemon does not list',
+);
+$answer = undef;
+$ids = PVE::Multipath::Identity::collect(all => 1);
+is(
+    PVE::Multipath::Identity::path_wwid($ids, 'sda'),
+    '3600udev',
+    'udev fallback when daemon cannot answer',
+);
+is_deeply(
+    PVE::Multipath::parse_path_identities("sda|3600one\nsdb|[undef]\n"),
+    { sda => { wwid => '3600one' } },
+    'path-list parser skips unknown identities',
+);
+is_deeply(PVE::Multipath::parse_path_identities('ok'), {}, 'empty daemon reply');
+ok(!defined(PVE::Multipath::parse_path_identities('timeout')), 'invalid daemon reply');
+
+done_testing();
diff --git a/src/test/run_multipath_tests.pl b/src/test/run_multipath_tests.pl
index db356cde..ae44e962 100755
--- a/src/test/run_multipath_tests.pl
+++ b/src/test/run_multipath_tests.pl
@@ -3,6 +3,7 @@
 use v5.36;
 use lib ('.', '..');
 use Test::More;
+use Test::MockModule;
 use PVE::Multipath;
 use PVE::Multipath::Config;
 use PVE::Tools qw(file_get_contents);
@@ -142,4 +143,15 @@ subtest 'one owner for map identity and membership' => sub {
     );
 };
 
+subtest 'short commands and link-only assembly wait' => sub {
+    my $mp = Test::MockModule->new('PVE::Multipath');
+    my @calls;
+    $mp->mock(run_command => sub($cmd, %opts) { push @calls, [$cmd, $opts{timeout}] });
+    ok(
+        !PVE::Multipath::wait_for_map('nonexistent-test-lun', 0),
+        'missing by-id block link times out',
+    );
+    is_deeply(\@calls, [], 'waiting never queries the daemon');
+};
+
 done_testing();
diff --git a/src/test/run_test_lvm_base_volume.pl b/src/test/run_test_lvm_base_volume.pl
index 208e7668..13ba5bd9 100755
--- a/src/test/run_test_lvm_base_volume.pl
+++ b/src/test/run_test_lvm_base_volume.pl
@@ -13,12 +13,12 @@ use lib ('.', '..');
 use PVE::Storage;
 use PVE::Storage::LVMPlugin;
 
-my (@calls, $volume_error);
+my (@calls, $volume_error, $managed);
 
 my $storage = Test::MockModule->new('PVE::Storage');
 $storage->mock(
     config => sub { {} },
-    storage_config => sub { { type => 'iscsi' } },
+    storage_config => sub { { type => 'iscsi', 'managed-multipath' => $managed } },
     path => sub { '/dev/disk/by-id/scsi-test' },
     activate_storage => sub { push @calls, 'activate_storage' },
     activate_volumes => sub {
@@ -46,4 +46,12 @@ eval { PVE::Storage::LVMPlugin->on_add_hook('lvm', $scfg) };
 is($@, $volume_error, 'failing base volume activation aborts adding the storage');
 ok(!grep({ $_ eq 'lvm_create_volume_group' } @calls), 'no volume group created on that device');
 
+($managed, $volume_error) = (1, undef);
+eval { PVE::Storage::LVMPlugin->on_add_hook('lvm', $scfg) };
+like($@, qr/is no multipath volume/, 'managed multipath refuses the name of a single path');
+for my $name (qw(dm-uuid-mpath-3600a dm-uuid-part1-mpath-3600a)) {
+    eval { PVE::Storage::LVMPlugin->on_add_hook('lvm', { %$scfg, base => "san:0.0.0.$name" }) };
+    is($@, '', "managed multipath accepts $name");
+}
+
 done_testing();




  parent reply	other threads:[~2026-11-18  6:56 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 cluster 01/42] cfs: observe the multipath configuration files Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 02/42] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 03/42] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 04/42] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 05/42] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 06/42] iscsi: factor out session device map from device list Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 07/42] multipath: add a library around multipathd Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 08/42] diskmanage: add helper to list multipath devices Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 09/42] multipath: add a cluster-wide configuration Thomas Lamprecht
2026-11-18  6:52 ` Thomas Lamprecht [this message]
2026-11-18  6:52 ` [PATCH v6 storage 11/42] lvm: activate a missing base volume before using the volume group Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 12/42] multipath: apply the configuration on every node Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 13/42] multipath: publish per-node status Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 14/42] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 15/42] api: multipath: add the cluster-wide health status Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 16/42] diskmanage: look up the requested disks by name Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 17/42] diskmanage: read the udev data of all disks with one call Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 18/42] api: scan: add a SAN LUN inventory Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 19/42] pvesm: expose the " Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 20/42] api: add node-level iSCSI status Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 21/42] disks: lvm: drop unused imports Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 22/42] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 23/42] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 24/42] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 storage 25/42] api: scan: report the process that has a SAN LUN open Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 docs 26/42] storage: document the cluster-wide multipath management Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 docs 27/42] storage: multipath: describe the use shown for an open LUN Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 28/42] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 29/42] report: add the managed multipath configuration Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 30/42] api: cluster: add the multipath endpoints Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 31/42] api: nodes: expose the iSCSI status Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 32/42] ui: dc: add a SAN view Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 33/42] ui: storage: iscsi: add the multipath option Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 34/42] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 35/42] ui: node: add SAN LUNs panel Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 36/42] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 37/42] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 38/42] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 39/42] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 40/42] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 41/42] ui: san: show the guest or process that has a LUN open Thomas Lamprecht
2026-11-18  6:52 ` [PATCH v6 manager 42/42] ui: node: san: add a column for the iSCSI target of a LUN Thomas Lamprecht
2026-11-18 20:28 ` superseded: [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht

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=20261118065302.3033937-11-t.lamprecht@proxmox.com \
    --to=t.lamprecht@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal