all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM
@ 2026-11-13  3:00 Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 cluster 01/36] cfs: observe the multipath configuration files Thomas Lamprecht
                   ` (36 more replies)
  0 siblings, 37 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

This is v4 of the combined and reduced series of the cluster-wide
multipath work [0][1] and Dietmar's RFC for guided remote storage setup
and SAN visibility [2].

v3 [3] had 76 patches in six repositories. I tried to trim v4 down by
reducing both the scope, minimally, and the implementation. This narrows
the series to shared LVM on iSCSI and Fibre Channel LUNs: 36 patches in
four repositories, about 7700 added lines instead of 26300. It basically
trades automatic cleanup and broad usage checks for a smaller
implementation and documented procedures for the admin. "The rework"
below gives some reasoning, "Changes since v3" the details.

Overview of what an admin gets with this:

 - Datacenter > Storage > SAN, a new entry below Storage, shows the
   multipath state of every node and of the LUNs that multipath
   handles, and edits the multipath entries and array-specific
   overrides. I explicitly chose this over the client/plugin side of
   Storage, as we do not have e.g. Ceph or ZFS/LVM/... creation in
   there either. We might want to rethink and consolidate our storage
   interface vs. management story in the future, but IMO a partial
   switch now is not worth it, that would add even more potential for
   confusion than the new SAN view.
 - Its Add Storage menu guides through shared LVM on a LUN: for iSCSI
   it connects or reuses a target, with the initiator names of all
   nodes at hand, for Fibre Channel it takes a LUN the nodes already
   see. Both set up multipath for the LUN and end with its state on
   every node of the new storage.
 - Datacenter > Storage > Add keeps its dialogs. The iSCSI one gets a
   Multipath option and the LVM one enables Shared for a base storage,
   so the same works there in two steps. Both name the SAN view in a
   note whose link opens it, as admins coming from other platforms look
   for their SAN there first.
 - Node > SAN lists the LUNs of a node with their paths and usage, can
   wipe a LUN that no storage uses, and shows the iSCSI sessions.

The rework:

The series is for a cluster that reaches the LUNs of an array over
iSCSI or Fibre Channel on two or more paths and puts shared LVM on
them. v3 went further: it cleaned up after the admin, tried to find
every user of a LUN before a write, and added iSCSI operations of its
own. Each of these brought a ton of state and failure handling that has
to be maintained and tested. v4 drops them for the time being to get
this into a shippable state, and tries to follow a few rules instead:

 - Add, never remove. A node adds the WWIDs it needs to the multipath
   allow-list, but never removes one and never flushes a map. v3 did,
   which took a record of who added what and probes for maps still in
   use. Removing a LUN is rare and hurts when it goes wrong, so I made
   it a documented procedure.
 - Check a write where it happens. Creating a volume group or wiping a
   LUN checks that no storage references it and looks at the device on
   that node for mounts, holders and, for a volume group, existing
   data. v3 also scanned for other local users, let the web UI ask the
   other nodes and verified the device again between the writes of a
   wipe. Stopping the users on other nodes and hosts before a wipe is
   up to the admin now.
 - Lists do not probe. The LUN inventory uses what udev, multipathd and
   LVM's hint file already know, it no longer reads signatures or runs
   LVM commands. The price is that usage can lag behind, for example on
   the other nodes after a wipe, and that LVM keeps no hints while it
   sees duplicate PVs, for example a LUN with an old PV that has two
   paths and no map yet. Until that is resolved, the node shows no
   volume group names and no storage for a Fibre Channel LUN, which has
   no base volume to go by. A write asks LVM itself and is not
   affected.
 - Use what is there. The output of multipathd is parsed in Perl. v3
   had a new crate in proxmox and its binding in proxmox-perl-rs for
   that (patches 01 and 02), both repositories are out of the series.
   Bounding the LVM status commands got reworked on top of the existing
   run_fork_with_timeout() and sent separately [4].
 - No new iSCSI operations. Session logout, record removal, rescan and
   session parameters are gone from the API and from pvenode. The iSCSI
   view is read-only and iscsiadm remains for the rest, so removing an
   iSCSI storage leaves its sessions and node records behind, as on
   master.
 - The guided setup makes the API calls an admin would make by hand,
   for iSCSI and Fibre Channel only. It no longer tracks and resumes
   partial setups, always enables multipath, and no storage plugin gets
   a setup method for it. It looks at the LUN on the node serving the
   web UI only and does not ask the other nodes before it writes.
   Instead it ends with the state of the LUN on each node of the
   storage, from the cluster-wide status, so that a node without access
   shows up right there.
 - Multipath management is turned on by the admin. The API no longer
   checks that every node supports it before the option is set, or
   that nothing needs the option or an entry before it is removed. The
   docs say to upgrade all nodes first and how to remove a LUN.

Again, we might reintroduce _some_ of this in a fitting form later, but
scope creep weighed v3 (and the revisions before it) down way too much
for it to ever get into a sane, shippable state where we do not get a
ton of maintenance issues. This here is certainly not perfect, but it
is at least still manageable and should get us the most relevant
convenience features.

Two things an admin will likely miss: there is no notification when a
LUN loses path redundancy, the state only shows on the SAN pages and in
the API. A node with fewer paths than its iSCSI portals or the expected
paths of the LUN's entry at least shows as degraded there, and a LUN
that only has one path reads "OK (1 path)" instead of optimal. And Fibre
Channel starts at a LUN the nodes already see, the web UI neither lists
the WWPNs of the nodes nor rescans their HBAs; the chapter gives the
commands for both, and the setup points to the rescan.

How it works:

 - /etc/pve/multipath.cfg holds explicit entries per WWID (nodes, alias,
   no-path-retry, expected paths), /etc/pve/multipath-overrides.conf
   array settings in multipath.conf syntax; patch 01 registers
   both. An iSCSI storage with the new 'multipath' option supplies its
   LUNs without entries, Fibre Channel LUNs get an explicit entry.
 - pvestatd calls one function of pve-storage per pass. It adds the
   WWIDs the node needs to /etc/multipath/wwids, writes the drop-ins
   /etc/multipath/conf.d/pve-*.conf (entries, overrides and one
   generated default, auto_resize grow_only) and reloads multipathd
   when something changed. The same call publishes the node's maps and
   their state through the node key-value store (key 'multipath').
 - /cluster/multipath/status aggregates these reports, derives
   'missing' from the configuration and names the storage that requests
   each map; /cluster/multipath/{wwid,overrides} edit the two files.
 - The volumes of an iSCSI storage with the option end in
   dm-uuid-mpath-<wwid> instead of the name of one path, so an LVM
   storage uses them through the existing 'base' mechanism.
 - /nodes/{node}/scan/san-luns and 'pvesm scan san-luns' return one row
   per LUN with a WWID, /nodes/{node}/iscsi/{status,target} the
   read-only session view.
 - Volume group creation and wipe run under a cluster lock per LUN
   (cfs_lock_domain) and do not hold the storage configuration lock
   while they write. Adding an LVM storage with a new base volume still
   does, as before.
 - multipath-tools becomes a Recommends of libpve-storage-perl. Nodes
   without it report that; plain iSCSI and LVM are unaffected.

Patches:

 - cluster 01: register the two configuration files
 - storage 02-22: helpers for the disk and iSCSI session inventory
   (mostly Dietmar's), the multipath library and configuration, the
   iSCSI option, the per-node apply and status with their API, the LUN
   inventory, the read-only iSCSI status, volume groups on LUNs and the
   wipe, in that order
 - docs 23: the multipath chapter, rewritten around tasks
 - manager 24-36: the pvestatd call, report and API mounts, then
   the views, the two dialog changes, the two guided setups and the
   note in the add dialogs

Changes since v3 [3] (numbers are v3 patches):

 - applied meanwhile: the independent fixes 05 and 07 to 11, the
   documentation note 43 and the scan picker fixes 47 and 48
 - sent separately [4]: the bound for LVM status commands (04, 06, 46),
   now one pve-storage patch without a pvestatd part or plugin API
   change. Unlike v3 it leaves thin pool activation unbounded.
   Whichever of the two is applied second has to pass the status cache
   to the two lvm_vgs() calls of the base volume activation
 - removed: everything "The rework" names, and with it the NFS,
   SMB/CIFS and ZFS over iSCSI types, the wipe step, the node selector
   and the multipath checkbox of the guided setup; the structured
   'defaults' section of multipath.cfg and the per-LUN path settings
   except no-path-retry (the generated defaults no longer set
   find_multipaths, user_friendly_names and polling_interval); the
   duplicate PV flag, the rows for devices without a WWID and the
   'incomplete' marking in the LUN lists; the include-remote option of
   the disk list; identity-based names for plain iSCSI volumes (40);
   the JavaScript unit tests
 - changed:
    - get_disks() lists iSCSI devices only on request, so Ceph OSD
      creation needs no change (45) and no Breaks
    - one SAN panel below Datacenter > Storage instead of a SAN and a
      Multipath view, with one state per node and per LUN. The state
      of a LUN names the nodes it applies to, a single path is shown
      as such instead of optimal, and the LUN list says how the
      multipath of each LUN is managed instead of a yes or no for an
      entry
    - the guided setup starts from the Add Storage menu of that panel
      instead of Datacenter > Storage > Add, offers snapshots as volume
      chain, the Fibre Channel one adds its storage itself, and both
      show the state of the LUN on each node at the end instead of
      asking the other nodes before
    - the node disk API adds the storage of a volume group on a LUN as
      shared and for all nodes, and only under a new storage ID
    - the chapter went from 527 to 260 lines
 - new: destroying the volume group of a shared storage through the node
   disk API is refused, and the LVM dialog enables Shared when a base
   storage is selected; explicit multipath entries can set the expected
   number of paths, which the Fibre Channel setup fills in

When applying, versioned dependencies have to be set: pve-manager on
libpve-storage-perl, and libpve-storage-perl (also as build dependency)
on the libpve-cluster-perl with patch 01, as PVE::Storage
registers the two files when it is loaded.

The per-node target and portal series [5][6] are independent of this
one. It takes the LUNs of an iSCSI storage from the sessions of its one
target, so if a storage can have several targets per node, whichever is
applied second has to cover that.

I tested this on a six-node nested cluster attached to a NetApp AFF A20
with three iSCSI portals and to Linux LIO targets with two: the guided
iSCSI setup with a new and with a reused connection storage, the same
through the plain dialogs and from the CLI as documented, a LUN that one
node is not allowed to see and gets access later, the Fibre Channel flow
through the web UI, also as an administrator other than root@pam, a
guest on the resulting storages (snapshot, rollback, online resize, live
migration, one path cut under I/O), growing a LUN, wipe and its
refusals, one path and all paths down with queued I/O, a stopped
multipathd, a node reboot and the documented LUN removal. The lab has no
FC hardware, so I emulated it with software FCoE in VN2VN mode and an
LIO tcm_fc target on two fabrics: the nodes get real FC host and remote
port objects, and the documented WWPN listing, rescan and LUN growth
work there as written. The guided Fibre Channel setup ran on such a LUN,
with one node on one fabric only and one node that saw the LUN only
after the rescan. The setup records the paths it sees in the LUN's
entry, so the node on one fabric shows as degraded, and a fabric cut
stays degraded also after the kernel removed the lost paths (66 seconds
dev_loss_tmo of the LIO profile). Real HBA drivers were not tested. Most
of that ran with the NVMe over Fabrics series on top and with the LVM
status patch [4] applied, the series alone ran on one node of that
cluster for the guided setups, the CLI procedure and the views. Without
[4] a stuck LVM command blocks pvestatd as on master.

[0]: https://lore.proxmox.com/pve-devel/20260626121000.2095591-1-t.lamprecht@proxmox.com/
[1]: https://lore.proxmox.com/pve-devel/20260703124707.1172980-2-t.lamprecht@proxmox.com/
[2]: https://lore.proxmox.com/pve-devel/20260731102156.3947857-1-dietmar@proxmox.com/
[3]: https://lore.proxmox.com/pve-devel/20261105233336.2178064-1-t.lamprecht@proxmox.com/
[4]: https://lore.proxmox.com/pve-devel/20261111015217.941220-1-t.lamprecht@proxmox.com/
[5]: https://lore.proxmox.com/pve-devel/20260430173220.441001-1-m.limbeck@proxmox.com/
[6]: https://lore.proxmox.com/pve-devel/20260804090819.2136483-1-dietmar@proxmox.com/

pve-cluster:

Thomas Lamprecht (1):
      cfs: observe the multipath configuration files

 src/PVE/Cluster.pm  | 2 ++
 src/pmxcfs/status.c | 2 ++
 2 files changed, 4 insertions(+)

pve-storage:

Dietmar Maurer (8):
      diskmanage: collect disk transport type from lsblk
      diskmanage: qualify NVMe over fabrics transport
      diskmanage: optionally include iSCSI session devices in disk enumeration
      diskmanage: collect native NVMe multipath path state
      iscsi: factor out session device map from device list
      diskmanage: add helper to list multipath devices
      pvesm: expose the SAN LUN inventory
      api: add node-level iSCSI status

Thomas Lamprecht (13):
      multipath: add a library around multipathd
      multipath: add a cluster-wide configuration
      iscsi: add an option to manage storage LUNs with multipath
      lvm: activate a missing base volume before using the volume group
      multipath: apply the configuration on every node
      multipath: publish per-node status
      api: add endpoints for the cluster-wide multipath configuration
      api: multipath: add the cluster-wide health status
      api: scan: add a SAN LUN inventory
      disks: lvm: drop unused imports
      disks: lvm: allow volume groups on SAN LUNs and multipath maps
      disks: lvm: refuse to destroy the volume group of a shared storage
      disks: allow wiping a SAN LUN that no storage uses

 debian/control                                |   3 +-
 src/PVE/API2/Disks.pm                         |  36 +-
 src/PVE/API2/Disks/LVM.pm                     |  64 ++-
 src/PVE/API2/ISCSI.pm                         | 165 +++++++
 src/PVE/API2/Makefile                         |   2 +
 src/PVE/API2/Multipath.pm                     | 446 ++++++++++++++++++
 src/PVE/API2/Storage/Scan.pm                  | 197 ++++++++
 src/PVE/CLI/pvesm.pm                          |  14 +
 src/PVE/Diskmanage.pm                         | 212 ++++++++-
 src/PVE/ISCSI/Topology.pm                     |  95 ++++
 src/PVE/Makefile                              |   6 +
 src/PVE/Multipath.pm                          | 211 +++++++++
 src/PVE/Multipath/Config.pm                   | 204 ++++++++
 src/PVE/Multipath/Generator.pm                | 112 +++++
 src/PVE/Multipath/Identity.pm                 |  43 ++
 src/PVE/Multipath/Status.pm                   | 184 ++++++++
 src/PVE/Storage/ISCSIPlugin.pm                | 211 +++++----
 src/PVE/Storage/LVMPlugin.pm                  | 128 ++++-
 src/PVE/Storage/Makefile                      |   3 +-
 src/PVE/Storage/SAN.pm                        | 328 +++++++++++++
 src/test/Makefile                             |  34 +-
 src/test/disk_api_test.pm                     | 256 ++++++++++
 src/test/disk_tests/iscsi/disklist            |   1 +
 .../disk_tests/iscsi/disklist_expected.json   |  19 +
 src/test/disk_tests/iscsi/lsblk               |   5 +
 src/test/disk_tests/iscsi/sda/device/model    |   1 +
 src/test/disk_tests/iscsi/sda/device/vendor   |   1 +
 .../disk_tests/iscsi/sda/queue/rotational     |   1 +
 src/test/disk_tests/iscsi/sda/size            |   1 +
 src/test/disk_tests/iscsi/sda_udevadm         |  21 +
 src/test/disk_tests/multipath/disklist        |  11 +
 .../multipath/disklist_expected.json          | 107 +++++
 src/test/disk_tests/multipath/dm-0/dm/name    |   1 +
 src/test/disk_tests/multipath/dm-0/dm/uuid    |   1 +
 src/test/disk_tests/multipath/dm-0/size       |   1 +
 src/test/disk_tests/multipath/dm-0_slaves     |   4 +
 src/test/disk_tests/multipath/dm-1/dm/name    |   1 +
 src/test/disk_tests/multipath/dm-1/dm/uuid    |   1 +
 src/test/disk_tests/multipath/dm-1/size       |   1 +
 src/test/disk_tests/multipath/dm-1_slaves     |   4 +
 src/test/disk_tests/multipath/dm-2/dm/name    |   1 +
 src/test/disk_tests/multipath/dm-2/dm/uuid    |   1 +
 src/test/disk_tests/multipath/dm-2/size       |   1 +
 src/test/disk_tests/multipath/dm-2_slaves     |   0
 src/test/disk_tests/multipath/dm-3/dm/name    |   1 +
 src/test/disk_tests/multipath/dm-3/dm/uuid    |   1 +
 src/test/disk_tests/multipath/dm-3/size       |   1 +
 src/test/disk_tests/multipath/dm-3_slaves     |   0
 src/test/disk_tests/multipath/dm-4/dm/name    |   1 +
 src/test/disk_tests/multipath/dm-4/dm/uuid    |   1 +
 src/test/disk_tests/multipath/dm-4/size       |   1 +
 src/test/disk_tests/multipath/dm-4_slaves     |   0
 src/test/disk_tests/multipath/lsblk           |  77 +++
 src/test/disk_tests/multipath/lvs             |   0
 src/test/disk_tests/multipath/mounts          |   1 +
 .../multipath/multipath_expected.json         |  59 +++
 src/test/disk_tests/multipath/multipathd      | 124 +++++
 .../multipath/multipathd_status_expected.json |  40 ++
 .../nvme-subsystem/nvme-subsys0/nvme3/address |   1 +
 .../nvme-subsys0/nvme3/nvme2c3n1/ana_state    |   1 +
 .../nvme-subsystem/nvme-subsys0/nvme3/state   |   1 +
 .../nvme-subsystem/nvme-subsys0/nvme4/address |   1 +
 .../nvme-subsys0/nvme4/nvme2c4n1/ana_state    |   1 +
 .../nvme-subsystem/nvme-subsys0/nvme4/state   |   1 +
 .../nvme-subsystem/nvme-subsys1/nvme0/address |   1 +
 .../nvme-subsystem/nvme-subsys1/nvme0/state   |   1 +
 .../disk_tests/multipath/nvme8n1/device/model |   1 +
 .../multipath/nvme8n1/device/transport        |   1 +
 .../multipath/nvme8n1/queue/rotational        |   1 +
 src/test/disk_tests/multipath/nvme8n1/size    |   1 +
 src/test/disk_tests/multipath/nvme8n1_udevadm |  14 +
 .../disk_tests/multipath/nvme9n1/device/model |   1 +
 .../multipath/nvme9n1/device/transport        |   1 +
 .../multipath/nvme9n1/device/vendor           |   1 +
 .../multipath/nvme9n1/queue/rotational        |   1 +
 src/test/disk_tests/multipath/nvme9n1/size    |   1 +
 src/test/disk_tests/multipath/nvme9n1_udevadm |  12 +
 .../multipath/nvme_path_status_expected.json  |  19 +
 src/test/disk_tests/multipath/partlist        |   0
 src/test/disk_tests/multipath/pvs             |   1 +
 .../disk_tests/multipath/sda/device/model     |   1 +
 .../disk_tests/multipath/sda/device/vendor    |   1 +
 .../disk_tests/multipath/sda/holders/holder   |   1 +
 .../disk_tests/multipath/sda/queue/rotational |   1 +
 src/test/disk_tests/multipath/sda/size        |   1 +
 src/test/disk_tests/multipath/sda_udevadm     |  18 +
 .../disk_tests/multipath/sdb/device/model     |   1 +
 .../disk_tests/multipath/sdb/device/vendor    |   1 +
 .../disk_tests/multipath/sdb/holders/holder   |   1 +
 .../disk_tests/multipath/sdb/queue/rotational |   1 +
 src/test/disk_tests/multipath/sdb/size        |   1 +
 src/test/disk_tests/multipath/sdb_udevadm     |  18 +
 .../disk_tests/multipath/sdc/device/model     |   1 +
 .../disk_tests/multipath/sdc/device/vendor    |   1 +
 .../disk_tests/multipath/sdc/holders/holder   |   1 +
 .../disk_tests/multipath/sdc/queue/rotational |   1 +
 src/test/disk_tests/multipath/sdc/size        |   1 +
 src/test/disk_tests/multipath/sdc_udevadm     |  18 +
 .../disk_tests/multipath/sdd/device/model     |   1 +
 .../disk_tests/multipath/sdd/device/vendor    |   1 +
 .../disk_tests/multipath/sdd/holders/holder   |   1 +
 .../disk_tests/multipath/sdd/queue/rotational |   1 +
 src/test/disk_tests/multipath/sdd/size        |   1 +
 src/test/disk_tests/multipath/sdd_udevadm     |  18 +
 src/test/disk_tests/multipath/zpool           |   1 +
 .../disk_tests/sas/disklist_expected.json     |   1 +
 src/test/disk_tests/sas/lsblk                 |   5 +
 src/test/disklist_test.pm                     | 107 ++++-
 src/test/multipath-three-states.json          |  52 ++
 src/test/run_disk_api_tests.pl                |  11 +
 src/test/run_iscsi_activation_tests.pl        |  86 ++++
 src/test/run_lun_identity_tests.pl            |  48 ++
 src/test/run_multipath_api_tests.pl           | 352 ++++++++++++++
 src/test/run_multipath_tests.pl               | 169 +++++++
 src/test/run_san_api_tests.pl                 |  94 ++++
 src/test/run_san_library_tests.pl             |  84 ++++
 src/test/run_san_lun_scan_tests.pl            | 180 +++++++
 src/test/run_san_nvme_tests.pl                | 107 +++++
 src/test/run_san_taint_tests.pl               |  60 +++
 src/test/run_san_wipe_tests.pl                | 137 ++++++
 src/test/run_test_lvm_base_activation.pl      | 117 +++++
 src/test/run_test_lvm_base_conflicts.pl       | 232 ++++++---
 src/test/run_test_lvm_create.pl               |  14 +
 123 files changed, 5244 insertions(+), 214 deletions(-)

pve-docs:

Thomas Lamprecht (1):
      storage: document the cluster-wide multipath management

 pmxcfs.adoc                  |   2 +
 pve-storage-iscsi.adoc       |  11 ++
 pve-storage-iscsidirect.adoc |   2 +-
 pve-storage-lvm.adoc         |   3 +
 pve-storage-multipath.adoc   | 260 +++++++++++++++++++++++++++++++++++
 pvesm.adoc                   |  18 ++-
 6 files changed, 290 insertions(+), 6 deletions(-)

pve-manager:

Dietmar Maurer (2):
      api: nodes: expose the iSCSI status
      ui: node: san: show iSCSI targets and sessions

Thomas Lamprecht (11):
      pvestatd: apply the multipath configuration and report the node status
      report: add the managed multipath configuration
      api: cluster: add the multipath endpoints
      ui: dc: add a SAN view
      ui: storage: iscsi: add the multipath option
      ui: lvm: enable shared when a base storage is selected
      ui: node: add SAN LUNs panel
      ui: node: san: wipe a LUN that no storage uses
      ui: dc: san: add a guided setup for shared LVM on iSCSI
      ui: dc: san: add a guided setup for shared LVM on Fibre Channel
      ui: storage: point the iSCSI and LVM add dialogs to the SAN view

 PVE/API2/Cluster.pm                           |   7 +
 PVE/API2/Nodes.pm                             |   7 +
 PVE/Report.pm                                 |   3 +
 PVE/Service/pvestatd.pm                       |   7 +
 www/manager6/Makefile                         |  12 +
 www/manager6/SANUtils.js                      | 161 +++++++++
 www/manager6/Utils.js                         |  14 +
 www/manager6/dc/Config.js                     |  23 +-
 www/manager6/dc/MultipathWwidEdit.js          |  81 +++++
 www/manager6/dc/SAN.js                        | 331 ++++++++++++++++++
 www/manager6/node/Config.js                   |  24 ++
 www/manager6/node/ISCSITargets.js             | 122 +++++++
 www/manager6/node/SANLuns.js                  | 184 ++++++++++
 www/manager6/storage/Base.js                  |   5 +
 www/manager6/storage/IScsiEdit.js             |  46 +++
 www/manager6/storage/LVMEdit.js               |   6 +
 www/manager6/storage/wizard/FibreChannel.js   | 162 +++++++++
 www/manager6/storage/wizard/IScsi.js          | 272 ++++++++++++++
 www/manager6/storage/wizard/LunSelect.js      | 181 ++++++++++
 www/manager6/storage/wizard/NodeIdentities.js |  83 +++++
 www/manager6/storage/wizard/Wizard.js         | 254 ++++++++++++++
 www/manager6/window/SANLunState.js            | 115 ++++++
 www/manager6/window/SANLunWipe.js             |  53 +++
 23 files changed, 2147 insertions(+), 6 deletions(-)




^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v4 cluster 01/36] cfs: observe the multipath configuration files
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 02/36] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
                   ` (35 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

pve-storage needs to register and lock /etc/pve/multipath.cfg and
/etc/pve/multipath-overrides.conf through PVE::Cluster. Add them to the
observed files so pmxcfs tracks their versions and readers can cache
the parsed configuration until it changes.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Cluster.pm  | 2 ++
 src/pmxcfs/status.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/PVE/Cluster.pm b/src/PVE/Cluster.pm
index 10c5686..7c1b47c 100644
--- a/src/PVE/Cluster.pm
+++ b/src/PVE/Cluster.pm
@@ -50,6 +50,8 @@ my $observed = {
     'vzdump.conf' => 1,
     'jobs.cfg' => 1,
     'storage.cfg' => 1,
+    'multipath.cfg' => 1,
+    'multipath-overrides.conf' => 1,
     'datacenter.cfg' => 1,
     'replication.cfg' => 1,
     'corosync.conf' => 1,
diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c
index e1ab438..e746c17 100644
--- a/src/pmxcfs/status.c
+++ b/src/pmxcfs/status.c
@@ -81,6 +81,8 @@ static memdb_change_t memdb_change_array[] = {
     {.path = "corosync.conf"},
     {.path = "corosync.conf.new"},
     {.path = "storage.cfg"},
+    {.path = "multipath.cfg"},
+    {.path = "multipath-overrides.conf"},
     {.path = "user.cfg"},
     {.path = "domains.cfg"},
     {.path = "notifications.cfg"},




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 02/36] diskmanage: collect disk transport type from lsblk
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 cluster 01/36] cfs: observe the multipath configuration files Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 03/36] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
                   ` (34 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

Expose the disk transport, for example sata, sas, usb, fc or nvme, in
the disk list. The SAN LUN inventory uses it to tell LUNs that are
attached over a SAN from local disks.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: clarify the transport description]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks.pm                          | 6 ++++++
 src/PVE/Diskmanage.pm                          | 6 +++++-
 src/test/disk_tests/sas/disklist_expected.json | 1 +
 src/test/disk_tests/sas/lsblk                  | 5 +++++
 4 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 src/test/disk_tests/sas/lsblk

diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index e707a9e9..1abab820 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -135,6 +135,12 @@ __PACKAGE__->register_method({
                 serial => { type => 'string', optional => 1 },
                 wwn => { type => 'string', optional => 1 },
                 health => { type => 'string', optional => 1 },
+                transport => {
+                    type => 'string',
+                    description =>
+                        "The device transport, for example 'sata', 'sas', 'usb', 'fc', or 'nvme'.",
+                    optional => 1,
+                },
                 parent => {
                     type => 'string',
                     description => 'For partitions only. The device path of '
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index f519f10a..4d66902b 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -193,7 +193,7 @@ sub get_smart_data {
 }
 
 sub get_lsblk_info {
-    my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype'];
+    my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype,tran'];
     my $output = "";
     eval {
         run_command($cmd, outfunc => sub { $output .= "$_[0]\n"; });
@@ -210,6 +210,7 @@ sub get_lsblk_info {
             $_->{path} => {
                 parttype => $_->{parttype},
                 fstype => $_->{fstype},
+                tran => $_->{tran},
             }
         } @{$list}
     };
@@ -646,6 +647,9 @@ sub get_disks {
                 devpath => $devpath,
                 wearout => $wearout,
             };
+
+            my $transport = $lsblk_info->{$devpath}->{tran};
+            $disklist->{$dev}->{transport} = $transport if defined($transport);
             $disklist->{$dev}->{mounted} = 1 if exists $mounted->{$devpath};
 
             my $by_id_link = $data->{by_id_link};
diff --git a/src/test/disk_tests/sas/disklist_expected.json b/src/test/disk_tests/sas/disklist_expected.json
index a4a1c4c1..26d0d173 100644
--- a/src/test/disk_tests/sas/disklist_expected.json
+++ b/src/test/disk_tests/sas/disklist_expected.json
@@ -13,6 +13,7 @@
 	"size" : 5120000,
 	"serial" : "SER2",
 	"wearout" : "N/A",
+	"transport" : "sas",
 	"by_id_link" : "/dev/disk/by-id/scsi-00000000000000000"
     }
 }
diff --git a/src/test/disk_tests/sas/lsblk b/src/test/disk_tests/sas/lsblk
new file mode 100644
index 00000000..cae98190
--- /dev/null
+++ b/src/test/disk_tests/sas/lsblk
@@ -0,0 +1,5 @@
+{
+   "blockdevices": [
+      {"path":"/dev/sda", "parttype":null, "fstype":null, "tran":"sas"}
+   ]
+}




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 03/36] diskmanage: qualify NVMe over fabrics transport
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 cluster 01/36] cfs: observe the multipath configuration files Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 02/36] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 04/36] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
                   ` (33 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

lsblk reports 'nvme' for namespaces attached over a fabric too, so
they cannot be told from local PCIe drives. Read the transport from
the controller, or from a controller of the subsystem with native
multipath, and report nvme-fc, nvme-tcp, nvme-rdma or nvme-loop for
such namespaces.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: add the test case with the two namespaces only, the multipath
 devices it was part of follow later; mention the new values in the
 transport description]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks.pm                         |  3 +-
 src/PVE/Diskmanage.pm                         | 27 ++++++++++++++
 src/test/disk_tests/multipath/disklist        |  2 ++
 .../multipath/disklist_expected.json          | 35 +++++++++++++++++++
 src/test/disk_tests/multipath/lsblk           | 18 ++++++++++
 .../disk_tests/multipath/nvme8n1/device/model |  1 +
 .../multipath/nvme8n1/device/transport        |  1 +
 .../multipath/nvme8n1/queue/rotational        |  1 +
 src/test/disk_tests/multipath/nvme8n1/size    |  1 +
 src/test/disk_tests/multipath/nvme8n1_udevadm | 14 ++++++++
 .../disk_tests/multipath/nvme9n1/device/model |  1 +
 .../multipath/nvme9n1/device/transport        |  1 +
 .../multipath/nvme9n1/device/vendor           |  1 +
 .../multipath/nvme9n1/queue/rotational        |  1 +
 src/test/disk_tests/multipath/nvme9n1/size    |  1 +
 src/test/disk_tests/multipath/nvme9n1_udevadm | 12 +++++++
 src/test/disklist_test.pm                     | 12 +++++++
 17 files changed, 131 insertions(+), 1 deletion(-)
 create mode 100644 src/test/disk_tests/multipath/disklist
 create mode 100644 src/test/disk_tests/multipath/disklist_expected.json
 create mode 100644 src/test/disk_tests/multipath/lsblk
 create mode 100644 src/test/disk_tests/multipath/nvme8n1/device/model
 create mode 100644 src/test/disk_tests/multipath/nvme8n1/device/transport
 create mode 100644 src/test/disk_tests/multipath/nvme8n1/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/nvme8n1/size
 create mode 100644 src/test/disk_tests/multipath/nvme8n1_udevadm
 create mode 100644 src/test/disk_tests/multipath/nvme9n1/device/model
 create mode 100644 src/test/disk_tests/multipath/nvme9n1/device/transport
 create mode 100644 src/test/disk_tests/multipath/nvme9n1/device/vendor
 create mode 100644 src/test/disk_tests/multipath/nvme9n1/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/nvme9n1/size
 create mode 100644 src/test/disk_tests/multipath/nvme9n1_udevadm

diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index 1abab820..980ba7ff 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -138,7 +138,8 @@ __PACKAGE__->register_method({
                 transport => {
                     type => 'string',
                     description =>
-                        "The device transport, for example 'sata', 'sas', 'usb', 'fc', or 'nvme'.",
+                        "The device transport, for example 'sata', 'sas', 'usb', 'fc',"
+                        . " 'nvme', 'nvme-fc', or 'nvme-tcp'.",
                     optional => 1,
                 },
                 parent => {
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index 4d66902b..7862bcd4 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -505,6 +505,26 @@ sub is_iscsi {
     return 0;
 }
 
+# Returns the NVMe transport (pcie, fc, tcp, rdma, loop) of a namespace, either directly from
+# its controller, or from any controller of its subsystem for native NVMe multipath setups.
+sub get_nvme_transport {
+    my ($sysdir) = @_;
+
+    my $transport = file_read_firstline("$sysdir/device/transport");
+    return $transport if defined($transport);
+
+    dir_glob_foreach(
+        "$sysdir/device",
+        'nvme\d+',
+        sub {
+            my ($controller) = @_;
+            $transport //= file_read_firstline("$sysdir/device/$controller/transport");
+        },
+    );
+
+    return $transport;
+}
+
 my sub is_ssdlike {
     my ($type) = @_;
     return $type eq 'ssd' || $type eq 'nvme';
@@ -597,6 +617,9 @@ sub get_disks {
             # we do not want iscsi devices
             return if is_iscsi($sysdir);
 
+            my $nvme_transport;
+            $nvme_transport = get_nvme_transport($sysdir) if $dev =~ m/^nvme/;
+
             my $sysdata = get_sysdir_info($sysdir);
             return if !defined($sysdata);
 
@@ -648,7 +671,11 @@ sub get_disks {
                 wearout => $wearout,
             };
 
+            # lsblk reports plain 'nvme' for fabrics attached namespaces
             my $transport = $lsblk_info->{$devpath}->{tran};
+            if (defined($nvme_transport) && $nvme_transport ne 'pcie') {
+                $transport = "nvme-$nvme_transport";
+            }
             $disklist->{$dev}->{transport} = $transport if defined($transport);
             $disklist->{$dev}->{mounted} = 1 if exists $mounted->{$devpath};
 
diff --git a/src/test/disk_tests/multipath/disklist b/src/test/disk_tests/multipath/disklist
new file mode 100644
index 00000000..b5e636a5
--- /dev/null
+++ b/src/test/disk_tests/multipath/disklist
@@ -0,0 +1,2 @@
+nvme8n1
+nvme9n1
diff --git a/src/test/disk_tests/multipath/disklist_expected.json b/src/test/disk_tests/multipath/disklist_expected.json
new file mode 100644
index 00000000..908c2b56
--- /dev/null
+++ b/src/test/disk_tests/multipath/disklist_expected.json
@@ -0,0 +1,35 @@
+{
+    "nvme8n1": {
+        "devpath": "/dev/nvme8n1",
+        "size": 10737418240,
+        "vendor": "unknown",
+        "model": "FCMODEL",
+        "serial": "FCNVME1",
+        "wwn": "uuid.20000000-0000-0000-0000-000000000001",
+        "gpt": 0,
+        "rpm": 0,
+        "type": "nvme",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/nvme-FCMODEL_FCNVME1",
+        "transport": "nvme-fc"
+    },
+    "nvme9n1": {
+        "devpath": "/dev/nvme9n1",
+        "size": 10737418240,
+        "vendor": "FABVEND",
+        "model": "FABRICS CTRL",
+        "serial": "FAB1",
+        "wwn": "uuid.10000000-0000-0000-0000-000000000001",
+        "gpt": 0,
+        "rpm": 0,
+        "type": "nvme",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "transport": "nvme-tcp"
+    }
+}
diff --git a/src/test/disk_tests/multipath/lsblk b/src/test/disk_tests/multipath/lsblk
new file mode 100644
index 00000000..597adf94
--- /dev/null
+++ b/src/test/disk_tests/multipath/lsblk
@@ -0,0 +1,18 @@
+{
+   "blockdevices": [
+      {
+         "path": "/dev/nvme8n1",
+         "parttype": null,
+         "fstype": null,
+         "tran": "nvme",
+         "pttype": null
+      },
+      {
+         "path": "/dev/nvme9n1",
+         "parttype": null,
+         "fstype": null,
+         "tran": "nvme",
+         "pttype": null
+      }
+   ]
+}
diff --git a/src/test/disk_tests/multipath/nvme8n1/device/model b/src/test/disk_tests/multipath/nvme8n1/device/model
new file mode 100644
index 00000000..1aac689e
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme8n1/device/model
@@ -0,0 +1 @@
+FCMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme8n1/device/transport b/src/test/disk_tests/multipath/nvme8n1/device/transport
new file mode 100644
index 00000000..8b517d01
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme8n1/device/transport
@@ -0,0 +1 @@
+fc
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme8n1/queue/rotational b/src/test/disk_tests/multipath/nvme8n1/queue/rotational
new file mode 100644
index 00000000..c2270834
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme8n1/queue/rotational
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme8n1/size b/src/test/disk_tests/multipath/nvme8n1/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme8n1/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme8n1_udevadm b/src/test/disk_tests/multipath/nvme8n1_udevadm
new file mode 100644
index 00000000..d0cd5ea9
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme8n1_udevadm
@@ -0,0 +1,14 @@
+P: /devices/virtual/nvme-subsystem/nvme-subsys8/nvme8n1
+N: nvme8n1
+S: disk/by-id/nvme-FCMODEL_FCNVME1
+E: DEVLINKS=/dev/disk/by-id/nvme-FCMODEL_FCNVME1
+E: DEVNAME=/dev/nvme8n1
+E: DEVPATH=/devices/virtual/nvme-subsystem/nvme-subsys8/nvme8n1
+E: DEVTYPE=disk
+E: ID_MODEL=FCMODEL
+E: ID_SERIAL=FCNVME_1
+E: ID_SERIAL_SHORT=FCNVME1
+E: ID_WWN=uuid.20000000-0000-0000-0000-000000000001
+E: MAJOR=259
+E: MINOR=1
+E: SUBSYSTEM=block
diff --git a/src/test/disk_tests/multipath/nvme9n1/device/model b/src/test/disk_tests/multipath/nvme9n1/device/model
new file mode 100644
index 00000000..aa0287c7
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1/device/model
@@ -0,0 +1 @@
+FABMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme9n1/device/transport b/src/test/disk_tests/multipath/nvme9n1/device/transport
new file mode 100644
index 00000000..f5483dbf
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1/device/transport
@@ -0,0 +1 @@
+tcp
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme9n1/device/vendor b/src/test/disk_tests/multipath/nvme9n1/device/vendor
new file mode 100644
index 00000000..cdc6ddfa
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1/device/vendor
@@ -0,0 +1 @@
+FABVEND
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme9n1/queue/rotational b/src/test/disk_tests/multipath/nvme9n1/queue/rotational
new file mode 100644
index 00000000..c2270834
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1/queue/rotational
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme9n1/size b/src/test/disk_tests/multipath/nvme9n1/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/nvme9n1_udevadm b/src/test/disk_tests/multipath/nvme9n1_udevadm
new file mode 100644
index 00000000..b6d13ccb
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme9n1_udevadm
@@ -0,0 +1,12 @@
+P: /devices/virtual/nvme-subsystem/nvme-subsys9/nvme9n1
+N: nvme9n1
+E: DEVNAME=/dev/nvme9n1
+E: DEVPATH=/devices/virtual/nvme-subsystem/nvme-subsys9/nvme9n1
+E: DEVTYPE=disk
+E: ID_MODEL=FABRICS CTRL
+E: ID_SERIAL=FABRICS_1
+E: ID_SERIAL_SHORT=FAB1
+E: ID_WWN=uuid.10000000-0000-0000-0000-000000000001
+E: MAJOR=259
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index a0dc01f6..51b20c53 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -101,6 +101,16 @@ sub mocked_is_iscsi {
     return 0;
 }
 
+sub mocked_file_read_firstline {
+    my ($path) = @_;
+
+    my $originalsub = $diskmanage_module->original('file_read_firstline');
+
+    $path =~ s|^/sys/block|disk_tests/$testcasedir|;
+
+    return &$originalsub($path);
+}
+
 sub mocked_dir_glob_foreach {
     my ($dir, $regex, $sub) = @_;
 
@@ -248,6 +258,8 @@ $diskmanage_module->mock(
     },
 );
 print("\tMocked dir_is_empty\n");
+$diskmanage_module->mock('file_read_firstline' => \&mocked_file_read_firstline);
+print("\tMocked file_read_firstline\n");
 $diskmanage_module->mock('check_bin' => sub { return 1; });
 print("\tMocked check_bin\n");
 my $tools_module = Test::MockModule->new('PVE::ProcFSTools', no_auto => 1);




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 04/36] diskmanage: optionally include iSCSI session devices in disk enumeration
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (2 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 03/36] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 05/36] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
                   ` (32 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

The disk enumeration skips iSCSI session devices, as its callers
manage local disks. The SAN LUN inventory needs them, so let a caller
ask for them. Such a listing also skips the usage probes that read
from the devices (pvs, ceph-volume), as they can block on a LUN whose
paths are down.

Callers that do not ask get the same list as before, so local disk
operations keep refusing iSCSI LUNs.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: include the devices only on request instead of always, and skip
 the usage probes that read from devices then]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Diskmanage.pm                         | 33 +++++++++----------
 src/test/disk_tests/iscsi/disklist            |  1 +
 .../disk_tests/iscsi/disklist_expected.json   | 19 +++++++++++
 src/test/disk_tests/iscsi/lsblk               |  5 +++
 src/test/disk_tests/iscsi/sda/device/model    |  1 +
 src/test/disk_tests/iscsi/sda/device/vendor   |  1 +
 .../disk_tests/iscsi/sda/queue/rotational     |  1 +
 src/test/disk_tests/iscsi/sda/size            |  1 +
 src/test/disk_tests/iscsi/sda_udevadm         | 21 ++++++++++++
 src/test/disklist_test.pm                     | 20 +++++++----
 10 files changed, 79 insertions(+), 24 deletions(-)
 create mode 100644 src/test/disk_tests/iscsi/disklist
 create mode 100644 src/test/disk_tests/iscsi/disklist_expected.json
 create mode 100644 src/test/disk_tests/iscsi/lsblk
 create mode 100644 src/test/disk_tests/iscsi/sda/device/model
 create mode 100644 src/test/disk_tests/iscsi/sda/device/vendor
 create mode 100644 src/test/disk_tests/iscsi/sda/queue/rotational
 create mode 100644 src/test/disk_tests/iscsi/sda/size
 create mode 100644 src/test/disk_tests/iscsi/sda_udevadm

diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index 7862bcd4..5043a83d 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -92,6 +92,13 @@ sub parse_wipefs_signatures {
     return $probe->{signatures};
 }
 
+sub is_iscsi_device {
+    my ($dev) = @_;
+
+    my $link = readlink("/sys/block/$dev");
+    return defined($link) && $link =~ m{/session\d+/} ? 1 : 0;
+}
+
 sub disk_is_used {
     my ($disk) = @_;
 
@@ -263,7 +270,7 @@ sub get_zfs_devices {
 }
 
 sub get_lvm_devices {
-    my ($lsblk_info) = @_;
+    my ($lsblk_info, $no_probe) = @_;
     my $res = {};
     eval {
         run_command(
@@ -275,7 +282,7 @@ sub get_lvm_devices {
                     $res->{$line} = 1;
                 }
             },
-        );
+        ) if !$no_probe;
     };
 
     # if something goes wrong, we do not want to give up, but indicate an error has occurred
@@ -495,16 +502,6 @@ sub dir_is_empty {
     return 1;
 }
 
-sub is_iscsi {
-    my ($sysdir) = @_;
-
-    if (-l $sysdir && readlink($sysdir) =~ m|host[^/]*/session[^/]*|) {
-        return 1;
-    }
-
-    return 0;
-}
-
 # Returns the NVMe transport (pcie, fc, tcp, rdma, loop) of a namespace, either directly from
 # its controller, or from any controller of its subsystem for native NVMe multipath setups.
 sub get_nvme_transport {
@@ -557,7 +554,8 @@ sub mounted_paths {
 }
 
 sub get_disks {
-    my ($disks, $nosmart, $include_partitions) = @_;
+    my ($disks, $nosmart, $include_partitions, $san_inventory) = @_;
+    # SAN inventory includes iSCSI session devices and skips usage probes that read devices.
     my $disklist = {};
 
     my $mounted = mounted_blockdevs();
@@ -565,11 +563,11 @@ sub get_disks {
     my $lsblk_info = get_lsblk_info();
 
     my $journalhash = get_ceph_journals($lsblk_info);
-    my $ceph_volume_infos = get_ceph_volume_infos();
+    my $ceph_volume_infos = $san_inventory ? {} : get_ceph_volume_infos();
 
     my $zfshash = get_zfs_devices($lsblk_info);
 
-    my $lvmhash = get_lvm_devices($lsblk_info);
+    my $lvmhash = get_lvm_devices($lsblk_info, $san_inventory);
 
     my $disk_regex = ".*";
     if (defined($disks)) {
@@ -609,14 +607,13 @@ sub get_disks {
                 && $dev !~ m/^nvme\d+n\d+$/
                 && $dev !~ m/^cciss\!c\d+d\d+$/;
 
+            return if !$san_inventory && is_iscsi_device($dev);
+
             my $data = get_udev_info("/sys/block/$dev") // return;
             my $devpath = $data->{devpath};
 
             my $sysdir = "/sys/block/$dev";
 
-            # we do not want iscsi devices
-            return if is_iscsi($sysdir);
-
             my $nvme_transport;
             $nvme_transport = get_nvme_transport($sysdir) if $dev =~ m/^nvme/;
 
diff --git a/src/test/disk_tests/iscsi/disklist b/src/test/disk_tests/iscsi/disklist
new file mode 100644
index 00000000..9191c61b
--- /dev/null
+++ b/src/test/disk_tests/iscsi/disklist
@@ -0,0 +1 @@
+sda
diff --git a/src/test/disk_tests/iscsi/disklist_expected.json b/src/test/disk_tests/iscsi/disklist_expected.json
new file mode 100644
index 00000000..ca334106
--- /dev/null
+++ b/src/test/disk_tests/iscsi/disklist_expected.json
@@ -0,0 +1,19 @@
+{
+    "sda": {
+        "devpath": "/dev/sda",
+        "size": 10737418240,
+        "vendor": "LIO-ORG",
+        "model": "vdisk1",
+        "serial": "ISER1",
+        "wwn": "0x60014051111111111",
+        "gpt": 0,
+        "rpm": -1,
+        "type": "unknown",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/scsi-360014051111111111",
+        "transport": "iscsi"
+    }
+}
diff --git a/src/test/disk_tests/iscsi/lsblk b/src/test/disk_tests/iscsi/lsblk
new file mode 100644
index 00000000..526d27c5
--- /dev/null
+++ b/src/test/disk_tests/iscsi/lsblk
@@ -0,0 +1,5 @@
+{
+   "blockdevices": [
+      {"path":"/dev/sda", "parttype":null, "fstype":null, "tran":"iscsi"}
+   ]
+}
diff --git a/src/test/disk_tests/iscsi/sda/device/model b/src/test/disk_tests/iscsi/sda/device/model
new file mode 100644
index 00000000..b14d6fe7
--- /dev/null
+++ b/src/test/disk_tests/iscsi/sda/device/model
@@ -0,0 +1 @@
+vdisk1
diff --git a/src/test/disk_tests/iscsi/sda/device/vendor b/src/test/disk_tests/iscsi/sda/device/vendor
new file mode 100644
index 00000000..968831cd
--- /dev/null
+++ b/src/test/disk_tests/iscsi/sda/device/vendor
@@ -0,0 +1 @@
+LIO-ORG
diff --git a/src/test/disk_tests/iscsi/sda/queue/rotational b/src/test/disk_tests/iscsi/sda/queue/rotational
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/src/test/disk_tests/iscsi/sda/queue/rotational
@@ -0,0 +1 @@
+1
diff --git a/src/test/disk_tests/iscsi/sda/size b/src/test/disk_tests/iscsi/sda/size
new file mode 100644
index 00000000..14faeece
--- /dev/null
+++ b/src/test/disk_tests/iscsi/sda/size
@@ -0,0 +1 @@
+20971520
diff --git a/src/test/disk_tests/iscsi/sda_udevadm b/src/test/disk_tests/iscsi/sda_udevadm
new file mode 100644
index 00000000..ca9f7815
--- /dev/null
+++ b/src/test/disk_tests/iscsi/sda_udevadm
@@ -0,0 +1,21 @@
+P: /devices/platform/host5/session1/target5:0:0/5:0:0:0/block/sda
+N: sda
+S: disk/by-id/scsi-360014051111111111
+S: disk/by-id/wwn-0x60014051111111111
+S: disk/by-path/ip-192.168.1.10:3260-iscsi-iqn.2003-01.org.linux-iscsi.storage:target1-lun-0
+E: DEVLINKS=/dev/disk/by-id/scsi-360014051111111111 /dev/disk/by-id/wwn-0x60014051111111111 /dev/disk/by-path/ip-192.168.1.10:3260-iscsi-iqn.2003-01.org.linux-iscsi.storage:target1-lun-0
+E: DEVNAME=/dev/sda
+E: DEVPATH=/devices/platform/host5/session1/target5:0:0/5:0:0:0/block/sda
+E: DEVTYPE=disk
+E: ID_BUS=scsi
+E: ID_MODEL=vdisk1
+E: ID_PATH=ip-192.168.1.10:3260-iscsi-iqn.2003-01.org.linux-iscsi.storage:target1-lun-0
+E: ID_SCSI=1
+E: ID_SERIAL=36001405111111111
+E: ID_SERIAL_SHORT=ISER1
+E: ID_TYPE=disk
+E: ID_VENDOR=LIO-ORG
+E: ID_WWN=0x60014051111111111
+E: MAJOR=8
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index 51b20c53..bd70dc33 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -97,10 +97,6 @@ sub mocked_get_sysdir_size {
     return &$originalsub($param);
 }
 
-sub mocked_is_iscsi {
-    return 0;
-}
-
 sub mocked_file_read_firstline {
     my ($path) = @_;
 
@@ -173,6 +169,7 @@ sub test_disk_list {
         eval { $disks = PVE::Diskmanage::get_disks(); };
         warn $@ if $@;
         $expected_disk_list = decode_json(read_test_file('disklist_expected.json'));
+        $expected_disk_list = {} if $testcasedir eq 'iscsi';
 
         print Dumper($disks) if $print;
         $testcount++;
@@ -223,6 +220,16 @@ sub test_disk_list {
         $testcount++;
         is_deeply($disks, $expected_disk_list, 'disk list should be the same');
 
+        if ($testcasedir eq 'iscsi') {
+            eval { PVE::Diskmanage::assert_disk_unused('/dev/sda'); };
+            $testcount++;
+            like($@, qr/not a valid local disk/, 'local disk operations reject an iSCSI LUN');
+
+            my $san_disks = PVE::Diskmanage::get_disks(undef, 1, 0, 1);
+            $testcount++;
+            ok($san_disks->{sda}, 'SAN inventory opts into iSCSI');
+        }
+
         done_testing($testcount);
     };
 }
@@ -243,8 +250,6 @@ $diskmanage_module->mock('get_sysdir_info' => \&mocked_get_sysdir_info);
 print("\tMocked get_sysdir_info\n");
 $diskmanage_module->mock('get_sysdir_size' => \&mocked_get_sysdir_size);
 print("\tMocked get_sysdir_size\n");
-$diskmanage_module->mock('is_iscsi' => \&mocked_is_iscsi);
-print("\tMocked is_iscsi\n");
 $diskmanage_module->mock('assert_blockdev' => sub { return 1; });
 print("\tMocked assert_blockdev\n");
 $diskmanage_module->mock(
@@ -262,6 +267,9 @@ $diskmanage_module->mock('file_read_firstline' => \&mocked_file_read_firstline);
 print("\tMocked file_read_firstline\n");
 $diskmanage_module->mock('check_bin' => sub { return 1; });
 print("\tMocked check_bin\n");
+# the test cases name iSCSI LUNs through the lsblk transport, the sysfs of the host must not count
+$diskmanage_module->mock('is_iscsi_device' => sub { return $testcasedir eq 'iscsi'; });
+print("\tMocked is_iscsi_device\n");
 my $tools_module = Test::MockModule->new('PVE::ProcFSTools', no_auto => 1);
 $tools_module->mock('parse_proc_mounts' => \&mocked_parse_proc_mounts);
 print("\tMocked parse_proc_mounts\n");




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 05/36] diskmanage: collect native NVMe multipath path state
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (3 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 04/36] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 06/36] iscsi: factor out session device map from device list Thomas Lamprecht
                   ` (31 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

NVMe over Fabrics usually uses native multipath, whose paths
multipathd does not know. Collect the controller state and address
and the ANA state of each path from sysfs, grouped by namespace, so
the SAN LUN inventory can report path health for both multipath
stacks. Devices with a single local controller have no per-path
entries and are left out.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: drop redundant comments]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Diskmanage.pm                         | 60 +++++++++++++++++++
 .../nvme-subsystem/nvme-subsys0/nvme3/address |  1 +
 .../nvme-subsys0/nvme3/nvme2c3n1/ana_state    |  1 +
 .../nvme-subsystem/nvme-subsys0/nvme3/state   |  1 +
 .../nvme-subsystem/nvme-subsys0/nvme4/address |  1 +
 .../nvme-subsys0/nvme4/nvme2c4n1/ana_state    |  1 +
 .../nvme-subsystem/nvme-subsys0/nvme4/state   |  1 +
 .../nvme-subsystem/nvme-subsys1/nvme0/address |  1 +
 .../nvme-subsystem/nvme-subsys1/nvme0/state   |  1 +
 .../multipath/nvme_path_status_expected.json  | 19 ++++++
 src/test/disklist_test.pm                     | 16 +++++
 11 files changed, 103 insertions(+)
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/address
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/nvme2c3n1/ana_state
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/state
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/address
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/nvme2c4n1/ana_state
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/state
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/address
 create mode 100644 src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/state
 create mode 100644 src/test/disk_tests/multipath/nvme_path_status_expected.json

diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index 5043a83d..d5251095 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -816,6 +816,66 @@ sub get_disks {
     return $disklist;
 }
 
+# Native multipath creates per-path namespace children nvmeXcYnZ below controllers. Local
+# single-controller devices lack these children and are omitted.
+sub get_nvme_path_status {
+    my $res = {};
+
+    dir_glob_foreach(
+        '/sys/class/nvme-subsystem',
+        'nvme-subsys\d+',
+        sub {
+            my ($subsys) = @_;
+            my $subsysdir = "/sys/class/nvme-subsystem/$subsys";
+
+            dir_glob_foreach(
+                $subsysdir,
+                'nvme\d+',
+                sub {
+                    my ($ctrl) = @_;
+                    my $ctrldir = "$subsysdir/$ctrl";
+                    my $state = file_read_firstline("$ctrldir/state") // return;
+                    my $address = file_read_firstline("$ctrldir/address");
+
+                    dir_glob_foreach(
+                        $ctrldir,
+                        'nvme\d+c\d+n\d+',
+                        sub {
+                            my ($pathdev) = @_;
+                            return if $pathdev !~ m/^nvme(\d+)c\d+n(\d+)$/;
+                            my $head = "nvme$1n$2";
+
+                            my $entry = { device => "/dev/$ctrl", state => $state };
+                            $entry->{address} = $address
+                                if defined($address) && $address ne '';
+                            my $ana = file_read_firstline("$ctrldir/$pathdev/ana_state");
+                            $entry->{'ana-state'} = $ana if defined($ana);
+
+                            # 'change' is transient; paths in 'inaccessible' or 'persistent-loss'
+                            # cannot serve IO even on a live controller
+                            my $usable = $state eq 'live'
+                                && (!defined($ana)
+                                    || $ana eq 'optimized'
+                                    || $ana eq 'non-optimized');
+
+                            my $status = $res->{$head} //= { active => 0, paths => [] };
+                            $status->{active}++ if $usable;
+                            push @{ $status->{paths} }, $entry;
+                        },
+                    );
+                },
+            );
+        },
+    );
+
+    for my $status (values %$res) {
+        @{ $status->{paths} } =
+            sort { $a->{device} cmp $b->{device} } @{ $status->{paths} };
+    }
+
+    return $res;
+}
+
 sub get_partnum {
     my ($part_path) = @_;
 
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/address b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/address
new file mode 100644
index 00000000..803fab3e
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/address
@@ -0,0 +1 @@
+traddr=192.168.3.209,trsvcid=4420,src_addr=192.168.2.171
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/nvme2c3n1/ana_state b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/nvme2c3n1/ana_state
new file mode 100644
index 00000000..e48c58f5
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/nvme2c3n1/ana_state
@@ -0,0 +1 @@
+optimized
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/state b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/state
new file mode 100644
index 00000000..e23fe645
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme3/state
@@ -0,0 +1 @@
+live
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/address b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/address
new file mode 100644
index 00000000..36618744
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/address
@@ -0,0 +1 @@
+traddr=192.168.3.109,trsvcid=4420,src_addr=192.168.2.171
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/nvme2c4n1/ana_state b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/nvme2c4n1/ana_state
new file mode 100644
index 00000000..436c48ee
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/nvme2c4n1/ana_state
@@ -0,0 +1 @@
+inaccessible
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/state b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/state
new file mode 100644
index 00000000..e23fe645
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys0/nvme4/state
@@ -0,0 +1 @@
+live
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/address b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/address
new file mode 100644
index 00000000..f99fcb14
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/address
@@ -0,0 +1 @@
+0000:02:00.0
diff --git a/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/state b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/state
new file mode 100644
index 00000000..e23fe645
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme-subsystem/nvme-subsys1/nvme0/state
@@ -0,0 +1 @@
+live
diff --git a/src/test/disk_tests/multipath/nvme_path_status_expected.json b/src/test/disk_tests/multipath/nvme_path_status_expected.json
new file mode 100644
index 00000000..62611b3f
--- /dev/null
+++ b/src/test/disk_tests/multipath/nvme_path_status_expected.json
@@ -0,0 +1,19 @@
+{
+    "nvme2n1": {
+        "active": 1,
+        "paths": [
+            {
+                "device": "/dev/nvme3",
+                "state": "live",
+                "address": "traddr=192.168.3.209,trsvcid=4420,src_addr=192.168.2.171",
+                "ana-state": "optimized"
+            },
+            {
+                "device": "/dev/nvme4",
+                "state": "live",
+                "address": "traddr=192.168.3.109,trsvcid=4420,src_addr=192.168.2.171",
+                "ana-state": "inaccessible"
+            }
+        ]
+    }
+}
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index bd70dc33..0d34c0db 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -103,6 +103,7 @@ sub mocked_file_read_firstline {
     my $originalsub = $diskmanage_module->original('file_read_firstline');
 
     $path =~ s|^/sys/block|disk_tests/$testcasedir|;
+    $path =~ s|^/sys/class/nvme-subsystem|disk_tests/$testcasedir/nvme-subsystem|;
 
     return &$originalsub($path);
 }
@@ -112,6 +113,12 @@ sub mocked_dir_glob_foreach {
 
     my $lines = [];
 
+    # nvme subsystem trees are provided as directories, glob them like production code
+    if ($dir =~ s|^/sys/class/nvme-subsystem|disk_tests/$testcasedir/nvme-subsystem|) {
+        my $originalsub = $diskmanage_module->original('dir_glob_foreach');
+        return &$originalsub($dir, $regex, $sub);
+    }
+
     # read lines in from file
     if ($dir =~ m{^/sys/block$}) {
         @$lines = split(/\n/, read_test_file('disklist'));
@@ -230,6 +237,15 @@ sub test_disk_list {
             ok($san_disks->{sda}, 'SAN inventory opts into iSCSI');
         }
 
+        if (-f "disk_tests/$testcasedir/nvme_path_status_expected.json") {
+            my $status = PVE::Diskmanage::get_nvme_path_status();
+            my $expected_status = decode_json(read_test_file('nvme_path_status_expected.json'));
+
+            print Dumper($status) if $print;
+            $testcount++;
+            is_deeply($status, $expected_status, 'nvme path status should be the same');
+        }
+
         done_testing($testcount);
     };
 }




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 06/36] iscsi: factor out session device map from device list
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (4 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 05/36] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 07/36] multipath: add a library around multipathd Thomas Lamprecht
                   ` (30 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

The SAN LUN inventory and the multipath handling need to know which
block devices belong to which iSCSI session, target and LUN. So far
only the device list of the plugin collects that. Provide it as a map
from kernel device names in a module of its own and build the device
list from it.

The device list stays the same. Only the fallback for the
'block:<name>' links that old kernels had instead of the 'block'
directory is gone.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: put the session walk into the new PVE::ISCSI::Topology module
 instead of the plugin; drop the fallback for old kernels]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/ISCSI/Topology.pm      |  75 +++++++++++++++++++++++
 src/PVE/Makefile               |   1 +
 src/PVE/Storage/ISCSIPlugin.pm | 107 +++++++++------------------------
 3 files changed, 106 insertions(+), 77 deletions(-)
 create mode 100644 src/PVE/ISCSI/Topology.pm

diff --git a/src/PVE/ISCSI/Topology.pm b/src/PVE/ISCSI/Topology.pm
new file mode 100644
index 00000000..fae1f6e7
--- /dev/null
+++ b/src/PVE/ISCSI/Topology.pm
@@ -0,0 +1,75 @@
+package PVE::ISCSI::Topology;
+
+use strict;
+use warnings;
+
+use PVE::Tools qw(dir_glob_foreach dir_glob_regex file_read_firstline);
+
+our $SYSFS = '/sys';
+
+sub foreach_session_lun {
+    my ($sessiondir, $code) = @_;
+    dir_glob_foreach(
+        $sessiondir,
+        'target\d+:\d+:\d+',
+        sub {
+            my ($targetdir) = @_;
+            dir_glob_foreach(
+                "$sessiondir/$targetdir",
+                '\d+:(\d+):(\d+):(\d+)',
+                sub {
+                    my ($hctl, $channel, $id, $lun) = @_;
+                    $code->("$sessiondir/$targetdir/$hctl", $channel, $id, $lun);
+                },
+            );
+        },
+    );
+}
+
+sub sessions {
+    my ($sysfs) = @_;
+    $sysfs //= $SYSFS;
+    my $res = {};
+    dir_glob_foreach(
+        "$sysfs/class/iscsi_session",
+        'session(\d+)',
+        sub {
+            my ($ent, $sid) = @_;
+            my $dir = "$sysfs/class/iscsi_session/$ent";
+            my $target = file_read_firstline("$dir/targetname") // return;
+            my $session = {
+                target => $target,
+                devices => {},
+            };
+            foreach_session_lun(
+                "$dir/device",
+                sub {
+                    my ($devdir, $channel, $id, $lun) = @_;
+                    return if (file_read_firstline("$devdir/type") // '') ne '0';
+                    my (undef, $dev) = dir_glob_regex("$devdir/block/", '([A-Za-z]\S*)');
+                    return if !defined($dev);
+                    $session->{devices}->{$dev} = {
+                        target => $target,
+                        session => int($sid),
+                        channel => int($channel),
+                        id => int($id),
+                        lun => int($lun),
+                    };
+                },
+            );
+            $res->{$sid} = $session;
+        },
+    );
+    return $res;
+}
+
+sub device_map {
+    my ($sysfs) = @_;
+    my $res = {};
+    for my $session (values %{ sessions($sysfs) }) {
+        $res->{$_} = $session->{devices}->{$_} for keys $session->{devices}->%*;
+    }
+    return $res;
+}
+
+1;
diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index 9e9f6aac..bd2ddfb9 100644
--- a/src/PVE/Makefile
+++ b/src/PVE/Makefile
@@ -4,6 +4,7 @@
 install:
 	install -D -m 0644 Storage.pm ${DESTDIR}${PERLDIR}/PVE/Storage.pm
 	install -D -m 0644 Diskmanage.pm ${DESTDIR}${PERLDIR}/PVE/Diskmanage.pm
+	install -D -m 0644 ISCSI/Topology.pm ${DESTDIR}${PERLDIR}/PVE/ISCSI/Topology.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/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index bb400fe6..373f9f84 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::Storage::Plugin;
+use PVE::ISCSI::Topology;
 use PVE::Tools
     qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach $IPV4RE $IPV6RE);
 
@@ -290,89 +291,41 @@ sub load_stable_scsi_paths {
     return $stable_paths;
 }
 
-# Offload initiators can run several sessions on one SCSI host, so the LUNs of a session are the
-# ones below its own target, not all LUNs of its host.
-my sub foreach_session_lun {
-    my ($sessiondir, $code) = @_;
-
-    dir_glob_foreach(
-        $sessiondir,
-        'target\d+:\d+:\d+',
-        sub {
-            my ($targetdir) = @_;
-            dir_glob_foreach(
-                "$sessiondir/$targetdir",
-                '\d+:(\d+):(\d+):(\d+)',
-                sub {
-                    my ($hctl, $channel, $id, $lun) = @_;
-                    $code->("$sessiondir/$targetdir/$hctl", $channel, $id, $lun);
-                },
-            );
-        },
-    );
-}
-
 sub iscsi_device_list {
 
     my $res = {};
 
-    my $dirname = "$SYSFS/class/iscsi_session";
-
     my $stable_paths = load_stable_scsi_paths();
 
-    dir_glob_foreach(
-        $dirname,
-        'session(\d+)',
-        sub {
-            my ($ent, $session) = @_;
-
-            my $target = file_read_firstline("$dirname/$ent/targetname");
-            return if !$target;
-
-            foreach_session_lun(
-                "$dirname/$ent/device",
-                sub {
-                    my ($devdir, $channel, $id, $lun) = @_;
-
-                    my $type = file_read_firstline("$devdir/type");
-                    return if !defined($type) || $type ne '0'; # list disks only
-
-                    my $bdev;
-                    if (-d "$devdir/block") { # newer kernels
-                        (undef, $bdev) = dir_glob_regex("$devdir/block/", '([A-Za-z]\S*)');
-                    } else {
-                        (undef, $bdev) = dir_glob_regex($devdir, 'block:(\S+)');
-                    }
-                    return if !$bdev;
-
-                    #check multipath
-                    if (-d "$SYSFS/block/$bdev/holders") {
-                        my $multipathdev =
-                            dir_glob_regex("$SYSFS/block/$bdev/holders", '[A-Za-z]\S*');
-                        $bdev = $multipathdev if $multipathdev;
-                    }
-
-                    my $blockdev = $stable_paths->{$bdev};
-                    return if !$blockdev;
-
-                    my $size = file_read_firstline("$SYSFS/block/$bdev/size");
-                    return if !$size;
-
-                    my $volid = "$channel.$id.$lun.$blockdev";
-
-                    $res->{$target}->{$volid} = {
-                        'format' => 'raw',
-                        'size' => int($size * 512),
-                        'vmid' => 0, # not assigned to any vm
-                        'channel' => int($channel),
-                        'id' => int($id),
-                        'lun' => int($lun),
-                    };
-                },
-            );
-
-        },
-    );
+    my $device_map = PVE::ISCSI::Topology::device_map($SYSFS);
+
+    for my $bdev (sort keys %$device_map) {
+        my $info = $device_map->{$bdev};
+        my ($channel, $id, $lun) = $info->@{qw(channel id lun)};
+
+        #check multipath
+        if (-d "$SYSFS/block/$bdev/holders") {
+            my $multipathdev = dir_glob_regex("$SYSFS/block/$bdev/holders", '[A-Za-z]\S*');
+            $bdev = $multipathdev if $multipathdev;
+        }
+
+        my $blockdev = $stable_paths->{$bdev};
+        next if !$blockdev;
+
+        my $size = file_read_firstline("$SYSFS/block/$bdev/size");
+        next if !$size;
+
+        my $volid = "$channel.$id.$lun.$blockdev";
+
+        $res->{ $info->{target} }->{$volid} = {
+            'format' => 'raw',
+            'size' => int($size * 512),
+            'vmid' => 0, # not assigned to any vm
+            'channel' => $channel,
+            'id' => $id,
+            'lun' => $lun,
+        };
+    }
 
     return $res;
 }




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 07/36] multipath: add a library around multipathd
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (5 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 06/36] iscsi: factor out session device map from device list Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 08/36] diskmanage: add helper to list multipath devices Thomas Lamprecht
                   ` (29 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

The SAN LUN inventory, the per-node status and the iSCSI plugin need
the multipath maps of a node and the state of their paths. Add a
module that reads the maps and their member devices from sysfs and
the path states from multipathd, with a timeout for the queries. Maps
are identified by the WWID of their LUN, which is the same on all
nodes. The iSCSI plugin uses the module to recognize a map already.

multipath-tools is only recommended, as storages that do not use
multipath work without it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 debian/control                       |   3 +-
 src/PVE/Makefile                     |   1 +
 src/PVE/Multipath.pm                 | 134 +++++++++++++++++++++++++++
 src/PVE/Storage/ISCSIPlugin.pm       |   3 +-
 src/test/Makefile                    |   5 +-
 src/test/multipath-three-states.json |  52 +++++++++++
 src/test/run_multipath_tests.pl      | 106 +++++++++++++++++++++
 7 files changed, 301 insertions(+), 3 deletions(-)
 create mode 100644 src/PVE/Multipath.pm
 create mode 100644 src/test/multipath-three-states.json
 create mode 100755 src/test/run_multipath_tests.pl

diff --git a/debian/control b/debian/control
index 3a86607e..14d8a648 100644
--- a/debian/control
+++ b/debian/control
@@ -54,7 +54,8 @@ Depends: bzip2,
          zstd,
          ${misc:Depends},
          ${perl:Depends},
-Recommends: pve-esxi-import-tools (>= 0.6.0),
+Recommends: multipath-tools,
+            pve-esxi-import-tools (>= 0.6.0),
             skopeo,
             zfsutils-linux (>= 2.4.1-pve2),
             zfs-zed,
diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index bd2ddfb9..db1c340d 100644
--- a/src/PVE/Makefile
+++ b/src/PVE/Makefile
@@ -5,6 +5,7 @@ install:
 	install -D -m 0644 Storage.pm ${DESTDIR}${PERLDIR}/PVE/Storage.pm
 	install -D -m 0644 Diskmanage.pm ${DESTDIR}${PERLDIR}/PVE/Diskmanage.pm
 	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 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
new file mode 100644
index 00000000..67ee39e9
--- /dev/null
+++ b/src/PVE/Multipath.pm
@@ -0,0 +1,134 @@
+package PVE::Multipath;
+
+use v5.36;
+
+use Encode qw(decode encode);
+use JSON qw(decode_json);
+use PVE::Diskmanage;
+use PVE::Tools qw(run_command file_read_firstline dir_glob_foreach);
+
+my $MULTIPATH = '/sbin/multipath';
+my $MULTIPATHD = '/sbin/multipathd';
+
+sub parse_dm_uuid($uuid) {
+    my ($part, $wwid) = ($uuid // '') =~ /^(?:part([1-9]\d*)-)?mpath-(\S+)$/;
+    return undef if !defined($wwid);
+    return { wwid => $wwid, defined($part) ? (partition => int($part)) : () };
+}
+
+sub map_info() {
+    my $maps = {};
+    dir_glob_foreach(
+        '/sys/block',
+        'dm-\\d+',
+        sub($dev, @) {
+            my $info = parse_dm_uuid(file_read_firstline("/sys/block/$dev/dm/uuid"));
+            return if !$info || $info->{partition};
+            my $name = file_read_firstline("/sys/block/$dev/dm/name") // return;
+            my @slaves;
+            dir_glob_foreach(
+                "/sys/block/$dev/slaves",
+                '[^.].*',
+                sub($slave, @) { push @slaves, $slave },
+            );
+            $maps->{$dev} = { %$info, name => $name, slaves => [sort @slaves] };
+        },
+    );
+    return $maps;
+}
+
+sub member_map($maps) {
+    my $members = {};
+    for my $dev (sort keys %$maps) {
+        $members->{$_} = $dev for $maps->{$dev}->{slaves}->@*;
+    }
+    return $members;
+}
+
+sub is_supported() { return -x $MULTIPATH && -x $MULTIPATHD ? 1 : 0 }
+sub assert_supported() { die "multipath-tools is not installed\n" if !is_supported() }
+
+sub is_running() {
+    return 0 if !is_supported();
+    my $running = 0;
+    eval {
+        run_command(
+            [$MULTIPATHD, 'show', 'daemon'],
+            timeout => 10,
+            outfunc => sub($line) { $running = 1 if $line =~ /^pid \d+ \S+/ },
+            errfunc => sub($line) { },
+        );
+    };
+    return $running;
+}
+
+my sub string_value($value) {
+    return undef if !defined($value) || $value eq '' || $value eq '[undef]';
+    die "invalid string in multipathd output\n" if ref($value);
+    return $value;
+}
+
+sub path_is_usable($path) {
+    return ($path->{'dm-state'} // '') eq 'active'
+        && (!defined($path->{'check-state'}) || $path->{'check-state'} =~ /^(?:ready|ghost)$/);
+}
+
+sub derive_health($active, $total, $expected = undef) {
+    return 'failed' if !$total || !$active;
+    return 'degraded' if $active < $total || $total < ($expected // 0);
+    return 'optimal';
+}
+
+sub parse_maps_json($json) {
+    $json = decode('UTF-8', $json) if !utf8::is_utf8($json);
+    my $data = decode_json(encode('UTF-8', $json));
+    die "invalid multipathd maps output\n"
+        if ref($data) ne 'HASH' || ref($data->{maps} // []) ne 'ARRAY';
+    my @maps;
+    for my $raw (($data->{maps} // [])->@*) {
+        die "invalid multipathd map\n" if ref($raw) ne 'HASH';
+        my $map = { paths => [], 'paths-total' => 0, 'paths-active' => 0 };
+        for my $pair ([uuid => 'wwid'], [name => 'name'], [sysfs => 'sysfs']) {
+            my $value = string_value($raw->{ $pair->[0] });
+            $map->{ $pair->[1] } = $value if defined($value);
+        }
+        for my $group (($raw->{path_groups} // [])->@*) {
+            for my $rawpath (($group->{paths} // [])->@*) {
+                my $path = { dev => string_value($rawpath->{dev}) // '' };
+                for my $pair (
+                    [dm_st => 'dm-state'],
+                    [chk_st => 'check-state'],
+                    [host_wwpn => 'host-wwpn'],
+                    [target_wwpn => 'target-wwpn'],
+                ) {
+                    my $value = string_value($rawpath->{ $pair->[0] });
+                    next if !defined($value) || ($pair->[0] =~ /wwpn$/ && $value eq '[unknown]');
+                    $path->{ $pair->[1] } = $value;
+                }
+                push $map->{paths}->@*, $path;
+                $map->{'paths-total'}++;
+                $map->{'paths-active'}++ if path_is_usable($path);
+            }
+        }
+        push @maps, $map;
+    }
+    return \@maps;
+}
+
+sub get_maps() {
+    assert_supported();
+    my $json = '';
+    run_command(
+        [$MULTIPATHD, 'show', 'maps', 'json'],
+        timeout => 10,
+        outfunc => sub($line) { $json .= "$line\n" },
+    );
+    my $maps = parse_maps_json($json);
+    for my $map (@$maps) {
+        $map->{size} = PVE::Diskmanage::get_sysdir_size("/sys/block/$map->{sysfs}")
+            if $map->{sysfs};
+    }
+    return $maps;
+}
+
+1;
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 373f9f84..70c0e9dc 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -9,6 +9,7 @@ use IO::Dir;
 use IO::File;
 
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::Multipath;
 use PVE::Storage::Plugin;
 use PVE::ISCSI::Topology;
 use PVE::Tools
@@ -582,7 +583,7 @@ $resolve_virtual_devices = sub {
         my $uuid = file_read_firstline("/sys/$dev/dm/uuid") // '';
         my ($name) = $dev =~ m!([^/]+)$!;
         die "'$name' is neither a multipath map nor a partition of one\n"
-            if $uuid !~ m/^(?:part\d+-)?mpath-\S+$/;
+            if !PVE::Multipath::parse_dm_uuid($uuid);
 
         dir_glob_foreach(
             "/sys/$dev/slaves",
diff --git a/src/test/Makefile b/src/test/Makefile
index 185b8ef7..3098bb15 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: 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_multipath
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -46,3 +46,6 @@ test_iscsi: run_iscsi_discovery_tests.pl run_iscsi_rescan_tests.pl run_iscsi_dev
 	./run_iscsi_device_list_tests.pl
 	./run_iscsi_session_tests.pl
 	./run_iscsi_volume_tests.pl
+
+test_multipath: run_multipath_tests.pl
+	./run_multipath_tests.pl
diff --git a/src/test/multipath-three-states.json b/src/test/multipath-three-states.json
new file mode 100644
index 00000000..b39b123f
--- /dev/null
+++ b/src/test/multipath-three-states.json
@@ -0,0 +1,52 @@
+{
+    "major_version": 0,
+    "minor_version": 1,
+    "maps": [
+        {
+            "name": "mpatha",
+            "uuid": "3600140500a1b2c3d4e5f6a7b8c9d0e1f",
+            "sysfs": "dm-0",
+            "dm_st": "active",
+            "paths": 2,
+            "path_faults": 0,
+            "path_groups": [{
+                "group": 1,
+                "dm_st": "active",
+                "pri": 50,
+                "paths": [
+                    { "dev": "sdb", "dm_st": "active", "dev_st": "running", "chk_st": "ready", "pri": 50, "host_wwpn": "0x21000024ff7d6a1c", "target_wwpn": "0x500a098000000001" },
+                    { "dev": "sdc", "dm_st": "active", "dev_st": "running", "chk_st": "ready", "pri": 50, "host_wwpn": "0x21000024ff7d6a1d", "target_wwpn": "0x500a098000000002" }
+                ]
+            }]
+        },
+        {
+            "name": "mpathb",
+            "uuid": "360014050aabbccddeeff00112233445566",
+            "sysfs": "dm-1",
+            "dm_st": "active",
+            "paths": 2,
+            "path_faults": 3,
+            "path_groups": [
+                { "group": 1, "dm_st": "active", "pri": 10, "paths": [
+                    { "dev": "sdd", "dm_st": "active", "dev_st": "running", "chk_st": "ready", "pri": 10 }
+                ] },
+                { "group": 2, "dm_st": "enabled", "pri": 0, "paths": [
+                    { "dev": "sde", "dm_st": "failed", "dev_st": "offline", "chk_st": "faulty", "pri": 0 }
+                ] }
+            ]
+        },
+        {
+            "name": "mpathc",
+            "uuid": "36001405ffffffffffffffffffffffffff",
+            "sysfs": "dm-2",
+            "dm_st": "active",
+            "paths": 1,
+            "path_groups": [{
+                "group": 1,
+                "dm_st": "enabled",
+                "pri": 0,
+                "paths": [{ "dev": "sdf", "dm_st": "failed", "dev_st": "offline", "chk_st": "faulty", "pri": 0, "target_wwpn": "[undef]", "host_adapter": "[undef]" }]
+            }]
+        }
+    ]
+}
diff --git a/src/test/run_multipath_tests.pl b/src/test/run_multipath_tests.pl
new file mode 100755
index 00000000..b1248ad0
--- /dev/null
+++ b/src/test/run_multipath_tests.pl
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+
+use v5.36;
+use lib ('.', '..');
+use Test::More;
+use PVE::Multipath;
+use PVE::Tools qw(file_get_contents);
+
+subtest 'multipathd JSON fixtures' => sub {
+    my $maps =
+        PVE::Multipath::parse_maps_json(file_get_contents('multipath-three-states.json'));
+    is_deeply(
+        [map { [$_->{'paths-active'}, $_->{'paths-total'}] } @$maps],
+        [[2, 2], [1, 2], [0, 1]],
+        'fixture path counts',
+    );
+    is_deeply(
+        [
+            map { PVE::Multipath::derive_health($_->{'paths-active'}, $_->{'paths-total'}) }
+                @$maps
+        ],
+        [qw(optimal degraded failed)],
+        'health is derived by consumers',
+    );
+    is_deeply(
+        [sort keys $maps->[0]->%*],
+        [qw(name paths paths-active paths-total sysfs wwid)],
+        'only consumed map fields are parsed',
+    );
+    is_deeply(
+        [sort keys $maps->[0]->{paths}->[0]->%*],
+        [qw(check-state dev dm-state host-wwpn target-wwpn)],
+        'only consumed path fields are parsed',
+    );
+    is($maps->[0]->{paths}->[0]->{'target-wwpn'}, '0x500a098000000001', 'FC target port');
+    my $json = '{ "maps": [ { "uuid": "3600a", "path_groups": [
+        { "group": 1, "pri": 50, "paths": [ { "dev": "sda", "dm_st": "active", "chk_st": "ready" } ] },
+        { "group": 2, "pri": 10, "paths": [ { "dev": "sdb", "dm_st": "active", "chk_st": "ghost" } ] }
+    ] } ] }';
+    my $map = PVE::Multipath::parse_maps_json($json)->[0];
+    is($map->{'paths-active'}, 2, 'ALUA ghost path is usable');
+    is_deeply(
+        [map { $_->{dev} } $map->{paths}->@*],
+        ['sda', 'sdb'],
+        'groups flatten into one path list',
+    );
+    $json =~ s/"ghost"/"faulty"/;
+    is(
+        PVE::Multipath::parse_maps_json($json)->[0]->{'paths-active'},
+        1,
+        'faulty path is unusable',
+    );
+    $json =~ s/"ready"/"faulty"/;
+    is(PVE::Multipath::parse_maps_json($json)->[0]->{'paths-active'}, 0, 'no usable paths');
+    $json = '{ "maps": [ { "uuid": "3600a", "path_faults": "7", "path_groups": [
+        { "group": "1", "pri": "50", "paths": [ { "dev": "sda", "dm_st": "active", "pri": "50" } ] }
+    ] } ] }';
+    $map = PVE::Multipath::parse_maps_json($json)->[0];
+    is_deeply(
+        $map,
+        {
+            wwid => '3600a',
+            'paths-active' => 1,
+            'paths-total' => 1,
+            paths => [{ dev => 'sda', 'dm-state' => 'active' }],
+        },
+        'numeric strings in unused fields are ignored',
+    );
+    $json = '{ "maps": [ { "uuid": "3600a", "path_groups": [ { "group": 1, "pri": 50, "paths": [
+        { "dev": "sda", "dm_st": "active", "host_wwpn": "[unknown]", "target_wwpn": "[unknown]" }
+    ] } ] } ] }';
+    my $path = PVE::Multipath::parse_maps_json($json)->[0]->{paths}->[0];
+    ok(!exists($path->{'host-wwpn'}), 'unknown WWPN is omitted');
+    $json =~ s/\[unknown\]/[undef]/g;
+    $path = PVE::Multipath::parse_maps_json($json)->[0]->{paths}->[0];
+    ok(!exists($path->{'target-wwpn'}), 'undefined WWPN is omitted');
+    is(
+        PVE::Multipath::parse_maps_json("{\"maps\":[{\"name\":\"lun\xff\"}]}")->[0]->{name},
+        "lun\x{fffd}",
+        'invalid UTF-8 alias is replaced, not a query failure',
+    );
+    is_deeply(PVE::Multipath::parse_maps_json('{}'), [], 'empty response');
+    is_deeply(PVE::Multipath::parse_maps_json('{"maps":[]}'), [], 'empty list');
+    eval { PVE::Multipath::parse_maps_json('not json') };
+    ok($@, 'invalid JSON fails');
+    is(PVE::Multipath::derive_health(1, 1, 2), 'degraded', 'removed expected path is degraded');
+    is(PVE::Multipath::derive_health(0, 0), 'failed', 'empty map is failed');
+};
+
+subtest 'one owner for map identity and membership' => sub {
+    is_deeply(PVE::Multipath::parse_dm_uuid('mpath-3600a'), { wwid => '3600a' }, 'whole map');
+    is_deeply(
+        PVE::Multipath::parse_dm_uuid('part2-mpath-3600a'),
+        { wwid => '3600a', partition => 2 },
+        'partition of map',
+    );
+    ok(!PVE::Multipath::parse_dm_uuid('LVM-abc'), 'LV is not a multipath map');
+    ok(!PVE::Multipath::parse_dm_uuid(undef), 'no identity does not invent a map');
+    is_deeply(
+        PVE::Multipath::member_map({ 'dm-0' => { slaves => ['sdb', 'sdc'] } }),
+        { sdb => 'dm-0', sdc => 'dm-0' },
+        'membership belongs to the map facts',
+    );
+};
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 08/36] diskmanage: add helper to list multipath devices
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (6 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 07/36] multipath: add a library around multipathd Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 09/36] multipath: add a cluster-wide configuration Thomas Lamprecht
                   ` (28 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

The disk enumeration leaves out multipath maps, as its callers manage
local disks. The SAN LUN inventory needs them, so add a separate
helper. It takes vendor, model and transport from a member path and
reuses the usage detection to tell unused LUNs from LVM physical
volumes and other uses.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: take the maps and their members from PVE::Multipath instead of
 reading sysfs here; never probe with pvs, which can block on a map;
 drop redundant comments]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Diskmanage.pm                         | 65 ++++++++++++++++-
 src/test/disk_tests/multipath/disklist        |  9 +++
 .../multipath/disklist_expected.json          | 72 +++++++++++++++++++
 src/test/disk_tests/multipath/dm-0/dm/name    |  1 +
 src/test/disk_tests/multipath/dm-0/dm/uuid    |  1 +
 src/test/disk_tests/multipath/dm-0/size       |  1 +
 src/test/disk_tests/multipath/dm-0_slaves     |  4 ++
 src/test/disk_tests/multipath/dm-1/dm/name    |  1 +
 src/test/disk_tests/multipath/dm-1/dm/uuid    |  1 +
 src/test/disk_tests/multipath/dm-1/size       |  1 +
 src/test/disk_tests/multipath/dm-1_slaves     |  4 ++
 src/test/disk_tests/multipath/dm-2/dm/name    |  1 +
 src/test/disk_tests/multipath/dm-2/dm/uuid    |  1 +
 src/test/disk_tests/multipath/dm-2/size       |  1 +
 src/test/disk_tests/multipath/dm-2_slaves     |  0
 src/test/disk_tests/multipath/dm-3/dm/name    |  1 +
 src/test/disk_tests/multipath/dm-3/dm/uuid    |  1 +
 src/test/disk_tests/multipath/dm-3/size       |  1 +
 src/test/disk_tests/multipath/dm-3_slaves     |  0
 src/test/disk_tests/multipath/dm-4/dm/name    |  1 +
 src/test/disk_tests/multipath/dm-4/dm/uuid    |  1 +
 src/test/disk_tests/multipath/dm-4/size       |  1 +
 src/test/disk_tests/multipath/dm-4_slaves     |  0
 src/test/disk_tests/multipath/lsblk           | 59 +++++++++++++++
 src/test/disk_tests/multipath/lvs             |  0
 src/test/disk_tests/multipath/mounts          |  1 +
 .../multipath/multipath_expected.json         | 59 +++++++++++++++
 src/test/disk_tests/multipath/partlist        |  0
 src/test/disk_tests/multipath/pvs             |  1 +
 .../disk_tests/multipath/sda/device/model     |  1 +
 .../disk_tests/multipath/sda/device/vendor    |  1 +
 .../disk_tests/multipath/sda/holders/holder   |  1 +
 .../disk_tests/multipath/sda/queue/rotational |  1 +
 src/test/disk_tests/multipath/sda/size        |  1 +
 src/test/disk_tests/multipath/sda_udevadm     | 18 +++++
 .../disk_tests/multipath/sdb/device/model     |  1 +
 .../disk_tests/multipath/sdb/device/vendor    |  1 +
 .../disk_tests/multipath/sdb/holders/holder   |  1 +
 .../disk_tests/multipath/sdb/queue/rotational |  1 +
 src/test/disk_tests/multipath/sdb/size        |  1 +
 src/test/disk_tests/multipath/sdb_udevadm     | 18 +++++
 .../disk_tests/multipath/sdc/device/model     |  1 +
 .../disk_tests/multipath/sdc/device/vendor    |  1 +
 .../disk_tests/multipath/sdc/holders/holder   |  1 +
 .../disk_tests/multipath/sdc/queue/rotational |  1 +
 src/test/disk_tests/multipath/sdc/size        |  1 +
 src/test/disk_tests/multipath/sdc_udevadm     | 18 +++++
 .../disk_tests/multipath/sdd/device/model     |  1 +
 .../disk_tests/multipath/sdd/device/vendor    |  1 +
 .../disk_tests/multipath/sdd/holders/holder   |  1 +
 .../disk_tests/multipath/sdd/queue/rotational |  1 +
 src/test/disk_tests/multipath/sdd/size        |  1 +
 src/test/disk_tests/multipath/sdd_udevadm     | 18 +++++
 src/test/disk_tests/multipath/zpool           |  1 +
 src/test/disklist_test.pm                     | 48 ++++++++++++-
 55 files changed, 428 insertions(+), 2 deletions(-)
 create mode 100644 src/test/disk_tests/multipath/dm-0/dm/name
 create mode 100644 src/test/disk_tests/multipath/dm-0/dm/uuid
 create mode 100644 src/test/disk_tests/multipath/dm-0/size
 create mode 100644 src/test/disk_tests/multipath/dm-0_slaves
 create mode 100644 src/test/disk_tests/multipath/dm-1/dm/name
 create mode 100644 src/test/disk_tests/multipath/dm-1/dm/uuid
 create mode 100644 src/test/disk_tests/multipath/dm-1/size
 create mode 100644 src/test/disk_tests/multipath/dm-1_slaves
 create mode 100644 src/test/disk_tests/multipath/dm-2/dm/name
 create mode 100644 src/test/disk_tests/multipath/dm-2/dm/uuid
 create mode 100644 src/test/disk_tests/multipath/dm-2/size
 create mode 100644 src/test/disk_tests/multipath/dm-2_slaves
 create mode 100644 src/test/disk_tests/multipath/dm-3/dm/name
 create mode 100644 src/test/disk_tests/multipath/dm-3/dm/uuid
 create mode 100644 src/test/disk_tests/multipath/dm-3/size
 create mode 100644 src/test/disk_tests/multipath/dm-3_slaves
 create mode 100644 src/test/disk_tests/multipath/dm-4/dm/name
 create mode 100644 src/test/disk_tests/multipath/dm-4/dm/uuid
 create mode 100644 src/test/disk_tests/multipath/dm-4/size
 create mode 100644 src/test/disk_tests/multipath/dm-4_slaves
 create mode 100644 src/test/disk_tests/multipath/lvs
 create mode 100644 src/test/disk_tests/multipath/mounts
 create mode 100644 src/test/disk_tests/multipath/multipath_expected.json
 create mode 100644 src/test/disk_tests/multipath/partlist
 create mode 100644 src/test/disk_tests/multipath/pvs
 create mode 100644 src/test/disk_tests/multipath/sda/device/model
 create mode 100644 src/test/disk_tests/multipath/sda/device/vendor
 create mode 100644 src/test/disk_tests/multipath/sda/holders/holder
 create mode 100644 src/test/disk_tests/multipath/sda/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/sda/size
 create mode 100644 src/test/disk_tests/multipath/sda_udevadm
 create mode 100644 src/test/disk_tests/multipath/sdb/device/model
 create mode 100644 src/test/disk_tests/multipath/sdb/device/vendor
 create mode 100644 src/test/disk_tests/multipath/sdb/holders/holder
 create mode 100644 src/test/disk_tests/multipath/sdb/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/sdb/size
 create mode 100644 src/test/disk_tests/multipath/sdb_udevadm
 create mode 100644 src/test/disk_tests/multipath/sdc/device/model
 create mode 100644 src/test/disk_tests/multipath/sdc/device/vendor
 create mode 100644 src/test/disk_tests/multipath/sdc/holders/holder
 create mode 100644 src/test/disk_tests/multipath/sdc/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/sdc/size
 create mode 100644 src/test/disk_tests/multipath/sdc_udevadm
 create mode 100644 src/test/disk_tests/multipath/sdd/device/model
 create mode 100644 src/test/disk_tests/multipath/sdd/device/vendor
 create mode 100644 src/test/disk_tests/multipath/sdd/holders/holder
 create mode 100644 src/test/disk_tests/multipath/sdd/queue/rotational
 create mode 100644 src/test/disk_tests/multipath/sdd/size
 create mode 100644 src/test/disk_tests/multipath/sdd_udevadm
 create mode 100644 src/test/disk_tests/multipath/zpool

diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index d5251095..5c021d6d 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -200,7 +200,7 @@ sub get_smart_data {
 }
 
 sub get_lsblk_info {
-    my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype,tran'];
+    my $cmd = [$LSBLK, '--json', '-o', 'path,parttype,fstype,tran,pttype'];
     my $output = "";
     eval {
         run_command($cmd, outfunc => sub { $output .= "$_[0]\n"; });
@@ -218,6 +218,7 @@ sub get_lsblk_info {
                 parttype => $_->{parttype},
                 fstype => $_->{fstype},
                 tran => $_->{tran},
+                pttype => $_->{pttype},
             }
         } @{$list}
     };
@@ -816,6 +817,68 @@ sub get_disks {
     return $disklist;
 }
 
+# Keep multipath maps separate from get_disks(), whose callers manage local disks.
+sub get_multipath_disks {
+    my ($maps) = @_;
+    my $mounted = mounted_blockdevs();
+    my $lsblk_info = get_lsblk_info();
+    my $zfshash = get_zfs_devices($lsblk_info);
+    my $lvmhash = get_lvm_devices($lsblk_info, 1); # no pvs probe, it can block on a map
+
+    my $disklist = {};
+
+    for my $dev (sort keys %$maps) {
+        my $sysdir = "/sys/block/$dev";
+        my $map = $maps->{$dev};
+        my $wwid = $map->{wwid};
+        my $devpath = "/dev/mapper/$map->{name}";
+        my $resolved_devpath = abs_path($devpath);
+        my @devpaths = ($devpath);
+        push @devpaths, $resolved_devpath
+            if defined($resolved_devpath) && $resolved_devpath ne $devpath;
+
+        my $size = get_sysdir_size($sysdir) or next;
+        my $slaves = $map->{slaves};
+
+        my ($vendor, $model, $transport) = ('unknown', 'unknown', undef);
+        if (my $first = $slaves->[0]) {
+            if (my $sysdata = get_sysdir_info("/sys/block/$first")) {
+                $vendor = $sysdata->{vendor};
+                $model = $sysdata->{model};
+            }
+            $transport = $lsblk_info->{"/dev/$first"}->{tran};
+        }
+
+        my $used;
+        $used = 'LVM' if grep { $lvmhash->{$_} } @devpaths;
+        $used //= 'ZFS' if grep { $zfshash->{$_} } @devpaths;
+        my $info = {};
+        for my $path (@devpaths) {
+            $info = $lsblk_info->{$path} // next;
+            last;
+        }
+        $used //= "$info->{fstype}" if defined($info->{fstype});
+        $used //= 'mounted' if grep { $mounted->{$_} } @devpaths;
+        $used //= 'partitions'
+            if defined($info->{pttype}) && $info->{pttype} ne '';
+        $used //= 'Device Mapper' if !dir_is_empty("$sysdir/holders");
+
+        $disklist->{$dev} = {
+            devpath => $devpath,
+            size => $size,
+            vendor => $vendor,
+            model => $model,
+            wwn => $wwid,
+            paths => scalar($slaves->@*),
+            slaves => [map { "/dev/$_" } $slaves->@*],
+        };
+        $disklist->{$dev}->{transport} = $transport if defined($transport);
+        $disklist->{$dev}->{used} = $used if $used;
+    }
+
+    return $disklist;
+}
+
 # Native multipath creates per-path namespace children nvmeXcYnZ below controllers. Local
 # single-controller devices lack these children and are omitted.
 sub get_nvme_path_status {
diff --git a/src/test/disk_tests/multipath/disklist b/src/test/disk_tests/multipath/disklist
index b5e636a5..f759ba9e 100644
--- a/src/test/disk_tests/multipath/disklist
+++ b/src/test/disk_tests/multipath/disklist
@@ -1,2 +1,11 @@
+sda
+sdb
+sdc
+sdd
+dm-0
+dm-1
+dm-2
+dm-3
+dm-4
 nvme8n1
 nvme9n1
diff --git a/src/test/disk_tests/multipath/disklist_expected.json b/src/test/disk_tests/multipath/disklist_expected.json
index 908c2b56..ec442969 100644
--- a/src/test/disk_tests/multipath/disklist_expected.json
+++ b/src/test/disk_tests/multipath/disklist_expected.json
@@ -1,4 +1,76 @@
 {
+    "sda": {
+        "devpath": "/dev/sda",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "serial": "SSERa",
+        "wwn": "0x600140500000000a",
+        "gpt": 0,
+        "rpm": -1,
+        "type": "unknown",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/scsi-36001405000000000000000000000000a",
+        "transport": "fc",
+        "used": "Device Mapper"
+    },
+    "sdb": {
+        "devpath": "/dev/sdb",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "serial": "SSERb",
+        "wwn": "0x600140500000000b",
+        "gpt": 0,
+        "rpm": -1,
+        "type": "unknown",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/scsi-36001405000000000000000000000000b",
+        "transport": "fc",
+        "used": "Device Mapper"
+    },
+    "sdc": {
+        "devpath": "/dev/sdc",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "serial": "SSERc",
+        "wwn": "0x600140500000000c",
+        "gpt": 0,
+        "rpm": -1,
+        "type": "unknown",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/scsi-36001405000000000000000000000000c",
+        "transport": "fc",
+        "used": "Device Mapper"
+    },
+    "sdd": {
+        "devpath": "/dev/sdd",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "serial": "SSERd",
+        "wwn": "0x600140500000000d",
+        "gpt": 0,
+        "rpm": -1,
+        "type": "unknown",
+        "health": "UNKNOWN",
+        "wearout": "N/A",
+        "osdid": -1,
+        "osdid-list": null,
+        "by_id_link": "/dev/disk/by-id/scsi-36001405000000000000000000000000d",
+        "transport": "fc",
+        "used": "Device Mapper"
+    },
     "nvme8n1": {
         "devpath": "/dev/nvme8n1",
         "size": 10737418240,
diff --git a/src/test/disk_tests/multipath/dm-0/dm/name b/src/test/disk_tests/multipath/dm-0/dm/name
new file mode 100644
index 00000000..0ed057a0
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-0/dm/name
@@ -0,0 +1 @@
+mpatha
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-0/dm/uuid b/src/test/disk_tests/multipath/dm-0/dm/uuid
new file mode 100644
index 00000000..094955aa
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-0/dm/uuid
@@ -0,0 +1 @@
+mpath-3600140500000000000000000000000001
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-0/size b/src/test/disk_tests/multipath/dm-0/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-0/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-0_slaves b/src/test/disk_tests/multipath/dm-0_slaves
new file mode 100644
index 00000000..16373159
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-0_slaves
@@ -0,0 +1,4 @@
+.
+..
+sda
+sdb
diff --git a/src/test/disk_tests/multipath/dm-1/dm/name b/src/test/disk_tests/multipath/dm-1/dm/name
new file mode 100644
index 00000000..f70ac3d8
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-1/dm/name
@@ -0,0 +1 @@
+mpathb
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-1/dm/uuid b/src/test/disk_tests/multipath/dm-1/dm/uuid
new file mode 100644
index 00000000..7e8567b8
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-1/dm/uuid
@@ -0,0 +1 @@
+mpath-3600140500000000000000000000000002
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-1/size b/src/test/disk_tests/multipath/dm-1/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-1/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/dm-1_slaves b/src/test/disk_tests/multipath/dm-1_slaves
new file mode 100644
index 00000000..cde08b36
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-1_slaves
@@ -0,0 +1,4 @@
+.
+..
+sdc
+sdd
diff --git a/src/test/disk_tests/multipath/dm-2/dm/name b/src/test/disk_tests/multipath/dm-2/dm/name
new file mode 100644
index 00000000..4770de43
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-2/dm/name
@@ -0,0 +1 @@
+mpathc
diff --git a/src/test/disk_tests/multipath/dm-2/dm/uuid b/src/test/disk_tests/multipath/dm-2/dm/uuid
new file mode 100644
index 00000000..2d607eae
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-2/dm/uuid
@@ -0,0 +1 @@
+mpath-3600140500000000000000000000000003
diff --git a/src/test/disk_tests/multipath/dm-2/size b/src/test/disk_tests/multipath/dm-2/size
new file mode 100644
index 00000000..14faeece
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-2/size
@@ -0,0 +1 @@
+20971520
diff --git a/src/test/disk_tests/multipath/dm-2_slaves b/src/test/disk_tests/multipath/dm-2_slaves
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/disk_tests/multipath/dm-3/dm/name b/src/test/disk_tests/multipath/dm-3/dm/name
new file mode 100644
index 00000000..a98ef69c
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-3/dm/name
@@ -0,0 +1 @@
+mpathd
diff --git a/src/test/disk_tests/multipath/dm-3/dm/uuid b/src/test/disk_tests/multipath/dm-3/dm/uuid
new file mode 100644
index 00000000..75f25b81
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-3/dm/uuid
@@ -0,0 +1 @@
+mpath-3600140500000000000000000000000004
diff --git a/src/test/disk_tests/multipath/dm-3/size b/src/test/disk_tests/multipath/dm-3/size
new file mode 100644
index 00000000..14faeece
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-3/size
@@ -0,0 +1 @@
+20971520
diff --git a/src/test/disk_tests/multipath/dm-3_slaves b/src/test/disk_tests/multipath/dm-3_slaves
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/disk_tests/multipath/dm-4/dm/name b/src/test/disk_tests/multipath/dm-4/dm/name
new file mode 100644
index 00000000..e084e8f6
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-4/dm/name
@@ -0,0 +1 @@
+mpathe
diff --git a/src/test/disk_tests/multipath/dm-4/dm/uuid b/src/test/disk_tests/multipath/dm-4/dm/uuid
new file mode 100644
index 00000000..0ca78754
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-4/dm/uuid
@@ -0,0 +1 @@
+mpath-3600140500000000000000000000000005
diff --git a/src/test/disk_tests/multipath/dm-4/size b/src/test/disk_tests/multipath/dm-4/size
new file mode 100644
index 00000000..14faeece
--- /dev/null
+++ b/src/test/disk_tests/multipath/dm-4/size
@@ -0,0 +1 @@
+20971520
diff --git a/src/test/disk_tests/multipath/dm-4_slaves b/src/test/disk_tests/multipath/dm-4_slaves
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/disk_tests/multipath/lsblk b/src/test/disk_tests/multipath/lsblk
index 597adf94..35cc1b8a 100644
--- a/src/test/disk_tests/multipath/lsblk
+++ b/src/test/disk_tests/multipath/lsblk
@@ -1,5 +1,64 @@
 {
    "blockdevices": [
+      {
+         "path": "/dev/sda",
+         "parttype": null,
+         "fstype": null,
+         "tran": "fc"
+      },
+      {
+         "path": "/dev/sdb",
+         "parttype": null,
+         "fstype": null,
+         "tran": "fc"
+      },
+      {
+         "path": "/dev/sdc",
+         "parttype": null,
+         "fstype": null,
+         "tran": "fc"
+      },
+      {
+         "path": "/dev/sdd",
+         "parttype": null,
+         "fstype": null,
+         "tran": "fc"
+      },
+      {
+         "path": "/dev/mapper/mpatha",
+         "parttype": null,
+         "fstype": null,
+         "tran": null,
+         "pttype": null
+      },
+      {
+         "path": "/dev/mapper/mpathb",
+         "parttype": null,
+         "fstype": "LVM2_member",
+         "tran": null,
+         "pttype": null
+      },
+      {
+         "path": "/dev/mapper/mpathc",
+         "parttype": null,
+         "fstype": null,
+         "tran": null,
+         "pttype": "gpt"
+      },
+      {
+         "path": "/dev/dm-3",
+         "parttype": null,
+         "fstype": null,
+         "tran": null,
+         "pttype": null
+      },
+      {
+         "path": "/dev/dm-4",
+         "parttype": null,
+         "fstype": null,
+         "tran": null,
+         "pttype": null
+      },
       {
          "path": "/dev/nvme8n1",
          "parttype": null,
diff --git a/src/test/disk_tests/multipath/lvs b/src/test/disk_tests/multipath/lvs
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/disk_tests/multipath/mounts b/src/test/disk_tests/multipath/mounts
new file mode 100644
index 00000000..06ada278
--- /dev/null
+++ b/src/test/disk_tests/multipath/mounts
@@ -0,0 +1 @@
+/dev/mapper/mpathe /mnt
diff --git a/src/test/disk_tests/multipath/multipath_expected.json b/src/test/disk_tests/multipath/multipath_expected.json
new file mode 100644
index 00000000..bee629a1
--- /dev/null
+++ b/src/test/disk_tests/multipath/multipath_expected.json
@@ -0,0 +1,59 @@
+{
+    "dm-0": {
+        "devpath": "/dev/mapper/mpatha",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "wwn": "3600140500000000000000000000000001",
+        "paths": 2,
+        "slaves": [
+            "/dev/sda",
+            "/dev/sdb"
+        ],
+        "transport": "fc"
+    },
+    "dm-1": {
+        "devpath": "/dev/mapper/mpathb",
+        "size": 10737418240,
+        "vendor": "SANVEND",
+        "model": "SANMODEL",
+        "wwn": "3600140500000000000000000000000002",
+        "paths": 2,
+        "slaves": [
+            "/dev/sdc",
+            "/dev/sdd"
+        ],
+        "transport": "fc",
+        "used": "LVM2_member"
+    },
+    "dm-2": {
+        "devpath": "/dev/mapper/mpathc",
+        "size": 10737418240,
+        "vendor": "unknown",
+        "model": "unknown",
+        "wwn": "3600140500000000000000000000000003",
+        "paths": 0,
+        "slaves": [],
+        "used": "partitions"
+    },
+    "dm-3": {
+        "devpath": "/dev/mapper/mpathd",
+        "size": 10737418240,
+        "vendor": "unknown",
+        "model": "unknown",
+        "wwn": "3600140500000000000000000000000004",
+        "paths": 0,
+        "slaves": [],
+        "used": "ZFS"
+    },
+    "dm-4": {
+        "devpath": "/dev/mapper/mpathe",
+        "size": 10737418240,
+        "vendor": "unknown",
+        "model": "unknown",
+        "wwn": "3600140500000000000000000000000005",
+        "paths": 0,
+        "slaves": [],
+        "used": "mounted"
+    }
+}
diff --git a/src/test/disk_tests/multipath/partlist b/src/test/disk_tests/multipath/partlist
new file mode 100644
index 00000000..e69de29b
diff --git a/src/test/disk_tests/multipath/pvs b/src/test/disk_tests/multipath/pvs
new file mode 100644
index 00000000..9c2f9b93
--- /dev/null
+++ b/src/test/disk_tests/multipath/pvs
@@ -0,0 +1 @@
+  /dev/dm-1
diff --git a/src/test/disk_tests/multipath/sda/device/model b/src/test/disk_tests/multipath/sda/device/model
new file mode 100644
index 00000000..2f50f3f3
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda/device/model
@@ -0,0 +1 @@
+SANMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sda/device/vendor b/src/test/disk_tests/multipath/sda/device/vendor
new file mode 100644
index 00000000..ead8944c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda/device/vendor
@@ -0,0 +1 @@
+SANVEND
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sda/holders/holder b/src/test/disk_tests/multipath/sda/holders/holder
new file mode 100644
index 00000000..9255a92c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda/holders/holder
@@ -0,0 +1 @@
+dm-holder
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sda/queue/rotational b/src/test/disk_tests/multipath/sda/queue/rotational
new file mode 100644
index 00000000..56a6051c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda/queue/rotational
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sda/size b/src/test/disk_tests/multipath/sda/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sda_udevadm b/src/test/disk_tests/multipath/sda_udevadm
new file mode 100644
index 00000000..7bd58b4e
--- /dev/null
+++ b/src/test/disk_tests/multipath/sda_udevadm
@@ -0,0 +1,18 @@
+P: /devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sda
+N: sda
+S: disk/by-id/scsi-36001405000000000000000000000000a
+E: DEVLINKS=/dev/disk/by-id/scsi-36001405000000000000000000000000a
+E: DEVNAME=/dev/sda
+E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sda
+E: DEVTYPE=disk
+E: ID_BUS=scsi
+E: ID_MODEL=SANMODEL
+E: ID_SCSI=1
+E: ID_SERIAL=SANSERIALa
+E: ID_SERIAL_SHORT=SSERa
+E: ID_TYPE=disk
+E: ID_VENDOR=SANVEND
+E: ID_WWN=0x600140500000000a
+E: MAJOR=8
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disk_tests/multipath/sdb/device/model b/src/test/disk_tests/multipath/sdb/device/model
new file mode 100644
index 00000000..2f50f3f3
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb/device/model
@@ -0,0 +1 @@
+SANMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdb/device/vendor b/src/test/disk_tests/multipath/sdb/device/vendor
new file mode 100644
index 00000000..ead8944c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb/device/vendor
@@ -0,0 +1 @@
+SANVEND
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdb/holders/holder b/src/test/disk_tests/multipath/sdb/holders/holder
new file mode 100644
index 00000000..9255a92c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb/holders/holder
@@ -0,0 +1 @@
+dm-holder
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdb/queue/rotational b/src/test/disk_tests/multipath/sdb/queue/rotational
new file mode 100644
index 00000000..56a6051c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb/queue/rotational
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdb/size b/src/test/disk_tests/multipath/sdb/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdb_udevadm b/src/test/disk_tests/multipath/sdb_udevadm
new file mode 100644
index 00000000..9a04c63f
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdb_udevadm
@@ -0,0 +1,18 @@
+P: /devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdb
+N: sdb
+S: disk/by-id/scsi-36001405000000000000000000000000b
+E: DEVLINKS=/dev/disk/by-id/scsi-36001405000000000000000000000000b
+E: DEVNAME=/dev/sdb
+E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdb
+E: DEVTYPE=disk
+E: ID_BUS=scsi
+E: ID_MODEL=SANMODEL
+E: ID_SCSI=1
+E: ID_SERIAL=SANSERIALb
+E: ID_SERIAL_SHORT=SSERb
+E: ID_TYPE=disk
+E: ID_VENDOR=SANVEND
+E: ID_WWN=0x600140500000000b
+E: MAJOR=8
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disk_tests/multipath/sdc/device/model b/src/test/disk_tests/multipath/sdc/device/model
new file mode 100644
index 00000000..2f50f3f3
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc/device/model
@@ -0,0 +1 @@
+SANMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdc/device/vendor b/src/test/disk_tests/multipath/sdc/device/vendor
new file mode 100644
index 00000000..ead8944c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc/device/vendor
@@ -0,0 +1 @@
+SANVEND
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdc/holders/holder b/src/test/disk_tests/multipath/sdc/holders/holder
new file mode 100644
index 00000000..9255a92c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc/holders/holder
@@ -0,0 +1 @@
+dm-holder
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdc/queue/rotational b/src/test/disk_tests/multipath/sdc/queue/rotational
new file mode 100644
index 00000000..56a6051c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc/queue/rotational
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdc/size b/src/test/disk_tests/multipath/sdc/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdc_udevadm b/src/test/disk_tests/multipath/sdc_udevadm
new file mode 100644
index 00000000..acff253e
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdc_udevadm
@@ -0,0 +1,18 @@
+P: /devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdc
+N: sdc
+S: disk/by-id/scsi-36001405000000000000000000000000c
+E: DEVLINKS=/dev/disk/by-id/scsi-36001405000000000000000000000000c
+E: DEVNAME=/dev/sdc
+E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdc
+E: DEVTYPE=disk
+E: ID_BUS=scsi
+E: ID_MODEL=SANMODEL
+E: ID_SCSI=1
+E: ID_SERIAL=SANSERIALc
+E: ID_SERIAL_SHORT=SSERc
+E: ID_TYPE=disk
+E: ID_VENDOR=SANVEND
+E: ID_WWN=0x600140500000000c
+E: MAJOR=8
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disk_tests/multipath/sdd/device/model b/src/test/disk_tests/multipath/sdd/device/model
new file mode 100644
index 00000000..2f50f3f3
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd/device/model
@@ -0,0 +1 @@
+SANMODEL
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdd/device/vendor b/src/test/disk_tests/multipath/sdd/device/vendor
new file mode 100644
index 00000000..ead8944c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd/device/vendor
@@ -0,0 +1 @@
+SANVEND
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdd/holders/holder b/src/test/disk_tests/multipath/sdd/holders/holder
new file mode 100644
index 00000000..9255a92c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd/holders/holder
@@ -0,0 +1 @@
+dm-holder
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdd/queue/rotational b/src/test/disk_tests/multipath/sdd/queue/rotational
new file mode 100644
index 00000000..56a6051c
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd/queue/rotational
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdd/size b/src/test/disk_tests/multipath/sdd/size
new file mode 100644
index 00000000..8280959b
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd/size
@@ -0,0 +1 @@
+20971520
\ No newline at end of file
diff --git a/src/test/disk_tests/multipath/sdd_udevadm b/src/test/disk_tests/multipath/sdd_udevadm
new file mode 100644
index 00000000..813c5f1d
--- /dev/null
+++ b/src/test/disk_tests/multipath/sdd_udevadm
@@ -0,0 +1,18 @@
+P: /devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdd
+N: sdd
+S: disk/by-id/scsi-36001405000000000000000000000000d
+E: DEVLINKS=/dev/disk/by-id/scsi-36001405000000000000000000000000d
+E: DEVNAME=/dev/sdd
+E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:02:00.0/host4/rport-4:0-0/target4:0:0/4:0:0:0/block/sdd
+E: DEVTYPE=disk
+E: ID_BUS=scsi
+E: ID_MODEL=SANMODEL
+E: ID_SCSI=1
+E: ID_SERIAL=SANSERIALd
+E: ID_SERIAL_SHORT=SSERd
+E: ID_TYPE=disk
+E: ID_VENDOR=SANVEND
+E: ID_WWN=0x600140500000000d
+E: MAJOR=8
+E: MINOR=0
+E: SUBSYSTEM=block
diff --git a/src/test/disk_tests/multipath/zpool b/src/test/disk_tests/multipath/zpool
new file mode 100644
index 00000000..e723f7e3
--- /dev/null
+++ b/src/test/disk_tests/multipath/zpool
@@ -0,0 +1 @@
+	/dev/dm-3	-
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index 0d34c0db..caa60e79 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -6,6 +6,7 @@ use warnings;
 use lib qw(..);
 
 use PVE::Diskmanage;
+use PVE::Multipath;
 use PVE::Tools;
 
 use Test::MockModule;
@@ -16,8 +17,17 @@ use Data::Dumper;
 my $testcasedir; # current case directory
 my $testcount = 0; # testcount for TAP::Harness
 my $diskmanage_module; # mockmodule for PVE::Diskmanage
+my $multipath_module; # mockmodule for PVE::Multipath
 my $print = 0;
 
+my $multipath_aliases = {
+    '/dev/mapper/mpatha' => '/dev/dm-0',
+    '/dev/mapper/mpathb' => '/dev/dm-1',
+    '/dev/mapper/mpathc' => '/dev/dm-2',
+    '/dev/mapper/mpathd' => '/dev/dm-3',
+    '/dev/mapper/mpathe' => '/dev/dm-4',
+};
+
 sub mocked_run_command {
     my ($cmd, %param) = @_;
 
@@ -122,6 +132,8 @@ sub mocked_dir_glob_foreach {
     # read lines in from file
     if ($dir =~ m{^/sys/block$}) {
         @$lines = split(/\n/, read_test_file('disklist'));
+    } elsif ($dir =~ m{^/sys/block/([^/]+)/slaves$}) {
+        @$lines = split(/\n/, read_test_file("${1}_slaves"));
     } elsif ($dir =~ m{^/sys/block/([^/]+)}) {
         @$lines = split(/\n/, read_test_file('partlist'));
     }
@@ -227,6 +239,21 @@ sub test_disk_list {
         $testcount++;
         is_deeply($disks, $expected_disk_list, 'disk list should be the same');
 
+        if (-f "disk_tests/$testcasedir/multipath_expected.json") {
+            my $multipath = PVE::Diskmanage::get_multipath_disks(PVE::Multipath::map_info());
+            my $expected_multipath = decode_json(read_test_file('multipath_expected.json'));
+
+            print Dumper($multipath) if $print;
+            $testcount++;
+            is_deeply($multipath, $expected_multipath, 'multipath list should be the same');
+
+            eval { PVE::Diskmanage::assert_disk_unused('/dev/dm-0'); };
+            $testcount++;
+            like($@, qr/not a valid local disk/,
+                'multipath devices require an explicit opt-in');
+
+        }
+
         if ($testcasedir eq 'iscsi') {
             eval { PVE::Diskmanage::assert_disk_unused('/dev/sda'); };
             $testcount++;
@@ -268,10 +295,20 @@ $diskmanage_module->mock('get_sysdir_size' => \&mocked_get_sysdir_size);
 print("\tMocked get_sysdir_size\n");
 $diskmanage_module->mock('assert_blockdev' => sub { return 1; });
 print("\tMocked assert_blockdev\n");
+$multipath_module = Test::MockModule->new('PVE::Multipath', no_auto => 1);
+$multipath_module->mock('dir_glob_foreach' => \&mocked_dir_glob_foreach);
+$multipath_module->mock('file_read_firstline' => \&mocked_file_read_firstline);
 $diskmanage_module->mock(
     'dir_is_empty' => sub {
-        # all partitions have a holder dir
         my $val = shift;
+        # let test cases provide the dir (e.g. holders) with content
+        my $mapped = $val;
+        $mapped =~ s|^/sys/block|disk_tests/$testcasedir|;
+        if (-d $mapped) {
+            my $originalsub = $diskmanage_module->original('dir_is_empty');
+            return &$originalsub($mapped);
+        }
+        # all partitions have a holder dir
         if ($val =~ m|^/sys/block/.+/.+/|) {
             return 0;
         }
@@ -281,6 +318,15 @@ $diskmanage_module->mock(
 print("\tMocked dir_is_empty\n");
 $diskmanage_module->mock('file_read_firstline' => \&mocked_file_read_firstline);
 print("\tMocked file_read_firstline\n");
+$diskmanage_module->mock(
+    'abs_path' => sub {
+        my ($path) = @_;
+        return $multipath_aliases->{$path}
+            if defined($multipath_aliases->{$path});
+        return &{ $diskmanage_module->original('abs_path') }($path);
+    },
+);
+print("\tMocked abs_path\n");
 $diskmanage_module->mock('check_bin' => sub { return 1; });
 print("\tMocked check_bin\n");
 # the test cases name iSCSI LUNs through the lsblk transport, the sysfs of the host must not count




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 09/36] multipath: add a cluster-wide configuration
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (7 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 08/36] diskmanage: add helper to list multipath devices Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 10/36] iscsi: add an option to manage storage LUNs with multipath Thomas Lamprecht
                   ` (27 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

A multipath configuration kept per node can drift, so that some nodes
use a LUN through its map and others through a single path. Keep it
in the cluster file system instead: /etc/pve/multipath.cfg has one
entry per LUN WWID with an optional map alias, node restriction,
no_path_retry setting and expected number of paths, and
/etc/pve/multipath-overrides.conf takes multipath.conf sections for
the settings an array needs.

The expected number of paths is for LUNs without a storage that knows
it, such as Fibre Channel ones: a node with fewer paths than expected
is degraded, also after the kernel removed a lost path.

Nothing applies the configuration on the nodes yet.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                  |   1 +
 src/PVE/Multipath/Config.pm       | 178 ++++++++++++++++++++++++++++++
 src/test/Makefile                 |   5 +-
 src/test/run_multipath_tests.pl   |  39 +++++++
 src/test/run_san_library_tests.pl |  47 ++++++++
 5 files changed, 269 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/Multipath/Config.pm
 create mode 100755 src/test/run_san_library_tests.pl

diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index db1c340d..597ad7a1 100644
--- a/src/PVE/Makefile
+++ b/src/PVE/Makefile
@@ -6,6 +6,7 @@ install:
 	install -D -m 0644 Diskmanage.pm ${DESTDIR}${PERLDIR}/PVE/Diskmanage.pm
 	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 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/Config.pm b/src/PVE/Multipath/Config.pm
new file mode 100644
index 00000000..8bf5efb2
--- /dev/null
+++ b/src/PVE/Multipath/Config.pm
@@ -0,0 +1,178 @@
+package PVE::Multipath::Config;
+
+use v5.36;
+
+use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::SectionConfig;
+use PVE::Tools;
+
+use base qw(PVE::SectionConfig);
+
+# multipath interprets a leading '-' as an option and major:minor as a device number.
+our $WWID_PATTERN = '(?!-|\d+:-?\d)[a-zA-Z0-9._:-]+';
+our $WWID_RE = qr/^(?:$WWID_PATTERN)\z/;
+
+my $properties = {
+    alias => {
+        type => 'string',
+        pattern => '[a-zA-Z0-9][a-zA-Z0-9._-]*',
+        maxLength => 64,
+        description => 'The name of the multipath map.',
+        optional => 1,
+    },
+    nodes => get_standard_option(
+        'pve-node-list',
+        {
+            description => 'The nodes that should assemble the map, or all nodes when unset.',
+            optional => 1,
+        },
+    ),
+    'no-path-retry' => {
+        type => 'string',
+        pattern => '(?:queue|fail|[0-9]+)',
+        description => 'The action or number of retries when all paths are down.',
+        optional => 1,
+    },
+    'paths-expected' => {
+        type => 'integer',
+        minimum => 1,
+        description => 'The number of paths each node should have to the LUN. A node with fewer'
+            . ' paths reports the LUN as degraded.',
+        optional => 1,
+    },
+};
+my $defaultData = {
+    propertyList => {
+        type => { description => 'The section type.' },
+        id => {
+            type => 'string',
+            pattern => $WWID_PATTERN,
+            maxLength => 128,
+            description => 'The LUN WWID.',
+        },
+        %$properties,
+    },
+};
+sub private($class) { return $defaultData }
+sub type($class) { return 'wwid' }
+
+sub options($class) {
+    return { map { $_ => { optional => 1 } } keys %$properties };
+}
+
+sub wwid_api_schema() {
+    return { map { $_ => { $properties->{$_}->%* } } keys %$properties };
+}
+
+sub parse_section_header($class, $line) {
+    my ($type, $id, $errmsg, $config) = $class->SUPER::parse_section_header($line);
+    return undef if !defined($type);
+    $errmsg //= "invalid WWID '$id'" if $id !~ $WWID_RE;
+    return ($type, $id, $errmsg, $config);
+}
+
+sub decode_value($class, $type, $key, $value) {
+    return {
+        map { $_ => 1 }
+        grep { PVE::JSONSchema::pve_verify_node_name($_) } PVE::Tools::split_list($value)
+        }
+        if $key eq 'nodes';
+    return $value;
+}
+
+sub encode_value($class, $type, $key, $value) {
+    return join(',', sort keys %$value) if $key eq 'nodes';
+    return $value;
+}
+__PACKAGE__->register();
+__PACKAGE__->init();
+
+sub check_overrides($text) {
+    my $allowed = { map { $_ => 1 } qw(devices overrides defaults blacklist blacklist_exceptions) };
+    my $depth = 0;
+    for my $line (split(/\n/, $text // '')) {
+        $line =~ s/"[^"]*"//g;
+        $line =~ s/[#!].*//;
+        while ($line =~ /(\w+)\s*\{|([{}])/g) {
+            if (defined($1)) {
+                my $keyword = $1;
+                die "multipath overrides: configure LUNs in multipath.cfg, not a multipaths block\n"
+                    if $keyword eq 'multipaths';
+                die "multipath overrides: unknown section '$keyword'\n"
+                    if !$depth && !$allowed->{$keyword};
+                $depth++;
+            } elsif ($2 eq '{') {
+                $depth++;
+            } else {
+                die "multipath overrides: unbalanced braces\n" if !$depth;
+                $depth--;
+            }
+        }
+    }
+    die "multipath overrides: unbalanced braces\n" if $depth;
+}
+
+sub format_overrides($text) {
+    $text //= '';
+    $text =~ s/\s+$//;
+    return length($text) ? "$text\n" : '';
+}
+
+cfs_register_file(
+    'multipath.cfg',
+    sub($filename, $data) { __PACKAGE__->parse_config($filename, $data) },
+    sub($filename, $data) { __PACKAGE__->write_config($filename, $data) },
+);
+cfs_register_file(
+    'multipath-overrides.conf',
+    sub($filename, $data) { $data // '' },
+    sub($filename, $data) { format_overrides($data) },
+);
+
+sub read_config() { return cfs_read_file('multipath.cfg') }
+sub write_cluster_config($cfg) { cfs_write_file('multipath.cfg', $cfg) }
+sub read_overrides() { return cfs_read_file('multipath-overrides.conf') }
+sub write_overrides($text) { cfs_write_file('multipath-overrides.conf', $text) }
+
+sub lock_config($code, $errmsg = undef) {
+    cfs_lock_file('multipath.cfg', undef, $code);
+    die defined($errmsg) ? "$errmsg - $@" : $@ if $@;
+}
+
+sub lock_overrides($code, $errmsg = undef) {
+    cfs_lock_file('multipath-overrides.conf', undef, $code);
+    die defined($errmsg) ? "$errmsg - $@" : $@ if $@;
+}
+
+sub generate_managed_conf() {
+    return "# Managed by Proxmox VE.\ndefaults {\n\tauto_resize grow_only\n}\n";
+}
+
+sub parse_wwids($text) {
+    return [map { m{^/($WWID_PATTERN)/\s*$} ? $1 : () } split(/\n/, $text // '')];
+}
+
+sub wwid_list($cfg) {
+    return [sort keys $cfg->{ids}->%*];
+}
+
+sub wwids_for_node($cfg, $node) {
+    return [grep { my $nodes = $cfg->{ids}->{$_}->{nodes}; !$nodes || !%$nodes || $nodes->{$node} }
+        wwid_list($cfg)->@*];
+}
+
+sub build_multipaths_block($cfg, $node) {
+    my $out = "# Managed by Proxmox VE.\nmultipaths {\n";
+    for my $wwid (wwids_for_node($cfg, $node)->@*) {
+        my $entry = $cfg->{ids}->{$wwid};
+        $out .= "\tmultipath {\n\t\twwid $wwid\n";
+        $out .= "\t\talias $entry->{alias}\n" if defined($entry->{alias});
+        $out .= "\t\tno_path_retry $entry->{'no-path-retry'}\n"
+            if defined($entry->{'no-path-retry'});
+        $out .= "\t}\n";
+    }
+    return "$out}\n";
+}
+
+1;
diff --git a/src/test/Makefile b/src/test/Makefile
index 3098bb15..21f51441 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_multipath
+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_multipath test_san_libraries
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -49,3 +49,6 @@ test_iscsi: run_iscsi_discovery_tests.pl run_iscsi_rescan_tests.pl run_iscsi_dev
 
 test_multipath: run_multipath_tests.pl
 	./run_multipath_tests.pl
+
+test_san_libraries: run_san_library_tests.pl
+	./run_san_library_tests.pl
diff --git a/src/test/run_multipath_tests.pl b/src/test/run_multipath_tests.pl
index b1248ad0..db356cde 100755
--- a/src/test/run_multipath_tests.pl
+++ b/src/test/run_multipath_tests.pl
@@ -4,6 +4,7 @@ use v5.36;
 use lib ('.', '..');
 use Test::More;
 use PVE::Multipath;
+use PVE::Multipath::Config;
 use PVE::Tools qw(file_get_contents);
 
 subtest 'multipathd JSON fixtures' => sub {
@@ -87,6 +88,44 @@ subtest 'multipathd JSON fixtures' => sub {
     is(PVE::Multipath::derive_health(0, 0), 'failed', 'empty map is failed');
 };
 
+subtest 'one section type and fixed baseline' => sub {
+    my $cfg = PVE::Multipath::Config->parse_config(
+        'multipath.cfg',
+        "wwid: 3600a\n\talias data\n\tnodes n1\n\tno-path-retry fail\n\tpaths-expected 2\n",
+    );
+    is_deeply(PVE::Multipath::Config::wwid_list($cfg), ['3600a'], 'WWID is listed');
+    is_deeply(PVE::Multipath::Config::wwids_for_node($cfg, 'n2'), [], 'node restriction');
+    is_deeply(
+        [sort keys PVE::Multipath::Config::wwid_api_schema()->%*],
+        [qw(alias no-path-retry nodes paths-expected)],
+        'only four options',
+    );
+    like(
+        PVE::Multipath::Config::generate_managed_conf(),
+        qr/auto_resize grow_only/,
+        'fixed baseline',
+    );
+    like(
+        PVE::Multipath::Config::build_multipaths_block($cfg, 'n1'),
+        qr/no_path_retry fail/,
+        'per-LUN option',
+    );
+    unlike(
+        PVE::Multipath::Config::build_multipaths_block($cfg, 'n1'),
+        qr/expected/,
+        'the expected path count is not a multipath option',
+    );
+    is_deeply(
+        PVE::Multipath::Config::parse_wwids("# header\n/3600a/\n/-bad/\n"),
+        ['3600a'],
+        'allow-list parser',
+    );
+    eval { PVE::Multipath::Config::check_overrides('multipaths { }') };
+    like($@, qr/configure LUNs/, 'LUN configuration belongs in explicit entries');
+    eval { PVE::Multipath::Config::check_overrides('defaults { user_friendly_names no }') };
+    is($@, '', 'raw defaults override is allowed');
+};
+
 subtest 'one owner for map identity and membership' => sub {
     is_deeply(PVE::Multipath::parse_dm_uuid('mpath-3600a'), { wwid => '3600a' }, 'whole map');
     is_deeply(
diff --git a/src/test/run_san_library_tests.pl b/src/test/run_san_library_tests.pl
new file mode 100755
index 00000000..819b9fc3
--- /dev/null
+++ b/src/test/run_san_library_tests.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::MockModule;
+use Test::More;
+
+use lib ('.', '..');
+use PVE::Cluster;
+
+my %registered;
+my $cluster = Test::MockModule->new('PVE::Cluster');
+$cluster->mock(cfs_register_file => sub { $registered{ $_[0] } = [@_[1, 2]] });
+require PVE::Multipath::Config;
+
+subtest 'CFS callbacks preserve filenames, data and method receivers' => sub {
+    my ($parse, $write) = $registered{'multipath.cfg'}->@*;
+    my $cfg = $parse->('multipath.cfg', undef);
+    is_deeply($cfg->{ids}, {}, 'an absent configuration parses as empty');
+    $cfg = $parse->('multipath.cfg', "wwid: 3600abc\n\talias san-lun\n\tnodes n2,n1\n");
+    is_deeply($cfg->{ids}->{'3600abc'}->{nodes}, { n1 => 1, n2 => 1 }, 'nodes are decoded');
+    my $again = $parse->('multipath.cfg', $write->('multipath.cfg', $cfg));
+    is_deeply($again->{ids}, $cfg->{ids}, 'sections survive the registered writer and parser');
+    ($parse, $write) = $registered{'multipath-overrides.conf'}->@*;
+    is($parse->('multipath-overrides.conf', undef), '', 'absent overrides parse as empty');
+    is($write->('multipath-overrides.conf', undef), '', 'undefined overrides write as empty');
+    is($write->('multipath-overrides.conf', "devices { }  \n"), "devices { }\n",
+        'writer trims');
+};
+
+subtest 'omitted optional parameters retain explicit undef behavior' => sub {
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    $config->mock(cfs_lock_file => sub { $@ = "lock unavailable\n" });
+    for my $lock (
+        \&PVE::Multipath::Config::lock_config, \&PVE::Multipath::Config::lock_overrides,
+    ) {
+        for my $args ([], [undef]) {
+            eval {
+                $lock->(sub { die "unexpected callback\n" }, @$args);
+            };
+            is($@, "lock unavailable\n", 'an omitted error prefix leaves the error intact');
+        }
+    }
+};
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 10/36] iscsi: add an option to manage storage LUNs with multipath
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (8 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 09/36] multipath: add a cluster-wide configuration Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 11/36] lvm: activate a missing base volume before using the volume group Thomas Lamprecht
                   ` (26 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

With the new '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. Activating such a volume waits up to ten seconds for
the map, and an LVM storage on top only accepts a map as base volume.

The WWID is the one multipathd reports for a path, or the ID_SERIAL
udev property of the disk if multipathd is not available. Adding the
LUNs to the multipath allow-list of the nodes follows separately.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                       |  1 +
 src/PVE/Multipath.pm                   | 36 +++++++++++
 src/PVE/Multipath/Identity.pm          | 43 +++++++++++++
 src/PVE/Storage/ISCSIPlugin.pm         | 40 +++++++++++-
 src/PVE/Storage/LVMPlugin.pm           |  7 ++-
 src/test/Makefile                      |  8 ++-
 src/test/run_iscsi_activation_tests.pl | 86 ++++++++++++++++++++++++++
 src/test/run_lun_identity_tests.pl     | 48 ++++++++++++++
 src/test/run_multipath_tests.pl        | 12 ++++
 9 files changed, 276 insertions(+), 5 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 67ee39e9..14be0210 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -5,6 +5,7 @@ use v5.36;
 use Encode qw(decode encode);
 use JSON qw(decode_json);
 use PVE::Diskmanage;
+use PVE::Multipath::Config;
 use PVE::Tools qw(run_command file_read_firstline dir_glob_foreach);
 
 my $MULTIPATH = '/sbin/multipath';
@@ -115,6 +116,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 = '';
@@ -131,4 +157,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..4362c041
--- /dev/null
+++ b/src/PVE/Multipath/Identity.pm
@@ -0,0 +1,43 @@
+package PVE::Multipath::Identity;
+
+use v5.36;
+
+use PVE::ISCSI::Topology;
+use PVE::Multipath;
+use PVE::Multipath::Config;
+use PVE::Tools qw(dir_glob_foreach file_get_contents file_read_firstline);
+
+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/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 70c0e9dc..b66a94b4 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");
@@ -356,6 +372,11 @@ sub properties {
             type => 'string',
             format => 'pve-storage-portal-dns',
         },
+        multipath => {
+            description => "Manage multipath access to the storage's LUNs and include them in"
+                . " the cluster-wide path-health monitoring.",
+            type => 'boolean',
+        },
     };
 }
 
@@ -367,6 +388,7 @@ sub options {
         disable => { optional => 1 },
         content => { optional => 1 },
         bwlimit => { optional => 1 },
+        multipath => { optional => 1 },
     };
 }
 
@@ -437,13 +459,14 @@ sub list_images {
 
     my $res = [];
 
-    $cache->{iscsi_devices} = iscsi_device_list() if !$cache->{iscsi_devices};
+    my $cache_key = $scfg->{multipath} ? "iscsi_devices_mpath:$scfg->{target}" : 'iscsi_devices';
+    $cache->{$cache_key} //= iscsi_device_list($scfg->{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) {
 
@@ -614,6 +637,19 @@ $resolve_virtual_devices = sub {
 sub activate_volume {
     my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
 
+    if ($scfg->{multipath}) {
+        my ($wwid) = $volname =~ m/\.dm-uuid-mpath-(\S+)$/;
+        if (defined($wwid) && !-b "/dev/disk/by-id/dm-uuid-mpath-$wwid") {
+            # 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 1b0c8020..479e27e9 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -1086,11 +1086,16 @@ sub on_add_hook {
         die "unsupported base type '$basecfg->{type}'"
             if $basecfg->{type} ne 'iscsi';
 
+        # Managed multipath requires the coalesced map, never a transient single-path PV.
+        die "base volume '$volname' is no multipath volume of storage '$baseid'\n"
+            if $basecfg->{multipath} && $volname !~ m/\.dm-uuid-mpath-\S+$/;
+
         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
         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 21f51441..389aac31 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_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_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
@@ -52,3 +53,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/run_iscsi_activation_tests.pl b/src/test/run_iscsi_activation_tests.pl
new file mode 100755
index 00000000..cb37473d
--- /dev/null
+++ b/src/test/run_iscsi_activation_tests.pl
@@ -0,0 +1,86 @@
+#!/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', 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', 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');
+
+$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..91a4fac7
--- /dev/null
+++ b/src/test/run_lun_identity_tests.pl
@@ -0,0 +1,48 @@
+#!/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 => { wwid => '3600daemon' }, sdb => { wwid => '[undef]' } };
+$mp->mock(query_path_identities => sub { return $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',
+);
+ok(!defined(PVE::Multipath::Identity::path_wwid($ids, 'sdb')), 'unknown identity skipped');
+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();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 11/36] lvm: activate a missing base volume before using the volume group
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (9 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 10/36] iscsi: add an option to manage storage LUNs with multipath Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 12/36] multipath: apply the configuration on every node Thomas Lamprecht
                   ` (25 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Activating an LVM storage activates its base storage, but not the
base volume. Right after the login its device can still be appearing,
for example while multipathd assembles the map, and a guest start
then does not find the volume group.

If the volume group is missing, activate the base volume, which waits
for its device, and look again, without the LVM hints if needed. This
also applies to the status update, which then waits for a missing map
on every pass. A visible volume group is used as before.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Storage/LVMPlugin.pm             |  29 ++++++
 src/test/Makefile                        |   5 +-
 src/test/run_test_lvm_base_activation.pl | 117 +++++++++++++++++++++++
 3 files changed, 150 insertions(+), 1 deletion(-)
 create mode 100755 src/test/run_test_lvm_base_activation.pl

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 479e27e9..ccae074a 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -1607,11 +1607,40 @@ my sub find_unhinted_vgs {
     delete $cache->{lvs};
 }
 
+# The base device may still be appearing after transport activation; wait before retrying LVM.
+my sub activate_missing_base {
+    my ($storeid, $scfg, $cache) = @_;
+
+    # the volume group list of the cache can predate the device
+    $cache->{vgs} = lvm_vgs();
+    return if $cache->{vgs}->{ $scfg->{vgname} };
+
+    eval {
+        my $cfg = PVE::Storage::config();
+        my ($baseid, $volname) = PVE::Storage::Plugin::parse_volume_id($scfg->{base});
+        my $basecfg = PVE::Storage::storage_config($cfg, $baseid);
+        my $plugin = PVE::Storage::Plugin->lookup($basecfg->{type});
+        # the activation of this storage activated the base storage with the same cache before
+        $plugin->activate_volume($baseid, $basecfg, $volname, undef, $cache);
+    };
+    warn "storage '$storeid': activating base volume '$scfg->{base}' failed - $@" if $@;
+
+    # A new device invalidates LVM's hints, but a PV written remotely to an existing device does
+    # not; retry without hints after each missing-base activation.
+    $cache->{vgs} = lvm_vgs();
+    # the logical volume list of the cache can predate the volume group too
+    delete $cache->{lvs};
+    find_unhinted_vgs($cache) if !$cache->{vgs}->{ $scfg->{vgname} };
+}
+
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
     $cache->{vgs} = lvm_vgs() if !$cache->{vgs};
 
+    activate_missing_base($storeid, $scfg, $cache)
+        if $scfg->{base} && !$cache->{vgs}->{ $scfg->{vgname} };
+
     find_unhinted_vgs($cache) if !$cache->{vgscaned} && !$cache->{vgs}->{ $scfg->{vgname} };
 
     # we do not acticate any volumes here ('vgchange -aly')
diff --git a/src/test/Makefile b/src/test/Makefile
index 389aac31..c3632e05 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_multipath test_san_libraries test_lun_identity
+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_multipath test_san_libraries test_lun_identity test_lvm_base_activation
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -56,3 +56,6 @@ test_san_libraries: run_san_library_tests.pl
 
 test_lun_identity: run_lun_identity_tests.pl
 	./run_lun_identity_tests.pl
+
+test_lvm_base_activation: run_test_lvm_base_activation.pl
+	./run_test_lvm_base_activation.pl
diff --git a/src/test/run_test_lvm_base_activation.pl b/src/test/run_test_lvm_base_activation.pl
new file mode 100755
index 00000000..fe0c573f
--- /dev/null
+++ b/src/test/run_test_lvm_base_activation.pl
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib '..';
+use Test::More;
+use Test::MockModule;
+
+use PVE::Storage;
+use PVE::Storage::LVMPlugin;
+
+my $CLASS = 'PVE::Storage::LVMPlugin';
+
+# the volume groups vgs lists through the device hints, those only a listing without them finds
+my ($vgs, $unhinted, @calls) = ([], []);
+
+my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+$lvm->mock(
+    lvm_vgs => sub {
+        my ($includepvs, $nohints) = @_;
+        push @calls, $nohints ? 'vgs --nohints' : 'vgs';
+        return { map { $_ => {} } $vgs->@*, ($nohints ? $unhinted->@* : ()) };
+    },
+    run_command => sub {
+        my ($cmd) = @_;
+        push @calls, join(' ', $cmd->[0] =~ s|^/sbin/||r, $cmd->@[1 .. $#$cmd]);
+    },
+);
+
+my $storage = Test::MockModule->new('PVE::Storage');
+$storage->mock(config => sub { return { ids => {} } });
+$storage->mock(storage_config => sub { return { type => 'fakebase' } });
+
+my $base_fails;
+my $plugin = Test::MockModule->new('PVE::Storage::Plugin');
+$plugin->mock(lookup => sub { return 'FakeBasePlugin' });
+
+{
+    no warnings 'once';
+    *FakeBasePlugin::activate_volume = sub {
+        my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+        push @calls, "base $storeid:$volname" . ($cache->{marker} ? ' shared-cache' : '');
+        die "volume '$volname' is not available on this node\n" if $base_fails;
+        # the device appeared while waiting, and with it the volume group
+        push $vgs->@*, $volname =~ s/^vol-//r;
+    };
+}
+
+my sub activate {
+    my ($scfg, $cache, $vgs_now, $unhinted_now) = @_;
+
+    ($vgs, $unhinted, @calls) = ($vgs_now // [], $unhinted_now // []);
+    my @warnings;
+    local $SIG{__WARN__} = sub { push @warnings, $_[0] };
+    $CLASS->activate_storage('lvm', $scfg, $cache);
+    return (join(', ', @calls), \@warnings);
+}
+
+my $with_base = { vgname => 'vg1', base => 'san:vol-vg1' };
+
+my ($calls, $warnings) = activate($with_base, { vgs => { vg1 => {} } });
+is($calls, '', 'present volume group: no base activation, no scan');
+
+($calls) = activate($with_base, { vgs => {} }, ['vg1']);
+is($calls, 'vgs', 'volume group appeared meanwhile: a fresh list, no base activation');
+
+my $cache = { marker => 1, vgs => {}, lvs => {} };
+($calls) = activate($with_base, $cache);
+is(
+    $calls,
+    'vgs, base san:vol-vg1 shared-cache, vgs',
+    'missing volume group: base activated with the shared cache, the device brings it into the list',
+);
+ok($cache->{vgs}->{vg1}, 'and the volume group list of the cache is refreshed');
+ok(!exists($cache->{lvs}), 'and its logical volume list is dropped');
+
+# the volume group another node created on a device this node had before, after an earlier probe
+$cache = { vgs => {}, vgscaned => 1 };
+{
+    no warnings 'redefine';
+    local *FakeBasePlugin::activate_volume = sub { push @calls, 'base present' };
+    ($calls) = activate($with_base, $cache, [], ['vg1']);
+}
+is(
+    $calls,
+    'vgs, base present, vgs, vgs --nohints, pvscan --cache',
+    'volume group missing from the hints: found without them despite an earlier probe',
+);
+ok($cache->{vgs}->{vg1}, 'and added to the volume group list of the cache');
+
+$cache = { vgs => {} };
+activate($with_base, $cache);
+($calls) = activate({ vgname => 'vg2', base => 'san:vol-vg2' }, $cache, ['vg1']);
+is($calls, 'vgs, base san:vol-vg2, vgs', 'a second base in the same cache is activated');
+
+$base_fails = 1;
+($calls, $warnings) = activate($with_base, { vgs => {} });
+is(
+    $calls,
+    'vgs, base san:vol-vg1, vgs, vgs --nohints',
+    'a failed base activation still looks for the volume group',
+);
+like(
+    $warnings->[0] // '',
+    qr/^storage 'lvm': activating base volume 'san:vol-vg1' failed - volume/,
+    'and warns about it',
+);
+$base_fails = 0;
+
+$cache = { vgs => {} };
+($calls) = activate({ vgname => 'vg1' }, $cache);
+is($calls, 'vgs --nohints', 'without base: one listing without hints per cache');
+($calls) = activate({ vgname => 'vg3' }, $cache);
+is($calls, '', 'and not again for the next storage');
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 12/36] multipath: apply the configuration on every node
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (10 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 11/36] lvm: activate a missing base volume before using the volume group Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 13/36] multipath: publish per-node status Thomas Lamprecht
                   ` (24 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Each node needs the cluster-wide configuration as local multipath.conf
drop-ins and the WWIDs of its LUNs in the allow-list of multipath:
the explicit entries valid for the node and the LUNs it sees through
sessions of enabled iSCSI storages with the multipath option.

The generated defaults set 'auto_resize grow_only', so that a map
follows a grown LUN. Missing WWIDs are added, nothing is ever removed.
multipathd is reloaded only after a change, and a failed reload is
retried after a minute. Nothing calls this yet.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                    |   1 +
 src/PVE/Multipath.pm                |  19 ++++-
 src/PVE/Multipath/Generator.pm      | 112 ++++++++++++++++++++++++++++
 src/PVE/Multipath/Identity.pm       |   2 +-
 src/PVE/Storage/ISCSIPlugin.pm      |  16 ++++
 src/test/Makefile                   |   8 +-
 src/test/run_multipath_api_tests.pl |  93 +++++++++++++++++++++++
 src/test/run_multipath_tests.pl     |  12 +++
 src/test/run_san_library_tests.pl   |   6 ++
 src/test/run_san_taint_tests.pl     |  34 +++++++++
 10 files changed, 300 insertions(+), 3 deletions(-)
 create mode 100644 src/PVE/Multipath/Generator.pm
 create mode 100755 src/test/run_multipath_api_tests.pl
 create mode 100755 src/test/run_san_taint_tests.pl

diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index 53347442..87d5c41f 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/Generator.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Generator.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
diff --git a/src/PVE/Multipath.pm b/src/PVE/Multipath.pm
index 14be0210..6f61a3fe 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -6,7 +6,7 @@ use Encode qw(decode encode);
 use JSON qw(decode_json);
 use PVE::Diskmanage;
 use PVE::Multipath::Config;
-use PVE::Tools qw(run_command file_read_firstline dir_glob_foreach);
+use PVE::Tools qw(run_command file_get_contents file_read_firstline dir_glob_foreach);
 
 my $MULTIPATH = '/sbin/multipath';
 my $MULTIPATHD = '/sbin/multipathd';
@@ -167,4 +167,21 @@ sub wait_for_map($wwid, $timeout = 10) {
     }
 }
 
+sub list_etc_multipath_wwids() {
+    return [] if !-e '/etc/multipath/wwids';
+    return PVE::Multipath::Config::parse_wwids(file_get_contents('/etc/multipath/wwids'));
+}
+
+sub add_wwid($wwid) {
+    assert_supported();
+    my ($id) = $wwid =~ /^($PVE::Multipath::Config::WWID_PATTERN)\z/;
+    die "invalid WWID '$wwid'\n" if !defined($id);
+    run_command([$MULTIPATH, '-a', '--', $id], timeout => 10);
+}
+
+sub reconfigure() {
+    assert_supported();
+    run_command([$MULTIPATHD, 'reconfigure'], timeout => 30);
+}
+
 1;
diff --git a/src/PVE/Multipath/Generator.pm b/src/PVE/Multipath/Generator.pm
new file mode 100644
index 00000000..971d68e4
--- /dev/null
+++ b/src/PVE/Multipath/Generator.pm
@@ -0,0 +1,112 @@
+package PVE::Multipath::Generator;
+
+use v5.36;
+
+use File::Path qw(make_path);
+use PVE::INotify;
+use PVE::Multipath;
+use PVE::Multipath::Config;
+use PVE::Multipath::Identity;
+use PVE::Tools qw(file_get_contents file_set_contents);
+
+# Local drop-ins let multipathd start before pmxcfs is available.
+our $DEFAULTS_DROPIN = '/etc/multipath/conf.d/pve-defaults.conf';
+our $OVERRIDES_DROPIN = '/etc/multipath/conf.d/pve-overrides.conf';
+our $ALIASES_DROPIN = '/etc/multipath/conf.d/pve-aliases.conf';
+our $RECONFIGURE_PENDING = '/run/pve-multipath.reconfigure-pending';
+my $failed_at;
+
+sub derived_wwids($cfg, $ids = undef) {
+    require PVE::Storage;
+    my @storages = grep {
+        my $scfg = $cfg->{ids}->{$_};
+        $scfg->{type} eq 'iscsi'
+            && $scfg->{multipath}
+            && PVE::Storage::storage_check_enabled($cfg, $_, undef, 1)
+    } sort keys $cfg->{ids}->%*;
+    if (!@storages) {
+        return {};
+    }
+    $ids //= PVE::Multipath::Identity::collect(
+        targets => { map { $cfg->{ids}->{$_}->{target} => 1 } @storages });
+    return { map { $_ => PVE::Storage::ISCSIPlugin->multipath_lun_wwids($cfg->{ids}->{$_}, $ids) }
+        @storages };
+}
+
+my sub pending() { file_set_contents($RECONFIGURE_PENDING, '') if !-e $RECONFIGURE_PENDING }
+my sub write_dropin($path, $content) {
+    my $old = -e $path ? file_get_contents($path) : '';
+    return if $old eq $content;
+    pending();
+    if (length($content)) {
+        make_path($path =~ s!/[^/]+$!!r);
+        file_set_contents($path, $content);
+    } else {
+        unlink($path) or die "cannot remove '$path' - $!\n";
+    }
+}
+
+sub regenerate($cfg = undef, $overrides = undef, $derived = undef) {
+    $cfg //= PVE::Multipath::Config::read_config();
+    $overrides //= PVE::Multipath::Config::read_overrides();
+    $derived //= {};
+    my $node = PVE::INotify::nodename();
+    my @explicit = PVE::Multipath::Config::wwids_for_node($cfg, $node)->@*;
+    my %wanted = map {
+        my $count = $cfg->{ids}->{$_}->{'paths-expected'};
+        $_ => defined($count) ? { 'paths-expected' => $count } : {}
+    } @explicit;
+    for my $sid (sort keys %$derived) {
+        for my $wwid (sort keys $derived->{$sid}->{wwids}->%*) {
+            push $wanted{$wwid}->{storages}->@*, $sid;
+            my $expected = $derived->{$sid}->{wwids}->{$wwid}->{'paths-expected'};
+            $wanted{$wwid}->{'paths-expected'} = $expected
+                if defined($expected) && $expected > ($wanted{$wwid}->{'paths-expected'} // 0);
+        }
+    }
+    eval {
+        my $in_use = @explicit || keys(%$derived) || length($overrides);
+        write_dropin(
+            $DEFAULTS_DROPIN,
+            $in_use ? PVE::Multipath::Config::generate_managed_conf() : '',
+        );
+        write_dropin(
+            $OVERRIDES_DROPIN,
+            length($overrides) ? "# Managed by Proxmox VE.\n$overrides" : '',
+        );
+        write_dropin(
+            $ALIASES_DROPIN,
+            @explicit ? PVE::Multipath::Config::build_multipaths_block($cfg, $node) : '',
+        );
+        my %current = map { $_ => 1 } PVE::Multipath::list_etc_multipath_wwids()->@*;
+        for my $wwid (sort keys %wanted) {
+            next if $current{$wwid};
+            pending();
+            PVE::Multipath::add_wwid($wwid);
+        }
+        if (-e $RECONFIGURE_PENDING) {
+            die "multipath reload pending after a failed reload\n"
+                if defined($failed_at) && time() - $failed_at < 60;
+            eval { PVE::Multipath::reconfigure() };
+            if (my $error = $@) {
+                $failed_at = time();
+                die $error;
+            }
+            unlink($RECONFIGURE_PENDING) or die "cannot clear multipath reload marker - $!\n";
+            $failed_at = undef;
+        }
+    };
+    my $error = $@;
+    return { wwids => \%wanted, $error ? (error => $error) : () };
+}
+
+sub sync() {
+    return {} if !PVE::Multipath::is_supported();
+    my $res = eval {
+        require PVE::Storage;
+        regenerate(undef, undef, derived_wwids(PVE::Storage::config()));
+    };
+    return $res // { error => "$@" };
+}
+
+1;
diff --git a/src/PVE/Multipath/Identity.pm b/src/PVE/Multipath/Identity.pm
index 4362c041..e3f6c22b 100644
--- a/src/PVE/Multipath/Identity.pm
+++ b/src/PVE/Multipath/Identity.pm
@@ -28,7 +28,7 @@ sub collect(%param) {
                 ($wwid) = $data =~ m/^E:ID_SERIAL=(.+)$/m;
             }
             return if !defined($wwid) || $wwid !~ $PVE::Multipath::Config::WWID_RE;
-            $paths{$dev} = { wwid => $wwid };
+            $paths{$dev} = { wwid => $wwid, $session ? (target => $session->{target}) : () };
         },
     );
     return {
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index b66a94b4..3bddcda6 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -347,6 +347,22 @@ sub iscsi_device_list {
     return $res;
 }
 
+# Each portal of the connection storage contributes one expected path.
+sub multipath_lun_wwids {
+    my ($class, $scfg, $ids) = @_;
+
+    my $res = { wwids => {} };
+    my $target = $scfg->{target};
+
+    my $portals = iscsi_portals($target, $scfg->{portal});
+    for my $path (values $ids->{paths}->%*) {
+        next if ($path->{target} // '') ne $target;
+        $res->{wwids}->{ $path->{wwid} } = { 'paths-expected' => scalar(@$portals) };
+    }
+
+    return $res;
+}
+
 # Configuration
 
 sub type {
diff --git a/src/test/Makefile b/src/test/Makefile
index c3632e05..a758e593 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_multipath test_san_libraries test_lun_identity test_lvm_base_activation
+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_multipath test_san_libraries test_lun_identity test_lvm_base_activation test_multipath_api test_san_taint
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -59,3 +59,9 @@ test_lun_identity: run_lun_identity_tests.pl
 
 test_lvm_base_activation: run_test_lvm_base_activation.pl
 	./run_test_lvm_base_activation.pl
+
+test_multipath_api: run_multipath_api_tests.pl
+	./run_multipath_api_tests.pl
+
+test_san_taint: run_san_taint_tests.pl
+	perl -T ./run_san_taint_tests.pl
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
new file mode 100755
index 00000000..82aaa5f0
--- /dev/null
+++ b/src/test/run_multipath_api_tests.pl
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+
+use v5.36;
+our $NOW = 1000;
+
+BEGIN {
+    *CORE::GLOBAL::time = sub { $NOW }
+}
+use lib ('.', '..');
+use File::Temp qw(tempdir);
+use Test::More;
+use Test::MockModule;
+use PVE::Multipath::Generator;
+
+subtest 'add-only generation and failed reload throttle' => sub {
+    my $dir = tempdir('multipath-test-XXXX', DIR => '.', CLEANUP => 1);
+    local $PVE::Multipath::Generator::DEFAULTS_DROPIN = "$dir/defaults";
+    local $PVE::Multipath::Generator::OVERRIDES_DROPIN = "$dir/overrides";
+    local $PVE::Multipath::Generator::ALIASES_DROPIN = "$dir/aliases";
+    local $PVE::Multipath::Generator::RECONFIGURE_PENDING = "$dir/pending";
+    my $node = Test::MockModule->new('PVE::INotify');
+    $node->mock(nodename => sub { 'n1' });
+    my $mp = Test::MockModule->new('PVE::Multipath');
+    my (%listed, @added, $reloads, $fail);
+    $mp->mock(list_etc_multipath_wwids => sub { [sort keys %listed] });
+    $mp->mock(add_wwid => sub { $listed{ $_[0] } = 1; push @added, $_[0] });
+    $mp->mock(reconfigure => sub { $reloads++; die "reload failed\n" if $fail });
+    my $cfg = { ids => { '3600a' => { type => 'wwid', alias => 'data' } } };
+    my $res = PVE::Multipath::Generator::regenerate($cfg, '', {});
+    is_deeply(\@added, ['3600a'], 'missing WWID added');
+    is_deeply($res->{wwids}->{'3600a'}, {}, 'no expected path count without one in the entry');
+    is($reloads, 1, 'changed config reloaded');
+    $res = PVE::Multipath::Generator::regenerate(
+        { ids => { '3600a' => { $cfg->{ids}->{'3600a'}->%*, 'paths-expected' => 2 } } },
+        '',
+        {},
+    );
+    is($res->{wwids}->{'3600a'}->{'paths-expected'}, 2, 'expected path count of the entry');
+    is($reloads, 1, 'unchanged config not reloaded');
+    PVE::Multipath::Generator::regenerate({ ids => {} }, '', {});
+    ok($listed{'3600a'}, 'removed entry remains allow-listed');
+    $fail = 1;
+    my $failed = PVE::Multipath::Generator::regenerate($cfg, '', {});
+    like($failed->{error}, qr/reload failed/, 'reload error returned');
+    ok(exists($failed->{wwids}->{'3600a'}), 'apply failure retains wanted LUNs');
+    ok(-e "$dir/pending", 'failed reload remains pending');
+    my $count = $reloads;
+    $NOW += 59;
+    $failed = PVE::Multipath::Generator::regenerate($cfg, '', {});
+    like($failed->{error}, qr/reload pending/, 'pending reload remains visible');
+    is($reloads, $count, 'no retry before 60 seconds');
+    $NOW++;
+    $fail = 0;
+    PVE::Multipath::Generator::regenerate($cfg, '', {});
+    is($reloads, $count + 1, 'retry at 60 seconds');
+    ok(!-e "$dir/pending", 'successful reload clears pending marker');
+};
+
+subtest 'storage LUNs are the identified paths of the storage target' => sub {
+    my $topology = Test::MockModule->new('PVE::ISCSI::Topology');
+    $topology->mock(
+        device_map => sub {
+            return { map { $_ => { target => $_ eq 'sdc' ? 'iqn.other' : 'iqn.san' } }
+                qw(sda sdb sdc) };
+        },
+    );
+    my $identity = Test::MockModule->new('PVE::Multipath::Identity');
+    $identity->mock(dir_glob_foreach => sub { $_[2]->($_) for qw(sda sdb sdc sdd) });
+    my $mp = Test::MockModule->new('PVE::Multipath');
+    my %wwid = (sda => '3600a', sdb => '3600a', sdc => '3600b', sdd => '3600c');
+    $mp->mock(
+        query_path_identities => sub {
+            return { map { $_ => { wwid => $wwid{$_} } } keys %wwid };
+        },
+    );
+    my $iscsi = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
+    $iscsi->mock(iscsi_portals => sub { ['192.0.2.1:3260', '192.0.2.2:3260'] });
+    my $cfg = { ids => { san => { type => 'iscsi', target => 'iqn.san', multipath => 1 } } };
+    my $expected = { san => { wwids => { '3600a' => { 'paths-expected' => 2 } } } };
+    is_deeply(
+        PVE::Multipath::Generator::derived_wwids($cfg),
+        $expected,
+        'one WWID per LUN of the target, one expected path per portal',
+    );
+    my $all = PVE::Multipath::Identity::collect(all => 1);
+    is_deeply(
+        PVE::Multipath::Generator::derived_wwids($cfg, $all),
+        $expected,
+        'paths of other targets and transports in a full collection are left out',
+    );
+};
+
+done_testing();
diff --git a/src/test/run_multipath_tests.pl b/src/test/run_multipath_tests.pl
index ae44e962..c8800c38 100755
--- a/src/test/run_multipath_tests.pl
+++ b/src/test/run_multipath_tests.pl
@@ -146,7 +146,19 @@ 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(is_supported => sub { 1 });
     $mp->mock(run_command => sub($cmd, %opts) { push @calls, [$cmd, $opts{timeout}] });
+    PVE::Multipath::add_wwid('3600a');
+    PVE::Multipath::reconfigure();
+    is_deeply(
+        \@calls,
+        [
+            [['/sbin/multipath', '-a', '--', '3600a'], 10],
+            [['/sbin/multipathd', 'reconfigure'], 30],
+        ],
+        'loop commands have short timeouts',
+    );
+    @calls = ();
     ok(
         !PVE::Multipath::wait_for_map('nonexistent-test-lun', 0),
         'missing by-id block link times out',
diff --git a/src/test/run_san_library_tests.pl b/src/test/run_san_library_tests.pl
index 819b9fc3..2ec2a651 100755
--- a/src/test/run_san_library_tests.pl
+++ b/src/test/run_san_library_tests.pl
@@ -13,6 +13,7 @@ my %registered;
 my $cluster = Test::MockModule->new('PVE::Cluster');
 $cluster->mock(cfs_register_file => sub { $registered{ $_[0] } = [@_[1, 2]] });
 require PVE::Multipath::Config;
+require PVE::Multipath::Generator;
 
 subtest 'CFS callbacks preserve filenames, data and method receivers' => sub {
     my ($parse, $write) = $registered{'multipath.cfg'}->@*;
@@ -31,6 +32,11 @@ subtest 'CFS callbacks preserve filenames, data and method receivers' => sub {
 
 subtest 'omitted optional parameters retain explicit undef behavior' => sub {
     my $config = Test::MockModule->new('PVE::Multipath::Config');
+    $config->mock(read_config => sub { die "configuration unavailable\n" });
+    for my $args ([], [undef, undef, undef]) {
+        eval { PVE::Multipath::Generator::regenerate(@$args) };
+        is($@, "configuration unavailable\n", 'regeneration reads the default configuration');
+    }
     $config->mock(cfs_lock_file => sub { $@ = "lock unavailable\n" });
     for my $lock (
         \&PVE::Multipath::Config::lock_config, \&PVE::Multipath::Config::lock_overrides,
diff --git a/src/test/run_san_taint_tests.pl b/src/test/run_san_taint_tests.pl
new file mode 100755
index 00000000..35b11cd7
--- /dev/null
+++ b/src/test/run_san_taint_tests.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -T
+
+use v5.36;
+use lib ('.', '..');
+use File::Temp qw(tempfile);
+use Scalar::Util qw(tainted);
+use Test::MockModule;
+use Test::More;
+use PVE::Multipath;
+use PVE::Tools;
+
+$ENV{PATH} = '/usr/sbin:/usr/bin:/sbin:/bin';
+delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+my ($fh, $path) = tempfile('multipath-taint-XXXX', DIR => '.', UNLINK => 1);
+print $fh '3600a';
+close($fh);
+my $wwid = PVE::Tools::file_get_contents($path);
+ok(tainted($wwid), 'WWID read from file is tainted');
+my $mp = Test::MockModule->new('PVE::Multipath');
+$mp->mock(is_supported => sub { 1 });
+$mp->mock(
+    run_command => sub($cmd, %opts) {
+        is_deeply($cmd, ['/sbin/multipath', '-a', '--', '3600a'], 'WWID add command');
+        ok($opts{timeout}, 'command is bounded');
+        PVE::Tools::run_command(['/usr/bin/true', @$cmd]);
+    },
+);
+PVE::Multipath::add_wwid($wwid);
+for my $bad ('-bad', '1:2', '../dev', "3600a\n") {
+    eval { PVE::Multipath::add_wwid($bad) };
+    like($@, qr/invalid WWID/, 'ambiguous identity refused');
+}
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 13/36] multipath: publish per-node status
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (11 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 12/36] multipath: apply the configuration on every node Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 14/36] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
                   ` (23 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Path health differs between nodes. Add the function that the status
daemon will call on each node: it applies the multipath configuration
and publishes the state of the node's maps in the cluster key-value
store, for the cluster-wide status.

A report has the WWID, state and path counts of each map, the iSCSI
initiator name of the node and the error of a failed configuration
run, or the reason why multipath is not usable. An unchanged report
is sent again once a minute, so that readers can tell a stale one.

The initiator name, which an admin needs for the access rules on the
storage array, comes from a new reader in the iSCSI plugin, which the
node iSCSI API will use as well.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                    |   1 +
 src/PVE/Multipath/Status.pm         |  75 +++++++++++++++++++
 src/PVE/Storage/ISCSIPlugin.pm      |  16 ++++
 src/PVE/Storage/LVMPlugin.pm        |  11 ++-
 src/test/run_multipath_api_tests.pl | 109 ++++++++++++++++++++++++++++
 src/test/run_san_library_tests.pl   |  31 ++++++++
 6 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/Multipath/Status.pm

diff --git a/src/PVE/Makefile b/src/PVE/Makefile
index 87d5c41f..13fecbf8 100644
--- a/src/PVE/Makefile
+++ b/src/PVE/Makefile
@@ -9,6 +9,7 @@ install:
 	install -D -m 0644 Multipath/Config.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Config.pm
 	install -D -m 0644 Multipath/Generator.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Generator.pm
 	install -D -m 0644 Multipath/Identity.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Identity.pm
+	install -D -m 0644 Multipath/Status.pm ${DESTDIR}${PERLDIR}/PVE/Multipath/Status.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/Status.pm b/src/PVE/Multipath/Status.pm
new file mode 100644
index 00000000..91b699c4
--- /dev/null
+++ b/src/PVE/Multipath/Status.pm
@@ -0,0 +1,75 @@
+package PVE::Multipath::Status;
+
+use v5.36;
+use JSON qw(decode_json);
+use PVE::Cluster;
+use PVE::INotify;
+use PVE::Multipath;
+use PVE::Multipath::Generator;
+
+my $json = JSON->new->utf8->canonical;
+my $KEY = 'multipath';
+
+sub publish($report) {
+    my $node = PVE::INotify::nodename();
+    my $now = time();
+    my $data = { %$report, time => $now };
+    my $encoded = $json->encode($data);
+    if (length($encoded) >= 32 * 1024) {
+        $data = { time => $now, error => 'too many LUNs to report' };
+        $encoded = $json->encode($data);
+    }
+    my $raw = PVE::Cluster::get_node_kv($KEY, $node);
+    my $previous = eval { decode_json($raw->{$node} // '') };
+    if (ref($previous) eq 'HASH') {
+        my $age = $now - ($previous->{time} // 0);
+        $previous->{time} = $now;
+        return if $age >= 0 && $age < 60 && $json->encode($previous) eq $encoded;
+    }
+    PVE::Cluster::broadcast_node_kv($KEY, $encoded);
+}
+
+sub update_node_status() {
+    my $apply = PVE::Multipath::Generator::sync();
+    my $report = { luns => [] };
+    $report->{'apply-error'} = $apply->{error} if defined($apply->{error});
+    require PVE::Storage::ISCSIPlugin;
+    my $initiator = eval { PVE::Storage::ISCSIPlugin::read_initiator_info() };
+    $report->{'iscsi-initiator-name'} = $initiator->{name}
+        if $initiator && defined($initiator->{name});
+    eval {
+        die "multipath-tools is not installed\n" if !PVE::Multipath::is_supported();
+        die "multipathd is not running\n" if !PVE::Multipath::is_running();
+        require PVE::Storage::LVMPlugin;
+        my $pv_vgs = PVE::Storage::LVMPlugin::cached_pv_volume_groups();
+        for my $map (PVE::Multipath::get_maps()->@*) {
+            my $wwid = $map->{wwid} // next;
+            my $info = $apply->{wwids}->{$wwid} // {};
+            my $lun = {
+                wwid => $wwid,
+                'paths-total' => $map->{'paths-total'},
+                'paths-active' => $map->{'paths-active'},
+                state => PVE::Multipath::derive_health(
+                    $map->{'paths-active'},
+                    $map->{'paths-total'},
+                    $info->{'paths-expected'},
+                ),
+            };
+            $lun->{size} = $map->{size} if defined($map->{size});
+            $lun->{name} = $map->{name} if defined($map->{name}) && $map->{name} ne $wwid;
+            $lun->{storage} = $info->{storages}->[0] if $info->{storages};
+            my $vg = defined($map->{sysfs}) ? $pv_vgs->{"/dev/$map->{sysfs}"} : undef;
+            $lun->{vgname} = $vg if defined($vg);
+            push $report->{luns}->@*, $lun;
+        }
+    };
+    if (my $error = $@) {
+        chomp $error;
+        $report->{error} = $error;
+        delete $report->{luns};
+    }
+    eval { publish($report) };
+    warn "multipath: cannot publish node status - $@" if $@;
+}
+
+1;
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 3bddcda6..d3ae56a4 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -21,8 +21,24 @@ use base qw(PVE::Storage::Plugin);
 # iscsi helper function
 
 my $ISCSIADM = '/usr/bin/iscsiadm';
+our $INITIATOR_NAME_FILE = '/etc/iscsi/initiatorname.iscsi';
 our $SYSFS = '/sys';
 
+sub read_initiator_info {
+    my $content = eval { PVE::Tools::file_get_contents($INITIATOR_NAME_FILE, 64 * 1024) };
+    return undef if !defined($content);
+
+    my $res = {};
+    for my $line (split(/\n/, $content)) {
+        if ($line =~ m/^\s*InitiatorName\s*=\s*(\S+)\s*$/) {
+            $res->{name} = $1;
+        } elsif ($line =~ m/^\s*InitiatorAlias\s*=\s*(.+?)\s*$/) {
+            $res->{alias} = $1;
+        }
+    }
+    return defined($res->{name}) ? $res : undef;
+}
+
 my $found_iscsi_adm_exe;
 my sub assert_iscsi_support {
     my ($noerr) = @_;
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index ccae074a..ee64b782 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -17,7 +17,7 @@ use PVE::Format qw(render_bytes render_duration);
 use PVE::INotify;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::RESTEnvironment qw(log_warn);
-use PVE::Tools qw(run_command file_read_firstline trim);
+use PVE::Tools qw(run_command file_get_contents file_read_firstline trim);
 
 use PVE::Storage::Common;
 use PVE::Storage::Plugin;
@@ -138,6 +138,15 @@ sub lvm_pv_info {
     return $pvinfo;
 }
 
+sub cached_pv_volume_groups {
+    my $data = eval { file_get_contents('/run/lvm/hints') } // '';
+    my $res = {};
+    while ($data =~ m/^scan:(\/dev\/\S+) pvid:\S+ devn:\d+:\d+ vg:([a-zA-Z0-9+_.-]+)$/mg) {
+        $res->{ abs_path($1) // $1 } = $2 if $2 ne '-';
+    }
+    return $res;
+}
+
 sub clear_first_sector {
     my ($dev) = shift;
 
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
index 82aaa5f0..7bed4266 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -8,9 +8,11 @@ BEGIN {
 }
 use lib ('.', '..');
 use File::Temp qw(tempdir);
+use JSON qw(decode_json);
 use Test::More;
 use Test::MockModule;
 use PVE::Multipath::Generator;
+use PVE::Storage;
 
 subtest 'add-only generation and failed reload throttle' => sub {
     my $dir = tempdir('multipath-test-XXXX', DIR => '.', CLEANUP => 1);
@@ -90,4 +92,111 @@ subtest 'storage LUNs are the identified paths of the storage target' => sub {
     );
 };
 
+subtest 'an unconfigured node does not write drop-ins or reload' => sub {
+    my $dir = tempdir('multipath-empty-XXXX', DIR => '.', CLEANUP => 1);
+    local $PVE::Multipath::Generator::DEFAULTS_DROPIN = "$dir/defaults";
+    local $PVE::Multipath::Generator::OVERRIDES_DROPIN = "$dir/overrides";
+    local $PVE::Multipath::Generator::ALIASES_DROPIN = "$dir/aliases";
+    local $PVE::Multipath::Generator::RECONFIGURE_PENDING = "$dir/pending";
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    $config->mock(read_config => sub { { ids => {} } });
+    $config->mock(read_overrides => sub { '' });
+    my $storage = Test::MockModule->new('PVE::Storage');
+    my $identity = Test::MockModule->new('PVE::Multipath::Identity');
+    $identity->mock(collect => sub { die "unexpected identity collection\n" });
+    my $mp = Test::MockModule->new('PVE::Multipath');
+    $mp->mock(is_supported => sub { 1 });
+    $mp->mock(is_running => sub { 1 });
+    $mp->mock(get_maps => sub { [] });
+    $mp->mock(list_etc_multipath_wwids => sub { [] });
+    my $generator = Test::MockModule->new('PVE::Multipath::Generator');
+    my @changes;
+
+    for my $function (qw(file_set_contents make_path)) {
+        $generator->mock($function => sub { push @changes, $function });
+    }
+    for my $function (qw(add_wwid reconfigure)) {
+        $mp->mock($function => sub { push @changes, $function });
+    }
+    my $iscsi = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
+    $iscsi->mock(read_initiator_info => sub { {} });
+    my $status = Test::MockModule->new('PVE::Multipath::Status');
+    my $report;
+    $status->mock(publish => sub { $report = $_[0] });
+    for my $ids ({}, { plain => { type => 'iscsi', target => 'iqn.test' } }) {
+        $storage->mock(config => sub { { ids => $ids } });
+        PVE::Multipath::Status::update_node_status();
+        ok(!exists($report->{error}), 'running daemon reports successfully');
+        ok(!exists($report->{'apply-error'}), 'unconfigured application succeeds');
+        is_deeply(\@changes, [], 'no write, mkdir, allow-list addition or reload');
+        is_deeply([glob("$dir/*")], [], 'no generated files or pending marker');
+    }
+};
+
+subtest 'node reports use read-back, refresh and a bounded error report' => sub {
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    my $node = Test::MockModule->new('PVE::INotify');
+    $node->mock(nodename => sub { 'n1' });
+    my (%raw, @sent);
+    $cluster->mock(get_node_kv => sub { \%raw });
+    $cluster->mock(
+        broadcast_node_kv => sub($key, $data) {
+            is($key, 'multipath', 'one node key');
+            push @sent, decode_json($data);
+            $raw{n1} = $data;
+        },
+    );
+    my $report = {
+        luns => [{
+            wwid => '3600a',
+            name => 'data',
+            state => 'optimal',
+            'paths-total' => 2,
+            'paths-active' => 2,
+        }],
+    };
+    PVE::Multipath::Status::publish($report);
+    $NOW += 59;
+    PVE::Multipath::Status::publish($report);
+    is(scalar(@sent), 1, 'same report younger than 60 seconds is skipped');
+    $NOW++;
+    PVE::Multipath::Status::publish($report);
+    is(scalar(@sent), 2, 'report refreshed at 60 seconds');
+    %raw = ();
+    PVE::Multipath::Status::publish($report);
+    is(scalar(@sent), 3, 'lost pmxcfs value is republished without local send state');
+    PVE::Multipath::Status::publish({ luns => [('x' x 33000)] });
+    is($sent[-1]->{error}, 'too many LUNs to report', 'oversized report is an error');
+    ok(!exists($sent[-1]->{luns}), 'not an empty or partial LUN report');
+};
+
+subtest 'one entry point applies configuration and reports unavailable reasons' => sub {
+    my $gen = Test::MockModule->new('PVE::Multipath::Generator');
+    my $status = Test::MockModule->new('PVE::Multipath::Status');
+    my $mp = Test::MockModule->new('PVE::Multipath');
+    my $iscsi = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
+    my ($report, @order);
+    $gen->mock(sync => sub { push @order, 'apply'; { error => 'reload failed' } });
+    $status->mock(publish => sub { push @order, 'publish'; $report = $_[0] });
+    $iscsi->mock(read_initiator_info => sub { { name => 'iqn.2025-01.example:node' } });
+    $mp->mock(is_supported => sub { 0 });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{error}, 'multipath-tools is not installed', 'missing tools reason only');
+    is_deeply(\@order, [qw(apply publish)], 'single call owns ordering');
+    is($report->{'apply-error'}, 'reload failed', 'apply failure is separate');
+    $mp->mock(is_supported => sub { 1 });
+    $mp->mock(is_running => sub { 0 });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{error}, 'multipathd is not running', 'stopped daemon reason only');
+    $mp->mock(is_running => sub { 1 });
+    $mp->mock(get_maps => sub { die "bad JSON\n" });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{error}, 'bad JSON', 'query error without unavailable prefix');
+    $mp->mock(get_maps =>
+        sub { [{ wwid => '3600a', name => 'data', 'paths-active' => 1, 'paths-total' => 2 }] });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{luns}->[0]->{state}, 'degraded', 'maps without PVE entries are included');
+    ok(!exists($report->{supported}), 'no separate capability state');
+};
+
 done_testing();
diff --git a/src/test/run_san_library_tests.pl b/src/test/run_san_library_tests.pl
index 2ec2a651..6a93e868 100755
--- a/src/test/run_san_library_tests.pl
+++ b/src/test/run_san_library_tests.pl
@@ -50,4 +50,35 @@ subtest 'omitted optional parameters retain explicit undef behavior' => sub {
     }
 };
 
+subtest 'LVM hints are optional cached display metadata' => sub {
+    require PVE::Storage::LVMPlugin;
+    my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    my $contents;
+    $lvm->mock(
+        file_get_contents => sub {
+            is($_[0], '/run/lvm/hints', 'only the existing LVM cache is read');
+            die "No such file\n" if !defined($contents);
+            return $contents;
+        },
+    );
+    $lvm->mock(abs_path => sub { $_[0] eq '/dev/disk/by-id/test' ? '/dev/dm-0' : $_[0] });
+    $lvm->mock(run_command => sub { die "unexpected device probe\n" });
+    for my $case (
+        [undef, {}, 'missing file'],
+        ['', {}, 'empty file'],
+        ["scan=/dev/sda pvid=abc devn=8:0 vg=data\n", {}, 'different format'],
+        ["scan:/dev/sda pvid:abc devn:8:0 vg:-\n", {}, 'orphan PV'],
+        ["scan:/dev/sda pvid:abc devn:8:0 vg:[unknown]\n", {}, 'unknown VG'],
+        ["scan:/dev/sda pvid:abc devn:8:0 vg:data\n", { '/dev/sda' => 'data' }, 'cached VG'],
+        [
+            "scan:/dev/disk/by-id/test pvid:abc devn:253:0 vg:data\n",
+            { '/dev/dm-0' => 'data' },
+            'resolved device name',
+        ],
+    ) {
+        $contents = $case->[0];
+        is_deeply(PVE::Storage::LVMPlugin::cached_pv_volume_groups(), $case->[1], $case->[2]);
+    }
+};
+
 done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 14/36] api: add endpoints for the cluster-wide multipath configuration
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (12 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 13/36] multipath: publish per-node status Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 15/36] api: multipath: add the cluster-wide health status Thomas Lamprecht
                   ` (22 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Add the API module for /cluster/multipath with the explicit LUN
entries (list, read, add, update, delete) and the overrides file
(read, write), so that the web UI and API clients can edit the
configuration. Reading needs Sys.Audit and writing Sys.Modify on '/',
and a digest protects against concurrent edits.

An alias that is the alias or WWID of another entry is refused, as
multipathd drops one of two maps that claim the same name. So is a
'multipaths' section in the overrides, as the entries generate it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Makefile               |   1 +
 src/PVE/API2/Multipath.pm           | 360 ++++++++++++++++++++++++++++
 src/PVE/Multipath/Config.pm         |  26 ++
 src/test/run_multipath_api_tests.pl |  36 +++
 4 files changed, 423 insertions(+)
 create mode 100644 src/PVE/API2/Multipath.pm

diff --git a/src/PVE/API2/Makefile b/src/PVE/API2/Makefile
index fe316c52..002a3bd4 100644
--- a/src/PVE/API2/Makefile
+++ b/src/PVE/API2/Makefile
@@ -3,5 +3,6 @@
 .PHONY: install
 install:
 	install -D -m 0644 Disks.pm ${DESTDIR}${PERLDIR}/PVE/API2/Disks.pm
+	install -D -m 0644 Multipath.pm ${DESTDIR}${PERLDIR}/PVE/API2/Multipath.pm
 	make -C Storage install
 	make -C Disks install
diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
new file mode 100644
index 00000000..667c2340
--- /dev/null
+++ b/src/PVE/API2/Multipath.pm
@@ -0,0 +1,360 @@
+package PVE::API2::Multipath;
+
+use v5.36;
+
+use HTTP::Status qw(:constants);
+
+use PVE::Exception qw(raise raise_param_exc);
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTHandler;
+use PVE::Tools qw(extract_param);
+
+use PVE::Multipath::Config;
+
+use base qw(PVE::RESTHandler);
+
+my sub assert_map_name_free($cfg, $wwid, $name) {
+    for my $other (sort keys $cfg->{ids}->%*) {
+        next if $other eq $wwid;
+        my $section = $cfg->{ids}->{$other};
+        die "'$name' is already the map name of WWID '$other'\n"
+            if $other eq $name || (defined($section->{alias}) && $section->{alias} eq $name);
+    }
+}
+
+my sub apply_section_update($section, $param, $delete) {
+    eval { PVE::Multipath::Config::apply_section_update($section, $param, $delete) };
+    raise_param_exc({ delete => $@ }) if $@;
+}
+
+my sub edit_config_locked($digest, $errmsg, $code) {
+    PVE::Multipath::Config::lock_config(
+        sub {
+            my $cfg = PVE::Multipath::Config::read_config();
+            PVE::Tools::assert_if_modified($cfg->{digest}, $digest);
+            $code->($cfg);
+            PVE::Multipath::Config::write_cluster_config($cfg);
+        },
+        $errmsg,
+    );
+}
+
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    description => "Directory index.",
+    permissions => { user => 'all' },
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => {
+        type => 'array',
+        items => {
+            type => 'object',
+            properties => {
+                name => { type => 'string' },
+            },
+        },
+        links => [{ rel => 'child', href => "{name}" }],
+    },
+    code => sub {
+        return [map { +{ name => $_ } } qw(overrides wwid)];
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'read_overrides',
+    path => 'overrides',
+    method => 'GET',
+    description => "Read the verbatim multipath.conf override sections.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Audit']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => {
+        type => 'object',
+        properties => {
+            overrides => {
+                type => 'string',
+                description => 'Verbatim override sections.',
+                optional => 1,
+            },
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    code => sub {
+        my $overrides = PVE::Multipath::Config::read_overrides();
+        return {
+            digest => PVE::Multipath::Config::overrides_digest($overrides),
+            defined($overrides) && length($overrides) ? (overrides => $overrides) : (),
+        };
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'set_overrides',
+    path => 'overrides',
+    method => 'PUT',
+    protected => 1,
+    description => "Set the verbatim multipath.conf sections for hardware-specific settings:"
+        . " 'devices', 'overrides', 'defaults', 'blacklist' and 'blacklist_exceptions' blocks,"
+        . " for example 'devices { device { ... } }'.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Modify']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            overrides => {
+                type => 'string',
+                description => 'Verbatim override sections. Omit to clear them.',
+                maxLength => 128 * 1024,
+                optional => 1,
+            },
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        my $overrides = $param->{overrides};
+        my $digest = extract_param($param, 'digest');
+        eval { PVE::Multipath::Config::check_overrides($overrides) };
+        raise_param_exc({ overrides => $@ }) if $@;
+
+        PVE::Multipath::Config::lock_overrides(
+            sub {
+                my $current = PVE::Multipath::Config::read_overrides();
+                PVE::Tools::assert_if_modified(
+                    PVE::Multipath::Config::overrides_digest($current), $digest,
+                );
+                PVE::Multipath::Config::write_overrides($overrides // '');
+            },
+            "updating multipath overrides failed",
+        );
+        return undef;
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'wwid_index',
+    path => 'wwid',
+    method => 'GET',
+    description => "List the explicit multipath entries with their alias and per-LUN"
+        . " multipathd settings.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Audit']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => {
+        type => 'array',
+        items => {
+            type => 'object',
+            properties => {
+                wwid => { type => 'string', description => 'The LUN WWID.' },
+                PVE::Multipath::Config::wwid_api_schema()->%*,
+            },
+        },
+        links => [{ rel => 'child', href => '{wwid}' }],
+    },
+    code => sub {
+        my $cfg = PVE::Multipath::Config::read_config();
+        my $sections = PVE::Multipath::Config::wwid_sections($cfg);
+        return [map { { wwid => $_, $sections->{$_}->%* } } sort keys %$sections];
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'read_wwid',
+    path => 'wwid/{wwid}',
+    method => 'GET',
+    description => "Read the explicit multipath entry of a WWID, with the digest of the"
+        . " configuration it was read from.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Audit']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            wwid => {
+                type => 'string',
+                description => 'The WWID to read.',
+                pattern => $PVE::Multipath::Config::WWID_PATTERN,
+                maxLength => 128,
+            },
+        },
+    },
+    returns => {
+        type => 'object',
+        properties => {
+            wwid => { type => 'string', description => 'The LUN WWID.' },
+            PVE::Multipath::Config::wwid_api_schema()->%*,
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    code => sub {
+        my ($param) = @_;
+
+        my $wwid = $param->{wwid};
+
+        my $cfg = PVE::Multipath::Config::read_config();
+        my $entry = PVE::Multipath::Config::wwid_sections($cfg)->{$wwid}
+            or raise("WWID '$wwid' is not explicitly allow-listed\n", code => HTTP_NOT_FOUND);
+        return { wwid => $wwid, $entry->%*, digest => $cfg->{digest} };
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'add_wwid',
+    path => 'wwid',
+    method => 'POST',
+    protected => 1,
+    description => "Add an explicit multipath entry for a LUN, with an optional alias, node"
+        . " restriction, and multipathd settings. For a LUN of an iSCSI storage with multipath"
+        . " enabled, an entry is only needed to set an alias or per-LUN settings. The entry"
+        . " keeps the LUN managed even if the storage's multipath option is disabled.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Modify']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            wwid => {
+                type => 'string',
+                description => 'The WWID of the LUN to manage via multipath.',
+                pattern => $PVE::Multipath::Config::WWID_PATTERN,
+                maxLength => 128,
+            },
+            PVE::Multipath::Config::wwid_api_schema()->%*,
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        my $wwid = extract_param($param, 'wwid');
+        my $digest = extract_param($param, 'digest');
+
+        edit_config_locked(
+            $digest,
+            "adding WWID '$wwid' failed",
+            sub {
+                my ($cfg) = @_;
+                raise_param_exc({ wwid => "WWID '$wwid' is already allow-listed" })
+                    if $cfg->{ids}->{$wwid};
+                assert_map_name_free($cfg, $wwid, $wwid);
+                assert_map_name_free($cfg, $wwid, $param->{alias}) if defined($param->{alias});
+                my $section = $cfg->{ids}->{$wwid} = { type => 'wwid' };
+                apply_section_update($section, $param, undef);
+            },
+        );
+        return undef;
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_wwid',
+    path => 'wwid/{wwid}',
+    method => 'PUT',
+    protected => 1,
+    description => "Update the alias, node restriction, and multipathd settings of an"
+        . " explicit multipath entry.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Modify']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            wwid => {
+                type => 'string',
+                description => 'The WWID to update.',
+                pattern => $PVE::Multipath::Config::WWID_PATTERN,
+                maxLength => 128,
+            },
+            PVE::Multipath::Config::wwid_api_schema()->%*,
+            delete => {
+                type => 'string',
+                format => 'pve-configid-list',
+                description => 'Comma-separated list of settings to unset.',
+                optional => 1,
+            },
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        my $wwid = extract_param($param, 'wwid');
+        my $delete = extract_param($param, 'delete');
+        my $digest = extract_param($param, 'digest');
+
+        edit_config_locked(
+            $digest,
+            "updating WWID '$wwid' failed",
+            sub {
+                my ($cfg) = @_;
+                my $section = $cfg->{ids}->{$wwid}
+                    or die "WWID '$wwid' is not explicitly allow-listed, add it first\n";
+                assert_map_name_free($cfg, $wwid, $param->{alias}) if defined($param->{alias});
+                apply_section_update($section, $param, $delete);
+            },
+        );
+        return undef;
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'remove_wwid',
+    path => 'wwid/{wwid}',
+    method => 'DELETE',
+    protected => 1,
+    description => "Remove an explicit multipath entry without changing node allow-lists.",
+    permissions => {
+        check => ['perm', '/', ['Sys.Modify']],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            wwid => {
+                type => 'string',
+                description => 'The WWID to remove.',
+                pattern => $PVE::Multipath::Config::WWID_PATTERN,
+                maxLength => 128,
+            },
+            digest => get_standard_option('pve-config-digest'),
+        },
+    },
+    returns => { type => 'null' },
+    code => sub {
+        my ($param) = @_;
+
+        my $wwid = $param->{wwid};
+        my $digest = extract_param($param, 'digest');
+
+        edit_config_locked(
+            $digest,
+            "removing WWID '$wwid' failed",
+            sub {
+                my ($cfg) = @_;
+                die "WWID '$wwid' is not explicitly allow-listed - a LUN of a multipath-enabled"
+                    . " storage is managed through that storage's multipath option\n"
+                    if !$cfg->{ids}->{$wwid};
+                delete $cfg->{ids}->{$wwid};
+            },
+        );
+        return undef;
+    },
+});
+
+1;
diff --git a/src/PVE/Multipath/Config.pm b/src/PVE/Multipath/Config.pm
index 8bf5efb2..837afb8f 100644
--- a/src/PVE/Multipath/Config.pm
+++ b/src/PVE/Multipath/Config.pm
@@ -2,6 +2,7 @@ package PVE::Multipath::Config;
 
 use v5.36;
 
+use Digest::SHA qw(sha1_hex);
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::SectionConfig;
@@ -134,6 +135,7 @@ sub read_config() { return cfs_read_file('multipath.cfg') }
 sub write_cluster_config($cfg) { cfs_write_file('multipath.cfg', $cfg) }
 sub read_overrides() { return cfs_read_file('multipath-overrides.conf') }
 sub write_overrides($text) { cfs_write_file('multipath-overrides.conf', $text) }
+sub overrides_digest($text) { return sha1_hex($text // '') }
 
 sub lock_config($code, $errmsg = undef) {
     cfs_lock_file('multipath.cfg', undef, $code);
@@ -162,6 +164,18 @@ sub wwids_for_node($cfg, $node) {
         wwid_list($cfg)->@*];
 }
 
+sub wwid_sections($cfg) {
+    my $res = {};
+    for my $wwid (wwid_list($cfg)->@*) {
+        my $section = $cfg->{ids}->{$wwid};
+        my $entry = { map { $_ => $section->{$_} } grep { $_ ne 'type' } keys %$section };
+        $entry->{nodes} = __PACKAGE__->encode_value('wwid', 'nodes', $entry->{nodes})
+            if $entry->{nodes};
+        $res->{$wwid} = $entry;
+    }
+    return $res;
+}
+
 sub build_multipaths_block($cfg, $node) {
     my $out = "# Managed by Proxmox VE.\nmultipaths {\n";
     for my $wwid (wwids_for_node($cfg, $node)->@*) {
@@ -175,4 +189,16 @@ sub build_multipaths_block($cfg, $node) {
     return "$out}\n";
 }
 
+sub apply_section_update($section, $param, $delete) {
+    for my $key (sort keys %$param) {
+        $section->{$key} = __PACKAGE__->decode_value($section->{type}, $key, $param->{$key});
+    }
+    PVE::SectionConfig::delete_from_config(
+        $section,
+        $properties,
+        $param,
+        [PVE::Tools::split_list($delete // '')],
+    );
+}
+
 1;
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
index 7bed4266..aac5e250 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -9,11 +9,47 @@ BEGIN {
 use lib ('.', '..');
 use File::Temp qw(tempdir);
 use JSON qw(decode_json);
+use Storable qw(dclone);
 use Test::More;
 use Test::MockModule;
+use PVE::API2::Multipath;
 use PVE::Multipath::Generator;
 use PVE::Storage;
 
+subtest 'explicit entries are ordinary configuration writes' => sub {
+    my $cfg = { ids => {}, digest => 'a' x 40 };
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    $config->mock(read_config => sub { dclone($cfg) });
+    $config->mock(lock_config => sub { $_[0]->() });
+    $config->mock(write_cluster_config => sub { $cfg = $_[0] });
+    PVE::API2::Multipath->add_wwid({ wwid => '3600a', alias => 'data' });
+    is(
+        $cfg->{ids}->{'3600a'}->{alias},
+        'data',
+        'entry can be added without node reports or tools',
+    );
+    eval { PVE::API2::Multipath->add_wwid({ wwid => '3600b', alias => 'data' }) };
+    like($@, qr/already|used|alias/, 'duplicate alias refused');
+    PVE::API2::Multipath->update_wwid({ wwid => '3600a', 'no-path-retry' => 'fail' });
+    is($cfg->{ids}->{'3600a'}->{'no-path-retry'}, 'fail', 'per-LUN setting updated');
+    eval { PVE::API2::Multipath->update_wwid({ wwid => '3600a', digest => 'b' x 40 }) };
+    like($@, qr/modified/, 'digest checked');
+    PVE::API2::Multipath->remove_wwid({ wwid => '3600a' });
+    is_deeply($cfg->{ids}, {}, 'entry removed without local device commands');
+
+    for my $name (qw(read_wwid add_wwid update_wwid remove_wwid)) {
+        my $schema = PVE::API2::Multipath->map_method_by_name($name)->{parameters};
+        eval { PVE::JSONSchema::validate({ wwid => '8:16' }, $schema) };
+        like($@, qr/wwid: value does not match/,
+            "$name refuses an ambiguous WWID as parameter");
+    }
+    is_deeply(
+        PVE::API2::Multipath->index({}),
+        [map { { name => $_ } } qw(overrides wwid)],
+        'index',
+    );
+};
+
 subtest 'add-only generation and failed reload throttle' => sub {
     my $dir = tempdir('multipath-test-XXXX', DIR => '.', CLEANUP => 1);
     local $PVE::Multipath::Generator::DEFAULTS_DROPIN = "$dir/defaults";




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 15/36] api: multipath: add the cluster-wide health status
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (13 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 14/36] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 16/36] api: scan: add a SAN LUN inventory Thomas Lamprecht
                   ` (21 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Combine the reports of the nodes into one view: the state of each
node (ok, multipath unavailable with the reason, or no report within
three minutes) and, per LUN, the state of its map on each node with
the worst one as summary. A LUN is listed if a node reports it, if it
has an explicit entry or if an LVM storage uses it as base volume.

A node should have a LUN if an explicit entry, the iSCSI storage that
requests the map or a shared LVM storage on it covers the node. One
that does not report it counts as missing, one without a current
report as unknown. Storage admins can read it as well, they need the
initiator names for the array.

Each LUN also names the enabled iSCSI storage with multipath that
requests its map on one of its nodes, so that a map without an explicit
entry can be told apart from one that nothing in Proxmox VE asked for. A
node reports the number of paths it expects, so that one with fewer
paths can show how many are missing.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Multipath.pm           |  88 ++++++++++++++++++++-
 src/PVE/Multipath/Status.pm         | 109 +++++++++++++++++++++++++
 src/test/run_multipath_api_tests.pl | 118 +++++++++++++++++++++++++++-
 3 files changed, 312 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
index 667c2340..d5d2df9d 100644
--- a/src/PVE/API2/Multipath.pm
+++ b/src/PVE/API2/Multipath.pm
@@ -10,6 +10,7 @@ use PVE::RESTHandler;
 use PVE::Tools qw(extract_param);
 
 use PVE::Multipath::Config;
+use PVE::Multipath::Status;
 
 use base qw(PVE::RESTHandler);
 
@@ -60,7 +61,92 @@ __PACKAGE__->register_method({
         links => [{ rel => 'child', href => "{name}" }],
     },
     code => sub {
-        return [map { +{ name => $_ } } qw(overrides wwid)];
+        return [map { +{ name => $_ } } qw(overrides status wwid)];
+    },
+});
+
+my $state_schema = {
+    type => 'string',
+    enum => ['optimal', 'degraded', 'failed', 'missing', 'unknown'],
+};
+my $lun_node_schema = {
+    type => 'object',
+    additionalProperties => 0,
+    properties => {
+        state => $state_schema,
+        name => { type => 'string', optional => 1 },
+        map { $_ => { type => 'integer', minimum => 0, optional => 1 } }
+            qw(size paths-active paths-total paths-expected),
+    },
+};
+my $node_schema = {
+    type => 'object',
+    additionalProperties => 0,
+    properties => {
+        state => { type => 'string', enum => ['ok', 'unavailable', 'no-report'] },
+        time => { type => 'integer', optional => 1 },
+        map { $_ => { type => 'string', optional => 1 } }
+            qw(error apply-error iscsi-initiator-name),
+    },
+};
+
+__PACKAGE__->register_method({
+    name => 'status',
+    path => 'status',
+    method => 'GET',
+    description => "Report the multipath health of each LUN on each node, and the worst"
+        . " state among the nodes that should see or report the LUN.",
+    # Storage administrators need path health and initiator names to configure SAN target ACLs.
+    permissions => {
+        check => [
+            'or', ['perm', '/', ['Sys.Audit']], ['perm', '/storage', ['Datastore.Allocate']],
+        ],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => {
+        type => 'object',
+        properties => {
+            luns => {
+                type => 'array',
+                description =>
+                    "One entry per LUN, identified by its WWID, with the state of its"
+                    . " map on each node and the overall cluster state.",
+                items => {
+                    type => 'object',
+                    additionalProperties => 0,
+                    properties => {
+                        wwid => { type => 'string', description => 'The LUN WWID.' },
+                        explicit =>
+                            { type => 'boolean', description => 'An explicit entry exists.' },
+                        name => { type => 'string', optional => 1 },
+                        'used-by-storage' => { type => 'string', optional => 1 },
+                        'multipath-storage' => {
+                            type => 'string',
+                            optional => 1,
+                            description => 'The storage that requests the map of the LUN.',
+                        },
+                        size => { type => 'integer', minimum => 0, optional => 1 },
+                        state => $state_schema,
+                        nodes => {
+                            type => 'object',
+                            description => "Map health keyed by node name.",
+                            additionalProperties => $lun_node_schema,
+                        },
+                    },
+                },
+            },
+            nodes => {
+                type => 'object',
+                description => "Available node reports, keyed by node name.",
+                additionalProperties => $node_schema,
+            },
+        },
+    },
+    code => sub {
+        return PVE::Multipath::Status::cluster_status();
     },
 });
 
diff --git a/src/PVE/Multipath/Status.pm b/src/PVE/Multipath/Status.pm
index 91b699c4..58d11f5d 100644
--- a/src/PVE/Multipath/Status.pm
+++ b/src/PVE/Multipath/Status.pm
@@ -5,11 +5,22 @@ use JSON qw(decode_json);
 use PVE::Cluster;
 use PVE::INotify;
 use PVE::Multipath;
+use PVE::Multipath::Config;
 use PVE::Multipath::Generator;
 
 my $json = JSON->new->utf8->canonical;
 my $KEY = 'multipath';
 
+sub worst_state(@states) {
+    my %rank = (unknown => -1, optimal => 0, degraded => 1, missing => 2, failed => 3);
+    my $worst = 'unknown';
+    for my $state (@states) {
+        $worst = $state
+            if defined($state) && exists($rank{$state}) && $rank{$state} > $rank{$worst};
+    }
+    return $worst;
+}
+
 sub publish($report) {
     my $node = PVE::INotify::nodename();
     my $now = time();
@@ -58,6 +69,8 @@ sub update_node_status() {
             $lun->{size} = $map->{size} if defined($map->{size});
             $lun->{name} = $map->{name} if defined($map->{name}) && $map->{name} ne $wwid;
             $lun->{storage} = $info->{storages}->[0] if $info->{storages};
+            $lun->{'paths-expected'} = $info->{'paths-expected'}
+                if defined($info->{'paths-expected'});
             my $vg = defined($map->{sysfs}) ? $pv_vgs->{"/dev/$map->{sysfs}"} : undef;
             $lun->{vgname} = $vg if defined($vg);
             push $report->{luns}->@*, $lun;
@@ -72,4 +85,100 @@ sub update_node_status() {
     warn "multipath: cannot publish node status - $@" if $@;
 }
 
+sub cluster_status() {
+    require PVE::Storage;
+
+    my $cfg = PVE::Multipath::Config::read_config();
+    my $storage = PVE::Storage::config();
+    my $all_nodes = PVE::Cluster::get_nodelist();
+    my $members = PVE::Cluster::get_members();
+    my $raw = PVE::Cluster::get_node_kv($KEY);
+    my (%nodes, %luns, %expected, %observed, %vg_owner);
+    my $storage_nodes = sub($scfg) {
+        return $scfg->{nodes} && $scfg->{nodes}->%* ? [keys $scfg->{nodes}->%*] : $all_nodes;
+    };
+    # only an enabled iSCSI storage with the option requests the maps of its LUNs, on its nodes
+    my %current = map { $_ => 1 } @$all_nodes;
+    my $requests_maps = sub($sid, $node = undef) {
+        my $scfg = defined($sid) ? $storage->{ids}->{$sid} : undef;
+        return 0
+            if !$scfg || $scfg->{type} ne 'iscsi' || !$scfg->{multipath} || $scfg->{disable};
+        my @nodes = grep { $current{$_} } $storage_nodes->($scfg)->@*;
+        return defined($node) ? !!grep({ $_ eq $node } @nodes) : !!@nodes;
+    };
+    for my $wwid (PVE::Multipath::Config::wwid_list($cfg)->@*) {
+        my $entry = $cfg->{ids}->{$wwid};
+        $luns{$wwid} = { wwid => $wwid, explicit => 1 };
+        $luns{$wwid}->{name} = $entry->{alias} if defined($entry->{alias});
+        $expected{$wwid}->{$_} = 1 for $storage_nodes->($entry)->@*;
+    }
+    for my $sid (sort keys $storage->{ids}->%*) {
+        my $scfg = $storage->{ids}->{$sid};
+        $vg_owner{ $scfg->{vgname} } //= $sid if defined($scfg->{vgname});
+        next if $scfg->{type} ne 'lvm';
+        my ($wwid) = ($scfg->{base} // '') =~ /(?:^|\.)dm-uuid-mpath-(\S+)$/;
+        next if !defined($wwid);
+        $luns{$wwid} //= { wwid => $wwid, explicit => 0 };
+        $luns{$wwid}->{'used-by-storage'} //= $sid;
+        my ($base) = $scfg->{base} =~ /^([^:]+):/;
+        $luns{$wwid}->{'multipath-storage'} //= $base if $requests_maps->($base);
+        $expected{$wwid}->{$_} = 1 for $storage_nodes->($scfg)->@*;
+    }
+    for my $node (sort @$all_nodes) {
+        my $report = eval { decode_json($raw->{$node} // '') };
+        $report = {} if ref($report) ne 'HASH';
+        my $entry = $nodes{$node} = { state => 'no-report' };
+        $entry->{time} = $report->{time} if defined($report->{time});
+        next
+            if (exists($members->{$node}) && !$members->{$node}->{online})
+            || !defined($report->{time})
+            || time() - $report->{time} > 180;
+        $entry->{$_} = $report->{$_}
+            for grep { defined($report->{$_}) } qw(error apply-error iscsi-initiator-name);
+        $entry->{state} = defined($report->{error}) ? 'unavailable' : 'ok';
+        next if $entry->{state} ne 'ok';
+
+        for my $lun (($report->{luns} // [])->@*) {
+            my $wwid = $lun->{wwid} // next;
+            my $row = $luns{$wwid} //= { wwid => $wwid, explicit => 0 };
+            $row->{$_} //= $lun->{$_} for grep { defined($lun->{$_}) } qw(name size);
+            my $owner = defined($lun->{vgname}) ? $vg_owner{ $lun->{vgname} } : undef;
+            $row->{'used-by-storage'} //= $owner if defined($owner);
+            # a shared LVM storage on the map needs it on its nodes, also without a base volume
+            my $lvm = defined($owner) ? $storage->{ids}->{$owner} : undef;
+            if ($lvm && $lvm->{type} eq 'lvm' && $lvm->{shared} && !$lvm->{disable}) {
+                $expected{$wwid}->{$_} = 1 for $storage_nodes->($lvm)->@*;
+            }
+            my $sid = $lun->{storage};
+            if (defined($sid) && (my $scfg = $storage->{ids}->{$sid})) {
+                $row->{'multipath-storage'} //= $sid if $requests_maps->($sid, $node);
+                $row->{'used-by-storage'} //= $sid
+                    if PVE::Storage::san_storage_serves_images($scfg);
+                $expected{$wwid}->{$_} = 1
+                    for !$scfg->{disable} ? $storage_nodes->($scfg)->@* : ();
+            }
+            $observed{$wwid}->{$node} = {
+                state => worst_state($lun->{state}),
+                map { $_ => $lun->{$_} }
+                    grep { defined($lun->{$_}) }
+                    qw(name size paths-active paths-total paths-expected),
+            };
+        }
+    }
+    for my $wwid (sort keys %luns) {
+        my $row = $luns{$wwid};
+        $row->{nodes} = {};
+        for my $node (sort @$all_nodes) {
+            if ($observed{$wwid}->{$node}) {
+                $row->{nodes}->{$node} = $observed{$wwid}->{$node};
+            } elsif ($expected{$wwid}->{$node}) {
+                $row->{nodes}->{$node} =
+                    { state => $nodes{$node}->{state} eq 'ok' ? 'missing' : 'unknown' };
+            }
+        }
+        $row->{state} = worst_state(map { $_->{state} } values $row->{nodes}->%*);
+    }
+    return { nodes => \%nodes, luns => [map { $luns{$_} } sort keys %luns] };
+}
+
 1;
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
index aac5e250..77ee3b9f 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -8,7 +8,7 @@ BEGIN {
 }
 use lib ('.', '..');
 use File::Temp qw(tempdir);
-use JSON qw(decode_json);
+use JSON qw(encode_json decode_json);
 use Storable qw(dclone);
 use Test::More;
 use Test::MockModule;
@@ -45,7 +45,7 @@ subtest 'explicit entries are ordinary configuration writes' => sub {
     }
     is_deeply(
         PVE::API2::Multipath->index({}),
-        [map { { name => $_ } } qw(overrides wwid)],
+        [map { { name => $_ } } qw(overrides status wwid)],
         'index',
     );
 };
@@ -232,7 +232,121 @@ subtest 'one entry point applies configuration and reports unavailable reasons'
         sub { [{ wwid => '3600a', name => 'data', 'paths-active' => 1, 'paths-total' => 2 }] });
     PVE::Multipath::Status::update_node_status();
     is($report->{luns}->[0]->{state}, 'degraded', 'maps without PVE entries are included');
+    ok(!exists($report->{luns}->[0]->{'paths-expected'}), 'no expected count without a source');
+    $gen->mock(sync => sub { { wwids => { '3600a' => { 'paths-expected' => 3 } } } });
+    $mp->mock(get_maps =>
+        sub { [{ wwid => '3600a', name => 'data', 'paths-active' => 2, 'paths-total' => 2 }] });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{luns}->[0]->{'paths-expected'}, 3, 'expected count reported');
+    is($report->{luns}->[0]->{state}, 'degraded', 'fewer paths than expected');
     ok(!exists($report->{supported}), 'no separate capability state');
 };
 
+subtest 'API returns final node and LUN states' => sub {
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    my $storage = Test::MockModule->new('PVE::Storage');
+    $cluster->mock(get_nodelist => sub { [qw(n1 n2 n3 n4 n5)] });
+    $cluster->mock(get_members => sub { { n4 => { online => 0 } } });
+    my %raw = (
+        n1 => encode_json({
+            time => $NOW,
+            luns => [
+                {
+                    wwid => '3600a',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    'paths-expected' => 2,
+                    storage => 'iscsi',
+                    vgname => 'vgfc',
+                },
+                {
+                    wwid => '3600d',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storage => 'off',
+                    vgname => 'vgshared',
+                },
+                {
+                    wwid => '3600f',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storage => 'scoped',
+                },
+            ],
+        }),
+        n2 => encode_json({ time => $NOW, luns => [] }),
+        n3 => encode_json({ time => $NOW - 181, luns => [] }),
+        n4 => encode_json({ time => $NOW, luns => [] }),
+        n5 => encode_json({ time => $NOW, error => 'multipath-tools is not installed' }),
+    );
+    $cluster->mock(get_node_kv => sub { \%raw });
+    $config->mock(read_config => sub { { ids => { '3600a' => { type => 'wwid' } } } });
+    $storage->mock(
+        config => sub { {
+            ids => {
+                iscsi => { type => 'iscsi', multipath => 1 },
+                lvm => { type => 'lvm', base => 'iscsi:0.0.0.dm-uuid-mpath-3600b' },
+                fc => { type => 'lvm', vgname => 'vgfc' },
+                off => { type => 'iscsi' },
+                lvmoff => { type => 'lvm', base => 'off:0.0.0.dm-uuid-mpath-3600c' },
+                shared => { type => 'lvm', vgname => 'vgshared', shared => 1 },
+                gone => { type => 'iscsi', multipath => 1, nodes => { departed => 1 } },
+                lvmgone => { type => 'lvm', base => 'gone:0.0.0.dm-uuid-mpath-3600e' },
+                scoped => { type => 'iscsi', multipath => 1, nodes => { n2 => 1 } },
+            },
+        } },
+    );
+    my $res = PVE::API2::Multipath->status({});
+    is_deeply(
+        [map { $res->{nodes}->{$_}->{state} } qw(n1 n2 n3 n4 n5)],
+        [qw(ok ok no-report no-report unavailable)],
+        'final node states',
+    );
+    is($res->{nodes}->{n3}->{time}, $NOW - 181, 'old report time retained');
+    my $lun = $res->{luns}->[0];
+    is($lun->{state}, 'missing', 'worst known state');
+    is($lun->{nodes}->{n1}->{state}, 'optimal', 'observed healthy map');
+    is($lun->{nodes}->{n2}->{state}, 'missing', 'expected map absent from current report');
+    is($lun->{nodes}->{n3}->{state}, 'unknown', 'stale observation');
+    is($lun->{'used-by-storage'}, 'fc', 'storage attributed through the reported volume group');
+    is($res->{luns}->[1]->{wwid}, '3600b', 'LVM base included without observation');
+    is($res->{luns}->[1]->{'used-by-storage'}, 'lvm', 'LVM consumer attributed');
+    is($lun->{'multipath-storage'}, 'iscsi', 'reported storage requests the map');
+    is($res->{luns}->[1]->{'multipath-storage'}, 'iscsi', 'base storage requests the map');
+    is($lun->{nodes}->{n1}->{'paths-expected'}, 2, 'expected path count of the node');
+    my %lun = map { $_->{wwid} => $_ } $res->{luns}->@*;
+    ok(
+        !exists($lun{'3600c'}->{'multipath-storage'}),
+        'a base without multipath requests nothing',
+    );
+    ok(!exists($lun{'3600d'}->{'multipath-storage'}), 'neither does a reported one');
+    ok(
+        !exists($lun{'3600e'}->{'multipath-storage'}),
+        'a base for no current node requests nothing',
+    );
+    ok(!exists($lun{'3600f'}->{'multipath-storage'}), 'a storage requests on its nodes only');
+    is(
+        $lun{'3600d'}->{nodes}->{n2}->{state},
+        'missing',
+        'the nodes of a shared LVM expect the map',
+    );
+    is($lun{'3600d'}->{'used-by-storage'}, 'shared', 'shared LVM attributed by volume group');
+    eval {
+        PVE::JSONSchema::validate(
+            $res,
+            PVE::API2::Multipath->map_method_by_name('status')->{returns},
+        );
+    };
+    is($@, '', 'result satisfies the API schema');
+    is(
+        PVE::Multipath::Status::worst_state(qw(unknown optimal failed degraded missing)),
+        'failed',
+        'one ranking',
+    );
+};
+
 done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 16/36] api: scan: add a SAN LUN inventory
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (14 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 15/36] api: multipath: add the cluster-wide health status Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 17/36] pvesm: expose the " Thomas Lamprecht
                   ` (20 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Add /nodes/{node}/scan/san-luns, which lists the LUNs a node sees
over iSCSI, Fibre Channel or NVMe over Fabrics, one row per WWID with
the paths folded into their multipath map. The node disk list has
neither the maps nor a relation to volume groups and storages.

A row has the device to use, its size and transport, how multipath
handles the LUN, the health and state of its paths, and the known
usage with the volume group and storage. The usage comes from cached
data only, as probing a LUN whose paths are down can block.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Storage/Scan.pm                  | 197 ++++++++++++++++++
 src/PVE/Diskmanage.pm                         |   7 +
 src/PVE/Multipath.pm                          |  24 +++
 src/PVE/Storage/Makefile                      |   3 +-
 src/PVE/Storage/SAN.pm                        | 189 +++++++++++++++++
 src/test/Makefile                             |   8 +-
 src/test/disk_tests/multipath/multipathd      | 124 +++++++++++
 .../multipath/multipathd_status_expected.json |  40 ++++
 src/test/disklist_test.pm                     |  15 ++
 src/test/run_san_api_tests.pl                 |  24 +++
 src/test/run_san_lun_scan_tests.pl            | 180 ++++++++++++++++
 11 files changed, 809 insertions(+), 2 deletions(-)
 create mode 100644 src/PVE/Storage/SAN.pm
 create mode 100644 src/test/disk_tests/multipath/multipathd
 create mode 100644 src/test/disk_tests/multipath/multipathd_status_expected.json
 create mode 100755 src/test/run_san_api_tests.pl
 create mode 100755 src/test/run_san_lun_scan_tests.pl

diff --git a/src/PVE/API2/Storage/Scan.pm b/src/PVE/API2/Storage/Scan.pm
index a58bdd80..96e1bd34 100644
--- a/src/PVE/API2/Storage/Scan.pm
+++ b/src/PVE/API2/Storage/Scan.pm
@@ -12,6 +12,7 @@ use PVE::SafeSyslog;
 use PVE::Storage::LVMPlugin;
 use PVE::Storage::LvmThinPlugin;
 use PVE::Storage::PBSPlugin;
+use PVE::Storage::SAN;
 use PVE::Storage;
 
 use base qw(PVE::RESTHandler);
@@ -49,6 +50,7 @@ __PACKAGE__->register_method({
             { method => 'lvm' },
             { method => 'nfs' },
             { method => 'pbs' },
+            { method => 'san-luns' },
             { method => 'zfs' },
         ];
 
@@ -373,6 +375,201 @@ __PACKAGE__->register_method({
     },
 });
 
+__PACKAGE__->register_method({
+    name => 'sanlunscan',
+    path => 'san-luns',
+    method => 'GET',
+    description => "List SAN LUNs with their paths and cached usage.",
+    protected => 1,
+    proxyto => "node",
+    permissions => {
+        check => [
+            'or',
+            ['perm', '/nodes/{node}', ['Sys.Audit']],
+            ['perm', '/storage', ['Datastore.Allocate']],
+        ],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            node => get_standard_option('pve-node'),
+        },
+    },
+    returns => {
+        type => 'array',
+        items => {
+            type => "object",
+            properties => {
+                devpath => {
+                    description => "The device path.",
+                    type => 'string',
+                },
+                size => {
+                    description => "The device size in bytes.",
+                    type => 'integer',
+                    renderer => 'bytes',
+                    optional => 1,
+                },
+                transport => {
+                    description =>
+                        "The device transport, for example 'sata', 'sas', 'usb', 'fc',"
+                        . " 'iscsi', 'nvme', 'nvme-fc', or 'nvme-tcp'.",
+                    type => 'string',
+                    optional => 1,
+                },
+                vendor => { type => 'string', optional => 1 },
+                model => { type => 'string', optional => 1 },
+                serial => { type => 'string', optional => 1 },
+                state => {
+                    description =>
+                        'The health of the multipath LUN when path status is available.',
+                    type => 'string',
+                    enum => ['optimal', 'degraded', 'failed'],
+                    optional => 1,
+                },
+                'paths-total' => {
+                    description => "The number of paths of a multipath mapped device or of"
+                        . " an NVMe namespace attached through multiple controllers.",
+                    type => 'integer',
+                    optional => 1,
+                },
+                'paths-active' => {
+                    description =>
+                        "The number of active paths whose checker state is ready, ghost,"
+                        . " or not reported. Native NVMe paths count when their controller is live"
+                        . " and their ANA state is optimized, non-optimized, or not reported.",
+                    type => 'integer',
+                    optional => 1,
+                },
+                'paths-expected' => {
+                    description => "The number of paths the LUN should have according to the"
+                        . " storage configuration, one per portal for iSCSI; absent when it is"
+                        . " not known.",
+                    type => 'integer',
+                    optional => 1,
+                },
+                'path-list' => {
+                    description => "The member paths of the device with their state.",
+                    type => 'array',
+                    optional => 1,
+                    items => {
+                        type => 'object',
+                        properties => {
+                            device => {
+                                description => "The path block device, or the NVMe"
+                                    . " controller device the path uses.",
+                                type => 'string',
+                            },
+                            state => {
+                                description => "The device mapper state of the path (for"
+                                    . " example active or failed) or the state of the NVMe"
+                                    . " controller (for example live or connecting).",
+                                type => 'string',
+                            },
+                            'checker-state' => {
+                                description => "The state reported by the multipathd path"
+                                    . " checker, for example ready, ghost or faulty.",
+                                type => 'string',
+                                optional => 1,
+                            },
+                            'ana-state' => {
+                                description => "The Asymmetric Namespace Access state of"
+                                    . " the namespace on this path, for example optimized"
+                                    . " or inaccessible.",
+                                type => 'string',
+                                optional => 1,
+                            },
+                            'host-wwpn' => {
+                                description => "The WWPN of the host (initiator) port of"
+                                    . " Fibre Channel attached paths.",
+                                type => 'string',
+                                optional => 1,
+                            },
+                            'target-wwpn' => {
+                                description => "The WWPN of the target port of Fibre"
+                                    . " Channel attached paths.",
+                                type => 'string',
+                                optional => 1,
+                            },
+                            address => {
+                                description => "The address of the NVMe controller the"
+                                    . " path uses.",
+                                type => 'string',
+                                optional => 1,
+                            },
+                        },
+                    },
+                },
+                usage => {
+                    description => "The usage indicated by cached device metadata.",
+                    type => 'string',
+                    enum => ['unused', 'lvm', 'other'],
+                },
+                vgname => {
+                    description => "The name of the LVM volume group the device belongs to.",
+                    type => 'string',
+                    optional => 1,
+                },
+                'by-id' => {
+                    description =>
+                        "A path under /dev/disk/by-id that encodes the device's identity"
+                        . " and has been verified to resolve to this device. Absent when no such"
+                        . " link could be verified.",
+                    type => 'string',
+                    optional => 1,
+                },
+                'used-by-storage' => {
+                    description => "The storage that uses the LUN: through the volume group"
+                        . " on it, or as an iSCSI storage that serves the LUNs of its target as"
+                        . " images.",
+                    type => 'string',
+                    optional => 1,
+                },
+                wwid => {
+                    description => "The LUN WWID.",
+                    type => 'string',
+                },
+                name => {
+                    description => 'The map alias, when different from its WWID.',
+                    type => 'string',
+                    optional => 1,
+                },
+                multipath => {
+                    description => "How the node manages multipath for the LUN. NVMe namespaces"
+                        . " use kernel-native multipath.",
+                    type => 'string',
+                    enum => ['none', 'pending', 'storage', 'manual', 'unmanaged', 'native'],
+                },
+                'multipath-storage' => {
+                    description =>
+                        "The multipath-enabled storage the LUN belongs to, whether or"
+                        . " not it also has an explicit multipath entry.",
+                    type => 'string',
+                    optional => 1,
+                },
+                'iscsi-target' => {
+                    description => "The IQN of the iSCSI target the LUN is attached through.",
+                    type => 'string',
+                    optional => 1,
+                },
+                'iscsi-lun' => {
+                    description => "The number of the LUN on its iSCSI target.",
+                    type => 'integer',
+                    optional => 1,
+                },
+                detail => {
+                    description => "The cached signature or usage when usage is 'other'.",
+                    type => 'string',
+                    optional => 1,
+                },
+            },
+        },
+    },
+    code => sub {
+        return PVE::Storage::SAN::scan_luns(PVE::Storage::config());
+    },
+});
+
 __PACKAGE__->register_method({
     name => 'zfsscan',
     path => 'zfs',
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index 5c021d6d..bef401af 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -523,6 +523,13 @@ sub get_nvme_transport {
     return $transport;
 }
 
+# SAS does not distinguish local from remote attachments, so it is not classified as remote.
+sub is_remote_transport {
+    my ($transport) = @_;
+
+    return ($transport // '') =~ m/^(?:fc|fcoe|iscsi|nvme-(?:fc|tcp|rdma))$/;
+}
+
 my sub is_ssdlike {
     my ($type) = @_;
     return $type eq 'ssd' || $type eq 'nvme';
diff --git a/src/PVE/Multipath.pm b/src/PVE/Multipath.pm
index 6f61a3fe..0d41d963 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -2,6 +2,8 @@ package PVE::Multipath;
 
 use v5.36;
 
+use Cwd qw(abs_path);
+use File::Basename qw(basename);
 use Encode qw(decode encode);
 use JSON qw(decode_json);
 use PVE::Diskmanage;
@@ -17,6 +19,12 @@ sub parse_dm_uuid($uuid) {
     return { wwid => $wwid, defined($part) ? (partition => int($part)) : () };
 }
 
+sub device_map($device) {
+    my $name = basename(abs_path($device) // $device);
+    return undef if $name !~ /^dm-\d+$/;
+    return parse_dm_uuid(file_read_firstline("/sys/block/$name/dm/uuid"));
+}
+
 sub map_info() {
     my $maps = {};
     dir_glob_foreach(
@@ -157,6 +165,22 @@ sub get_maps() {
     return $maps;
 }
 
+sub path_status_by_wwid() {
+    my $res = {};
+    for my $map (get_maps()->@*) {
+        my $wwid = $map->{wwid} // next;
+        my @paths;
+        for my $path ($map->{paths}->@*) {
+            my $row = { device => "/dev/$path->{dev}", state => $path->{'dm-state'} // 'undef' };
+            $row->{'checker-state'} = $path->{'check-state'} if defined($path->{'check-state'});
+            $row->{$_} = $path->{$_} for grep { defined($path->{$_}) } qw(host-wwpn target-wwpn);
+            push @paths, $row;
+        }
+        $res->{$wwid} = { active => $map->{'paths-active'}, paths => \@paths };
+    }
+    return $res;
+}
+
 sub wait_for_map($wwid, $timeout = 10) {
     my $link = "/dev/disk/by-id/dm-uuid-mpath-$wwid";
     my $deadline = time() + ($timeout // 10);
diff --git a/src/PVE/Storage/Makefile b/src/PVE/Storage/Makefile
index a67dc25f..a2df83c0 100644
--- a/src/PVE/Storage/Makefile
+++ b/src/PVE/Storage/Makefile
@@ -14,7 +14,8 @@ SOURCES= \
 	PBSPlugin.pm \
 	BTRFSPlugin.pm \
 	LvmThinPlugin.pm \
-	ESXiPlugin.pm
+	ESXiPlugin.pm \
+	SAN.pm
 
 .PHONY: install
 install:
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
new file mode 100644
index 00000000..f13d9633
--- /dev/null
+++ b/src/PVE/Storage/SAN.pm
@@ -0,0 +1,189 @@
+package PVE::Storage::SAN;
+
+use v5.36;
+
+use Cwd qw(abs_path);
+use File::Basename qw(basename);
+
+use PVE::INotify;
+
+use PVE::Diskmanage;
+use PVE::ISCSI::Topology;
+use PVE::Multipath;
+use PVE::Multipath::Generator;
+use PVE::Multipath::Config;
+use PVE::Multipath::Identity;
+use PVE::Storage;
+use PVE::Storage::LVMPlugin;
+use PVE::Tools qw(file_read_firstline);
+
+sub scan_luns($cfg) {
+    my $ids = PVE::Multipath::Identity::collect(all => 1);
+    my $disks = PVE::Diskmanage::get_disks(undef, 1, 0, 1);
+    my $map_info = PVE::Multipath::map_info();
+    my $members = PVE::Multipath::member_map($map_info);
+    my $maps = PVE::Diskmanage::get_multipath_disks($map_info);
+    my $sessions = PVE::ISCSI::Topology::device_map();
+    my $status = eval { PVE::Multipath::path_status_by_wwid() } // {};
+    my $nvme = PVE::Diskmanage::get_nvme_path_status();
+    my $pv_vgs = PVE::Storage::LVMPlugin::cached_pv_volume_groups();
+    my $mpcfg = PVE::Multipath::Config::read_config();
+    my %explicit = map { $_ => 1 }
+        PVE::Multipath::Config::wwids_for_node($mpcfg, PVE::INotify::nodename())->@*;
+    my %listed = map { $_ => 1 } PVE::Multipath::list_etc_multipath_wwids()->@*;
+    my $derived = PVE::Multipath::Generator::derived_wwids($cfg, $ids);
+    my (%storage, %expected, %vg_owner, %target_owner, %base_owner);
+
+    for my $sid (sort keys %$derived) {
+        for my $wwid (keys $derived->{$sid}->{wwids}->%*) {
+            $storage{$wwid} //= $sid;
+            my $count = $derived->{$sid}->{wwids}->{$wwid}->{'paths-expected'};
+            $expected{$wwid} = $count if defined($count) && $count > ($expected{$wwid} // 0);
+        }
+    }
+    for my $wwid (keys %explicit) {
+        my $count = $mpcfg->{ids}->{$wwid}->{'paths-expected'};
+        $expected{$wwid} = $count if defined($count) && $count > ($expected{$wwid} // 0);
+    }
+    for my $sid (sort keys $cfg->{ids}->%*) {
+        my $scfg = $cfg->{ids}->{$sid};
+        $vg_owner{ $scfg->{vgname} } //= $sid if defined($scfg->{vgname});
+        $target_owner{ $scfg->{target} } //= $sid
+            if defined($scfg->{target}) && PVE::Storage::san_storage_serves_images($scfg);
+        $base_owner{$1} //= $sid if ($scfg->{base} // '') =~ m/(?:^|\.)dm-uuid-mpath-(.+)$/;
+    }
+
+    my %rows;
+    my $add = sub($disk, $map = 0) {
+        my $name = basename(abs_path($disk->{devpath}) // $disk->{devpath});
+        return
+            if !is_san_device(
+                $disk->{devpath},
+                {
+                    map => $map,
+                    transport => $disk->{transport},
+                    session => $sessions->{$name},
+                },
+            );
+        my $wwid = $map ? $disk->{wwn} : PVE::Multipath::Identity::path_wwid($ids, $name);
+        $wwid //= file_read_firstline("/sys/class/block/$name/wwid") if $name =~ /^nvme/;
+        return if !defined($wwid) || !length($wwid);
+
+        my $row = $rows{$wwid} //= {
+            wwid => $wwid,
+            devpath => $disk->{devpath},
+            size => $disk->{size},
+            usage => 'unused',
+            multipath => $listed{$wwid}
+                || $explicit{$wwid}
+                || $storage{$wwid} ? 'pending' : 'none',
+        };
+        my $link = stable_path($disk->{devpath}, $wwid, $map);
+        # The device and its by-id name come from one disk. A map replaces a single path.
+        if ($map || (defined($link) && !$row->{'by-id'})) {
+            delete $row->{'by-id'};
+            $row->{devpath} = $disk->{devpath};
+            $row->{size} = $disk->{size};
+            $row->{'by-id'} = $link if defined($link);
+        }
+        if ($map) {
+            my $alias = basename($disk->{devpath});
+            $row->{name} = $alias if $alias ne $wwid;
+            $row->{multipath} =
+                $explicit{$wwid} ? 'manual'
+                : $storage{$wwid} ? 'storage'
+                : 'unmanaged';
+        }
+        $row->{multipath} = 'native' if $name =~ /^nvme\d+n\d+$/;
+        for my $key (qw(transport vendor model serial)) {
+            my $value = $disk->{$key};
+            $row->{$key} //= $value if defined($value) && $value ne 'unknown';
+        }
+        for my $member (map { basename($_) } ($disk->{slaves} // [$disk->{devpath}])->@*) {
+            my $session = $sessions->{$member} // next;
+            $row->{'iscsi-target'} //= $session->{target};
+            $row->{'iscsi-lun'} //= $session->{lun};
+            $row->{transport} = 'iscsi';
+        }
+        my $used = $disk->{used};
+        if (defined($used)) {
+            if ($used eq 'LVM' || $used eq 'LVM2_member') {
+                $row->{usage} = 'lvm';
+                delete $row->{detail};
+            } elsif ($row->{usage} ne 'lvm') {
+                $row->{usage} = 'other';
+                $row->{detail} = $used;
+            }
+        }
+        my $vg = $pv_vgs->{ abs_path($disk->{devpath}) // $disk->{devpath} };
+        if (defined($vg)) {
+            $row->{vgname} //= $vg;
+            $row->{usage} = 'lvm';
+            delete $row->{detail};
+        }
+        my $paths = $map ? $status->{$wwid} : $nvme->{$name};
+        if ($paths) {
+            $row->{'path-list'} = $paths->{paths};
+            $row->{'paths-total'} = scalar($paths->{paths}->@*);
+            $row->{'paths-active'} = $paths->{active};
+        } elsif ($map) {
+            $row->{'paths-total'} = $disk->{paths};
+        }
+        $row->{'multipath-storage'} = $storage{$wwid} if defined($storage{$wwid});
+        # multipath entries and iSCSI portals are for maps, not for native NVMe multipath
+        $row->{'paths-expected'} = $expected{$wwid}
+            if defined($expected{$wwid}) && $row->{multipath} ne 'native';
+    };
+    for my $name (sort keys %$disks) {
+        my $disk = $disks->{$name};
+        next if $members->{$name};
+        $add->($disk);
+    }
+    $add->($maps->{$_}, 1) for sort keys %$maps;
+    for my $row (values %rows) {
+        if (defined($row->{'paths-active'})) {
+            $row->{state} = PVE::Multipath::derive_health(
+                $row->{'paths-active'},
+                $row->{'paths-total'},
+                $row->{'paths-expected'},
+            );
+        }
+        my $owner = $base_owner{ $row->{wwid} } // $vg_owner{ $row->{vgname} // '' }
+            // $target_owner{ $row->{'iscsi-target'} // '' };
+        $row->{'used-by-storage'} = $owner if defined($owner);
+    }
+    return [map { $rows{$_} } sort keys %rows];
+}
+
+sub stable_path($device, $wwid, $map = 0) {
+    my $prefix = $map ? 'dm-uuid-mpath' : basename($device) =~ /^nvme/ ? 'nvme' : 'scsi';
+    my ($link) = "/dev/disk/by-id/$prefix-$wwid" =~ m{\A(/dev/disk/by-id/[A-Za-z0-9_.:+-]+)\z};
+    return undef if !defined($link);
+    return $link if (abs_path($link) // '') eq (abs_path($device) // $device);
+    return undef;
+}
+
+sub is_san_device($device, $info = undef) {
+    if (!$info) {
+        my $path = abs_path($device) // $device;
+        return 0 if PVE::Diskmanage::is_partition($path);
+        my $name = basename($path);
+        my $transport;
+        if ($name =~ /^nvme/) {
+            $transport = 'nvme-' . (PVE::Diskmanage::get_nvme_transport("/sys/block/$name") // '');
+        } elsif ((readlink("/sys/block/$name") // '') =~ m{/rport-\d+}) {
+            $transport = 'fc';
+        }
+        $info = {
+            map => PVE::Multipath::device_map($path),
+            transport => $transport,
+            session => PVE::Diskmanage::is_iscsi_device($name),
+        };
+    }
+    return
+        $info->{map}
+        || $info->{session}
+        || PVE::Diskmanage::is_remote_transport($info->{transport}) ? 1 : 0;
+}
+
+1;
diff --git a/src/test/Makefile b/src/test/Makefile
index a758e593..6348c61e 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_multipath test_san_libraries test_lun_identity test_lvm_base_activation test_multipath_api test_san_taint
+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_multipath test_san_libraries test_lun_identity test_lvm_base_activation test_multipath_api test_san_taint test_san_lun_scan test_san_api
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -65,3 +65,9 @@ test_multipath_api: run_multipath_api_tests.pl
 
 test_san_taint: run_san_taint_tests.pl
 	perl -T ./run_san_taint_tests.pl
+
+test_san_lun_scan: run_san_lun_scan_tests.pl
+	./run_san_lun_scan_tests.pl
+
+test_san_api: run_san_api_tests.pl
+	./run_san_api_tests.pl
diff --git a/src/test/disk_tests/multipath/multipathd b/src/test/disk_tests/multipath/multipathd
new file mode 100644
index 00000000..40243f91
--- /dev/null
+++ b/src/test/disk_tests/multipath/multipathd
@@ -0,0 +1,124 @@
+{
+   "major_version": 0,
+   "minor_version": 1,
+   "maps": [{
+      "name" : "mpatha",
+      "uuid" : "3600140500000000000000000000000001",
+      "sysfs" : "dm-0",
+      "failback" : "immediate",
+      "queueing" : "5 chk",
+      "paths" : 2,
+      "write_prot" : "rw",
+      "dm_st" : "active",
+      "features" : "1 queue_if_no_path",
+      "hwhandler" : "1 alua",
+      "action" : "",
+      "path_faults" : 0,
+      "vend" : "SANVEND ",
+      "prod" : "SANMODEL",
+      "rev" : "4.1",
+      "switch_grp" : 0,
+      "map_loads" : 1,
+      "total_q_time" : 0,
+      "q_timeouts" : 0,
+      "path_groups": [{
+         "selector" : "service-time 0",
+         "pri" : 50,
+         "dm_st" : "active",
+         "marginal_st" : "normal",
+         "group" : 1,
+         "paths": [{
+            "dev" : "sda",
+            "dev_t" : "8:0",
+            "dm_st" : "active",
+            "dev_st" : "running",
+            "chk_st" : "ready",
+            "checker" : "tur",
+            "pri" : 50,
+            "host_wwnn" : "0x20000024ff7d6a1c",
+            "target_wwnn" : "0x2000d039ea28bf00",
+            "host_wwpn" : "0x21000024ff7d6a1c",
+            "target_wwpn" : "0x2100d039ea28bf00",
+            "host_adapter" : "0000:41:00.0",
+            "lun_hex" : "0x0001000000000000",
+            "marginal_st" : "normal"
+         },
+         {
+            "dev" : "sdb",
+            "dev_t" : "8:16",
+            "dm_st" : "active",
+            "dev_st" : "running",
+            "chk_st" : "ready",
+            "checker" : "tur",
+            "pri" : 50,
+            "host_wwnn" : "0x20000024ff7d6a1d",
+            "target_wwnn" : "0x2000d039ea28bf00",
+            "host_wwpn" : "0x21000024ff7d6a1d",
+            "target_wwpn" : "0x2200d039ea28bf00",
+            "host_adapter" : "0000:41:00.1",
+            "lun_hex" : "0x0001000000000000",
+            "marginal_st" : "normal"
+         }]
+      }]
+   },
+   {
+      "name" : "mpathb",
+      "uuid" : "3600140500000000000000000000000002",
+      "sysfs" : "dm-1",
+      "failback" : "immediate",
+      "queueing" : "5 chk",
+      "paths" : 2,
+      "write_prot" : "rw",
+      "dm_st" : "active",
+      "features" : "1 queue_if_no_path",
+      "hwhandler" : "1 alua",
+      "action" : "",
+      "path_faults" : 3,
+      "vend" : "SANVEND ",
+      "prod" : "SANMODEL",
+      "rev" : "4.1",
+      "switch_grp" : 0,
+      "map_loads" : 1,
+      "total_q_time" : 0,
+      "q_timeouts" : 0,
+      "path_groups": [{
+         "selector" : "service-time 0",
+         "pri" : 50,
+         "dm_st" : "active",
+         "marginal_st" : "normal",
+         "group" : 1,
+         "paths": [{
+            "dev" : "sdc",
+            "dev_t" : "8:32",
+            "dm_st" : "active",
+            "dev_st" : "running",
+            "chk_st" : "ready",
+            "checker" : "tur",
+            "pri" : 50,
+            "host_wwnn" : "0x20000024ff7d6a1c",
+            "target_wwnn" : "0x2000d039ea28bf00",
+            "host_wwpn" : "0x21000024ff7d6a1c",
+            "target_wwpn" : "0x2100d039ea28bf00",
+            "host_adapter" : "0000:41:00.0",
+            "lun_hex" : "0x0002000000000000",
+            "marginal_st" : "normal"
+         },
+         {
+            "dev" : "sdd",
+            "dev_t" : "8:48",
+            "dm_st" : "failed",
+            "dev_st" : "running",
+            "chk_st" : "faulty",
+            "checker" : "tur",
+            "pri" : 0,
+            "host_wwnn" : "0x20000024ff7d6a1d",
+            "target_wwnn" : "0x2000d039ea28bf00",
+            "host_wwpn" : "0x21000024ff7d6a1d",
+            "target_wwpn" : "0x2200d039ea28bf00",
+            "host_adapter" : "0000:41:00.1",
+            "lun_hex" : "0x0002000000000000",
+            "marginal_st" : "normal"
+         }]
+      }]
+   }]
+}
diff --git a/src/test/disk_tests/multipath/multipathd_status_expected.json b/src/test/disk_tests/multipath/multipathd_status_expected.json
new file mode 100644
index 00000000..df5a24da
--- /dev/null
+++ b/src/test/disk_tests/multipath/multipathd_status_expected.json
@@ -0,0 +1,40 @@
+{
+    "3600140500000000000000000000000001": {
+        "active": 2,
+        "paths": [
+            {
+                "device": "/dev/sda",
+                "state": "active",
+                "checker-state": "ready",
+                "host-wwpn": "0x21000024ff7d6a1c",
+                "target-wwpn": "0x2100d039ea28bf00"
+            },
+            {
+                "device": "/dev/sdb",
+                "state": "active",
+                "checker-state": "ready",
+                "host-wwpn": "0x21000024ff7d6a1d",
+                "target-wwpn": "0x2200d039ea28bf00"
+            }
+        ]
+    },
+    "3600140500000000000000000000000002": {
+        "active": 1,
+        "paths": [
+            {
+                "device": "/dev/sdc",
+                "state": "active",
+                "checker-state": "ready",
+                "host-wwpn": "0x21000024ff7d6a1c",
+                "target-wwpn": "0x2100d039ea28bf00"
+            },
+            {
+                "device": "/dev/sdd",
+                "state": "failed",
+                "checker-state": "faulty",
+                "host-wwpn": "0x21000024ff7d6a1d",
+                "target-wwpn": "0x2200d039ea28bf00"
+            }
+        ]
+    }
+}
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index caa60e79..2f22fae8 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -70,6 +70,8 @@ sub mocked_run_command {
                 $content = '{}';
             }
             @$outputlines = split(/\n/, $content);
+        } elsif ($cmd->[0] =~ m/multipathd/i) {
+            @$outputlines = split(/\n/, read_test_file('multipathd'));
         } else {
             die "unexpected run_command call: '@$cmd', aborting\n";
         }
@@ -264,6 +266,16 @@ sub test_disk_list {
             ok($san_disks->{sda}, 'SAN inventory opts into iSCSI');
         }
 
+        if (-f "disk_tests/$testcasedir/multipathd_status_expected.json") {
+            my $status = PVE::Multipath::path_status_by_wwid();
+            my $expected_status =
+                decode_json(read_test_file('multipathd_status_expected.json'));
+
+            print Dumper($status) if $print;
+            $testcount++;
+            is_deeply($status, $expected_status, 'multipath status should be the same');
+        }
+
         if (-f "disk_tests/$testcasedir/nvme_path_status_expected.json") {
             my $status = PVE::Diskmanage::get_nvme_path_status();
             my $expected_status = decode_json(read_test_file('nvme_path_status_expected.json'));
@@ -296,8 +308,11 @@ print("\tMocked get_sysdir_size\n");
 $diskmanage_module->mock('assert_blockdev' => sub { return 1; });
 print("\tMocked assert_blockdev\n");
 $multipath_module = Test::MockModule->new('PVE::Multipath', no_auto => 1);
+$multipath_module->mock('run_command' => \&mocked_run_command);
+$multipath_module->mock('is_supported' => sub { return 1; });
 $multipath_module->mock('dir_glob_foreach' => \&mocked_dir_glob_foreach);
 $multipath_module->mock('file_read_firstline' => \&mocked_file_read_firstline);
+print("\tMocked PVE::Multipath run_command and is_supported\n");
 $diskmanage_module->mock(
     'dir_is_empty' => sub {
         my $val = shift;
diff --git a/src/test/run_san_api_tests.pl b/src/test/run_san_api_tests.pl
new file mode 100755
index 00000000..4bd7d2d7
--- /dev/null
+++ b/src/test/run_san_api_tests.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use lib qw(. ..);
+use PVE::API2::Storage::Scan;
+
+for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
+    my ($class, @names) = @$case;
+    for my $name (@names) {
+        is_deeply(
+            $class->map_method_by_name($name)->{permissions}->{check},
+            [
+                'or',
+                ['perm', '/nodes/{node}', ['Sys.Audit']],
+                ['perm', '/storage', ['Datastore.Allocate']],
+            ],
+            "$class $name read permission",
+        );
+    }
+}
+
+done_testing();
diff --git a/src/test/run_san_lun_scan_tests.pl b/src/test/run_san_lun_scan_tests.pl
new file mode 100755
index 00000000..94df0d5c
--- /dev/null
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -0,0 +1,180 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use lib qw(..);
+use Test::More;
+use Test::MockModule;
+
+use PVE::Storage::SAN;
+use PVE::API2::Storage::Scan;
+
+my $disk = Test::MockModule->new('PVE::Diskmanage');
+my $mp = Test::MockModule->new('PVE::Multipath');
+my $id = Test::MockModule->new('PVE::Multipath::Identity');
+my $config = Test::MockModule->new('PVE::Multipath::Config');
+my $storage = Test::MockModule->new('PVE::Storage');
+my $iscsi = Test::MockModule->new('PVE::ISCSI::Topology');
+my $scan = Test::MockModule->new('PVE::Storage::SAN');
+my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+my $hints;
+$lvm->mock(file_get_contents => sub { $hints // die "No such file\n" });
+$lvm->mock(abs_path => sub { $_[0] });
+$lvm->mock(run_command => sub { die "unexpected LVM device probe\n" });
+
+my $disks = {
+    sda => { devpath => '/dev/sda', size => 100, transport => 'sata' },
+    sdb => { devpath => '/dev/sdb', size => 200, transport => 'iscsi' },
+    sdc => { devpath => '/dev/sdc', size => 200, transport => 'iscsi', used => 'LVM2_member' },
+    sdd =>
+        { devpath => '/dev/sdd', size => 300, transport => 'fc', multipath => '/dev/mapper/lun' },
+    sde => { devpath => '/dev/sde', size => 400, transport => 'fc' },
+};
+my $maps = {
+    'dm-0' => {
+        devpath => '/dev/mapper/lun',
+        size => 300,
+        wwn => '3600map',
+        paths => 2,
+        slaves => ['/dev/sdd', '/dev/sdf'],
+        transport => 'fc',
+    },
+};
+$id->mock(collect => sub { {} });
+$id->mock(path_wwid => sub { $_[1] =~ /^(sdb|sdc)$/ ? '3600plain' : undef });
+$config->mock(read_config => sub { { ids => { '3600map' => { type => 'wwid' } } } });
+my $generator = Test::MockModule->new('PVE::Multipath::Generator');
+$generator->mock(derived_wwids => sub { {} });
+$iscsi->mock(
+    device_map => sub {
+        return { map { $_ => { target => 'iqn.test', lun => 1 } } qw(sdb sdc) };
+    },
+);
+$disk->mock(
+    get_disks => sub { ok($_[3], 'SAN inventory opts into iSCSI'); $disks },
+    get_multipath_disks => sub { $maps },
+    get_nvme_path_status => sub { {} },
+    run_command => sub { die 'unexpected device probe' },
+);
+$mp->mock(list_etc_multipath_wwids => sub { [] });
+$mp->mock(
+    map_info => sub {
+        return {
+            map {
+                $_ => {
+                    wwid => $maps->{$_}->{wwn},
+                    slaves => [map { s{^/dev/}{}r } $maps->{$_}->{slaves}->@*],
+                }
+            } keys %$maps
+        };
+    },
+);
+$mp->mock(
+    path_status_by_wwid => sub {
+        return {
+            '3600map' => {
+                active => 1,
+                paths => [
+                    { device => '/dev/sdd', state => 'active', 'checker-state' => 'ghost' },
+                    { device => '/dev/sdf', state => 'failed', 'checker-state' => 'faulty' },
+                ],
+            },
+        };
+    },
+);
+$scan->mock(abs_path => sub { $_[0] });
+$scan->mock(stable_path => sub { '/dev/disk/by-id/scsi-' . $_[1] });
+my $cfg =
+    { ids => { direct => { type => 'iscsi', target => 'iqn.test', content => { images => 1 } } } };
+my $rows = PVE::Storage::SAN::scan_luns($cfg);
+is(scalar(@$rows), 2, 'only identified SAN LUNs, one row per identity');
+my %row = map { $_->{wwid} => $_ } @$rows;
+is($row{'3600plain'}->{usage}, 'lvm', 'positive usage from any path survives folding');
+is($row{'3600plain'}->{'used-by-storage'}, 'direct', 'a storage serving the LUNs uses them');
+{
+    local $cfg->{ids}->{direct}->{content} = { none => 1 };
+    my %plain = map { $_->{wwid} => $_ } PVE::Storage::SAN::scan_luns($cfg)->@*;
+    is($plain{'3600plain'}->{'used-by-storage'}, undef, 'a connection storage does not');
+}
+ok(!exists($row{'3600plain'}->{state}), 'single path devices have no multipath health');
+is($row{'3600map'}->{state}, 'degraded', 'final state counts usable paths');
+is($row{'3600map'}->{multipath}, 'manual', 'explicit map');
+is($row{'3600map'}->{devpath}, '/dev/mapper/lun', 'map is the selected device');
+my $schema = PVE::API2::Storage::Scan->map_method_by_name('sanlunscan')->{returns};
+eval { PVE::JSONSchema::validate($rows, $schema) };
+is($@, '', 'rows match the public schema');
+is($row{'3600map'}->{name}, 'lun', 'map alias is exposed');
+$maps->{'dm-0'}->{devpath} = '/dev/mapper/3600map';
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+my ($unnamed) = grep { $_->{wwid} eq '3600map' } @$rows;
+ok(!exists($unnamed->{name}), 'WWID is not repeated as an alias');
+$maps->{'dm-0'}->{devpath} = '/dev/mapper/lun';
+
+{
+    my $healthy = {
+        '3600map' => {
+            active => 2,
+            paths => [map { { device => $_, state => 'active' } } qw(/dev/sdd /dev/sdf)],
+        },
+    };
+    $mp->mock(path_status_by_wwid => sub { $healthy });
+    my ($map) = grep { $_->{wwid} eq '3600map' } PVE::Storage::SAN::scan_luns($cfg)->@*;
+    is($map->{state}, 'optimal', 'all paths usable without an expected count');
+    $config->mock(
+        read_config =>
+            sub { { ids => { '3600map' => { type => 'wwid', 'paths-expected' => 3 } } } },
+    );
+    ($map) = grep { $_->{wwid} eq '3600map' } PVE::Storage::SAN::scan_luns($cfg)->@*;
+    is($map->{'paths-expected'}, 3, 'expected count of the entry');
+    is($map->{state}, 'degraded', 'fewer paths than the entry expects');
+    $config->mock(read_config => sub { { ids => { '3600map' => { type => 'wwid' } } } });
+}
+
+$mp->mock(path_status_by_wwid => sub { {} });
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+my ($unobserved) = grep { $_->{wwid} eq '3600map' } @$rows;
+is($unobserved->{'paths-total'}, 2, 'map membership supplies total without daemon status');
+ok(!exists($unobserved->{'paths-active'}), 'no invented active count');
+ok(!exists($unobserved->{state}), 'no false failed state');
+
+$cfg->{ids}->{data} = { type => 'lvm', vgname => 'data' };
+$hints = "scan:/dev/mapper/lun pvid:abc devn:253:0 vg:data\n";
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+my ($cached) = grep { $_->{wwid} eq '3600map' } @$rows;
+is($cached->{vgname}, 'data', 'hints supply the display VG');
+is($cached->{usage}, 'lvm', 'hints also supply cached usage evidence');
+is($cached->{'used-by-storage'}, 'data', 'VG allows storage attribution');
+for my $contents (undef, '', "scan=/dev/mapper/lun vg=data\n") {
+    $hints = $contents;
+    $rows = PVE::Storage::SAN::scan_luns($cfg);
+    is(scalar(@$rows), 2, 'missing or unrecognized hints do not lose LUNs');
+    my ($uncached) = grep { $_->{wwid} eq '3600map' } @$rows;
+    ok(!exists($uncached->{vgname}), 'VG name is absent without a hint');
+    ok(!exists($uncached->{'used-by-storage'}), 'VG-derived attribution is also absent');
+    is($uncached->{usage}, 'unused', 'usage falls back to other cached evidence');
+}
+
+$disks->{sdc}->{used} = 'ext4';
+$maps = {};
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+is($rows->[0]->{usage}, 'other', 'foreign data from a sibling path is retained');
+is($rows->[0]->{detail}, 'ext4', 'signature detail');
+$scan->mock(stable_path => sub { $_[0] eq '/dev/sdc' ? '/dev/disk/by-id/scsi-3600plain' : undef });
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+is($rows->[0]->{'by-id'}, '/dev/disk/by-id/scsi-3600plain', 'by-id link of the second path');
+is($rows->[0]->{devpath}, '/dev/sdc', 'the row names the path that its by-id link resolves to');
+
+$disks = { nvme0n1 => { devpath => '/dev/nvme0n1', size => 100, transport => 'nvme-fc' } };
+$scan->mock(file_read_firstline => sub { 'eui.0123456789abcdef' });
+$scan->unmock('stable_path');
+$scan->mock(abs_path => sub { '/dev/nvme0n1' });
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+is($rows->[0]->{multipath}, 'native', 'NVMe uses kernel-native multipath');
+is($rows->[0]->{'by-id'}, '/dev/disk/by-id/nvme-eui.0123456789abcdef', 'NVMe stable name');
+eval { PVE::JSONSchema::validate($rows, $schema) };
+is($@, '', 'native row matches the API schema');
+
+$disk->mock(is_partition => sub { 1 });
+ok(!PVE::Storage::SAN::is_san_device('/dev/sdb1'), 'a partition is never a LUN');
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 17/36] pvesm: expose the SAN LUN inventory
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (15 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 16/36] api: scan: add a SAN LUN inventory Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 18/36] api: add node-level iSCSI status Thomas Lamprecht
                   ` (19 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

Add 'pvesm scan san-luns', so that administrators can look at the
LUNs of a node with their multipath state, usage and storage on the
command line, for example before setting up shared LVM.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: print a concise column set]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/CLI/pvesm.pm          | 14 ++++++++++++++
 src/test/run_san_api_tests.pl | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/src/PVE/CLI/pvesm.pm b/src/PVE/CLI/pvesm.pm
index 1eb83331..347fbffa 100755
--- a/src/PVE/CLI/pvesm.pm
+++ b/src/PVE/CLI/pvesm.pm
@@ -736,6 +736,20 @@ our $cmddef = {
             $print_api_result,
             $PVE::RESTHandler::standard_output_options,
         ],
+        'san-luns' => [
+            "PVE::API2::Storage::Scan",
+            'sanlunscan',
+            [],
+            { node => $nodename },
+            sub {
+                my ($data, $schema, $options) = @_;
+                my $columns =
+                    [qw(devpath name size transport state paths-active paths-expected multipath
+                        usage vgname used-by-storage wwid)];
+                PVE::CLIFormatter::print_api_result($data, $schema, $columns, $options);
+            },
+            $PVE::RESTHandler::standard_output_options,
+        ],
         zfs => [
             "PVE::API2::Storage::Scan",
             'zfsscan',
diff --git a/src/test/run_san_api_tests.pl b/src/test/run_san_api_tests.pl
index 4bd7d2d7..f3846ba4 100755
--- a/src/test/run_san_api_tests.pl
+++ b/src/test/run_san_api_tests.pl
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use Test::MockModule;
 use Test::More;
 use lib qw(. ..);
 use PVE::API2::Storage::Scan;
@@ -21,4 +22,19 @@ for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
     }
 }
 
+require PVE::CLI::pvesm;
+my $formatter = Test::MockModule->new('PVE::CLIFormatter');
+my $data = [{ wwid => '3600abc', devpath => '/dev/sda', serial => 'S1' }];
+my $schema = PVE::API2::Storage::Scan->map_method_by_name('sanlunscan')->{returns};
+$formatter->mock(
+    print_api_result => sub {
+        is($_[0], $data, 'CLI forwards complete rows');
+        is($_[1], $schema, 'CLI forwards complete schema');
+        ok(grep { $_ eq 'state' } $_[2]->@*, 'CLI shows final state');
+        is($_[3]->{'output-format'}, 'json', 'CLI preserves output format');
+    },
+);
+$PVE::CLI::pvesm::cmddef->{scan}->{'san-luns'}->[4]
+    ->($data, $schema, { 'output-format' => 'json' });
+
 done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 18/36] api: add node-level iSCSI status
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (16 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 17/36] pvesm: expose the " Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 19/36] disks: lvm: drop unused imports Thomas Lamprecht
                   ` (18 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

Activating an iSCSI storage logs in on its own, but looking at the
sessions of a node needs iscsiadm on a shell. Add the API module for
/nodes/{node}/iscsi with a read-only view: the initiator name and
alias, and the targets with their portals, session state, block
devices and the storage of the target. Node records without a session
are listed too, so a target that is not connected stays visible.

Reading needs Sys.Audit on the node or Datastore.Allocate on
/storage.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: keep it read-only, without rescan and node record removal;
 report the initiator name and alias as top-level fields; move the
 iscsiadm helpers into the plugin]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/ISCSI.pm          | 165 +++++++++++++++++++++++++++++++++
 src/PVE/API2/Makefile          |   1 +
 src/PVE/ISCSI/Topology.pm      |  20 ++++
 src/PVE/Storage/ISCSIPlugin.pm |  27 ++++++
 src/test/run_san_api_tests.pl  |  56 ++++++++++-
 5 files changed, 268 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/API2/ISCSI.pm

diff --git a/src/PVE/API2/ISCSI.pm b/src/PVE/API2/ISCSI.pm
new file mode 100644
index 00000000..40044005
--- /dev/null
+++ b/src/PVE/API2/ISCSI.pm
@@ -0,0 +1,165 @@
+package PVE::API2::ISCSI;
+
+use v5.36;
+
+use PVE::ISCSI::Topology;
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTHandler;
+use PVE::Storage;
+use PVE::Storage::ISCSIPlugin;
+
+use base qw(PVE::RESTHandler);
+
+my $read_permissions = {
+    check => [
+        'or',
+        ['perm', '/nodes/{node}', ['Sys.Audit']],
+        ['perm', '/storage', ['Datastore.Allocate']],
+    ],
+};
+
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    proxyto => 'node',
+    permissions => { user => 'all' },
+    description => 'Node iSCSI index.',
+    parameters =>
+        { additionalProperties => 0, properties => { node => get_standard_option('pve-node') } },
+    returns => {
+        type => 'array',
+        items => { type => 'object', properties => { name => { type => 'string' } } },
+        links => [{ rel => 'child', href => '{name}' }],
+    },
+    code => sub { return [{ name => 'status' }, { name => 'target' }] },
+});
+
+__PACKAGE__->register_method({
+    name => 'status',
+    path => 'status',
+    method => 'GET',
+    protected => 1,
+    proxyto => 'node',
+    description => 'Report the iSCSI initiator identity and availability.',
+    permissions => $read_permissions,
+    parameters =>
+        { additionalProperties => 0, properties => { node => get_standard_option('pve-node') } },
+    returns => {
+        type => 'object',
+        properties => {
+            supported =>
+                { type => 'boolean', description => 'Whether open-iscsi is installed.' },
+            'initiator-name' =>
+                { type => 'string', optional => 1, description => 'The initiator IQN.' },
+            'initiator-alias' =>
+                { type => 'string', optional => 1, description => 'The initiator alias.' },
+        },
+    },
+    code => sub {
+        my $res = { supported => PVE::Storage::ISCSIPlugin::iscsi_supported() };
+        my $info = PVE::Storage::ISCSIPlugin::read_initiator_info() // {};
+        $res->{'initiator-name'} = $info->{name} if defined($info->{name});
+        $res->{'initiator-alias'} = $info->{alias} if defined($info->{alias});
+        return $res;
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'targets',
+    path => 'target',
+    method => 'GET',
+    protected => 1,
+    proxyto => 'node',
+    description => 'List iSCSI targets and their sessions and devices.',
+    permissions => $read_permissions,
+    parameters =>
+        { additionalProperties => 0, properties => { node => get_standard_option('pve-node') } },
+    returns => {
+        type => 'array',
+        items => {
+            type => 'object',
+            properties => {
+                target => { type => 'string', description => 'The target IQN.' },
+                portal => { type => 'string', description => 'The portal address and port.' },
+                'session-id' =>
+                    { type => 'integer', optional => 1, description => 'The kernel session ID.' },
+                state => {
+                    type => 'string',
+                    enum => ['logged-in', 'recovering', 'failed', 'not-connected', 'unknown'],
+                    description => 'The connection state.',
+                },
+                'kernel-state' =>
+                    { type => 'string', optional => 1, description => 'The kernel session state.' },
+                'used-by-storage' => {
+                    type => 'string',
+                    optional => 1,
+                    description => 'An iSCSI storage using the target.',
+                },
+                devices => {
+                    type => 'array',
+                    description => 'The block devices of the session.',
+                    items => {
+                        type => 'object',
+                        properties => {
+                            devpath =>
+                                { type => 'string', description => 'The block device path.' },
+                            lun => { type => 'integer', description => 'The LUN number.' },
+                        },
+                    },
+                },
+            },
+        },
+    },
+    code => sub {
+        my $sessions = PVE::ISCSI::Topology::sessions();
+        my $cfg = PVE::Storage::config();
+        my %owners;
+        for my $sid (sort keys $cfg->{ids}->%*) {
+            my $scfg = $cfg->{ids}->{$sid};
+            $owners{ $scfg->{target} } //= $sid if $scfg->{type} eq 'iscsi' && $scfg->{target};
+        }
+        my (@rows, %seen);
+        for my $sid (sort { $a <=> $b } keys %$sessions) {
+            my $session = $sessions->{$sid};
+            my $state = $session->{state};
+            my $row = {
+                target => $session->{target},
+                portal => $session->{portal},
+                'session-id' => int($sid),
+                state => $state eq 'LOGGED_IN' ? 'logged-in'
+                : $state eq 'FAILED' ? 'recovering'
+                : $state eq 'FREE' ? 'failed'
+                : 'unknown',
+                'kernel-state' => $state,
+                devices => [
+                    sort { $a->{lun} <=> $b->{lun} || $a->{devpath} cmp $b->{devpath} }
+                    map { { devpath => "/dev/$_", lun => $session->{devices}->{$_}->{lun} } }
+                    keys $session->{devices}->%*
+                ],
+            };
+            push @rows, $row;
+            $seen{"$row->{target}\0$row->{portal}"} = 1;
+        }
+        if (PVE::Storage::ISCSIPlugin::iscsi_supported()) {
+            for my $record (PVE::Storage::ISCSIPlugin::iscsi_node_list()->@*) {
+                my $portal = PVE::ISCSI::Topology::normalize_portal($record->{portal});
+                next if $seen{"$record->{target}\0$portal"}++;
+                push @rows,
+                    {
+                        target => $record->{target},
+                        portal => $portal,
+                        state => 'not-connected',
+                        devices => [],
+                    };
+            }
+        }
+        for my $row (@rows) {
+            $row->{'used-by-storage'} = $owners{ $row->{target} }
+                if defined($owners{ $row->{target} });
+        }
+        return [sort { $a->{target} cmp $b->{target} || $a->{portal} cmp $b->{portal} } @rows];
+    },
+});
+
+1;
diff --git a/src/PVE/API2/Makefile b/src/PVE/API2/Makefile
index 002a3bd4..9ab978b0 100644
--- a/src/PVE/API2/Makefile
+++ b/src/PVE/API2/Makefile
@@ -3,6 +3,7 @@
 .PHONY: install
 install:
 	install -D -m 0644 Disks.pm ${DESTDIR}${PERLDIR}/PVE/API2/Disks.pm
+	install -D -m 0644 ISCSI.pm ${DESTDIR}${PERLDIR}/PVE/API2/ISCSI.pm
 	install -D -m 0644 Multipath.pm ${DESTDIR}${PERLDIR}/PVE/API2/Multipath.pm
 	make -C Storage install
 	make -C Disks install
diff --git a/src/PVE/ISCSI/Topology.pm b/src/PVE/ISCSI/Topology.pm
index fae1f6e7..0d16b13a 100644
--- a/src/PVE/ISCSI/Topology.pm
+++ b/src/PVE/ISCSI/Topology.pm
@@ -39,8 +39,18 @@ sub sessions {
             my $target = file_read_firstline("$dir/targetname") // return;
             my $session = {
                 target => $target,
+                state => file_read_firstline("$dir/state") // '',
+                portal => '',
                 devices => {},
             };
+            my (undef, $conn) = dir_glob_regex("$dir/device", '(connection\d+:\d+)');
+            if (defined($conn)) {
+                my $cdir = "$dir/device/$conn/iscsi_connection/$conn";
+                my $address = file_read_firstline("$cdir/persistent_address") // '';
+                my $port = file_read_firstline("$cdir/persistent_port") // '';
+                $address = "[$address]" if $address =~ m/:/;
+                $session->{portal} = normalize_portal("$address:$port");
+            }
             foreach_session_lun(
                 "$dir/device",
                 sub {
@@ -72,4 +82,14 @@ sub device_map {
     return $res;
 }
 
+sub normalize_portal {
+    my ($portal) = @_;
+    return $portal if $portal !~ m/^(.+):(\d+)$/;
+    my ($addr, $port) = ($1, $2);
+    $addr =~ s/^\[(.*)\]$/$1/;
+    $addr =~ s/^::ffff:(\d+\.\d+\.\d+\.\d+)$/$1/i;
+    $addr = "[$addr]" if $addr =~ m/:/;
+    return "$addr:$port";
+}
+
 1;
diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index d3ae56a4..840568b6 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -84,6 +84,33 @@ sub iscsi_session_list {
     return $res;
 }
 
+sub iscsi_node_list {
+    assert_iscsi_support();
+
+    my $res = [];
+    eval {
+        run_command(
+            [$ISCSIADM, '--mode', 'node'],
+            errmsg => 'iscsi node record scan failed',
+            outfunc => sub {
+                my $line = shift;
+                if ($line =~ $ISCSI_TARGET_RE) {
+                    push @$res, { portal => $1, target => $2 };
+                }
+            },
+        );
+    };
+    if (my $err = $@) {
+        die $err if $err !~ m/: No records found/i;
+    }
+
+    return $res;
+}
+
+sub iscsi_supported {
+    return -x $ISCSIADM ? 1 : 0;
+}
+
 sub iscsi_test_session {
     my ($sid) = @_;
 
diff --git a/src/test/run_san_api_tests.pl b/src/test/run_san_api_tests.pl
index f3846ba4..a051350d 100755
--- a/src/test/run_san_api_tests.pl
+++ b/src/test/run_san_api_tests.pl
@@ -5,9 +5,58 @@ use warnings;
 use Test::MockModule;
 use Test::More;
 use lib qw(. ..);
+use PVE::API2::ISCSI;
 use PVE::API2::Storage::Scan;
 
-for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
+my $plugin = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
+my $topology = Test::MockModule->new('PVE::ISCSI::Topology');
+my $storage = Test::MockModule->new('PVE::Storage');
+$plugin->mock(iscsi_supported => sub { 1 });
+$plugin->mock(read_initiator_info => sub { { name => 'iqn.test', alias => 'test' } });
+$plugin->mock(iscsi_node_list => sub { [{ target => 'iqn.target', portal => '192.0.2.2:3260' }] });
+$storage->mock(config => sub { { ids => { san => { type => 'iscsi', target => 'iqn.target' } } } });
+my $state = 'LOGGED_IN';
+$topology->mock(
+    sessions => sub {
+        return {
+            7 => {
+                target => 'iqn.target',
+                portal => '192.0.2.1:3260',
+                state => $state,
+                devices => { sda => { lun => 1 }, sdb => { lun => 0 } },
+            },
+        };
+    },
+);
+my $status = PVE::API2::ISCSI->map_method_by_name('status');
+is_deeply(
+    $status->{code}->({ node => 'test' }),
+    { supported => 1, 'initiator-name' => 'iqn.test', 'initiator-alias' => 'test' },
+    'initiator identity',
+);
+my $targets = PVE::API2::ISCSI->map_method_by_name('targets');
+for my $case (
+    ['LOGGED_IN', 'logged-in'],
+    ['FAILED', 'recovering'],
+    ['FREE', 'failed'],
+    ['', 'unknown'],
+) {
+    $state = $case->[0];
+    my $rows = $targets->{code}->({ node => 'test' });
+    is($rows->[0]->{state}, $case->[1], "session state $state");
+    is_deeply(
+        $rows->[0]->{devices},
+        [{ devpath => '/dev/sdb', lun => 0 }, { devpath => '/dev/sda', lun => 1 }],
+        'session devices ordered by LUN',
+    );
+    is($rows->[1]->{state}, 'not-connected', 'node record without a session');
+    is($rows->[0]->{'used-by-storage'}, 'san', 'target storage attribution');
+    eval { PVE::JSONSchema::validate($rows, $targets->{returns}) };
+    is($@, '', 'rows satisfy the schema');
+}
+for my $case (
+    ['PVE::API2::ISCSI', qw(status targets)], ['PVE::API2::Storage::Scan', 'sanlunscan'],
+) {
     my ($class, @names) = @$case;
     for my $name (@names) {
         is_deeply(
@@ -21,6 +70,11 @@ for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
         );
     }
 }
+is_deeply(
+    PVE::API2::ISCSI->map_method_by_name('index')->{code}->({}),
+    [{ name => 'status' }, { name => 'target' }],
+    'only read-only children',
+);
 
 require PVE::CLI::pvesm;
 my $formatter = Test::MockModule->new('PVE::CLIFormatter');




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 19/36] disks: lvm: drop unused imports
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (17 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 18/36] api: add node-level iSCSI status Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 20/36] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
                   ` (17 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Nothing in the module calls lock_file or run_command, the disk
actions take their lock through PVE::Diskmanage.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks/LVM.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/PVE/API2/Disks/LVM.pm b/src/PVE/API2/Disks/LVM.pm
index 9f8f9516..6101743b 100644
--- a/src/PVE/API2/Disks/LVM.pm
+++ b/src/PVE/API2/Disks/LVM.pm
@@ -7,7 +7,6 @@ use PVE::Storage::LVMPlugin;
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::API2::Storage::Config;
-use PVE::Tools qw(lock_file run_command);
 
 use PVE::RPCEnvironment;
 use PVE::RESTHandler;




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 20/36] disks: lvm: allow volume groups on SAN LUNs and multipath maps
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (18 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 19/36] disks: lvm: drop unused imports Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 21/36] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
                   ` (16 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

The node disk API creates volume groups on local disks only. It takes
a Fibre Channel LUN for one, but not a multipath map, and adds the
storage as local to the node. Accept the LUNs of the SAN inventory and
add their storage as shared and without node restriction. Refuse an
existing storage ID for them: adding the node to a storage with the
same volume group name is meant for local volume groups and would
combine two different volume groups in one shared storage.

Initializing a LUN, here or as base volume of a new LVM storage, now
takes a cluster-wide lock per WWID and refuses a LUN that a storage
references through its volume group, as base volume or as iSCSI
target serving images.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks/LVM.pm               |  56 +++---
 src/PVE/Storage/LVMPlugin.pm            |  74 +++++++-
 src/PVE/Storage/SAN.pm                  |  97 +++++++++-
 src/test/Makefile                       |   8 +-
 src/test/disk_api_test.pm               | 235 ++++++++++++++++++++++++
 src/test/run_disk_api_tests.pl          |  11 ++
 src/test/run_san_nvme_tests.pl          |  91 +++++++++
 src/test/run_san_taint_tests.pl         |  26 +++
 src/test/run_test_lvm_base_conflicts.pl | 232 ++++++++++++++++-------
 src/test/run_test_lvm_create.pl         |  14 ++
 10 files changed, 746 insertions(+), 98 deletions(-)
 create mode 100644 src/test/disk_api_test.pm
 create mode 100755 src/test/run_disk_api_tests.pl
 create mode 100755 src/test/run_san_nvme_tests.pl

diff --git a/src/PVE/API2/Disks/LVM.pm b/src/PVE/API2/Disks/LVM.pm
index 6101743b..a0ab6d69 100644
--- a/src/PVE/API2/Disks/LVM.pm
+++ b/src/PVE/API2/Disks/LVM.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use PVE::Storage::LVMPlugin;
+use PVE::Storage::SAN;
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::API2::Storage::Config;
@@ -130,7 +131,8 @@ __PACKAGE__->register_method({
             name => get_standard_option('pve-storage-id'),
             device => {
                 type => 'string',
-                description => 'The block device you want to create the volume group on',
+                description => 'The block device you want to create the volume group on.'
+                    . ' Multipath mapped devices are supported.',
             },
             add_storage => {
                 description => "Configure storage using the Volume Group",
@@ -152,48 +154,54 @@ __PACKAGE__->register_method({
         my $node = $param->{node};
 
         $dev = PVE::Diskmanage::verify_blockdev_path($dev);
-        PVE::Diskmanage::assert_disk_unused($dev);
+        my $san = PVE::Storage::SAN::is_san_device($dev);
+        PVE::Diskmanage::assert_disk_unused($dev) if !$san;
 
         my $storage_params = {
             type => 'lvm',
             vgname => $name,
             storage => $name,
             content => 'rootdir,images',
-            shared => 0,
-            nodes => $node,
+            shared => $san ? 1 : 0,
+            $san ? () : (nodes => $node),
         };
         my $verify_params = [qw(vgname)];
 
         if ($param->{add_storage}) {
             $rpcenv->check($user, "/storage", ['Datastore.Allocate']);
 
+            # only local volume groups of the same name may share a storage that exists already
+            die "storage ID '$name' already defined\n"
+                if $san && PVE::Storage::storage_config(PVE::Storage::config(), $name, 1);
+
             # reserve the name and add as disabled, will be enabled below if creation works out
             PVE::API2::Storage::Config->create_or_update(
                 $name, $node, $storage_params, $verify_params, 1,
             );
         }
 
+        my $create_group = sub {
+            PVE::Diskmanage::assert_disk_unused($dev) if !$san;
+            die "volume group with name '${name}' already exists on node '${node}'\n"
+                if PVE::Storage::LVMPlugin::lvm_vgs()->{$name};
+
+            if (PVE::Diskmanage::is_partition($dev)) {
+                eval { PVE::Diskmanage::change_parttype($dev, '8E00'); };
+                warn $@ if $@;
+            }
+
+            PVE::Storage::LVMPlugin::lvm_create_volume_group($dev, $name, $san);
+
+            PVE::Diskmanage::udevadm_trigger($dev);
+
+            if ($param->{add_storage}) {
+                PVE::API2::Storage::Config->create_or_update(
+                    $name, $node, $storage_params, $verify_params,
+                );
+            }
+        };
         my $worker = sub {
-            PVE::Diskmanage::locked_disk_action(sub {
-                PVE::Diskmanage::assert_disk_unused($dev);
-                die "volume group with name '${name}' already exists on node '${node}'\n"
-                    if PVE::Storage::LVMPlugin::lvm_vgs()->{$name};
-
-                if (PVE::Diskmanage::is_partition($dev)) {
-                    eval { PVE::Diskmanage::change_parttype($dev, '8E00'); };
-                    warn $@ if $@;
-                }
-
-                PVE::Storage::LVMPlugin::lvm_create_volume_group($dev, $name);
-
-                PVE::Diskmanage::udevadm_trigger($dev);
-
-                if ($param->{add_storage}) {
-                    PVE::API2::Storage::Config->create_or_update(
-                        $name, $node, $storage_params, $verify_params,
-                    );
-                }
-            });
+            $san ? $create_group->() : PVE::Diskmanage::locked_disk_action($create_group);
         };
 
         return $rpcenv->fork_worker('lvmcreate', $name, $user, $worker);
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index ee64b782..c9e52b4c 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -16,6 +16,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_get_contents file_read_firstline trim);
 
@@ -147,6 +148,37 @@ sub cached_pv_volume_groups {
     return $res;
 }
 
+sub lun_volume_groups {
+    my ($devices) = @_;
+    my $output = '';
+    run_command(
+        [
+            '/sbin/pvs',
+            '--nohints',
+            '--readonly',
+            '--devices',
+            join(',', @$devices),
+            '--reportformat',
+            'json',
+            '--options',
+            'pv_name,vg_name',
+        ],
+        timeout => 10,
+        outfunc => sub { $output .= "$_[0]\n" },
+    );
+    my $data = decode_json($output);
+    my $pvs = $data->{report}->[0]->{pv};
+    die "unable to inspect volume groups - invalid pvs report\n" if ref($pvs) ne 'ARRAY';
+    my %vgs;
+    for my $pv (@$pvs) {
+        my $vg = $pv->{vg_name};
+        die "unable to inspect volume groups - missing volume group metadata\n"
+            if !defined($vg) || $vg eq '[unknown]';
+        $vgs{$vg} = 1 if length($vg);
+    }
+    return [sort keys %vgs];
+}
+
 sub clear_first_sector {
     my ($dev) = shift;
 
@@ -157,10 +189,16 @@ sub clear_first_sector {
     }
 }
 
-sub lvm_create_volume_group {
-    my ($device, $vgname, $shared, $guard) = @_;
-
+my sub create_volume_group {
+    my ($device, $vgname, $lun, $guard) = @_;
     $device = PVE::Diskmanage::verify_blockdev_path($device);
+    my $fh;
+    if ($lun) {
+        sysopen($fh, $lun->{'by-id'}, O_RDWR) or die "cannot open '$device' - $!\n";
+    }
+    my $check_name = sub {
+        PVE::Storage::SAN::assert_same_device($lun, $fh) if $lun;
+    };
     my $refuse_data = sub {
         my (@types) = @_;
         die "device '$device' contains data ("
@@ -178,7 +216,7 @@ sub lvm_create_volume_group {
         if !defined($size) || $size !~ m/^\d+$/ || !$size;
     die "unable to probe '$device' - missing device mapper identity\n"
         if basename($device) =~ m/^dm-\d+$/ && !defined($uuid);
-    if (defined($uuid) && $uuid =~ m/^mpath-/) {
+    if (PVE::Multipath::parse_dm_uuid($uuid)) {
         # A queueing map without a running path can stall even a read-only probe.
         my $running = 0;
         PVE::Tools::dir_glob_foreach(
@@ -247,26 +285,48 @@ sub lvm_create_volume_group {
     }
     $refuse_data->(keys %signatures) if %signatures;
 
+    # Only initializing the device needs the checks, an existing volume group on it can be added.
     $guard->{check_storage}->($device) if $guard && $guard->{check_storage};
-    clear_first_sector($device); # else pvcreate fails
+    PVE::Storage::SAN::assert_lun_unreferenced(
+        PVE::Storage::config(),
+        $lun,
+        $guard ? $guard->{exempt} : undef,
+    ) if $lun;
+
+    $check_name->();
+    clear_first_sector($lun ? '/proc/' . $$ . '/fd/' . fileno($fh) : $device);
 
     # we use --metadatasize 250k, which reseults in "pe_start = 512"
     # so pe_start is aligned on a 128k boundary (advantage for SSDs)
     my $cmd = ['/sbin/pvcreate', '--metadatasize', '250k', $device];
 
-    run_command($cmd, errmsg => "pvcreate '$device' error");
+    $check_name->();
+    run_command($cmd, errmsg => "pvcreate '$device' error", $lun ? (timeout => 30) : ());
 
     $cmd = ['/sbin/vgcreate', $vgname, $device];
     # push @$cmd, '-c', 'y' if $shared; # we do not use this yet
 
+    $check_name->();
     run_command(
         $cmd,
+        $lun ? (timeout => 30) : (),
         errmsg => "vgcreate $vgname $device error",
         errfunc => $ignore_no_medium_warnings,
         outfunc => $ignore_no_medium_warnings,
     );
 }
 
+sub lvm_create_volume_group {
+    my ($device, $vgname, $shared, $guard) = @_;
+    require PVE::Storage::SAN;
+    my $lun = PVE::Storage::SAN::lun_for_device($device);
+    return create_volume_group($device, $vgname, undef, $guard) if !$lun;
+    PVE::Storage::SAN::with_lun_lock(
+        $lun,
+        sub { create_volume_group($device, $vgname, $lun, $guard) },
+    );
+}
+
 sub lvm_destroy_volume_group {
     my ($vgname) = @_;
 
@@ -1130,7 +1190,7 @@ sub on_add_hook {
             $path,
             $scfg->{vgname},
             $scfg->{shared},
-            { check_storage => $check_target },
+            { check_storage => $check_target, exempt => $storeid },
         );
     }
 
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index f13d9633..210c3a78 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -5,6 +5,7 @@ use v5.36;
 use Cwd qw(abs_path);
 use File::Basename qw(basename);
 
+use PVE::Cluster;
 use PVE::INotify;
 
 use PVE::Diskmanage;
@@ -15,7 +16,7 @@ use PVE::Multipath::Config;
 use PVE::Multipath::Identity;
 use PVE::Storage;
 use PVE::Storage::LVMPlugin;
-use PVE::Tools qw(file_read_firstline);
+use PVE::Tools qw(file_read_firstline dir_glob_foreach);
 
 sub scan_luns($cfg) {
     my $ids = PVE::Multipath::Identity::collect(all => 1);
@@ -186,4 +187,98 @@ sub is_san_device($device, $info = undef) {
         || PVE::Diskmanage::is_remote_transport($info->{transport}) ? 1 : 0;
 }
 
+sub lun_for_device($device) {
+    $device = PVE::Diskmanage::verify_blockdev_path($device);
+    return undef if !is_san_device($device);
+    my $rows = scan_luns(PVE::Storage::config());
+    for my $lun (@$rows) {
+        next if (abs_path($lun->{devpath}) // '') ne $device;
+        die "cannot use '$device' - no stable name under /dev/disk/by-id\n" if !$lun->{'by-id'};
+        # read from sysfs, but used in command lines and in the name of the cluster lock
+        ($lun->{devpath}) = $lun->{devpath} =~ m{\A(/dev/[A-Za-z0-9_.:+/-]+)\z}
+            or die "cannot use '$device' - unexpected device path\n";
+        ($lun->{wwid}) = $lun->{wwid} =~ m/\A([A-Za-z0-9_.:+=-]+)\z/
+            or die "cannot use '$device' - unexpected WWID\n";
+        return $lun;
+    }
+    die "cannot use '$device' - select an identified LUN or its multipath map\n";
+}
+
+sub lun_partitions($lun) {
+    my $device = PVE::Diskmanage::verify_blockdev_path($lun->{devpath});
+    my $name = basename($device);
+    my @parts;
+    dir_glob_foreach(
+        "/sys/class/block/$name",
+        "\Q$name\E.+",
+        sub($part, @) {
+            my ($path) = "/dev/$part" =~ m{\A(/dev/[A-Za-z0-9_.+-]+)\z};
+            push @parts, $path if defined($path) && -e "/sys/class/block/$name/$part/partition";
+        },
+    );
+    dir_glob_foreach(
+        "/sys/class/block/$name/holders",
+        'dm-\\d+',
+        sub($part, @) {
+            my $map = PVE::Multipath::parse_dm_uuid(
+                file_read_firstline("/sys/class/block/$part/dm/uuid"));
+            my ($path) = "/dev/$part" =~ m{\A(/dev/dm-\d+)\z};
+            push @parts, $path
+                if defined($path) && $map && $map->{partition} && $map->{wwid} eq $lun->{wwid};
+        },
+    );
+    return \@parts;
+}
+
+sub assert_lun_unreferenced($cfg, $lun, $exempt = undef) {
+    my %vgs = map { $_ => 1 } PVE::Storage::LVMPlugin::lun_volume_groups(
+        [$lun->{devpath}, lun_partitions($lun)->@*],
+    )->@*;
+    # the paths of a LUN can belong to more than one target
+    my %targets = map { $_->{target} => 1 }
+        grep { $_->{wwid} eq $lun->{wwid} && defined($_->{target}) }
+        values PVE::Multipath::Identity::collect(all => 1)->{paths}->%*;
+    for my $sid (sort keys $cfg->{ids}->%*) {
+        next if defined($exempt) && $sid eq $exempt;
+        my $scfg = $cfg->{ids}->{$sid};
+        my $type = $scfg->{type};
+        if (($type eq 'lvm' || $type eq 'lvmthin') && $vgs{ $scfg->{vgname} // '' }) {
+            die "cannot use '$lun->{devpath}' - volume group is used by storage '$sid'\n";
+        }
+        if (
+            defined($scfg->{target})
+            && $targets{ $scfg->{target} }
+            && PVE::Storage::san_storage_serves_images($scfg)
+        ) {
+            die "cannot use '$lun->{devpath}' - storage '$sid' serves images from this target\n";
+        }
+        next if $type ne 'lvm' || !$scfg->{base};
+        my (undef, $volname) = PVE::Storage::Plugin::parse_volume_id($scfg->{base});
+        my ($wwid) = $volname =~ m/(?:^|\.)(?:dm-uuid-mpath|scsi|nvme)-(.+)$/;
+        my $matches = defined($wwid) && $wwid eq $lun->{wwid};
+        if (!$matches) {
+            my $path = eval { abs_path(PVE::Storage::path($cfg, $scfg->{base})) };
+            my $device = abs_path($lun->{devpath});
+            $matches = defined($path) && defined($device) && $path eq $device;
+        }
+        die "cannot use '$lun->{devpath}' - storage '$sid' uses this LUN as its base volume\n"
+            if $matches;
+    }
+    return;
+}
+
+# Serializes writes to a LUN cluster-wide. The code sees the current storage configuration.
+sub with_lun_lock($lun, $code) {
+    my $key = $lun->{wwid} =~ s/([^A-Za-z0-9_.:-])/sprintf('=%02x', ord($1))/ger;
+    PVE::Cluster::cfs_lock_domain("san-$key", undef, $code);
+    die $@ if $@;
+}
+
+sub assert_same_device($lun, $fh) {
+    my @held = stat($fh);
+    my @named = stat($lun->{'by-id'});
+    die "cannot use '$lun->{devpath}' - its by-id name changed\n"
+        if !@held || !@named || $held[6] != $named[6];
+}
+
 1;
diff --git a/src/test/Makefile b/src/test/Makefile
index 6348c61e..e453951a 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_multipath test_san_libraries test_lun_identity test_lvm_base_activation test_multipath_api test_san_taint test_san_lun_scan test_san_api
+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_multipath test_san_libraries test_lun_identity test_lvm_base_activation test_multipath_api test_san_taint test_san_lun_scan test_san_api test_disk_api
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -69,5 +69,9 @@ test_san_taint: run_san_taint_tests.pl
 test_san_lun_scan: run_san_lun_scan_tests.pl
 	./run_san_lun_scan_tests.pl
 
-test_san_api: run_san_api_tests.pl
+test_san_api: run_san_api_tests.pl run_san_nvme_tests.pl
 	./run_san_api_tests.pl
+	./run_san_nvme_tests.pl
+
+test_disk_api: run_disk_api_tests.pl
+	./run_disk_api_tests.pl
diff --git a/src/test/disk_api_test.pm b/src/test/disk_api_test.pm
new file mode 100644
index 00000000..32ab5c80
--- /dev/null
+++ b/src/test/disk_api_test.pm
@@ -0,0 +1,235 @@
+package PVE::API2::Disks::Test;
+
+use strict;
+use warnings;
+
+use lib qw(..);
+
+use PVE::API2::Disks;
+use PVE::API2::Disks::LVM;
+use PVE::Diskmanage;
+use PVE::Storage;
+use PVE::Storage::LVMPlugin;
+
+use Test::MockModule;
+use Test::More;
+
+my @transport_cases = (
+    ['none', undef],
+    ['unknown', 'unknown'],
+    ['ata', 'ata'],
+    ['sata', 'sata'],
+    ['sas', 'sas'],
+    ['spi', 'spi'],
+    ['sbp', 'sbp'],
+    ['usb', 'usb'],
+    ['fc', 'fc'],
+    ['fcoe', 'fcoe'],
+    ['iscsi', 'iscsi'],
+    ['nvme', 'nvme'],
+    ['virtio', 'virtio'],
+    ['nvme-fc', 'nvme-fc'],
+    ['nvme-tcp', 'nvme-tcp'],
+    ['nvme-rdma', 'nvme-rdma'],
+    ['nvme-loop', 'nvme-loop'],
+);
+
+my $disks = {};
+my @all;
+for my $case (@transport_cases) {
+    my ($name, $transport) = $case->@*;
+    my $devpath = "/dev/test-$name";
+    my $entry = {
+        devpath => $devpath,
+        gpt => 0,
+        osdid => -1,
+    };
+    $entry->{transport} = $transport if defined($transport);
+    $disks->{$name} = $entry;
+    push @all, $devpath;
+}
+
+my $diskmanage_module = Test::MockModule->new('PVE::Diskmanage', no_auto => 1);
+$diskmanage_module->mock('get_disks' => sub { return $disks });
+
+my $list_handler = PVE::API2::Disks->map_method_by_name('list')->{code};
+my $list_devpaths = sub {
+    my ($param) = @_;
+    my $result = $list_handler->({ node => 'test-node', skipsmart => 1, $param->%* });
+    return [sort map { $_->{devpath} } $result->@*];
+};
+
+is_deeply(
+    $list_devpaths->({}), [sort @all], 'the disk list uses the default disk inventory',
+);
+
+is_deeply(
+    $list_devpaths->({ type => 'unused' }),
+    [sort @all],
+    'unused disk selection preserves transport visibility',
+);
+
+$diskmanage_module->mock(
+    'get_disks' => sub {
+        return {
+            'fc-disk' => {
+                devpath => '/dev/fc-disk',
+                gpt => 0,
+                osdid => -1,
+                transport => 'fc',
+            },
+            'fc-partition' => {
+                devpath => '/dev/fc-disk1',
+                gpt => 0,
+                osdid => -1,
+                parent => '/dev/fc-disk',
+            },
+            'loop-disk' => {
+                devpath => '/dev/loop-disk',
+                gpt => 0,
+                osdid => -1,
+                transport => 'nvme-loop',
+            },
+            'loop-partition' => {
+                devpath => '/dev/loop-disk1',
+                gpt => 0,
+                osdid => -1,
+                parent => '/dev/loop-disk',
+            },
+        };
+    },
+);
+
+is_deeply(
+    $list_devpaths->({ 'include-partitions' => 1 }),
+    ['/dev/fc-disk', '/dev/fc-disk1', '/dev/loop-disk', '/dev/loop-disk1'],
+    'the plain list keeps FC disks and their partitions',
+);
+
+is_deeply(
+    $list_devpaths->({ 'include-partitions' => 1, type => 'unused' }),
+    ['/dev/fc-disk', '/dev/fc-disk1', '/dev/loop-disk', '/dev/loop-disk1'],
+    'unused partitions preserve transport visibility',
+);
+
+subtest 'volume group creation leaves SAN locking to the LVM helper' => sub {
+    my $storage = Test::MockModule->new('PVE::Storage');
+    my $disk = $diskmanage_module;
+    my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    my $rpc = Test::MockModule->new('PVE::RPCEnvironment');
+    my (@stack, @created);
+    my $lock = sub {
+        my ($name, $code) = @_;
+        push @stack, $name;
+        my $res = eval { $code->() };
+        my $err = $@;
+        pop @stack;
+        die $err if $err;
+        return $res;
+    };
+    $storage->mock(lock_storage_config => sub { $lock->('storage.cfg', $_[0]) });
+    $disk->mock(locked_disk_action => sub { $lock->('disk', $_[0]) });
+    $disk->mock(verify_blockdev_path => sub { $_[0] });
+    $disk->mock(assert_disk_unused => sub { });
+    $disk->mock(is_partition => sub { 0 });
+    $disk->mock(udevadm_trigger => sub { });
+    $lvm->mock(lvm_vgs => sub { {} });
+    $lvm->mock(
+        lvm_create_volume_group => sub {
+            is(scalar(@_), 3, 'disk API does not exempt a storage');
+            push @created, [$_[0], join('>', @stack)];
+        },
+    );
+    {
+
+        package MultipathTestRPC;
+        sub get_user { 'root@pam' }
+        sub check { 1 }
+        sub fork_worker { $_[4]->(); return 'test-upid' }
+    }
+    $rpc->mock(get => sub { bless {}, 'MultipathTestRPC' });
+
+    my ($is_map, $is_san) = (1, 0);
+    my $san = Test::MockModule->new('PVE::Storage::SAN');
+    $san->mock(is_san_device => sub { $is_map || $is_san });
+    PVE::API2::Disks::LVM->create({ node => 'n1', name => 'vg1', device => '/dev/dm-3' });
+    ($is_map, $is_san) = (0, 1);
+    PVE::API2::Disks::LVM->create({ node => 'n1', name => 'vg2', device => '/dev/sdc' });
+    ($is_map, $is_san) = (0, 0);
+    PVE::API2::Disks::LVM->create({ node => 'n1', name => 'vg3', device => '/dev/sdb' });
+    is_deeply(
+        \@created,
+        [
+            ['/dev/dm-3', ''], ['/dev/sdc', ''], ['/dev/sdb', 'disk'],
+        ],
+        'SAN writes use no local disk or storage configuration lock',
+    );
+    my $config_api = Test::MockModule->new('PVE::API2::Storage::Config');
+    my @params;
+    $config_api->mock(create_or_update => sub { push @params, $_[3] });
+    my $cfg =
+        { ids => { other => { type => 'lvm', vgname => 'other', nodes => { n2 => 1 } } } };
+    $storage->mock(config => sub { $cfg });
+    $is_san = 1;
+    PVE::API2::Disks::LVM->create({
+        node => 'n1',
+        name => 'vg4',
+        device => '/dev/sdc',
+        add_storage => 1,
+    });
+    is($params[-1]->{shared}, 1, 'SAN storage is shared');
+    ok(!exists($params[-1]->{nodes}), 'SAN storage covers all nodes');
+    @created = ();
+    eval {
+        PVE::API2::Disks::LVM->create({
+            node => 'n1',
+            name => 'other',
+            device => '/dev/sdc',
+            add_storage => 1,
+        });
+    };
+    like($@, qr/already defined/, 'SAN volume group does not join the storage of another node');
+    is_deeply(\@created, [], 'existing storage ID prevents initialization');
+    $is_san = 0;
+    PVE::API2::Disks::LVM->create({
+        node => 'n1',
+        name => 'vg5',
+        device => '/dev/sdb',
+        add_storage => 1,
+    });
+    is($params[-1]->{shared}, 0, 'local storage is not shared');
+    is($params[-1]->{nodes}, 'n1', 'local storage remains node-restricted');
+    @created = ();
+    $disk->mock(assert_disk_unused => sub { die "device is already in use\n" });
+    eval {
+        PVE::API2::Disks::LVM->create({
+            node => 'n1',
+            name => 'vg',
+            device => '/dev/sdc',
+        });
+    };
+    like($@, qr/already in use/, 'disk API rejects a used inventory entry');
+    is_deeply(\@created, [], 'used inventory prevents initialization');
+    $disk->mock(assert_disk_unused => sub { });
+    $lvm->mock(lvm_vgs => sub { { vg => {} } });
+    eval {
+        PVE::API2::Disks::LVM->create({
+            node => 'n1',
+            name => 'vg',
+            device => '/dev/sdc',
+        });
+    };
+    like(
+        $@,
+        qr/volume group with name 'vg' already exists/,
+        'stale inventory does not permit an existing VG',
+    );
+    is_deeply(\@created, [], 'existing VG prevents initialization');
+    $disk->unmock($_)
+        for qw(
+        locked_disk_action verify_blockdev_path assert_disk_unused is_partition
+        udevadm_trigger
+        );
+};
+
+done_testing();
diff --git a/src/test/run_disk_api_tests.pl b/src/test/run_disk_api_tests.pl
new file mode 100755
index 00000000..75fc98c6
--- /dev/null
+++ b/src/test/run_disk_api_tests.pl
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use TAP::Harness;
+
+my $harness = TAP::Harness->new({ verbosity => -2 });
+my $res = $harness->runtests("disk_api_test.pm");
+
+exit -1 if !$res || $res->{failed} || $res->{parse_errors};
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
new file mode 100755
index 00000000..b28efe7d
--- /dev/null
+++ b/src/test/run_san_nvme_tests.pl
@@ -0,0 +1,91 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+our ($backing, @opens);
+
+BEGIN {
+    *CORE::GLOBAL::sysopen = sub (*$$;$) {
+        push @opens, $_[1];
+        my $path = $_[1] =~ m{^/dev/disk/by-id/nvme-} ? $backing : $_[1];
+        return CORE::sysopen($_[0], $path, $_[2]);
+    };
+}
+use lib qw(..);
+use File::Temp qw(tempfile);
+use Test::More;
+use Test::MockModule;
+use PVE::Storage::SAN;
+
+my ($fh, $file) = tempfile('san-nvme-XXXX', DIR => '.', UNLINK => 1);
+close($fh);
+$backing = $file;
+my $device = '/dev/nvme0n1';
+my $link = '/dev/disk/by-id/nvme-eui.0123456789abcdef';
+my $lun =
+    { devpath => $device, 'by-id' => $link, wwid => 'eui.0123456789abcdef', multipath => 'native' };
+my $san = Test::MockModule->new('PVE::Storage::SAN');
+my $disk = Test::MockModule->new('PVE::Diskmanage');
+my $mp = Test::MockModule->new('PVE::Multipath');
+my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+my $storage = Test::MockModule->new('PVE::Storage');
+my $cluster = Test::MockModule->new('PVE::Cluster');
+my $cfg = { ids => {} };
+my @order;
+$storage->mock(config => sub { $cfg });
+$disk->mock(verify_blockdev_path => sub { $device });
+$disk->mock(is_partition => sub { 0 });
+$disk->mock(get_nvme_transport => sub { 'fc' });
+$disk->mock(is_iscsi_device => sub { 0 });
+$disk->mock(is_mounted => sub { 0 });
+$disk->mock(has_holder => sub { 0 });
+$mp->mock(device_map => sub { undef });
+$san->mock(abs_path => sub { $device });
+$san->mock(scan_luns => sub { [$lun] });
+$san->mock(lun_partitions => sub { [] });
+$san->mock(assert_same_device => sub { ok(defined(fileno($_[1])), 'held descriptor checked') });
+$lvm->mock(lun_volume_groups => sub { push @order, 'check'; [] });
+$cluster->mock(
+    cfs_lock_domain => sub {
+        is($_[0], 'san-eui.0123456789abcdef', 'native namespace uses the LUN lock');
+        push @order, 'lock';
+        $_[2]->();
+        push @order, 'unlock';
+        $@ = '';
+    },
+);
+is(PVE::Storage::SAN::stable_path($device, $lun->{wwid}), $link, 'native stable path');
+is_deeply(PVE::Storage::SAN::lun_for_device($link), $lun, 'native row selected for writes');
+$disk->mock(is_partition => sub { 1 });
+is(PVE::Storage::SAN::lun_for_device($link), undef, 'a partition is handled as a local device');
+$disk->mock(is_partition => sub { 0 });
+$cfg->{ids}->{data} = { type => 'lvm', base => 'fabric:nvme-eui.0123456789abcdef' };
+eval { PVE::Storage::SAN::assert_lun_unreferenced($cfg, $lun) };
+like($@, qr/base volume/, 'native base reference refuses');
+$cfg->{ids} = {};
+@order = @opens = ();
+$lvm->mock(file_read_firstline => sub { $_[0] =~ m{/size$} ? 1024 : undef });
+$lvm->mock(lvm_pv_info => sub { undef });
+$lvm->mock(
+    clear_first_sector => sub { push @order, 'clear'; ok(-e $_[0], 'VG clear uses held fd') });
+$lvm->mock(
+    run_command => sub {
+        my ($cmd, %opts) = @_;
+        if ($cmd->[0] eq 'wipefs') {
+            $opts{outfunc}->('{"signatures":[]}');
+        } else {
+            is($cmd->[-1], $device, 'VG command uses the checked device');
+            push @order, $cmd->[0];
+        }
+    },
+);
+PVE::Storage::LVMPlugin::lvm_create_volume_group($link, 'data', 1);
+is_deeply(
+    \@order,
+    [qw(lock check clear /sbin/pvcreate /sbin/vgcreate unlock)],
+    'native VG sequencing',
+);
+is_deeply(\@opens, [$link], 'VG creation holds the native by-id device');
+
+done_testing();
diff --git a/src/test/run_san_taint_tests.pl b/src/test/run_san_taint_tests.pl
index 35b11cd7..0ccd9e2f 100755
--- a/src/test/run_san_taint_tests.pl
+++ b/src/test/run_san_taint_tests.pl
@@ -31,4 +31,30 @@ for my $bad ('-bad', '1:2', '../dev', "3600a\n") {
     like($@, qr/invalid WWID/, 'ambiguous identity refused');
 }
 
+# the LUN that write operations get must be usable in command lines and lock names
+use PVE::Storage::SAN;
+my $san = Test::MockModule->new('PVE::Storage::SAN');
+my $tainted_dev = PVE::Tools::file_get_contents('/proc/self/comm') =~ s/.*//sr . '/dev/null';
+ok(tainted($tainted_dev), 'device path derived from a file is tainted');
+$san->mock(
+    is_san_device => sub { 1 },
+    scan_luns => sub {
+        return [{
+            devpath => $tainted_dev,
+            wwid => $wwid,
+            'by-id' => '/dev/null',
+            usage => 'unused',
+            multipath => 'none',
+        }];
+    },
+);
+my $disks = Test::MockModule->new('PVE::Diskmanage');
+$disks->mock(verify_blockdev_path => sub { '/dev/null' });
+my $storage = Test::MockModule->new('PVE::Storage');
+$storage->mock(config => sub { { ids => {} } });
+my $lun = PVE::Storage::SAN::lun_for_device('/dev/null');
+ok(!tainted($lun->{devpath}), 'LUN device path is untainted');
+ok(!tainted($lun->{wwid}), 'LUN WWID is untainted');
+is($lun->{wwid}, '3600a', 'LUN WWID is unchanged');
+
 done_testing();
diff --git a/src/test/run_test_lvm_base_conflicts.pl b/src/test/run_test_lvm_base_conflicts.pl
index 26362a74..beb38a4e 100755
--- a/src/test/run_test_lvm_base_conflicts.pl
+++ b/src/test/run_test_lvm_base_conflicts.pl
@@ -2,78 +2,182 @@
 
 use strict;
 use warnings;
-
-use Test::MockModule;
+use lib qw(..);
 use Test::More;
+use Test::MockModule;
+use PVE::Storage::SAN;
 
-use lib ('.', '..');
-use PVE::Storage;
-use PVE::Storage::LVMPlugin;
-
-my $storage = Test::MockModule->new('PVE::Storage');
+my $scan = Test::MockModule->new('PVE::Storage::SAN');
 my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
-my ($cfg, $created, $existing);
-$storage->mock(
-    config => sub { $cfg },
-    path => sub { '/dev/sda' },
-    activate_storage => sub { },
-    activate_volumes => sub { },
-);
-$lvm->mock(
-    lvm_create_volume_group => sub {
-        my ($device, $vgname, $shared, $guard) = @_;
-        return if $existing;
-        $guard->{check_storage}->($device);
-        $created++;
-    },
-    assert_discard_supported => sub { },
-);
-
-for my $case (
-    ['iscsi', {}, 0],
-    ['iscsi', { images => 1 }, 1],
-    ['iscsidirect', {}, 1],
-    ['zfs', {}, 1],
-    ['vendor', { images => 1 }, 1],
-) {
-    my ($type, $content, $conflict) = @$case;
-    $created = 0;
-    $cfg = {
-        ids => {
-            base => { type => 'iscsi', target => 'iqn.test', content => { none => 1 } },
-            other => {
-                type => $type,
-                target => 'iqn.test',
-                content => $content,
-                disable => 1,
-                nodes => { elsewhere => 1 },
+my $storage = Test::MockModule->new('PVE::Storage');
+my $cluster = Test::MockModule->new('PVE::Cluster');
+my $lun = { wwid => '3600+abc', devpath => '/dev/dm-0', 'iscsi-target' => 'iqn.test' };
+# the LUN is exported through two targets, its row names only the first
+my $identity = Test::MockModule->new('PVE::Multipath::Identity');
+$identity->mock(
+    collect => sub {
+        {
+            paths => {
+                sdb => { wwid => '3600+abc', target => 'iqn.test' },
+                sdc => { wwid => '3600+abc', target => 'iqn.second' },
+                sdd => { wwid => '3600+other', target => 'iqn.other' },
             },
+        };
+    },
+);
+my $vgs = [];
+$scan->mock(lun_partitions => sub { [] });
+$lvm->mock(lun_volume_groups => sub { $vgs });
+$lvm->mock(cached_pv_volume_groups => sub { die "write check must not use cached PV metadata\n" });
+my $cfg = { ids => {} };
+$storage->mock(config => sub { $cfg });
+my $check = sub {
+    eval { PVE::Storage::SAN::assert_lun_unreferenced($cfg, $lun, @_) };
+    return $@;
+};
+is($check->(), '', 'unreferenced LUN accepted');
+for my $type (qw(lvm lvmthin)) {
+    $vgs = ['data'];
+    $cfg->{ids} = {
+        data => {
+            type => $type,
+            vgname => 'data',
+            shared => 1,
+            disable => 1,
+            nodes => { other => 1 },
         },
     };
-    eval {
-        PVE::Storage::LVMPlugin->on_add_hook(
-            'test',
-            { base => 'base:0.0.1.scsi-test', vgname => 'test' },
-        );
-    };
-    if ($conflict) {
-        like($@, qr/storage 'other' serves disk images from this target/, "$type conflict refused");
-        like($@, qr/set its content to 'none'/, "$type: remedy named for iSCSI only")
-            if $type eq 'iscsi';
-    } else {
-        is($@, '', 'connection-only storage permits initialization');
+    for my $cached_vg (undef, 'unrelated') {
+        $lun->{vgname} = $cached_vg;
+        $lun->{usage} = 'unused';
+        like($check->(), qr/used by storage 'data'/, "$type refusal ignores display VG and usage");
     }
-    is($created, $conflict ? 0 : 1, 'no writes on conflicting target');
+    is($check->('data'), '', 'the storage being added can be exempted');
+}
+delete $lun->{vgname};
+delete $lun->{usage};
+$vgs = [];
+$cfg->{ids} = { direct => { type => 'iscsi', target => 'iqn.test', content => { images => 1 } } };
+like($check->(), qr/storage 'direct' serves images from this target$/, 'direct image use refuses');
+$cfg->{ids}->{direct}->{target} = 'iqn.second';
+like($check->(), qr/storage 'direct' serves images/, 'also through another target of the LUN');
+$cfg->{ids}->{direct}->{target} = 'iqn.other';
+is($check->(), '', 'a target of another LUN is no reference');
+$cfg->{ids}->{direct}->{target} = 'iqn.test';
+$cfg->{ids}->{direct}->{content} = { none => 1 };
+is($check->(), '', 'connection-only storage permits use');
 
-    $existing = 1;
-    eval {
-        PVE::Storage::LVMPlugin->on_add_hook(
-            'test',
-            { base => 'base:0.0.1.scsi-test', vgname => 'test' },
-        );
-    };
-    is($@, '', "$type: an existing volume group on the base volume can be added");
-    $existing = 0;
+for my $type (qw(iscsidirect zfs)) {
+    local $cfg->{ids}->{other} = { type => $type, target => 'iqn.test', content => {} };
+    like(
+        $check->(),
+        qr/storage 'other' serves images from this target$/,
+        "$type storage of the target refuses",
+    );
 }
+$cfg->{ids}->{data} = { type => 'lvm', base => 'direct:0.0.1.dm-uuid-mpath-3600+abc' };
+like($check->(), qr/base volume/, 'base reference refuses');
+$cfg->{ids}->{data}->{base} = 'direct:0.0.1.scsi-3600+abc';
+like($check->(), qr/base volume/, 'scsi WWID in base name refuses');
+$cfg->{ids}->{data}->{base} = 'direct:0.0.1.scsi-legacy';
+$storage->mock(path => sub { '/dev/disk/by-id/legacy' });
+$scan->mock(abs_path => sub { '/dev/dm-0' });
+like($check->(), qr/base volume/, 'resolved alias to the LUN refuses');
+$scan->mock(abs_path => sub { $_[0] eq $lun->{devpath} ? '/dev/dm-0' : '/dev/dm-1' });
+is($check->(), '', 'base on another device is no match');
+$scan->mock(abs_path => sub { undef });
+is($check->(), '', 'unresolvable base is no match');
+$storage->mock(path => sub { die "base unavailable\n" });
+is($check->(), '', 'unavailable base is no match');
+ok(!PVE::Storage::LVMPlugin->can('create_volume_group'), 'creation implementation is lexical');
+$cfg->{ids} = {};
+my @order;
+$cluster->mock(
+    cfs_lock_domain => sub {
+        is($_[0], 'san-3600=2babc', 'lock name escapes unsafe characters without collisions');
+        push @order, 'lock';
+        $_[2]->();
+        push @order, 'unlock';
+        $@ = '';
+    },
+);
+PVE::Storage::SAN::with_lun_lock($lun, sub { push @order, 'write' });
+is_deeply(\@order, [qw(lock write unlock)], 'the code runs under the lock of the LUN');
+
+# volume group creation checks the references only when it has to initialize the LUN
+my $disks = Test::MockModule->new('PVE::Diskmanage');
+$disks->mock(
+    verify_blockdev_path => sub { $_[0] },
+    is_mounted => sub { undef },
+    has_holder => sub { undef },
+);
+my ($signatures, $pvinfo) = ('', undef);
+$lun->{'by-id'} = '/dev/null';
+$scan->mock(
+    lun_for_device => sub { $lun },
+    assert_same_device => sub { },
+    assert_lun_unreferenced => sub { push @order, 'check'; die "referenced\n" },
+);
+$lvm->mock(
+    file_read_firstline => sub { $_[0] =~ m{/size$} ? '2048' : undef },
+    lvm_pv_info => sub { $pvinfo },
+    clear_first_sector => sub { push @order, 'clear' },
+    run_command => sub {
+        my ($cmd, %param) = @_;
+        return $param{outfunc}->(qq({"signatures":[$signatures]})) if $cmd->[0] eq 'wipefs';
+        push @order, $cmd->[0];
+    },
+);
+@order = ();
+$signatures = '{"type":"LVM2_member","offset":"0x218"}';
+$pvinfo = { vgname => 'data', in_use => '1' };
+eval {
+    PVE::Storage::LVMPlugin::lvm_create_volume_group(
+        '/dev/null',
+        'data',
+        1,
+        { exempt => 'new' },
+    );
+};
+is($@, '', 'an existing volume group can be added whatever references its LUN');
+is_deeply(\@order, [qw(lock unlock)], 'without reference check or write');
+eval {
+    PVE::Storage::LVMPlugin::lvm_create_volume_group(
+        '/dev/null',
+        'other',
+        1,
+        { exempt => 'new' },
+    );
+};
+like($@, qr/already used by volume group 'data'/, 'another volume group on the LUN refuses');
+@order = ();
+($signatures, $pvinfo) = ('', undef);
+eval {
+    PVE::Storage::LVMPlugin::lvm_create_volume_group(
+        '/dev/null',
+        'data',
+        1,
+        { exempt => 'new' },
+    );
+};
+like($@, qr/referenced/, 'initializing a referenced LUN refuses');
+is_deeply(\@order, [qw(lock check)], 'the check precedes the first write');
+$scan->mock(assert_lun_unreferenced =>
+    sub { is($_[2], 'new', 'new storage exempt'); push @order, 'check' });
+@order = ();
+eval {
+    PVE::Storage::LVMPlugin::lvm_create_volume_group(
+        '/dev/null',
+        'data',
+        1,
+        { exempt => 'new' },
+    );
+};
+is($@, '', 'an unreferenced empty LUN is initialized');
+is_deeply(
+    \@order,
+    [qw(lock check clear /sbin/pvcreate /sbin/vgcreate unlock)],
+    'checked once, then written under the lock',
+);
 
 done_testing();
diff --git a/src/test/run_test_lvm_create.pl b/src/test/run_test_lvm_create.pl
index d4be25b0..4d94ea9c 100755
--- a/src/test/run_test_lvm_create.pl
+++ b/src/test/run_test_lvm_create.pl
@@ -10,9 +10,12 @@ use Test::More;
 
 use lib ('.', '..');
 use PVE::Storage::LVMPlugin;
+use PVE::Storage::SAN;
 
 my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
 my $disk = Test::MockModule->new('PVE::Diskmanage');
+my $san = Test::MockModule->new('PVE::Storage::SAN');
+$san->mock(lun_for_device => sub { undef });
 my $tools = Test::MockModule->new('PVE::Tools');
 my $inotify = Test::MockModule->new('PVE::INotify');
 $inotify->mock(nodename => sub { 'testnode' });
@@ -170,6 +173,17 @@ like(
     qr/contains data \(gpt\)/,
     'a partition table of a map is data, kpartx may not map it',
 );
+reset_case();
+($signatures, $partitioned) = ([{ type => 'PMBR' }, { type => 'gpt' }], 1);
+$san->mock(
+    lun_for_device =>
+        sub { { wwid => '3600abc', devpath => '/dev/sda', 'by-id' => '/dev/null' } },
+    with_lun_lock => sub { $_[1]->() },
+);
+like(create(), qr/contains data \(PMBR, gpt\)/, 'a partitioned LUN that is no map is data too');
+is_deeply(\@writes, [], 'partitioned LUN: no writes');
+$san->unmock('with_lun_lock');
+$san->mock(lun_for_device => sub { undef });
 
 my $uuid = 'aaaaaa-bbbb-cccc-dddd-eeee-ffff-gggggg';
 for my $vg ('test', 'other', 'unknown', '') {




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 21/36] disks: lvm: refuse to destroy the volume group of a shared storage
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (19 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 20/36] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 storage 22/36] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
                   ` (15 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Destroying a volume group through the node disk API removes it with
'vgremove -y' and, with cleanup-disks, wipes its physical volumes.
For a volume group on a SAN LUN, that destroys the guest disks of all
nodes that use it.

Refuse the removal if a shared storage uses the volume group. Volume
groups of node-local storages can be destroyed as before, including
the cleanup of their storage entry.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks/LVM.pm |  7 +++++++
 src/test/disk_api_test.pm | 21 +++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/PVE/API2/Disks/LVM.pm b/src/PVE/API2/Disks/LVM.pm
index a0ab6d69..8d66d156 100644
--- a/src/PVE/API2/Disks/LVM.pm
+++ b/src/PVE/API2/Disks/LVM.pm
@@ -3,6 +3,7 @@ package PVE::API2::Disks::LVM;
 use strict;
 use warnings;
 
+use PVE::Storage;
 use PVE::Storage::LVMPlugin;
 use PVE::Storage::SAN;
 use PVE::Diskmanage;
@@ -255,6 +256,12 @@ __PACKAGE__->register_method({
 
         my $worker = sub {
             PVE::Diskmanage::locked_disk_action(sub {
+                my $cfg = PVE::Storage::config();
+                for my $sid (sort keys $cfg->{ids}->%*) {
+                    my $scfg = $cfg->{ids}->{$sid};
+                    die "cannot remove volume group '$name' - shared storage '$sid' uses it\n"
+                        if $scfg->{shared} && ($scfg->{vgname} // '') eq $name;
+                }
                 my $vgs = PVE::Storage::LVMPlugin::lvm_vgs(1);
                 die "no such volume group '$name'\n" if !$vgs->{$name};
 
diff --git a/src/test/disk_api_test.pm b/src/test/disk_api_test.pm
index 32ab5c80..f8eb3575 100644
--- a/src/test/disk_api_test.pm
+++ b/src/test/disk_api_test.pm
@@ -232,4 +232,25 @@ subtest 'volume group creation leaves SAN locking to the LVM helper' => sub {
         );
 };
 
+subtest 'shared volume groups cannot be destroyed' => sub {
+    my $storage = Test::MockModule->new('PVE::Storage');
+    my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    my $rpc = Test::MockModule->new('PVE::RPCEnvironment');
+    $rpc->mock(get => sub { bless {}, 'MultipathTestRPC' });
+    my $cfg = { ids => { shared => { type => 'lvm', vgname => 'data', shared => 1 } } };
+    $storage->mock(config => sub { $cfg });
+    $diskmanage_module->mock(locked_disk_action => sub { $_[0]->() });
+    my @writes;
+    $lvm->mock(lvm_vgs => sub { { data => { pvs => [] } } });
+    $lvm->mock(lvm_destroy_volume_group => sub { push @writes, $_[0] });
+    eval {
+        PVE::API2::Disks::LVM->delete({ node => 'n1', name => 'data', 'cleanup-disks' => 1 });
+    };
+    like($@, qr/shared storage 'shared'/, 'shared reference refuses deletion');
+    is_deeply(\@writes, [], 'refused VG is not removed');
+    $cfg->{ids}->{shared}->{shared} = 0;
+    PVE::API2::Disks::LVM->delete({ node => 'n1', name => 'data' });
+    is_deeply(\@writes, ['data'], 'node-local deletion still works');
+};
+
 done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 storage 22/36] disks: allow wiping a SAN LUN that no storage uses
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (20 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 21/36] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 docs 23/36] storage: document the cluster-wide multipath management Thomas Lamprecht
                   ` (14 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

A recycled LUN can hold old data, for example the partition table of
a VMFS datastore, which the volume group creation refuses. The disk
wipe of a node wipes any block device that is not mounted and has no
holder. So it refuses a multipath map whose partitions are mapped,
but wipes a LUN that is only in use on other nodes.

For a LUN of the SAN inventory, run the wipe under the cluster-wide
lock of the LUN and only if no storage references it. Besides the
mount and holder checks of the local wipe, it removes the partition
mappings of a multipath map and writes through an exclusively opened
descriptor. The device parameter now accepts the characters of by-id
and mapper names, so that a LUN can be given by those.

LVM keeps listing a PV that was wiped by other means in its hint
file until two more of its commands ran, and the SAN inventory takes
the volume group names from that file. Remove the file after the wipe
and let one LVM command write a new one, so that the LUN list of the
node does not show the wiped LUN with its old volume group.

Other devices, including kernel partitions of a LUN, are wiped as
before.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks.pm          |  29 +++++--
 src/PVE/Diskmanage.pm          |  28 +++++--
 src/PVE/Storage/LVMPlugin.pm   |   7 ++
 src/PVE/Storage/SAN.pm         |  46 ++++++++++-
 src/test/Makefile              |   3 +-
 src/test/run_san_nvme_tests.pl |  16 ++++
 src/test/run_san_wipe_tests.pl | 137 +++++++++++++++++++++++++++++++++
 7 files changed, 251 insertions(+), 15 deletions(-)
 create mode 100755 src/test/run_san_wipe_tests.pl

diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index 980ba7ff..13f7c005 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -9,6 +9,8 @@ use HTTP::Status qw(:constants);
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::SafeSyslog;
+use PVE::Storage::LVMPlugin;
+use PVE::Storage::SAN;
 use PVE::Tools qw(run_command);
 
 use PVE::API2::Disks::Directory;
@@ -296,7 +298,7 @@ __PACKAGE__->register_method({
             disk => {
                 type => 'string',
                 description => "Block device name",
-                pattern => '^/dev/[a-zA-Z0-9\/]+$',
+                pattern => '^/dev/[a-zA-Z0-9._:+/-]+$',
             },
         },
     },
@@ -306,18 +308,31 @@ __PACKAGE__->register_method({
 
         my $disk = PVE::Diskmanage::verify_blockdev_path($param->{disk});
 
-        my $mounted = PVE::Diskmanage::is_mounted($disk);
-        die "disk/partition '${mounted}' is mounted\n" if $mounted;
+        my $lun = PVE::Storage::SAN::lun_for_device($disk);
+        if (!$lun) {
+            my $mounted = PVE::Diskmanage::is_mounted($disk);
+            die "disk/partition '${mounted}' is mounted\n" if $mounted;
 
-        my $held = PVE::Diskmanage::has_holder($disk);
-        die "disk/partition '${held}' has a holder\n" if $held;
+            my $held = PVE::Diskmanage::has_holder($disk);
+            die "disk/partition '${held}' has a holder\n" if $held;
+        }
 
         my $rpcenv = PVE::RPCEnvironment::get();
         my $authuser = $rpcenv->get_user();
 
         my $worker = sub {
-            PVE::Diskmanage::wipe_blockdev($disk);
-            PVE::Diskmanage::udevadm_trigger($disk);
+            if ($lun) {
+                PVE::Storage::SAN::with_lun_lock(
+                    $lun,
+                    sub { PVE::Storage::SAN::wipe_lun($lun) },
+                );
+                PVE::Diskmanage::udevadm_trigger($disk, PVE::Storage::SAN::lun_paths($lun)->@*);
+                run_command(['udevadm', 'settle', '--timeout=30'], timeout => 35);
+                PVE::Storage::LVMPlugin::refresh_cached_pv_volume_groups();
+            } else {
+                PVE::Diskmanage::wipe_blockdev($disk);
+                PVE::Diskmanage::udevadm_trigger($disk);
+            }
         };
 
         my $basename = basename($disk); # avoid '/' in the ID
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index bef401af..d6340d32 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -1119,7 +1119,7 @@ sub change_parttype {
 # If called with a partition, also sets the partition type to 0x83 'Linux filesystem'.
 # Expected to be called with a result of verify_blockdev_path().
 sub wipe_blockdev {
-    my ($devpath) = @_;
+    my ($devpath, $writepath) = @_;
 
     my $devname = basename($devpath);
     my $dev_size = PVE::Tools::file_get_contents("/sys/class/block/$devname/size");
@@ -1138,23 +1138,39 @@ sub wipe_blockdev {
             my ($part) = @_;
             push $to_wipe->@*, "/dev/${part}" if -b "/dev/${part}";
         },
-    );
+    ) if !defined($writepath);
 
     if (scalar($to_wipe->@*) > 0) {
         print "found child partitions to wipe: " . join(', ', $to_wipe->@*) . "\n";
     }
-    push $to_wipe->@*, $devpath; # put actual device last
+    push $to_wipe->@*, $writepath // $devpath; # put actual device last
 
     print "wiping block device ${devpath}\n";
 
-    run_command(['wipefs', '--all', $to_wipe->@*], errmsg => "error wiping '${devpath}'");
+    # The caller's exclusive descriptor checks use, so wipefs must not claim the device again.
+    run_command(
+        ['wipefs', '--all', defined($writepath) ? ('--force') : (), $to_wipe->@*],
+        errmsg => "error wiping '${devpath}'",
+        defined($writepath) ? (timeout => 10) : (),
+    );
 
+    my $target = $writepath // $devpath;
     run_command(
-        ['dd', 'if=/dev/zero', "of=${devpath}", 'bs=1M', 'conv=fdatasync', "count=${count}"],
+        [
+            'dd',
+            'if=/dev/zero',
+            "of=${target}",
+            'bs=1M',
+            'conv=fdatasync',
+            defined($writepath)
+            ? ('iflag=count_bytes', 'count=' . ($count * 1024 * 1024))
+            : "count=${count}",
+        ],
         errmsg => "error wiping '${devpath}'",
+        defined($writepath) ? (timeout => 60) : (),
     );
 
-    if (is_partition($devpath)) {
+    if (!defined($writepath) && is_partition($devpath)) {
         eval { change_parttype($devpath, '8300'); };
         warn $@ if $@;
     }
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index c9e52b4c..4e885429 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -148,6 +148,13 @@ sub cached_pv_volume_groups {
     return $res;
 }
 
+# LVM keeps listing a PV that was wiped by other means in its hint file until two more LVM commands
+# ran. It writes a new file when there is none.
+sub refresh_cached_pv_volume_groups {
+    unlink '/run/lvm/hints';
+    lvm_vgs();
+}
+
 sub lun_volume_groups {
     my ($devices) = @_;
     my $output = '';
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index 210c3a78..bba3c128 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -4,6 +4,7 @@ use v5.36;
 
 use Cwd qw(abs_path);
 use File::Basename qw(basename);
+use Fcntl qw(O_RDWR O_EXCL);
 
 use PVE::Cluster;
 use PVE::INotify;
@@ -16,7 +17,7 @@ use PVE::Multipath::Config;
 use PVE::Multipath::Identity;
 use PVE::Storage;
 use PVE::Storage::LVMPlugin;
-use PVE::Tools qw(file_read_firstline dir_glob_foreach);
+use PVE::Tools qw(file_read_firstline dir_glob_foreach run_command);
 
 sub scan_luns($cfg) {
     my $ids = PVE::Multipath::Identity::collect(all => 1);
@@ -281,4 +282,47 @@ sub assert_same_device($lun, $fh) {
         if !@held || !@named || $held[6] != $named[6];
 }
 
+# The SCSI paths of the LUN. Without a map, udev keeps the signatures it has seen for each of them.
+sub lun_paths($lun) {
+    my $paths = PVE::Multipath::Identity::collect(all => 1)->{paths};
+    return [
+        map { m/^(sd[a-z]+)$/ ? "/dev/$1" : () }
+        grep { $paths->{$_}->{wwid} eq $lun->{wwid} } sort keys %$paths
+    ];
+}
+
+sub wipe_lun($lun) {
+    assert_lun_unreferenced(PVE::Storage::config(), $lun);
+    my $device = PVE::Diskmanage::verify_blockdev_path($lun->{'by-id'});
+    my $parts = lun_partitions($lun);
+    my %parts = map { basename($_) => 1 } @$parts;
+    dir_glob_foreach(
+        '/sys/class/block/' . basename($device) . '/holders',
+        '[^.].*',
+        sub($name, @) {
+            die "cannot wipe '$device' - another block device uses it\n" if !$parts{$name};
+        },
+    );
+    for my $path ($device, @$parts) {
+        die "cannot wipe '$device' - '$path' is mounted\n" if PVE::Diskmanage::is_mounted($path);
+        next if $path eq $device;
+        die "cannot wipe '$device' - another block device uses '$path'\n"
+            if PVE::Diskmanage::has_holder($path);
+    }
+    sysopen(my $fh, $lun->{'by-id'}, O_RDWR) or die "cannot open '$device' - $!\n";
+    for my $part (@$parts) {
+        assert_same_device($lun, $fh);
+        run_command(['wipefs', '--all', $part], timeout => 10);
+        if ($part =~ m{^/dev/dm-}) {
+            assert_same_device($lun, $fh);
+            run_command(['dmsetup', 'remove', '--retry', $part], timeout => 10);
+        }
+    }
+    assert_same_device($lun, $fh);
+    close($fh);
+    sysopen($fh, $lun->{'by-id'}, O_RDWR | O_EXCL) or die "cannot claim '$device' - $!\n";
+    my $path = '/proc/' . $$ . '/fd/' . fileno($fh);
+    PVE::Diskmanage::wipe_blockdev($device, $path);
+}
+
 1;
diff --git a/src/test/Makefile b/src/test/Makefile
index e453951a..c9bcea8f 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -69,8 +69,9 @@ test_san_taint: run_san_taint_tests.pl
 test_san_lun_scan: run_san_lun_scan_tests.pl
 	./run_san_lun_scan_tests.pl
 
-test_san_api: run_san_api_tests.pl run_san_nvme_tests.pl
+test_san_api: run_san_api_tests.pl run_san_wipe_tests.pl run_san_nvme_tests.pl
 	./run_san_api_tests.pl
+	./run_san_wipe_tests.pl
 	./run_san_nvme_tests.pl
 
 test_disk_api: run_disk_api_tests.pl
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
index b28efe7d..c2f3c65e 100755
--- a/src/test/run_san_nvme_tests.pl
+++ b/src/test/run_san_nvme_tests.pl
@@ -31,6 +31,7 @@ my $mp = Test::MockModule->new('PVE::Multipath');
 my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
 my $storage = Test::MockModule->new('PVE::Storage');
 my $cluster = Test::MockModule->new('PVE::Cluster');
+my $tools = Test::MockModule->new('PVE::Tools');
 my $cfg = { ids => {} };
 my @order;
 $storage->mock(config => sub { $cfg });
@@ -44,6 +45,7 @@ $mp->mock(device_map => sub { undef });
 $san->mock(abs_path => sub { $device });
 $san->mock(scan_luns => sub { [$lun] });
 $san->mock(lun_partitions => sub { [] });
+$san->mock(dir_glob_foreach => sub { });
 $san->mock(assert_same_device => sub { ok(defined(fileno($_[1])), 'held descriptor checked') });
 $lvm->mock(lun_volume_groups => sub { push @order, 'check'; [] });
 $cluster->mock(
@@ -64,6 +66,20 @@ $cfg->{ids}->{data} = { type => 'lvm', base => 'fabric:nvme-eui.0123456789abcdef
 eval { PVE::Storage::SAN::assert_lun_unreferenced($cfg, $lun) };
 like($@, qr/base volume/, 'native base reference refuses');
 $cfg->{ids} = {};
+@order = @opens = ();
+$tools->mock(file_get_contents => sub { 1024 });
+$disk->mock(
+    run_command => sub {
+        my ($cmd, %opts) = @_;
+        push @order, $cmd->[0];
+        my ($path) = map { /^of=(.*)$/ ? $1 : m{^(/proc/\d+/fd/\d+)$} ? $1 : () } @$cmd;
+        ok(defined($path) && -e $path, 'native wipe writes through the held descriptor');
+    },
+);
+PVE::Storage::SAN::with_lun_lock($lun, sub { PVE::Storage::SAN::wipe_lun($lun) });
+is_deeply(\@order, [qw(lock check wipefs dd unlock)], 'native wipe sequencing');
+is_deeply(\@opens, [$link, $link], 'native wipe opens its by-id name');
+
 @order = @opens = ();
 $lvm->mock(file_read_firstline => sub { $_[0] =~ m{/size$} ? 1024 : undef });
 $lvm->mock(lvm_pv_info => sub { undef });
diff --git a/src/test/run_san_wipe_tests.pl b/src/test/run_san_wipe_tests.pl
new file mode 100755
index 00000000..9fffe294
--- /dev/null
+++ b/src/test/run_san_wipe_tests.pl
@@ -0,0 +1,137 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+our @open_modes;
+
+BEGIN {
+    *CORE::GLOBAL::sysopen = sub (*$$;$) {
+        push @open_modes, $_[2];
+        return @_ == 4
+            ? CORE::sysopen($_[0], $_[1], $_[2], $_[3])
+            : CORE::sysopen($_[0], $_[1], $_[2]);
+    };
+}
+
+use lib qw(..);
+use Fcntl qw(O_RDWR O_EXCL);
+use File::Temp qw(tempfile);
+use Test::MockModule;
+use Test::More;
+use PVE::Storage::SAN;
+
+my ($file, $name) = tempfile('san-wipe-XXXX', DIR => '.', UNLINK => 1);
+close($file);
+my $lun = { devpath => '/dev/dm-0', 'by-id' => $name, wwid => '3600a' };
+my $san = Test::MockModule->new('PVE::Storage::SAN');
+my $disk = Test::MockModule->new('PVE::Diskmanage');
+my $tools = Test::MockModule->new('PVE::Tools');
+my (@commands, @parts, @parttypes);
+my $sectors = 1024 * 1024;
+my $run = sub {
+    my ($cmd, %opts) = @_;
+    push @commands, [$cmd, \%opts];
+    if ($cmd->[0] eq 'dd' || ($cmd->[0] eq 'wipefs' && grep { $_ eq '--force' } @$cmd)) {
+        my ($path) = map { /^of=(.*)$/ ? $1 : m{^(/proc/\d+/fd/\d+)$} ? $1 : () } @$cmd;
+        ok(defined($path) && -e $path, 'whole-device command uses a live descriptor');
+        is((stat($path))[1], (stat($name))[1], 'descriptor still names the opened device');
+        ok($open_modes[-1] & O_EXCL, 'exclusive descriptor held for whole-device commands');
+    }
+};
+$san->mock(run_command => $run);
+my $referenced = 0;
+my $storage = Test::MockModule->new('PVE::Storage');
+$storage->mock(config => sub { { ids => {} } });
+$san->mock(assert_lun_unreferenced => sub { die "referenced\n" if $referenced });
+$san->mock(lun_partitions => sub { [@parts] });
+$san->mock(dir_glob_foreach => sub { });
+$disk->mock(verify_blockdev_path => sub { '/dev/dm-0' });
+$disk->mock(is_mounted => sub { 0 });
+$disk->mock(has_holder => sub { 0 });
+$disk->mock(run_command => $run);
+$disk->mock(dir_glob_foreach => sub { die "partition enumeration after exclusive open\n" });
+$disk->mock(is_partition => sub { die "partition check after exclusive open\n" });
+$tools->mock(file_get_contents => sub { $sectors });
+
+$referenced = 1;
+@commands = @open_modes = ();
+eval { PVE::Storage::SAN::wipe_lun($lun) };
+like($@, qr/referenced/, 'a referenced LUN is refused');
+is_deeply([\@commands, \@open_modes], [[], []], 'before the device is opened or written');
+$referenced = 0;
+
+for my $count (0, 2, 10) {
+    @parts = map { "/dev/dm-$_" } 1 .. $count;
+    @commands = @open_modes = ();
+    PVE::Storage::SAN::wipe_lun($lun);
+    is_deeply(\@open_modes, [O_RDWR, O_RDWR | O_EXCL], 'one exclusive whole-device open');
+    my $fdpath = $commands[-2]->[0]->[-1];
+    is_deeply(
+        $commands[-2]->[0],
+        ['wipefs', '--all', '--force', $fdpath],
+        'force avoids a second exclusive claim',
+    );
+    is($commands[-1]->[1]->{timeout}, 60, 'dd has 60 seconds for fdatasync');
+    ok(grep({ $_ eq 'count=209715200' } $commands[-1]->[0]->@*), 'wipe capped at 200 MiB');
+
+    for my $i (0 .. $#parts) {
+        is_deeply(
+            $commands[2 * $i]->[0],
+            ['wipefs', '--all', $parts[$i]],
+            'partition signatures first',
+        );
+        is_deeply(
+            $commands[2 * $i + 1]->[0],
+            ['dmsetup', 'remove', '--retry', $parts[$i]],
+            'remove partition map with retry',
+        );
+    }
+    is($_->[1]->{timeout}, 10, 'partition command has a fixed timeout')
+        for @commands[0 .. $#commands - 2];
+    ok(!-e $fdpath, 'descriptor released on return');
+}
+
+@parts = ();
+@commands = ();
+$sectors = 1;
+PVE::Storage::SAN::wipe_lun($lun);
+ok(grep({ $_ eq 'count=512' } $commands[-1]->[0]->@*), 'small device uses a byte count');
+
+$disk->mock(dir_glob_foreach => sub { });
+$disk->mock(is_partition => sub { 1 });
+$disk->mock(change_parttype => sub { push @parttypes, [@_] });
+$disk->mock(run_command => sub { my ($cmd, %opts) = @_; push @commands, [$cmd, \%opts] });
+@commands = ();
+$sectors = 204800;
+PVE::Diskmanage::wipe_blockdev('/dev/sda1');
+is_deeply(
+    [map { $_->[0] } @commands],
+    [
+        ['wipefs', '--all', '/dev/sda1'],
+        ['dd', 'if=/dev/zero', 'of=/dev/sda1', 'bs=1M', 'conv=fdatasync', 'count=100'],
+    ],
+    'local disk command lines unchanged',
+);
+ok(!grep({ exists($_->[1]->{timeout}) } @commands), 'local disk timeout behavior unchanged');
+is_deeply(\@parttypes, [['/dev/sda1', '8300']], 'local partition type still updated');
+
+my $identity = Test::MockModule->new('PVE::Multipath::Identity');
+$identity->mock(
+    collect => sub {
+        {
+            paths => {
+                sdb => { wwid => '3600a' },
+                sdc => { wwid => '3600b' },
+                sdd => { wwid => '3600a' },
+            },
+        };
+    },
+);
+is_deeply(
+    PVE::Storage::SAN::lun_paths($lun),
+    ['/dev/sdb', '/dev/sdd'],
+    'all paths of the LUN are refreshed after a wipe',
+);
+
+done_testing();




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 docs 23/36] storage: document the cluster-wide multipath management
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (21 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 storage 22/36] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 24/36] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
                   ` (13 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Add a chapter for multipath on iSCSI and Fibre Channel SANs, written
around the tasks an admin has: prerequisites, setting up shared LVM
with the guided setup or by hand, adding, growing and removing a LUN,
reading the states during a path failure, array-specific settings and
moving over from a hand-made multipath.conf.

Removing a LUN stays a manual procedure, as Proxmox VE never removes a
WWID or a map by itself, so the chapter spells it out including how to
get out of queued I/O.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 pmxcfs.adoc                  |   2 +
 pve-storage-iscsi.adoc       |  11 ++
 pve-storage-iscsidirect.adoc |   2 +-
 pve-storage-lvm.adoc         |   3 +
 pve-storage-multipath.adoc   | 260 +++++++++++++++++++++++++++++++++++
 pvesm.adoc                   |  18 ++-
 6 files changed, 290 insertions(+), 6 deletions(-)
 create mode 100644 pve-storage-multipath.adoc

diff --git a/pmxcfs.adoc b/pmxcfs.adoc
index 4a334fd..9a1dbd0 100644
--- a/pmxcfs.adoc
+++ b/pmxcfs.adoc
@@ -105,6 +105,8 @@ Files
 |`ha/manager_status`                    | JSON-formatted information regarding HA services on the cluster
 |`ha/resources.cfg`                     | Resources managed by high availability, and their current state
 |`ha/rules.cfg`                         | Rules putting constraints on the HA manager's scheduling of HA resources
+|`multipath-overrides.conf`             | Hardware-specific multipath settings, in `multipath.conf` format, applied on all nodes
+|`multipath.cfg`                        | {pve} cluster-wide multipath configuration (LUN entries)
 |`nodes/<NAME>/config`                  | Node-specific configuration
 |`nodes/<NAME>/lxc/<VMID>.conf`         | VM configuration data for LXC containers
 |`nodes/<NAME>/openvz/`                 | Prior to {pve} 4.0, used for container configuration data (deprecated, removed soon)
diff --git a/pve-storage-iscsi.adoc b/pve-storage-iscsi.adoc
index a02ed46..f8b3a76 100644
--- a/pve-storage-iscsi.adoc
+++ b/pve-storage-iscsi.adoc
@@ -23,6 +23,10 @@ resources.
 
 Low-level iscsi management task can be done using the `iscsiadm` tool.
 
+TIP: To set up shared LVM on a LUN of an iSCSI target, use the guided setup
+under *Datacenter -> Storage -> SAN* in the web UI, see
+xref:storage_multipath_setup[Multipath].
+
 
 Configuration
 ~~~~~~~~~~~~~
@@ -38,6 +42,13 @@ target::
 
 iSCSI target.
 
+multipath::
+
+Combine the paths to each LUN of the target into one `dm-multipath` map on every
+node the storage is enabled on, and monitor the maps cluster-wide. A shared LVM
+storage on a target with several portals needs this option. See
+xref:storage_multipath[Multipath].
+
 
 .Configuration Example (`/etc/pve/storage.cfg`)
 ----
diff --git a/pve-storage-iscsidirect.adoc b/pve-storage-iscsidirect.adoc
index ae722e8..822e9c7 100644
--- a/pve-storage-iscsidirect.adoc
+++ b/pve-storage-iscsidirect.adoc
@@ -21,7 +21,7 @@ Configuration
 ~~~~~~~~~~~~~
 
 The user mode iSCSI backend uses the same configuration options as the
-Open-iSCSI backend.
+Open-iSCSI backend, except for `multipath`.
 
 .Configuration Example (`/etc/pve/storage.cfg`)
 ----
diff --git a/pve-storage-lvm.adoc b/pve-storage-lvm.adoc
index 5b88151..3813a06 100644
--- a/pve-storage-lvm.adoc
+++ b/pve-storage-lvm.adoc
@@ -121,6 +121,9 @@ A benefit of LVM is that it can be used with shared storage.
 For example, an iSCSI LUN. The backend implements proper cluster-wide locking if
 the storage is marked as shared in the configuration.
 
+TIP: The guided setup under *Datacenter -> Storage -> SAN* in the web UI creates
+a shared LVM storage on a SAN LUN, see xref:storage_multipath_setup[Multipath].
+
 NOTE: If you extend a shared volume group onto another device on one node, the
 other nodes may only see the added physical volume after LVM has scanned their
 devices again, for example with `pvscan --cache`. This command also resets the
diff --git a/pve-storage-multipath.adoc b/pve-storage-multipath.adoc
new file mode 100644
index 0000000..d4503a7
--- /dev/null
+++ b/pve-storage-multipath.adoc
@@ -0,0 +1,260 @@
+[[storage_multipath]]
+Multipath
+---------
+ifdef::wiki[]
+:pve-toplevel:
+:title: Storage: Multipath
+endif::wiki[]
+
+Use multipath for shared LVM on an iSCSI or Fibre Channel SAN with redundant
+connections. Device-mapper multipath combines the paths to a LUN into one block
+device, called a map, so I/O can continue when a path fails. Its World Wide
+Identifier (WWID) identifies the same LUN on every node.
+
+{pve} configures maps cluster-wide and shows their state under *Datacenter ->
+Storage -> SAN*. An iSCSI storage with *Multipath* enabled requests maps for its
+LUNs; Fibre Channel LUNs need entries in `/etc/pve/multipath.cfg`. NVMe
+namespaces use kernel-native multipath instead; the procedures below cover SCSI
+LUNs.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+. Upgrade all nodes before enabling cluster-wide multipath management.
+. Install `multipath-tools` on every participating node. The
+  `libpve-storage-perl` package recommends it, but installations without
+  recommended packages need it added separately. A node without it shows
+  *Multipath unavailable* with the reason under *Datacenter -> Storage -> SAN*.
+  Plain iSCSI and LVM without the multipath option still work without it.
+. Allow each node's iSCSI initiator name on the array; the names are shown under
+  *Datacenter -> Storage -> SAN* and in the guided setup. Install `open-iscsi`
+  if needed.
+  For Fibre Channel, configure zoning and LUN masking for the WWPNs of each
+  node's HBA ports, which `cat /sys/class/fc_host/host*/port_name` lists.
+. Present the same empty LUN to all intended nodes over redundant paths. A node
+  does not scan for a Fibre Channel LUN that is mapped to it later, so rescan
+  the Fibre Channel hosts on each node:
++
+----
+# for host in /sys/class/fc_host/host*; do echo '- - -' > /sys/class/scsi_host/${host##*/}/scan; done
+----
++
+If the LUN still does not show up, check the target ports of the array on the
+node. This lists the WWPN, state and roles of each remote port; those of the
+array need the state `Online` and the role `FCP Target`. A `Blocked` port needs
+its connection restored before a rescan can reach it:
++
+----
+# for port in /sys/class/fc_remote_ports/rport-*; do echo $(cat $port/{port_name,port_state,roles}); done
+----
+
+[[storage_multipath_setup]]
+Setting Up Shared LVM
+~~~~~~~~~~~~~~~~~~~~
+
+. Open *Datacenter -> Storage -> SAN* in the web UI on a node that can access
+  the LUN and select *Add Storage -> LVM on iSCSI* or *LVM on Fibre Channel*.
+. For iSCSI, enter a portal, select the target and name the connection storage.
+  This storage connects to the target with `content none` and *Multipath*
+  enabled, while the LVM storage manages guest disks. Continuing creates or
+  reuses the connection storage before you select a LUN.
+. Select the LUN, choose the storage ID and volume group, then confirm. For
+  Fibre Channel, the setup adds the multipath entry of the LUN if it has none.
+  An entry it adds expects as many paths as the map has on the node serving
+  the web UI when it appears, if that is at least two; existing entries and
+  maps stay as they are. Set *Expected Paths* in the entry if it is missing or
+  does not match the intended topology, for example because a fabric was down
+  at that time or nodes have different path counts.
+  Leave *Nodes* empty for all nodes. Virtual machines on the storage can only
+  have snapshots with *Allow Snapshots as Volume-Chain*, a technology preview
+  that applies to disks created after it is set; see
+  xref:pvesm_lvm_config[LVM configuration].
+. Check the state of the LUN on each node of the storage, which the setup
+  shows once the storage is added. Before that, only the node serving the web
+  UI looked at the LUN; the LUN list names it as *Scan node*. The other nodes
+  set the LUN up with their next status updates and show *Pending* during the
+  first minute. For a node that stays *Missing*, check its access to the LUN
+  on the array before placing guests on the storage. *OK (1 path)* means that
+  the node reaches the LUN over a single path. The *State* column of the view
+  shows the same later.
+
+A LUN that a storage uses cannot be selected, and the setup refuses a LUN that
+contains data. To reuse such a LUN, first stop all its users on all hosts and
+remove its storage references, then use *Wipe* under *Node -> SAN* as
+`root@pam`. This destroys its data. The usage shown for a LUN is cached per
+node, so other nodes can still show the old content after a wipe. If setup
+fails, check the error, the node's task log and *Datacenter -> Storage* before
+retrying; closing the dialog does not undo changes.
+
+The dialogs under *Datacenter -> Storage -> Add* can do the same for iSCSI in
+two steps: add an *iSCSI* storage with *Multipath* enabled and *Use LUNs
+directly* cleared, then an *LVM* storage with it as *Base storage* and the LUN
+as *Base volume*. Selecting a base storage enables *Shared*; keep it enabled.
+
+To set up iSCSI by hand, run these commands on a node with access to the target:
+
+----
+# pvesm add iscsi <connection> --portal <portal> --target <iqn> --content none --multipath 1
+# pvesm list <connection> --content images
+# pvesm add lvm <storage> --vgname <vg> --base <volume-id> --shared 1
+----
+
+Use the complete volume ID from the listing, including the connection storage
+prefix and the `dm-uuid-mpath-<wwid>` suffix. Adding the LVM storage creates the
+volume group. Keep its base volume: it connects the target before LVM
+activation.
+
+For Fibre Channel, add an entry with the number of paths each node should
+have, wait for the scan to show a by-id path with `dm-uuid-mpath-<wwid>`, then
+create the volume group and shared storage:
+
+----
+# pvesh create /cluster/multipath/wwid --wwid <wwid> --paths-expected <paths>
+# pvesm scan san-luns --output-format json
+# pvesh create /nodes/<node>/disks/lvm --name <storage> \
+    --device /dev/disk/by-id/dm-uuid-mpath-<wwid> --add_storage 1
+----
+
+These examples allow all nodes. For a subset, set `--nodes <nodes>` on the
+entry or iSCSI storage and on the LVM storage (`pvesm set <storage> --nodes
+<nodes>`), using a comma-separated list. `pvesh` waits for the creation task;
+check its output for errors before using the storage.
+
+Adding Another LUN
+~~~~~~~~~~~~~~~~~~
+
+. Present the new LUN to the same nodes on the array. Enabled iSCSI storages
+  rescan their sessions automatically; for Fibre Channel, rescan the hosts as
+  shown in the prerequisites.
+. Run the guided setup again. For iSCSI, select the same target to reuse its
+  connection storage. If it lacks *Multipath*, enable that option in its edit
+  dialog first, observing the migration advice below.
+. Select the new LUN and create a separate LVM storage. By hand, repeat the
+  iSCSI listing and LVM command above, or the Fibre Channel procedure.
+
+[[storage_multipath_grow]]
+Growing a LUN
+~~~~~~~~~~~~~
+
+. Grow the LUN on the array. Never shrink a LUN in use.
+. Wait for the iSCSI session rescan, or rescan each SCSI path on every Fibre
+  Channel node with `echo 1 > /sys/block/<path>/device/rescan`, where `<path>`
+  is a member device such as `sdc`, not the map.
+. Check the map size on every node with `multipath -ll <wwid>` or under
+  *Node -> SAN*. The generated configuration sets `auto_resize grow_only`:
+  the map grows once all its paths report the new size. If necessary, run
+  `multipathd resize map <map>` after all paths have grown.
+. Run `pvresize /dev/disk/by-id/dm-uuid-mpath-<wwid>` on one node only, after
+  every node's map has grown. A smaller map cannot access the added space.
+
+[[storage_multipath_remove]]
+Removing a LUN
+~~~~~~~~~~~~~~
+
+{pve} never flushes maps or removes WWIDs from `/etc/multipath/wwids`.
+Removing a configuration entry is not enough. A map that queues I/O without
+paths can block guests and LVM commands, so disable queueing before unmapping:
+
+. Stop all users of the LUN on all hosts, or move their data elsewhere. Remove
+  the LVM storage with `pvesm remove <storage>` and deactivate its volume group
+  on every node with `vgchange -an <vg>`. Neither command erases the data.
+. Set an existing entry to fail I/O with
+  `pvesh set /cluster/multipath/wwid/<wwid> --no-path-retry fail`.
+  If none exists, create one with
+  `pvesh create /cluster/multipath/wwid --wwid <wwid> --no-path-retry fail`.
+  Add `--nodes <nodes>` if only a subset of nodes sees the LUN.
+. Wait until `multipath -ll <wwid>` on every participating node no longer lists
+  `queue_if_no_path` in the map's features. Wait for offline nodes to return.
+  Record the map name and member devices, and each member's identifier from
+  `/sys/block/<path>/device/wwid`.
+. Unmap the LUN on the array.
+. On every node, flush the map with `multipath -f <map>`. If it is busy, retry
+  after a few seconds; if it stays busy, find and stop its remaining users. Do
+  not force removal. For each recorded path,
+  check that its identifier is unchanged, then delete it with
+  `echo 1 > /sys/block/<path>/device/delete`. Skip paths already gone; stop if
+  an identifier changed.
+. Remove the explicit entry with `pvesh delete /cluster/multipath/wwid/<wwid>`.
+  Removing it earlier makes the nodes apply the default retry policy of the
+  array again, which can queue I/O on a map that is not flushed yet and block
+  whatever opens it.
+. On every node, wait until its next status update has removed the WWID from
+  `/etc/multipath/conf.d/pve-aliases.conf`, which takes about ten seconds, then
+  run `multipath -w <wwid>` to remove it from the allow-list. Running it before
+  that update can let the update add the WWID again. Check that
+  `grep -c '^/<wwid>/$' /etc/multipath/wwids` prints 0, and again after the
+  next status update.
+
+If the LUN was already unmapped and I/O is stuck, run
+`multipathd disablequeueing map <map>` on each affected node, then continue
+with the removal procedure.
+
+[[storage_multipath_disconnect]]
+Removing an iSCSI connection storage does not log out its sessions. Keep it
+while other LUNs of the target are in use; session maintenance is done with
+`iscsiadm`, not the read-only *Node -> SAN -> iSCSI* view.
+
+Checking Path Failures
+~~~~~~~~~~~~~~~~~~~~~
+
+*Datacenter -> Storage -> SAN* shows node availability, configuration errors
+and LUN states. The *State* of a LUN is the worst one among its nodes and names
+them if they are only some of the nodes. Hover over it for the states and path
+counts of all nodes. *Multipath* describes how the map is managed, not its
+health: by an explicit entry, by the storage that requests it, or *Unmanaged*
+for a map that {pve} did not set up. Under *Node -> SAN*, expand the LUN to
+inspect individual paths. *Node -> SAN -> iSCSI* shows targets and sessions.
+
+*Optimal*:: All known paths are usable and no expected path is missing.
+*OK (1 path)*:: The only path is usable, and there is no other path to fail
+over to. The API reports this as `optimal` with one path.
+*Degraded*:: Some paths are unusable or fewer paths exist than expected.
+*Failed*:: No usable path remains; I/O queues or fails according to the retry
+policy.
+*Missing*:: A node with a current report is expected to have the LUN but does
+not.
+*Unknown*:: No usable current observation is available for that node.
+
+During a path failure, inspect the degraded LUN's paths and restore the failed
+connection. The state returns to *Optimal* when the paths recover. Check node
+availability too: unknown observations do not worsen a known LUN state.
+
+An iSCSI storage expects one path per portal. For a Fibre Channel LUN, set
+*Expected Paths* in its multipath entry, as the guided setup does. Without it,
+a node only shows fewer paths than it should have while the lost ones are
+still listed. Depending on the settings for the array, the kernel removes a
+path that stays down longer than `dev_loss_tmo`, and the map then shows
+*Optimal* with fewer paths, or *OK (1 path)* for the last one.
+
+[[storage_multipath_config]]
+Array Settings and Existing Configurations
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Use the built-in device profiles unless the array vendor requires changes.
+*Edit Overrides* under *Datacenter -> Storage -> SAN* edits
+`/etc/pve/multipath-overrides.conf` for all nodes. For example, to set a retry
+count for one array model (replace the vendor and product expressions):
+
+----
+devices {
+    device {
+        vendor "<vendor>"
+        product "<product>"
+        no_path_retry 12
+    }
+}
+----
+
+To move from a hand-made `/etc/multipath.conf`:
+
+. Back up the local configuration on every node. Move shared array settings to
+  the overrides file; add WWID entries under *Datacenter -> Storage -> SAN* for
+  Fibre Channel LUNs or per-LUN aliases and `no-path-retry` settings.
+. Enable *Multipath* on existing iSCSI storages. Keep existing LVM base volumes.
+  Check `multipathd show config` on every node before removing duplicate local
+  settings. Do not edit the generated `/etc/multipath/conf.d/pve-*.conf` files.
+. Check active volume dependencies with `lsblk` on each node. Enabling multipath
+  does not move active volumes off individual paths. Stop and restart affected
+  guests, or migrate them away and back, before relying on path redundancy.
+  Keep LVM component detection enabled and follow the
+  xref:storage_lvm[shared LVM autoactivation guidance].
diff --git a/pvesm.adoc b/pvesm.adoc
index 5bd24b2..5668a41 100644
--- a/pvesm.adoc
+++ b/pvesm.adoc
@@ -96,11 +96,10 @@ TiB sized), these operations may take several minutes, or in extreme cases, even
 hours. If your setup is affected, create and remove snapshots while the VM is
 shut down, expecting a long task duration.
 
-^3^: With iSCSI, FibreChannel (FC), or SAS block storage as shared storage in a
-cluster, LVM is used to split the LUN into virtual disks. The
-https://pve.proxmox.com/wiki/Multipath[Multipath Guide] explains how to
-configure it in a cluster, including multipathing which is usually a
-requirement in these scenarios.
+^3^: With iSCSI, Fibre Channel (FC), or SAS block storage as shared storage in
+a cluster, LVM is used to split the LUN into virtual disks. A LUN is usually
+reachable over several paths; xref:storage_multipath[Multipath] describes how
+{pve} manages them in a cluster.
 
 ^4^: Since {pve} 9, snapshots as a volume chain have been available for VMs.
 These snapshots use separate volumes for the snapshot data and layer them.  For
@@ -153,6 +152,11 @@ also useful for local storage types. In this case such local storage
 is available on all nodes, but it is physically different and can have
 totally different content.
 
+Add storage under *Datacenter -> Storage -> Add* in the web UI. For shared LVM
+on a xref:storage_multipath_setup[SAN LUN], use the guided setup under
+*Datacenter -> Storage -> SAN -> Add Storage* instead. It creates the storages
+that are needed and enables multipath for the LUN.
+
 
 Storage Pools
 ~~~~~~~~~~~~~
@@ -421,6 +425,8 @@ See Also
 
 * link:/wiki/Storage:_iSCSI[Storage: iSCSI]
 
+* link:/wiki/Storage:_Multipath[Storage: Multipath]
+
 * link:/wiki/Storage:_LVM[Storage: LVM]
 
 * link:/wiki/Storage:_LVM_Thin[Storage: LVM Thin]
@@ -463,6 +469,8 @@ include::pve-storage-iscsi.adoc[]
 
 include::pve-storage-iscsidirect.adoc[]
 
+include::pve-storage-multipath.adoc[]
+
 include::pve-storage-rbd.adoc[]
 
 include::pve-storage-cephfs.adoc[]




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 24/36] pvestatd: apply the multipath configuration and report the node status
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (22 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 docs 23/36] storage: document the cluster-wide multipath management Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 25/36] report: add the managed multipath configuration Thomas Lamprecht
                   ` (12 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

The cluster-wide multipath configuration has to reach multipathd on
every node, also after a reboot or a storage change, and the cluster
needs to know which path state each node sees. Do both from the
periodic status loop.

Run this before the node, guest and storage updates. The storage
status can block in LVM while all paths of a LUN are lost, which would
delay the report of exactly that outage.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/Service/pvestatd.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index cec66e001..d9fbd2666 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -20,6 +20,7 @@ use PVE::RS::SDN::Fabrics;
 use PVE::NodeConfig;
 use PVE::Cluster qw(cfs_read_file);
 use PVE::Storage;
+use PVE::Multipath::Status;
 use PVE::QemuServer;
 use PVE::QemuServer::Monitor;
 use PVE::LXC;
@@ -814,6 +815,12 @@ sub update_status {
 
     my $status_cfg = PVE::Cluster::cfs_read_file('status.cfg');
 
+    # apply the multipath configuration before the other updates: the storage status update can
+    # block in LVM while all paths of a LUN are lost
+    eval { PVE::Multipath::Status::update_node_status(); };
+    $err = $@;
+    syslog('err', "multipath update error: $err") if $err;
+
     eval { update_node_status($status_cfg, $pull_txn); };
     $err = $@;
     syslog('err', "node status update error: $err") if $err;




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 25/36] report: add the managed multipath configuration
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (23 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 24/36] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 26/36] api: cluster: add the multipath endpoints Thomas Lamprecht
                   ` (11 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

The report shows /etc/multipath.conf, the WWID allow-list and the map
topology, but not the configuration that Proxmox VE manages: the LUN
entries and the overrides file kept cluster-wide in /etc/pve, and the
drop-ins pvestatd generates from them under /etc/multipath/conf.d.

Include them, so a report shows what Proxmox VE configured on the
node. As before, only nodes with multipath-tools installed report
this.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/Report.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/PVE/Report.pm b/PVE/Report.pm
index e255d538f..76d644847 100644
--- a/PVE/Report.pm
+++ b/PVE/Report.pm
@@ -183,7 +183,10 @@ my $init_report_cmds = sub {
 
     if (cmd_exists('multipath')) {
         push @{ $report_def->{disks}->{cmds} },
+            'cat /etc/pve/multipath.cfg',
+            'cat /etc/pve/multipath-overrides.conf',
             'cat /etc/multipath.conf',
+            sub { dir2text('/etc/multipath/conf.d/', 'pve-.+\.conf') },
             'cat /etc/multipath/wwids',
             'multipath -ll',
             ;




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 26/36] api: cluster: add the multipath endpoints
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (24 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 25/36] report: add the managed multipath configuration Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 27/36] api: nodes: expose the iSCSI status Thomas Lamprecht
                   ` (10 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Make the cluster-wide multipath management available below
/cluster/multipath: the explicit LUN entries, the overrides file and
the status that combines the reports of all nodes.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/API2/Cluster.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 4e5efbfd9..576840181 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -35,6 +35,7 @@ use PVE::API2::Cluster::Qemu;
 use PVE::API2::ClusterConfig;
 use PVE::API2::Firewall::Cluster;
 use PVE::API2::HAConfig;
+use PVE::API2::Multipath;
 use PVE::API2::ReplicationConfig;
 
 my $have_sdn;
@@ -100,6 +101,11 @@ __PACKAGE__->register_method({
     path => 'ceph',
 });
 
+__PACKAGE__->register_method({
+    subclass => "PVE::API2::Multipath",
+    path => 'multipath',
+});
+
 __PACKAGE__->register_method({
     subclass => "PVE::API2::Cluster::Jobs",
     path => 'jobs',
@@ -169,6 +175,7 @@ __PACKAGE__->register_method({
             { name => 'log' },
             { name => 'mapping' },
             { name => 'metrics' },
+            { name => 'multipath' },
             { name => 'notifications' },
             { name => 'nextid' },
             { name => 'options' },




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 27/36] api: nodes: expose the iSCSI status
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (25 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 26/36] api: cluster: add the multipath endpoints Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 28/36] ui: dc: add a SAN view Thomas Lamprecht
                   ` (9 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

Mount the read-only iSCSI API at /nodes/{node}/iscsi, next to the
other storage-backed node endpoints. It returns the initiator name of
the node and its targets and sessions with their state and devices,
which the web UI needs to show how a node is connected to an array.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: reword the commit message for the now read-only iSCSI API]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 PVE/API2/Nodes.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 1e2a96f1a..2a7ab4133 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -50,6 +50,7 @@ use PVE::API2::Certificates;
 use PVE::API2::Disks;
 use PVE::API2::Firewall::Host;
 use PVE::API2::Hardware;
+use PVE::API2::ISCSI;
 use PVE::API2::LXC::Status;
 use PVE::API2::LXC;
 use PVE::API2::Network;
@@ -160,6 +161,11 @@ __PACKAGE__->register_method({
     path => 'hardware',
 });
 
+__PACKAGE__->register_method({
+    subclass => "PVE::API2::ISCSI",
+    path => 'iscsi',
+});
+
 __PACKAGE__->register_method({
     subclass => "PVE::API2::Capabilities",
     path => 'capabilities',
@@ -240,6 +246,7 @@ __PACKAGE__->register_method({
             { name => 'firewall' },
             { name => 'hardware' },
             { name => 'hosts' },
+            { name => 'iscsi' },
             { name => 'journal' },
             { name => 'lxc' },
             { name => 'migrateall' },




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 28/36] ui: dc: add a SAN view
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (26 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 27/36] api: nodes: expose the iSCSI status Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 29/36] ui: storage: iscsi: add the multipath option Thomas Lamprecht
                   ` (8 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Admins need to see whether every node reaches each LUN and over how
many paths, without running "multipath -ll" on all nodes. Add a SAN
view with the multipath state of each node and of each LUN across the
cluster. The state of a LUN names the nodes it applies to if those are
only some of them, the path counts per node are in a tooltip. A LUN
with a single path reads "OK (1 path)" instead of optimal: it works,
but has no path to fail over to.

The node list includes the iSCSI initiator names, which can be copied
for the access rules of an array. The explicit multipath entries and
the overrides file are edited from the LUN list, which also shows how
the multipath of each LUN is managed: by an explicit entry, by the
storage that requests it, or not by Proxmox VE. A plain yes or no for
an entry made healthy LUNs of iSCSI storages look unprotected.

The view is an entry below Datacenter > Storage, which is expanded by
default: it shows what the shared storages of the cluster are built
on, and storage is where admins look for it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile                |   3 +
 www/manager6/SANUtils.js             |  52 +++++
 www/manager6/Utils.js                |  14 ++
 www/manager6/dc/Config.js            |  23 +-
 www/manager6/dc/MultipathWwidEdit.js |  81 +++++++
 www/manager6/dc/SAN.js               | 312 +++++++++++++++++++++++++++
 6 files changed, 479 insertions(+), 6 deletions(-)
 create mode 100644 www/manager6/SANUtils.js
 create mode 100644 www/manager6/dc/MultipathWwidEdit.js
 create mode 100644 www/manager6/dc/SAN.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index d2ea786be..f268a4d70 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -7,6 +7,7 @@ JSSRC= 							\
 	StateProvider.js				\
 	qemu/Architecture.js				\
 	Utils.js					\
+	SANUtils.js					\
 	UIOptions.js					\
 	Toolkit.js					\
 	VNCConsole.js					\
@@ -184,6 +185,7 @@ JSSRC= 							\
 	dc/Guests.js					\
 	dc/Health.js					\
 	dc/Log.js					\
+	dc/MultipathWwidEdit.js				\
 	dc/NodeView.js					\
 	dc/OptionView.js				\
 	dc/PermissionView.js				\
@@ -191,6 +193,7 @@ JSSRC= 							\
 	dc/PoolView.js					\
 	dc/RoleEdit.js					\
 	dc/RoleView.js					\
+	dc/SAN.js					\
 	dc/SecurityGroups.js				\
 	dc/StorageView.js				\
 	dc/Summary.js					\
diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
new file mode 100644
index 000000000..e83f8533c
--- /dev/null
+++ b/www/manager6/SANUtils.js
@@ -0,0 +1,52 @@
+Ext.define('PVE.SANUtils', {
+    singleton: true,
+
+    // A LUN with a single path is fine, but has no path to fail over to, so it is not optimal.
+    lunState: function (state, pathsTotal) {
+        return state === 'optimal' && Number(pathsTotal) === 1 ? 'single-path' : state;
+    },
+
+    // Usable paths of a node out of those it has, or out of those it should have if more.
+    pathCount: function (report) {
+        let total = Math.max(report['paths-total'] ?? 0, report['paths-expected'] ?? 0);
+        return `${report['paths-active']}/${total}`;
+    },
+
+    // How the multipath of a LUN is managed, as plain text.
+    multipathText: function (value, storage) {
+        if (value === 'storage' && storage) {
+            return Ext.String.format(gettext('Storage "{0}"'), storage);
+        }
+        return (
+            {
+                none: gettext('Not enabled'),
+                pending: gettext('Pending'),
+                manual: gettext('Explicit entry'),
+                storage: gettext('Storage'),
+                unmanaged: gettext('Unmanaged'),
+                native: gettext('Native'),
+            }[value] ??
+            value ??
+            ''
+        );
+    },
+
+    renderState: function (value) {
+        if (!value) {
+            return '';
+        }
+        let display = {
+            ok: ['check-circle good', gettext('OK')],
+            optimal: ['check-circle good', gettext('Optimal')],
+            'single-path': ['check-circle good', gettext('OK (1 path)')],
+            degraded: ['exclamation-circle warning', gettext('Degraded')],
+            failed: ['times-circle critical', gettext('Failed')],
+            missing: ['times-circle critical', gettext('Missing')],
+            unknown: ['question-circle faded', gettext('Unknown')],
+            unavailable: ['exclamation-circle warning', gettext('Multipath unavailable')],
+            'no-report': ['question-circle faded', gettext('No current report')],
+        }[value];
+        let [icon, label] = display ?? ['question-circle faded', value];
+        return `<i class="fa fa-fw fa-${icon}"></i> ${Ext.htmlEncode(label)}`;
+    },
+});
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 61b8def27..865ba44ff 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1118,6 +1118,20 @@ Ext.define('PVE.Utils', {
             return Ext.String.htmlEncode(result);
         },
 
+        copyToClipboard: function (text) {
+            let fail = (err) =>
+                Ext.Msg.alert(
+                    gettext('Error'),
+                    Ext.htmlEncode(
+                        Ext.String.format(
+                            gettext('Copying to the clipboard failed: {0}'),
+                            `${err}`,
+                        ),
+                    ),
+                );
+            navigator.clipboard.writeText(text).catch(fail);
+        },
+
         render_serverity: function (value) {
             return PVE.Utils.log_severity_hash[value] || value;
         },
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 83c48c3d6..65252b9d8 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -124,12 +124,23 @@ Ext.define('PVE.dc.Config', {
         }
 
         if (caps.storage['Datastore.Allocate'] || caps.dc['Sys.Audit']) {
-            me.items.push({
-                xtype: 'pveStorageView',
-                title: gettext('Storage'),
-                iconCls: 'fa fa-database',
-                itemId: 'storage',
-            });
+            me.items.push(
+                {
+                    xtype: 'pveStorageView',
+                    title: gettext('Storage'),
+                    iconCls: 'fa fa-database',
+                    itemId: 'storage',
+                    expandedOnInit: true,
+                },
+                // storage admins need the node identities for the target ACLs too
+                {
+                    xtype: 'pveDcSAN',
+                    title: 'SAN',
+                    iconCls: 'fa fa-cubes',
+                    itemId: 'san',
+                    groups: ['storage'],
+                },
+            );
         }
 
         if (caps.dc['Sys.Audit']) {
diff --git a/www/manager6/dc/MultipathWwidEdit.js b/www/manager6/dc/MultipathWwidEdit.js
new file mode 100644
index 000000000..405a5fdbb
--- /dev/null
+++ b/www/manager6/dc/MultipathWwidEdit.js
@@ -0,0 +1,81 @@
+Ext.define('PVE.dc.MultipathWwidEdit', {
+    extend: 'Proxmox.window.Edit',
+    subject: gettext('Multipath Entry'),
+    isAdd: true,
+    onlineHelp: 'storage_multipath',
+    width: 520,
+    fieldDefaults: { labelWidth: 170 },
+
+    initComponent: function () {
+        let me = this;
+        me.method = me.isCreate ? 'POST' : 'PUT';
+        me.url = '/cluster/multipath/wwid';
+        if (!me.isCreate) {
+            me.url += `/${encodeURIComponent(me.wwid)}`;
+            me.autoLoad = true;
+            me.autoLoadOptions = {
+                success: (response) => {
+                    let values = response.result.data;
+                    values.nodes = values.nodes ? values.nodes.split(',') : [];
+                    me.setValues(values);
+                },
+            };
+        }
+        me.items = [
+            {
+                xtype: me.isCreate ? 'proxmoxtextfield' : 'displayfield',
+                name: 'wwid',
+                fieldLabel: 'WWID',
+                value: me.wwid,
+                allowBlank: false,
+                maxLength: 128,
+            },
+            {
+                xtype: 'proxmoxtextfield',
+                name: 'alias',
+                fieldLabel: gettext('Alias'),
+                maxLength: 64,
+                deleteEmpty: !me.isCreate,
+            },
+            {
+                xtype: 'pveNodeSelector',
+                name: 'nodes',
+                fieldLabel: gettext('Nodes'),
+                emptyText: gettext('All (No restrictions)'),
+                multiSelect: true,
+                autoSelect: false,
+                allowBlank: true,
+                skipEmptyText: true,
+                deleteEmpty: !me.isCreate,
+            },
+            {
+                xtype: 'proxmoxKVComboBox',
+                name: 'no-path-retry',
+                fieldLabel: gettext('When All Paths Fail'),
+                deleteEmpty: !me.isCreate,
+                editable: true,
+                value: '__default__',
+                comboItems: [
+                    ['__default__', Proxmox.Utils.defaultText],
+                    ['queue', gettext('Queue I/O')],
+                    ['fail', gettext('Fail I/O')],
+                ],
+            },
+            {
+                xtype: 'proxmoxintegerfield',
+                name: 'paths-expected',
+                fieldLabel: gettext('Expected Paths'),
+                minValue: 1,
+                emptyText: Proxmox.Utils.noneText,
+                deleteEmpty: !me.isCreate,
+                autoEl: {
+                    tag: 'div',
+                    'data-qtip': gettext(
+                        'A node with fewer paths to the LUN shows it as degraded, also after the kernel removed a lost path.',
+                    ),
+                },
+            },
+        ];
+        me.callParent();
+    },
+});
diff --git a/www/manager6/dc/SAN.js b/www/manager6/dc/SAN.js
new file mode 100644
index 000000000..2ef60900a
--- /dev/null
+++ b/www/manager6/dc/SAN.js
@@ -0,0 +1,312 @@
+Ext.define('pve-san-status', {
+    extend: 'Ext.data.Model',
+    fields: [
+        'id',
+        'kind',
+        'node',
+        'state',
+        'error',
+        'apply-error',
+        'time',
+        'iscsi-initiator-name',
+        'wwid',
+        'name',
+        'explicit',
+        'multipath-storage',
+        'nodes',
+        'size',
+        'used-by-storage',
+    ],
+});
+
+Ext.define('PVE.dc.MultipathOverridesEdit', {
+    extend: 'Proxmox.window.Edit',
+    subject: gettext('Multipath Overrides'),
+    onlineHelp: 'storage_multipath',
+    width: 600,
+    autoLoad: true,
+    method: 'PUT',
+    url: '/cluster/multipath/overrides',
+    items: [
+        {
+            xtype: 'textarea',
+            name: 'overrides',
+            fieldLabel: gettext('Overrides'),
+            emptyText: gettext(
+                'multipath.conf sections for all nodes, for example a devices section with array settings',
+            ),
+            height: 320,
+            fieldStyle: 'font-family: monospace;',
+        },
+    ],
+});
+
+Ext.define('PVE.dc.SANView', {
+    extend: 'Ext.panel.Panel',
+    xtype: 'pveDcSAN',
+    onlineHelp: 'storage_multipath',
+    layout: { type: 'vbox', align: 'stretch' },
+
+    initComponent: function () {
+        let me = this;
+        let caps = Ext.state.Manager.get('GuiCap').dc;
+        let canModify = !!caps['Sys.Modify'];
+        let canEdit = canModify && !!caps['Sys.Audit'];
+        me.rstore = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: 'dc-san-status',
+            model: 'pve-san-status',
+            interval: 5000,
+            proxy: {
+                type: 'proxmox',
+                url: '/api2/json/cluster/multipath/status',
+                reader: {
+                    type: 'json',
+                    rootProperty: 'data',
+                    transform: function (raw) {
+                        let data = raw.data;
+                        return {
+                            ...raw,
+                            data: [
+                                ...Object.entries(data.nodes).map(([node, report]) => ({
+                                    ...report,
+                                    node,
+                                    id: `node/${node}`,
+                                    kind: 'node',
+                                })),
+                                ...data.luns.map((lun) => ({
+                                    ...lun,
+                                    id: `lun/${lun.wwid}`,
+                                    kind: 'lun',
+                                })),
+                            ],
+                        };
+                    },
+                },
+            },
+        });
+        let nodeStore = Ext.create('Proxmox.data.DiffStore', {
+            rstore: me.rstore,
+            filters: [{ property: 'kind', value: 'node' }],
+            sorters: ['node'],
+            sortAfterUpdate: true,
+        });
+        let lunStore = Ext.create('Proxmox.data.DiffStore', {
+            rstore: me.rstore,
+            filters: [{ property: 'kind', value: 'lun' }],
+            sorters: ['wwid'],
+            sortAfterUpdate: true,
+        });
+        let reload = () => me.rstore.load();
+        let edit = (rec) =>
+            Ext.create('PVE.dc.MultipathWwidEdit', {
+                wwid: rec?.get('wwid'),
+                isCreate: !rec,
+                autoShow: true,
+                apiCallDone: (success) => success && reload(),
+            });
+        me.items = [
+            {
+                xtype: 'grid',
+                title: gettext('Nodes'),
+                store: nodeStore,
+                flex: 2,
+                viewConfig: { enableTextSelection: true },
+                tbar: [
+                    {
+                        text: gettext('Copy Initiator Names'),
+                        iconCls: 'fa fa-clipboard',
+                        handler: () =>
+                            PVE.Utils.copyToClipboard(
+                                nodeStore
+                                    .getRange()
+                                    .map((rec) => rec.get('iscsi-initiator-name'))
+                                    .filter(Boolean)
+                                    .join('\n'),
+                            ),
+                    },
+                ],
+                columns: [
+                    {
+                        text: gettext('Node'),
+                        dataIndex: 'node',
+                        width: 120,
+                        renderer: Ext.htmlEncode,
+                    },
+                    {
+                        text: gettext('State'),
+                        dataIndex: 'state',
+                        width: 170,
+                        renderer: PVE.SANUtils.renderState,
+                    },
+                    {
+                        text: gettext('Message'),
+                        dataIndex: 'error',
+                        flex: 1,
+                        renderer: (value, md, rec) =>
+                            [value, rec.get('apply-error')]
+                                .filter(Boolean)
+                                .map(Ext.htmlEncode)
+                                .join('<br>'),
+                    },
+                    {
+                        text: gettext('iSCSI Initiator Name'),
+                        dataIndex: 'iscsi-initiator-name',
+                        flex: 2,
+                        renderer: Ext.htmlEncode,
+                    },
+                    {
+                        text: gettext('Last Report'),
+                        dataIndex: 'time',
+                        width: 160,
+                        renderer: Proxmox.Utils.render_timestamp,
+                        hidden: true,
+                    },
+                ],
+            },
+            {
+                xtype: 'grid',
+                title: 'LUNs',
+                store: lunStore,
+                flex: 3,
+                viewConfig: { enableTextSelection: true },
+                tbar: [
+                    { text: gettext('Add'), disabled: !canModify, handler: () => edit() },
+                    {
+                        xtype: 'proxmoxButton',
+                        text: gettext('Edit'),
+                        disabled: true,
+                        enableFn: (rec) => canEdit && !!rec.get('explicit'),
+                        handler: (button) => edit(button.up('grid').getSelection()[0]),
+                    },
+                    {
+                        xtype: 'proxmoxButton',
+                        text: gettext('Remove'),
+                        disabled: true,
+                        enableFn: (rec) => canModify && !!rec.get('explicit'),
+                        confirmMsg: (rec) =>
+                            Ext.String.format(
+                                gettext(
+                                    'Remove the multipath entry for {0}? Existing multipath maps are not removed.',
+                                ),
+                                Ext.htmlEncode(rec.get('name') || rec.get('wwid')),
+                            ),
+                        handler: function (button) {
+                            let rec = button.up('grid').getSelection()[0];
+                            Proxmox.Utils.API2Request({
+                                url: `/cluster/multipath/wwid/${encodeURIComponent(rec.get('wwid'))}`,
+                                method: 'DELETE',
+                                waitMsgTarget: me,
+                                failure: (response) =>
+                                    Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+                                success: reload,
+                            });
+                        },
+                    },
+                    {
+                        text: gettext('Edit Overrides'),
+                        disabled: !canEdit,
+                        handler: () =>
+                            Ext.create('PVE.dc.MultipathOverridesEdit', {
+                                autoShow: true,
+                                apiCallDone: (success) => success && reload(),
+                            }),
+                    },
+                ],
+                columns: [
+                    {
+                        text: gettext('Name'),
+                        dataIndex: 'name',
+                        flex: 2,
+                        renderer: (value, md, rec) => Ext.htmlEncode(value || rec.get('wwid')),
+                    },
+                    {
+                        text: 'WWID',
+                        dataIndex: 'wwid',
+                        flex: 2,
+                        hidden: true,
+                        renderer: Ext.htmlEncode,
+                    },
+                    {
+                        text: gettext('State'),
+                        dataIndex: 'state',
+                        flex: 1,
+                        minWidth: 160,
+                        renderer: function (value, md, rec) {
+                            let nodes = Object.entries(rec.get('nodes') || {})
+                                .map(([node, report]) => [
+                                    node,
+                                    PVE.SANUtils.lunState(report.state, report['paths-total']),
+                                    report,
+                                ])
+                                .sort(([a], [b]) => a.localeCompare(b));
+                            let tip = nodes
+                                .map(([node, nodeState, report]) => {
+                                    let state = PVE.SANUtils.renderState(nodeState);
+                                    if (
+                                        nodeState !== 'single-path' &&
+                                        report['paths-active'] !== undefined &&
+                                        report['paths-total'] !== undefined
+                                    ) {
+                                        state += ` (${Ext.htmlEncode(PVE.SANUtils.pathCount(report))})`;
+                                    }
+                                    return `${Ext.htmlEncode(node)}: ${state}`;
+                                })
+                                .join('<br>');
+                            md.tdAttr = `data-qtip="${Ext.htmlEncode(tip)}"`;
+                            if (value === 'optimal' && nodes.some(([, s]) => s === 'single-path')) {
+                                value = 'single-path';
+                            }
+                            let affected = nodes
+                                .filter(([, s]) => s === value)
+                                .map(([node]) => node);
+                            // name the affected nodes if they are only a part of all
+                            if (value === 'optimal' || affected.length === nodes.length) {
+                                return PVE.SANUtils.renderState(value);
+                            }
+                            let names = Ext.htmlEncode(affected.join(', '));
+                            if (value === 'single-path') {
+                                let text = Ext.String.format(
+                                    Ext.htmlEncode(gettext('OK (1 path on {0})')),
+                                    names,
+                                );
+                                return `<i class="fa fa-fw fa-check-circle good"></i> ${text}`;
+                            }
+                            return `${PVE.SANUtils.renderState(value)} (${names})`;
+                        },
+                    },
+                    {
+                        text: gettext('Multipath'),
+                        dataIndex: 'explicit',
+                        width: 170,
+                        renderer: (value, md, rec) => {
+                            let storage = rec.get('multipath-storage');
+                            let kind = value ? 'manual' : storage ? 'storage' : 'unmanaged';
+                            return Ext.htmlEncode(PVE.SANUtils.multipathText(kind, storage));
+                        },
+                    },
+                    {
+                        text: gettext('Used By'),
+                        dataIndex: 'used-by-storage',
+                        flex: 1,
+                        renderer: Ext.htmlEncode,
+                    },
+                    {
+                        text: gettext('Size'),
+                        dataIndex: 'size',
+                        width: 100,
+                        renderer: Proxmox.Utils.render_size,
+                    },
+                ],
+            },
+        ];
+        me.callParent();
+        me.query('grid').forEach((grid) => Proxmox.Utils.monStoreErrors(grid, me.rstore));
+        me.on('activate', () => me.rstore.startUpdate());
+        me.on('deactivate', () => me.rstore.stopUpdate());
+        me.on('destroy', () => {
+            nodeStore.destroy();
+            lunStore.destroy();
+            me.rstore.destroy();
+        });
+    },
+});




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 29/36] ui: storage: iscsi: add the multipath option
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (27 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 28/36] ui: dc: add a SAN view Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 30/36] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
                   ` (7 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Offer the multipath option in the dialog of an iSCSI storage. With it
the nodes of the storage combine the paths of each LUN into one
multipath device, without multipath being set up on every node by
hand.

Enabling the option on an existing storage does not move logical
volumes and guests that are already active on individual paths. Show
that limit in the dialog when the option gets enabled there, and link
to the documentation on checking the device dependencies.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/storage/IScsiEdit.js | 43 +++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/www/manager6/storage/IScsiEdit.js b/www/manager6/storage/IScsiEdit.js
index c005eeb15..0725edad0 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -75,6 +75,15 @@ Ext.define('PVE.storage.IScsiInputPanel', {
 
     onlineHelp: 'storage_open_iscsi',
 
+    // Loading sets the value before its original value, so use the dirty state.
+    updateMultipathActivation: function () {
+        let me = this;
+        let field = me.down('field[name=multipath]');
+        me.lookup('multipathActivation').setHidden(
+            me.isCreate || !field.getValue() || !field.isDirty(),
+        );
+    },
+
     onGetValues: function (values) {
         let me = this;
 
@@ -149,5 +158,39 @@ Ext.define('PVE.storage.IScsiInputPanel', {
             checked: true,
             fieldLabel: gettext('Use LUNs directly'),
         },
+        {
+            xtype: 'proxmoxcheckbox',
+            name: 'multipath',
+            fieldLabel: gettext('Multipath'),
+            cbind: {
+                deleteEmpty: '{!isCreate}',
+            },
+            autoEl: {
+                tag: 'div',
+                'data-qtip': gettext(
+                    'Combine the paths of each LUN into one device on every node using the storage.',
+                ),
+            },
+            listeners: {
+                change: (field) => field.up('inputpanel').updateMultipathActivation(),
+                dirtychange: (field) => field.up('inputpanel').updateMultipathActivation(),
+            },
+        },
+        {
+            xtype: 'displayfield',
+            reference: 'multipathActivation',
+            userCls: 'pmx-hint',
+            htmlEncode: false,
+            hidden: true,
+            cbind: {
+                value: () =>
+                    Ext.String.format(
+                        gettext(
+                            'Active logical volumes and guests using individual paths do not switch to the multipath map. Check their device dependencies before relying on path redundancy (<a href="{0}" target="_blank" rel="noopener noreferrer">documentation</a>).',
+                        ),
+                        Ext.htmlEncode(Proxmox.Utils.get_help_link('storage_multipath')),
+                    ),
+            },
+        },
     ],
 });




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 30/36] ui: lvm: enable shared when a base storage is selected
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (28 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 29/36] ui: storage: iscsi: add the multipath option Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 31/36] ui: node: add SAN LUNs panel Thomas Lamprecht
                   ` (6 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

A volume group on a LUN of a base storage is reachable from every node
that uses that storage. Without the shared flag each node handles it
as a local volume group of its own: allocations are only serialized
per node, and a migration treats the disks as local ones that have to
be copied. The checkbox is off by default and easy to miss.

Enable it when a base storage gets selected, and disable it again for
an existing volume group, where it was off before. It can still be
changed afterwards.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/storage/LVMEdit.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/www/manager6/storage/LVMEdit.js b/www/manager6/storage/LVMEdit.js
index 148f0601c..0c56455df 100644
--- a/www/manager6/storage/LVMEdit.js
+++ b/www/manager6/storage/LVMEdit.js
@@ -174,6 +174,9 @@ Ext.define('PVE.storage.LVMInputPanel', {
 
                     vgNameField.setVisible(!!value);
                     vgNameField.setDisabled(!value);
+
+                    // a LUN of a base storage is reachable from all nodes of that storage
+                    me.up('inputpanel').down('field[name=shared]').setValue(!!value);
                 },
             },
         },




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 31/36] ui: node: add SAN LUNs panel
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (29 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 30/36] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 32/36] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
                   ` (5 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Show the LUNs a node sees from a SAN under Node > SAN, separate from
the local disks: identity, size, transport, usage and how multipath
handles each LUN, with the state of every path in the expanded row.
Admins no longer need "multipath -ll" or sysfs to check a node.

For a LUN not reached over iSCSI, such as a Fibre Channel LUN,
multipath can be enabled from here. Node auditors and storage
administrators can open the view, matching the API permissions.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile        |   1 +
 www/manager6/SANUtils.js     |  68 ++++++++++++++
 www/manager6/node/Config.js  |  15 ++++
 www/manager6/node/SANLuns.js | 170 +++++++++++++++++++++++++++++++++++
 4 files changed, 254 insertions(+)
 create mode 100644 www/manager6/node/SANLuns.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index f268a4d70..723007220 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -249,6 +249,7 @@ JSSRC= 							\
 	node/Directory.js				\
 	node/LVM.js					\
 	node/LVMThin.js					\
+	node/SANLuns.js					\
 	node/StatusView.js				\
 	node/Subscription.js				\
 	node/Summary.js					\
diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
index e83f8533c..a3920db2b 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -1,3 +1,31 @@
+Ext.define('pve-san-lun', {
+    extend: 'Ext.data.Model',
+    idProperty: 'wwid',
+    fields: [
+        'wwid',
+        'name',
+        'devpath',
+        'by-id',
+        'size',
+        'transport',
+        'vendor',
+        'model',
+        'serial',
+        'state',
+        'paths-active',
+        'paths-total',
+        'path-list',
+        'usage',
+        'vgname',
+        'detail',
+        'used-by-storage',
+        'multipath',
+        'multipath-storage',
+        'iscsi-target',
+        'iscsi-lun',
+    ],
+});
+
 Ext.define('PVE.SANUtils', {
     singleton: true,
 
@@ -49,4 +77,44 @@ Ext.define('PVE.SANUtils', {
         let [icon, label] = display ?? ['question-circle faded', value];
         return `<i class="fa fa-fw fa-${icon}"></i> ${Ext.htmlEncode(label)}`;
     },
+
+    renderSanLunMultipath: function (value, metaData, rec) {
+        return Ext.htmlEncode(PVE.SANUtils.multipathText(value, rec.get('multipath-storage')));
+    },
+
+    usageText: function (row) {
+        return (
+            row['used-by-storage'] ||
+            row.vgname ||
+            row.detail ||
+            {
+                unused: gettext('Unused'),
+                lvm: gettext('LVM physical volume'),
+                other: gettext('Other'),
+            }[row.usage] ||
+            ''
+        );
+    },
+
+    renderSanLunUsage: function (value, metaData, rec) {
+        return Ext.htmlEncode(PVE.SANUtils.usageText(rec.data));
+    },
+
+    renderSanTransport: function (value) {
+        return Ext.htmlEncode(
+            {
+                iscsi: 'iSCSI',
+                iser: 'iSER',
+                fc: 'FC',
+                fcoe: 'FCoE',
+                sas: 'SAS',
+                nvme: 'NVMe',
+                'nvme-tcp': 'NVMe/TCP',
+                'nvme-rdma': 'NVMe/RDMA',
+                'nvme-fc': 'NVMe/FC',
+            }[value] ??
+                value ??
+                '',
+        );
+    },
 });
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 217ee284c..7b1222817 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -357,6 +357,21 @@ Ext.define('PVE.node.Config', {
                     groups: ['storage'],
                     xtype: 'pveZFSList',
                 },
+            );
+        }
+
+        // the san-luns read accepts either privilege
+        if (caps.nodes['Sys.Audit'] || caps.storage['Datastore.Allocate']) {
+            me.items.push({
+                xtype: 'pveSANLunList',
+                title: 'SAN',
+                itemId: 'san',
+                iconCls: 'fa fa-cubes',
+            });
+        }
+
+        if (caps.nodes['Sys.Audit']) {
+            me.items.push(
                 {
                     xtype: 'pveNodeCephStatus',
                     title: 'Ceph',
diff --git a/www/manager6/node/SANLuns.js b/www/manager6/node/SANLuns.js
new file mode 100644
index 000000000..dc659dd24
--- /dev/null
+++ b/www/manager6/node/SANLuns.js
@@ -0,0 +1,170 @@
+Ext.define('PVE.node.SANLunList', {
+    extend: 'Ext.grid.Panel',
+    xtype: 'pveSANLunList',
+    onlineHelp: 'storage_multipath',
+    stateful: true,
+    stateId: 'grid-node-san-luns',
+    emptyText: gettext('No LUNs found. Check connections and array access.'),
+    viewConfig: { enableTextSelection: true },
+
+    plugins: [
+        {
+            ptype: 'rowexpander',
+            expandOnDblClick: false,
+            rowBodyTpl: [
+                '{[this.paths(values)]}',
+                {
+                    paths: function (values) {
+                        let columns = [
+                            ['device', gettext('Path')],
+                            ['state', gettext('State')],
+                            ['checker-state', gettext('Checker')],
+                            ['ana-state', 'ANA'],
+                            ['host-wwpn', gettext('Host WWPN')],
+                            ['target-wwpn', gettext('Target WWPN')],
+                            ['address', gettext('Address')],
+                        ];
+                        let paths = values['path-list'] || [];
+                        columns = columns.filter(([key]) =>
+                            paths.some((path) => path[key] !== undefined),
+                        );
+                        let headers = columns
+                            .map(([, label]) => `<th>${Ext.htmlEncode(label)}</th>`)
+                            .join('');
+                        let rows = paths
+                            .map(
+                                (path) =>
+                                    '<tr>' +
+                                    columns
+                                        .map(
+                                            ([key]) =>
+                                                `<td>${Ext.htmlEncode(path[key] ?? '')}</td>`,
+                                        )
+                                        .join('') +
+                                    '</tr>',
+                            )
+                            .join('');
+                        return `<table style="border-spacing: 10px 2px;"><tr>${headers}</tr>${rows}</table>`;
+                    },
+                },
+            ],
+        },
+    ],
+    columns: [
+        {
+            text: gettext('Name'),
+            dataIndex: 'name',
+            flex: 2,
+            minWidth: 150,
+            renderer: (value, md, rec) => Ext.htmlEncode(value || rec.get('wwid')),
+        },
+        { text: 'WWID', dataIndex: 'wwid', flex: 2, hidden: true, renderer: Ext.htmlEncode },
+        {
+            text: gettext('State'),
+            dataIndex: 'state',
+            width: 120,
+            renderer: (value, md, rec) =>
+                PVE.SANUtils.renderState(PVE.SANUtils.lunState(value, rec.get('paths-total'))),
+        },
+        {
+            text: gettext('Multipath'),
+            dataIndex: 'multipath',
+            width: 150,
+            renderer: PVE.SANUtils.renderSanLunMultipath,
+        },
+        {
+            text: gettext('Used By'),
+            dataIndex: 'usage',
+            flex: 1,
+            renderer: PVE.SANUtils.renderSanLunUsage,
+        },
+        {
+            text: gettext('Device'),
+            dataIndex: 'devpath',
+            width: 180,
+            hidden: true,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Size'),
+            dataIndex: 'size',
+            width: 100,
+            renderer: Proxmox.Utils.render_size,
+        },
+        {
+            text: gettext('Transport'),
+            dataIndex: 'transport',
+            width: 100,
+            renderer: PVE.SANUtils.renderSanTransport,
+        },
+        { text: 'LUN', dataIndex: 'iscsi-lun', width: 60, hidden: true },
+        {
+            text: gettext('Vendor'),
+            dataIndex: 'vendor',
+            width: 100,
+            hidden: true,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Model'),
+            dataIndex: 'model',
+            width: 140,
+            hidden: true,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Serial'),
+            dataIndex: 'serial',
+            width: 140,
+            hidden: true,
+            renderer: Ext.htmlEncode,
+        },
+    ],
+
+    initComponent: function () {
+        let me = this;
+        me.nodename = me.pveSelNode.data.node;
+        me.rstore = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: `san-luns-${me.nodename}`,
+            model: 'pve-san-lun',
+            interval: 5000,
+            proxy: {
+                type: 'proxmox',
+                url: `/api2/json/nodes/${me.nodename}/scan/san-luns`,
+            },
+        });
+        me.store = Ext.create('Proxmox.data.DiffStore', { rstore: me.rstore });
+        let reload = () => me.rstore.load();
+        let caps = Ext.state.Manager.get('GuiCap');
+        me.tbar = [
+            { text: gettext('Reload'), iconCls: 'fa fa-refresh', handler: reload },
+            {
+                xtype: 'proxmoxButton',
+                text: gettext('Enable Multipath'),
+                disabled: true,
+                enableFn: (rec) =>
+                    !!caps.dc['Sys.Modify'] &&
+                    rec.get('multipath') === 'none' &&
+                    !rec.get('iscsi-target') &&
+                    !['iscsi', 'iser'].includes(rec.get('transport')),
+                handler: (button, event, rec) =>
+                    Proxmox.Utils.API2Request({
+                        url: '/cluster/multipath/wwid',
+                        method: 'POST',
+                        params: { wwid: rec.get('wwid') },
+                        waitMsgTarget: me,
+                        failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+                        success: reload,
+                    }),
+            },
+        ];
+        me.callParent();
+        Proxmox.Utils.monStoreErrors(me, me.rstore);
+        me.on('activate', () => me.rstore.startUpdate());
+        me.on('deactivate', () => me.rstore.stopUpdate());
+        me.on('destroy', () => {
+            me.store.destroy();
+            me.rstore.destroy();
+        });
+    },
+});




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 32/36] ui: node: san: wipe a LUN that no storage uses
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (30 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 31/36] ui: node: add SAN LUNs panel Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 33/36] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
                   ` (4 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

A recycled LUN often still carries a volume group or partitions from
its previous use and cannot be set up again until those are gone. Let
root@pam, the only user the wipe API accepts, wipe a LUN from
Node > SAN.

The dialog shows what the node knows about the content of the LUN and
asks for its name as confirmation. The button is disabled for a LUN
that the list attributes to a storage. The list shows cached state, so
the check of the node on the wipe itself stays the one that counts.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile             |  1 +
 www/manager6/node/SANLuns.js      | 14 ++++++++
 www/manager6/window/SANLunWipe.js | 53 +++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 www/manager6/window/SANLunWipe.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 723007220..19433ef9c 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -137,6 +137,7 @@ JSSRC= 							\
 	window/Restore.js				\
 	window/SafeDestroyGuest.js			\
 	window/SafeDestroyStorage.js			\
+	window/SANLunWipe.js				\
 	window/Settings.js				\
 	window/Snapshot.js				\
 	window/StartupEdit.js				\
diff --git a/www/manager6/node/SANLuns.js b/www/manager6/node/SANLuns.js
index dc659dd24..b290488a6 100644
--- a/www/manager6/node/SANLuns.js
+++ b/www/manager6/node/SANLuns.js
@@ -157,6 +157,20 @@ Ext.define('PVE.node.SANLunList', {
                         success: reload,
                     }),
             },
+            {
+                xtype: 'proxmoxButton',
+                text: gettext('Wipe'),
+                iconCls: 'fa fa-eraser',
+                disabled: true,
+                enableFn: (rec) => Proxmox.UserName === 'root@pam' && !rec.get('used-by-storage'),
+                handler: (button, event, rec) =>
+                    Ext.create('PVE.window.SANLunWipe', {
+                        node: me.nodename,
+                        lun: rec.data,
+                        autoShow: true,
+                        taskDone: () => !me.destroyed && reload(),
+                    }),
+            },
         ];
         me.callParent();
         Proxmox.Utils.monStoreErrors(me, me.rstore);
diff --git a/www/manager6/window/SANLunWipe.js b/www/manager6/window/SANLunWipe.js
new file mode 100644
index 000000000..4d2713996
--- /dev/null
+++ b/www/manager6/window/SANLunWipe.js
@@ -0,0 +1,53 @@
+Ext.define('PVE.window.SANLunWipe', {
+    extend: 'Proxmox.window.Edit',
+    title: gettext('Wipe LUN'),
+    onlineHelp: 'storage_multipath',
+    width: 550,
+    isCreate: true,
+    showProgress: true,
+    submitText: gettext('Wipe'),
+    method: 'PUT',
+
+    initComponent: function () {
+        let me = this;
+        let lun = me.lun;
+        let name = lun.name || lun.wwid;
+        me.url = `/nodes/${me.node}/disks/wipedisk`;
+        me.extraRequestParams = { disk: lun['by-id'] || lun.devpath };
+        me.items = [
+            {
+                xtype: 'component',
+                cls: 'pmx-hint',
+                html: Ext.htmlEncode(
+                    Ext.String.format(
+                        gettext('Wipe LUN {0} on node "{1}"? All data on the device will be lost!'),
+                        name,
+                        me.node,
+                    ),
+                ),
+            },
+            {
+                xtype: 'displayfield',
+                fieldLabel: gettext('Used By'),
+                value: PVE.SANUtils.usageText(lun),
+            },
+            {
+                xtype: 'displayfield',
+                fieldLabel: gettext('Size'),
+                value: Proxmox.Utils.format_size(lun.size),
+            },
+            {
+                xtype: 'textfield',
+                fieldLabel: Ext.String.format(
+                    gettext('Please enter the ID to confirm ({0})'),
+                    Ext.htmlEncode(name),
+                ),
+                labelAlign: 'top',
+                submitValue: false,
+                allowBlank: false,
+                validator: (value) => value === name || gettext('The ID does not match.'),
+            },
+        ];
+        me.callParent();
+    },
+});




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 33/36] ui: node: san: show iSCSI targets and sessions
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (31 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 32/36] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 34/36] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
                   ` (3 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

The LUN list cannot explain how a node is connected to an iSCSI
target. Add a child view of Node > SAN with the targets, their portals
with the session state, and the devices of each session. Portals that
the node knows but has no session to are listed as not connected.

Show the initiator name of the node with a copy button, as the access
rules of an array need it, and a message instead of an empty tree if
open-iscsi is not installed.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: keep the view read-only, without rescan, logout, record removal
 and session details; reword the commit message accordingly]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile             |   1 +
 www/manager6/SANUtils.js          |   3 +
 www/manager6/node/Config.js       |  23 ++++--
 www/manager6/node/ISCSITargets.js | 122 ++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+), 7 deletions(-)
 create mode 100644 www/manager6/node/ISCSITargets.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 19433ef9c..7fb4d7944 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -248,6 +248,7 @@ JSSRC= 							\
 	node/CmdMenu.js					\
 	node/Config.js					\
 	node/Directory.js				\
+	node/ISCSITargets.js				\
 	node/LVM.js					\
 	node/LVMThin.js					\
 	node/SANLuns.js					\
diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
index a3920db2b..8947d83e5 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -73,6 +73,9 @@ Ext.define('PVE.SANUtils', {
             unknown: ['question-circle faded', gettext('Unknown')],
             unavailable: ['exclamation-circle warning', gettext('Multipath unavailable')],
             'no-report': ['question-circle faded', gettext('No current report')],
+            'logged-in': ['check-circle good', gettext('Connected')],
+            recovering: ['exclamation-circle warning', gettext('Reconnecting')],
+            'not-connected': ['times-circle faded', gettext('Not connected')],
         }[value];
         let [icon, label] = display ?? ['question-circle faded', value];
         return `<i class="fa fa-fw fa-${icon}"></i> ${Ext.htmlEncode(label)}`;
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 7b1222817..d4a292d68 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -360,14 +360,23 @@ Ext.define('PVE.node.Config', {
             );
         }
 
-        // the san-luns read accepts either privilege
+        // the san-luns and iscsi reads accept either privilege
         if (caps.nodes['Sys.Audit'] || caps.storage['Datastore.Allocate']) {
-            me.items.push({
-                xtype: 'pveSANLunList',
-                title: 'SAN',
-                itemId: 'san',
-                iconCls: 'fa fa-cubes',
-            });
+            me.items.push(
+                {
+                    xtype: 'pveSANLunList',
+                    title: 'SAN',
+                    itemId: 'san',
+                    iconCls: 'fa fa-cubes',
+                },
+                {
+                    xtype: 'pveISCSITargetTree',
+                    title: 'iSCSI',
+                    itemId: 'san-iscsi',
+                    iconCls: 'fa fa-bullseye',
+                    groups: ['san'],
+                },
+            );
         }
 
         if (caps.nodes['Sys.Audit']) {
diff --git a/www/manager6/node/ISCSITargets.js b/www/manager6/node/ISCSITargets.js
new file mode 100644
index 000000000..428ee948e
--- /dev/null
+++ b/www/manager6/node/ISCSITargets.js
@@ -0,0 +1,122 @@
+Ext.define('PVE.node.ISCSITargetTree', {
+    extend: 'Ext.tree.Panel',
+    xtype: 'pveISCSITargetTree',
+    onlineHelp: 'storage_open_iscsi',
+    rootVisible: false,
+    viewConfig: { emptyText: gettext('No iSCSI targets found'), enableTextSelection: true },
+    store: {
+        type: 'tree',
+        fields: ['text', 'state', 'session-id', 'used-by-storage', 'lun'],
+        root: { expanded: true, children: [] },
+    },
+    columns: [
+        {
+            xtype: 'treecolumn',
+            text: gettext('Target'),
+            dataIndex: 'text',
+            flex: 3,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('State'),
+            dataIndex: 'state',
+            width: 150,
+            renderer: PVE.SANUtils.renderState,
+        },
+        { text: gettext('Session ID'), dataIndex: 'session-id', width: 100 },
+        { text: 'LUN', dataIndex: 'lun', width: 70 },
+        {
+            text: gettext('Connection Storage'),
+            dataIndex: 'used-by-storage',
+            flex: 1,
+            renderer: Ext.htmlEncode,
+        },
+    ],
+
+    reload: function () {
+        let me = this;
+        Proxmox.Utils.API2Request({
+            url: `/nodes/${me.nodename}/iscsi/status`,
+            method: 'GET',
+            waitMsgTarget: me.getView(),
+            failure: (response) => Proxmox.Utils.setErrorMask(me.getView(), response.htmlStatus),
+            success: function (response) {
+                if (me.destroyed) {
+                    return;
+                }
+                let status = response.result.data;
+                me.down('#initiator').setValue(status['initiator-name'] || '');
+                if (!status.supported) {
+                    Proxmox.Utils.setErrorMask(
+                        me.getView(),
+                        gettext('open-iscsi is not installed on this node.'),
+                    );
+                    return;
+                }
+                Proxmox.Utils.API2Request({
+                    url: `/nodes/${me.nodename}/iscsi/target`,
+                    method: 'GET',
+                    waitMsgTarget: me.getView(),
+                    failure: (res) => Proxmox.Utils.setErrorMask(me.getView(), res.htmlStatus),
+                    success: function (res) {
+                        if (me.destroyed) {
+                            return;
+                        }
+                        Proxmox.Utils.setErrorMask(me.getView(), false);
+                        let targets = {};
+                        for (let row of res.result.data) {
+                            targets[row.target] ??= {
+                                text: row.target,
+                                iconCls: 'fa fa-bullseye',
+                                expanded: true,
+                                children: [],
+                            };
+                            targets[row.target].children.push({
+                                text: row.portal,
+                                state: row.state,
+                                'session-id': row['session-id'],
+                                'used-by-storage': row['used-by-storage'],
+                                iconCls: 'fa fa-link',
+                                expanded: true,
+                                leaf: !row.devices.length,
+                                children: row.devices.map((device) => ({
+                                    text: device.devpath,
+                                    lun: device.lun,
+                                    iconCls: 'fa fa-hdd-o',
+                                    leaf: true,
+                                })),
+                            });
+                        }
+                        me.setRootNode({ expanded: true, children: Object.values(targets) });
+                    },
+                });
+            },
+        });
+    },
+
+    listeners: {
+        activate: function () {
+            this.reload();
+        },
+    },
+
+    initComponent: function () {
+        let me = this;
+        me.nodename = me.pveSelNode.data.node;
+        me.tbar = [
+            { text: gettext('Reload'), iconCls: 'fa fa-refresh', handler: () => me.reload() },
+            '->',
+            {
+                xtype: 'displayfield',
+                itemId: 'initiator',
+                fieldLabel: gettext('Initiator Name'),
+            },
+            {
+                iconCls: 'fa fa-clipboard',
+                tooltip: gettext('Copy to Clipboard'),
+                handler: () => PVE.Utils.copyToClipboard(me.down('#initiator').getValue()),
+            },
+        ];
+        me.callParent();
+    },
+});




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 34/36] ui: dc: san: add a guided setup for shared LVM on iSCSI
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (32 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 33/36] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 35/36] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
                   ` (2 subsequent siblings)
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Shared LVM on an iSCSI LUN needs an iSCSI storage with multipath, the
right LUN as base volume and an LVM storage on top, in that order. Add
a guided setup for it to the SAN view: connect to the target, with the
initiator names of all nodes at hand for the access rules of the
array, select a LUN, name the volume group and storage, and confirm.
The LUN list shows the model of each LUN, the confirm step how its
multipath is set up.

It starts from the SAN view and not from Datacenter > Storage > Add,
as it creates a volume group and up to two storages, while an entry of
the Add menu attaches one storage of its type. Those dialogs stay as
they are and can do the same in two steps. Continuing from the target
step creates or reuses the connection storage, before the confirm
step, so the step says so.

A LUN that a storage uses cannot be selected. The list is the one of
the node serving the web UI, which the LUN step names. Whether the
other nodes of the storage see the LUN as well is what matters for a
shared storage, so the setup ends with the state of the LUN on each of
them, taken from the cluster-wide status. Nodes set up a new LUN with
their next status updates, so for the first minute a node without it
shows as pending and not as missing. A tooltip on that state says that
the SAN view lists such a node as missing meanwhile, and the note of
the window that guests on the storage cannot run on a node that stays
missing.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile                         |   5 +
 www/manager6/dc/SAN.js                        |  20 +-
 www/manager6/storage/wizard/IScsi.js          | 272 ++++++++++++++++++
 www/manager6/storage/wizard/LunSelect.js      | 158 ++++++++++
 www/manager6/storage/wizard/NodeIdentities.js |  83 ++++++
 www/manager6/storage/wizard/Wizard.js         | 180 ++++++++++++
 www/manager6/window/SANLunState.js            | 111 +++++++
 7 files changed, 828 insertions(+), 1 deletion(-)
 create mode 100644 www/manager6/storage/wizard/IScsi.js
 create mode 100644 www/manager6/storage/wizard/LunSelect.js
 create mode 100644 www/manager6/storage/wizard/NodeIdentities.js
 create mode 100644 www/manager6/storage/wizard/Wizard.js
 create mode 100644 www/manager6/window/SANLunState.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 7fb4d7944..c7cefeacc 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -137,6 +137,7 @@ JSSRC= 							\
 	window/Restore.js				\
 	window/SafeDestroyGuest.js			\
 	window/SafeDestroyStorage.js			\
+	window/SANLunState.js				\
 	window/SANLunWipe.js				\
 	window/Settings.js				\
 	window/Snapshot.js				\
@@ -384,6 +385,10 @@ JSSRC= 							\
 	storage/ZFSEdit.js				\
 	storage/ZFSPoolEdit.js				\
 	storage/ESXIEdit.js				\
+	storage/wizard/Wizard.js			\
+	storage/wizard/LunSelect.js			\
+	storage/wizard/NodeIdentities.js		\
+	storage/wizard/IScsi.js				\
 	Workspace.js					\
 # end of JSSRC list
 
diff --git a/www/manager6/dc/SAN.js b/www/manager6/dc/SAN.js
index 2ef60900a..fa60a1e6f 100644
--- a/www/manager6/dc/SAN.js
+++ b/www/manager6/dc/SAN.js
@@ -49,7 +49,8 @@ Ext.define('PVE.dc.SANView', {
 
     initComponent: function () {
         let me = this;
-        let caps = Ext.state.Manager.get('GuiCap').dc;
+        let allCaps = Ext.state.Manager.get('GuiCap');
+        let caps = allCaps.dc;
         let canModify = !!caps['Sys.Modify'];
         let canEdit = canModify && !!caps['Sys.Audit'];
         me.rstore = Ext.create('Proxmox.data.UpdateStore', {
@@ -104,6 +105,23 @@ Ext.define('PVE.dc.SANView', {
                 autoShow: true,
                 apiCallDone: (success) => success && reload(),
             });
+        let setupItem = (wizardType) => ({
+            text: PVE.storage.wizard.subject(wizardType),
+            iconCls: 'fa fa-fw fa-building',
+            handler: () =>
+                Ext.create('PVE.storage.wizard.SAN', {
+                    wizardType,
+                    autoShow: true,
+                    reloadCallback: reload,
+                }),
+        });
+        me.tbar = [
+            {
+                text: gettext('Add Storage'),
+                disabled: !allCaps.storage['Datastore.Allocate'],
+                menu: [setupItem('iscsi')],
+            },
+        ];
         me.items = [
             {
                 xtype: 'grid',
diff --git a/www/manager6/storage/wizard/IScsi.js b/www/manager6/storage/wizard/IScsi.js
new file mode 100644
index 000000000..515d1206f
--- /dev/null
+++ b/www/manager6/storage/wizard/IScsi.js
@@ -0,0 +1,272 @@
+Ext.define('PVE.storage.wizard.IScsiTarget', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pveStorageWizardIScsiTarget',
+    onlineHelp: 'storage_open_iscsi',
+
+    updateConnectionField: function () {
+        let me = this;
+        let target = me.down('field[name=target]').getValue();
+        let storage = me.storages?.find(
+            (entry) => entry.type === 'iscsi' && entry.target === target,
+        );
+        let field = me.down('field[name=connection]');
+        if (storage) {
+            field.setValue(storage.storage);
+        } else if (field.readOnly) {
+            field.setValue('');
+        }
+        field.setReadOnly(!!storage);
+    },
+
+    onSubmit: function () {
+        let me = this;
+        let wizard = me.up('window');
+        let values = me.getValues();
+        let params = {
+            type: 'iscsi',
+            storage: values.connection,
+            portal: values.portal,
+            target: values.target,
+            content: 'none',
+            multipath: 1,
+        };
+        let nodes = []
+            .concat(values.nodes || [])
+            .filter(Boolean)
+            .join(',');
+        if (nodes) {
+            params.nodes = nodes;
+        }
+        let connected = function (connection) {
+            if (wizard.destroyed) {
+                return;
+            }
+            wizard.connection = connection;
+            let tabs = wizard.down('#wizcontent');
+            wizard.down('#luns').enable();
+            tabs.setActiveTab(wizard.down('#luns'));
+            me.disable();
+        };
+        let fail = (response) => wizard.showError(response.htmlStatus);
+        Proxmox.Utils.API2Request({
+            url: '/storage',
+            method: 'GET',
+            waitMsgTarget: wizard,
+            failure: fail,
+            success: function (response) {
+                if (wizard.destroyed) {
+                    return;
+                }
+                me.storages = response.result.data;
+                me.updateConnectionField();
+                let users = me.storages.filter((entry) => entry.target === values.target);
+                if (users.length) {
+                    let base = users[0];
+                    if (
+                        users.length !== 1 ||
+                        base.type !== 'iscsi' ||
+                        `${base.content ?? ''}` !== 'none'
+                    ) {
+                        wizard.showError(
+                            gettext(
+                                'This target is already used by another storage. Check Datacenter > Storage.',
+                            ),
+                        );
+                        return;
+                    }
+                    if (base.disable) {
+                        wizard.showError(
+                            Ext.htmlEncode(
+                                Ext.String.format(
+                                    gettext(
+                                        'Storage "{0}" connects to this target, but it is disabled. Enable that storage first.',
+                                    ),
+                                    base.storage,
+                                ),
+                            ),
+                        );
+                        return;
+                    }
+                    let baseNodes = base.nodes ? base.nodes.split(',') : [];
+                    if (baseNodes.length && !baseNodes.includes(Proxmox.NodeName)) {
+                        wizard.showError(
+                            Ext.htmlEncode(
+                                Ext.String.format(
+                                    gettext(
+                                        'Connection storage "{0}" is not available on node "{1}". Open the web UI on one of its nodes.',
+                                    ),
+                                    base.storage,
+                                    Proxmox.NodeName,
+                                ),
+                            ),
+                        );
+                        return;
+                    }
+                    let selectedNodes = nodes ? nodes.split(',') : baseNodes;
+                    if (
+                        baseNodes.length &&
+                        selectedNodes.some((node) => !baseNodes.includes(node))
+                    ) {
+                        wizard.showError(
+                            gettext(
+                                'The connection storage is not available on all selected nodes.',
+                            ),
+                        );
+                        return;
+                    }
+                    let connection = {
+                        storage: base.storage,
+                        target: base.target,
+                        nodes: selectedNodes.join(','),
+                    };
+                    if (!base.multipath) {
+                        wizard.showError(
+                            Ext.htmlEncode(
+                                Ext.String.format(
+                                    gettext(
+                                        'Enable Multipath in the edit dialog of storage "{0}" before using it here.',
+                                    ),
+                                    base.storage,
+                                ),
+                            ),
+                        );
+                        return;
+                    }
+                    connected(connection);
+                    return;
+                }
+                Proxmox.Utils.API2Request({
+                    url: '/storage',
+                    method: 'POST',
+                    params,
+                    waitMsgTarget: wizard,
+                    failure: fail,
+                    success: () =>
+                        connected({ storage: params.storage, target: params.target, nodes }),
+                });
+            },
+        });
+    },
+
+    initComponent: function () {
+        let me = this;
+        let common = PVE.panel.StorageBase.commonFields(true);
+        // wide enough for the longest label of the step
+        let labelWidth = 150;
+        me.items = [
+            {
+                xtype: 'textfield',
+                name: 'portal',
+                fieldLabel: 'Portal',
+                labelWidth,
+                allowBlank: false,
+                listeners: {
+                    change: {
+                        buffer: 500,
+                        fn: function (field, value) {
+                            let target = me.down('field[name=target]');
+                            target.setDisabled(!value);
+                            target.setValue('');
+                            target.setPortal(value);
+                        },
+                    },
+                },
+            },
+            {
+                xtype: 'pveIScsiScan',
+                name: 'target',
+                fieldLabel: gettext('Target'),
+                labelWidth,
+                disabled: true,
+                showNodeSelector: false,
+                nodename: Proxmox.NodeName,
+                listeners: { change: () => me.updateConnectionField() },
+                listConfig: {
+                    width: 650,
+                    emptyText: PVE.Utils.renderNotFound(gettext('iSCSI Target')),
+                    columns: [
+                        {
+                            text: gettext('Target'),
+                            dataIndex: 'target',
+                            flex: 1,
+                            renderer: Ext.htmlEncode,
+                        },
+                        {
+                            text: gettext('Portals'),
+                            dataIndex: 'portal',
+                            width: 220,
+                            renderer: Ext.htmlEncode,
+                        },
+                    ],
+                },
+            },
+            {
+                ...common.id,
+                name: 'connection',
+                fieldLabel: gettext('Connection Storage'),
+                labelWidth,
+            },
+            {
+                xtype: 'component',
+                margin: '0 0 10 0',
+                html: `<span class="pmx-hint">${Ext.htmlEncode(gettext('Note:'))}</span> ${Ext.htmlEncode(
+                    gettext(
+                        'Next creates or reuses the connection storage before you select a LUN.',
+                    ),
+                )}`,
+            },
+            { xtype: 'pveStorageWizardNodeIdentities' },
+        ];
+        me.advancedItems = [
+            { ...common.nodes, labelWidth, validator: PVE.storage.wizard.validateNodes },
+        ];
+        me.callParent();
+        me.on('afterrender', () =>
+            Proxmox.Utils.API2Request({
+                url: '/storage',
+                method: 'GET',
+                waitMsgTarget: me,
+                failure: function (response) {
+                    if (!me.destroyed) {
+                        me.up('window').showError(response.htmlStatus);
+                    }
+                },
+                success: function (response) {
+                    if (!me.destroyed) {
+                        me.storages = response.result.data;
+                        me.updateConnectionField();
+                    }
+                },
+            }),
+        );
+    },
+});
+
+PVE.storage.wizard.createIScsiLVM = function (wizard, values, lun) {
+    let connection = wizard.connection;
+    let fail = (response) => wizard.showError(response.htmlStatus);
+    Proxmox.Utils.API2Request({
+        url: `/nodes/${Proxmox.NodeName}/storage/${encodeURIComponent(connection.storage)}/content`,
+        method: 'GET',
+        params: { content: 'images' },
+        waitMsgTarget: wizard,
+        failure: fail,
+        success: function (response) {
+            if (wizard.destroyed) {
+                return;
+            }
+            let volume = response.result.data.find((entry) =>
+                entry.volid.endsWith(`.dm-uuid-mpath-${lun.wwid}`),
+            );
+            if (!volume) {
+                wizard.showError(
+                    gettext(
+                        'The selected LUN has no multipath volume yet. Check Node > SAN, then retry.',
+                    ),
+                );
+                return;
+            }
+            wizard.addLVMStorage({ ...values, base: volume.volid }, fail);
+        },
+    });
+};
diff --git a/www/manager6/storage/wizard/LunSelect.js b/www/manager6/storage/wizard/LunSelect.js
new file mode 100644
index 000000000..1156a4eee
--- /dev/null
+++ b/www/manager6/storage/wizard/LunSelect.js
@@ -0,0 +1,158 @@
+Ext.define('PVE.storage.wizard.LunSelect', {
+    extend: 'Ext.panel.Panel',
+    xtype: 'pveStorageWizardLunSelect',
+    layout: { type: 'vbox', align: 'stretch' },
+
+    // as an input panel does, so that the wizard shows its help button for this step
+    listeners: {
+        activate: function () {
+            Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp);
+        },
+        deactivate: function () {
+            Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp);
+        },
+    },
+
+    getSelection: function () {
+        return this.down('grid').getSelection()[0]?.data;
+    },
+
+    reload: function () {
+        let me = this;
+        let wizard = me.up('window');
+        let grid = me.down('grid');
+        me.rstore.stopUpdate();
+        me.store.setFilters([
+            { property: 'iscsi-target', value: wizard.connection.target, exactMatch: true },
+        ]);
+        Proxmox.Utils.API2Request({
+            url: `/nodes/${Proxmox.NodeName}/storage/${encodeURIComponent(wizard.connection.storage)}/content`,
+            method: 'GET',
+            waitMsgTarget: grid,
+            failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+            callback: function () {
+                if (!me.destroyed && wizard.down('#wizcontent').getActiveTab() === me) {
+                    me.rstore.startUpdate();
+                }
+            },
+        });
+    },
+
+    initComponent: function () {
+        let me = this;
+        me.rstore = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: 'san-wizard-luns',
+            model: 'pve-san-lun',
+            interval: 3000,
+            proxy: { type: 'proxmox', url: `/api2/json/nodes/${Proxmox.NodeName}/scan/san-luns` },
+        });
+        me.store = Ext.create('Proxmox.data.DiffStore', { rstore: me.rstore });
+        let updateSelection = function () {
+            let row = me.getSelection();
+            me.down('#selection').setValue(row && !row['used-by-storage'] ? row.wwid : '');
+        };
+        me.items = [
+            {
+                xtype: 'textfield',
+                itemId: 'selection',
+                hidden: true,
+                allowBlank: false,
+                submitValue: false,
+            },
+            {
+                xtype: 'component',
+                cls: 'pmx-hint',
+                margin: '0 0 10 0',
+                html: gettext(
+                    'A LUN used by a storage cannot be selected. A LUN with other data has to be wiped under Node > SAN first.',
+                ),
+            },
+            {
+                xtype: 'grid',
+                flex: 1,
+                store: me.store,
+                emptyText: gettext('No LUNs found. Check connections and array access.'),
+                viewConfig: {
+                    enableTextSelection: true,
+                    getRowClass: (rec) => (rec.get('used-by-storage') ? 'x-item-disabled' : ''),
+                },
+                listeners: {
+                    beforeselect: (sm, rec) => !rec.get('used-by-storage'),
+                    selectionchange: updateSelection,
+                },
+                columns: [
+                    {
+                        text: gettext('Name'),
+                        dataIndex: 'name',
+                        flex: 1,
+                        minWidth: 260,
+                        renderer: (value, md, rec) => Ext.htmlEncode(value || rec.get('wwid')),
+                    },
+                    { text: 'LUN', dataIndex: 'iscsi-lun', width: 60 },
+                    {
+                        text: gettext('Model'),
+                        dataIndex: 'model',
+                        width: 160,
+                        renderer: (value, md, rec) =>
+                            Ext.htmlEncode([rec.get('vendor'), value].filter(Boolean).join(' ')),
+                    },
+                    {
+                        text: gettext('State'),
+                        dataIndex: 'state',
+                        width: 110,
+                        renderer: (value, md, rec) =>
+                            PVE.SANUtils.renderState(
+                                PVE.SANUtils.lunState(value, rec.get('paths-total')),
+                            ),
+                    },
+                    {
+                        text: gettext('Multipath'),
+                        dataIndex: 'multipath',
+                        width: 170,
+                        renderer: PVE.SANUtils.renderSanLunMultipath,
+                    },
+                    {
+                        text: gettext('Used By'),
+                        dataIndex: 'usage',
+                        width: 130,
+                        renderer: PVE.SANUtils.renderSanLunUsage,
+                    },
+                    {
+                        text: gettext('Size'),
+                        dataIndex: 'size',
+                        width: 100,
+                        renderer: Proxmox.Utils.render_size,
+                    },
+                    {
+                        text: gettext('Device'),
+                        dataIndex: 'devpath',
+                        width: 180,
+                        hidden: true,
+                        renderer: Ext.htmlEncode,
+                    },
+                ],
+                tbar: [
+                    {
+                        text: gettext('Reload'),
+                        iconCls: 'fa fa-refresh',
+                        handler: () => me.reload(),
+                    },
+                    '->',
+                    {
+                        xtype: 'tbtext',
+                        html: Ext.htmlEncode(`${gettext('Scan node')}: ${Proxmox.NodeName}`),
+                    },
+                ],
+            },
+        ];
+        me.callParent();
+        Proxmox.Utils.monStoreErrors(me.down('grid'), me.rstore);
+        me.mon(me.rstore, 'load', updateSelection);
+        me.on('activate', () => me.reload());
+        me.on('deactivate', () => me.rstore.stopUpdate());
+        me.on('destroy', () => {
+            me.store.destroy();
+            me.rstore.destroy();
+        });
+    },
+});
diff --git a/www/manager6/storage/wizard/NodeIdentities.js b/www/manager6/storage/wizard/NodeIdentities.js
new file mode 100644
index 000000000..9c7ab8cce
--- /dev/null
+++ b/www/manager6/storage/wizard/NodeIdentities.js
@@ -0,0 +1,83 @@
+Ext.define('pve-san-node-identity', {
+    extend: 'Ext.data.Model',
+    idProperty: 'node',
+    fields: ['node', 'state', 'iscsi-initiator-name'],
+});
+
+Ext.define('PVE.storage.wizard.NodeIdentities', {
+    extend: 'Ext.grid.Panel',
+    xtype: 'pveStorageWizardNodeIdentities',
+    height: 220,
+    disableSelection: true,
+    viewConfig: { enableTextSelection: true },
+    columns: [
+        { text: gettext('Node'), dataIndex: 'node', width: 100, renderer: Ext.htmlEncode },
+        {
+            text: gettext('State'),
+            dataIndex: 'state',
+            width: 175,
+            renderer: PVE.SANUtils.renderState,
+        },
+        {
+            text: gettext('Initiator Name'),
+            dataIndex: 'iscsi-initiator-name',
+            flex: 1,
+            renderer: Ext.htmlEncode,
+        },
+    ],
+
+    initComponent: function () {
+        let me = this;
+        me.rstore = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: 'san-wizard-identities',
+            model: 'pve-san-node-identity',
+            interval: 5000,
+            proxy: {
+                type: 'proxmox',
+                url: '/api2/json/cluster/multipath/status',
+                reader: {
+                    type: 'json',
+                    rootProperty: 'data',
+                    transform: (raw) => ({
+                        ...raw,
+                        data: Object.entries(raw.data.nodes).map(([node, report]) => ({
+                            ...report,
+                            node,
+                        })),
+                    }),
+                },
+            },
+        });
+        me.store = Ext.create('Proxmox.data.DiffStore', {
+            rstore: me.rstore,
+            sorters: ['node'],
+            sortAfterUpdate: true,
+        });
+        me.tbar = [
+            {
+                xtype: 'tbtext',
+                text: gettext('Allow these initiator names on the target.'),
+            },
+            '->',
+            {
+                text: gettext('Copy Initiator Names'),
+                iconCls: 'fa fa-clipboard',
+                handler: () =>
+                    PVE.Utils.copyToClipboard(
+                        me.store
+                            .getRange()
+                            .map((rec) => rec.get('iscsi-initiator-name'))
+                            .filter(Boolean)
+                            .join('\n'),
+                    ),
+            },
+        ];
+        me.callParent();
+        Proxmox.Utils.monStoreErrors(me, me.rstore);
+        me.on('afterrender', () => me.rstore.startUpdate());
+        me.on('destroy', () => {
+            me.store.destroy();
+            me.rstore.destroy();
+        });
+    },
+});
diff --git a/www/manager6/storage/wizard/Wizard.js b/www/manager6/storage/wizard/Wizard.js
new file mode 100644
index 000000000..3062cfa99
--- /dev/null
+++ b/www/manager6/storage/wizard/Wizard.js
@@ -0,0 +1,180 @@
+Ext.ns('PVE.storage.wizard');
+
+PVE.storage.wizard.subject = (type) =>
+    Ext.String.format(gettext('LVM on {0}'), PVE.Utils.format_storage_type(type));
+
+PVE.storage.wizard.validateNodes = function () {
+    let nodes = [].concat(this.getValue() || []).filter(Boolean);
+    return (
+        !nodes.length ||
+        nodes.includes(Proxmox.NodeName) ||
+        Ext.String.format(
+            gettext('Must include node "{0}", which sets up the volume group.'),
+            Proxmox.NodeName,
+        )
+    );
+};
+
+Ext.define('PVE.storage.wizard.SAN', {
+    extend: 'PVE.window.Wizard',
+    width: 1050,
+    height: 620,
+
+    showError: function (message) {
+        if (this.destroyed) {
+            return;
+        }
+        this.down('#submit').enable();
+        Ext.Msg.alert(gettext('Error'), message);
+    },
+
+    volumeSettings: function () {
+        let me = this;
+        let value = (name) => me.down(`field[name=${name}]`).getValue();
+        return {
+            storage: value('storage'),
+            vgname: value('vgname'),
+            'snapshot-as-volume-chain': value('snapshot-as-volume-chain') ? 1 : 0,
+            nodes: me.connection.nodes,
+        };
+    },
+
+    // Adds the LVM storage with the volume settings as the last request of a setup. Only the node
+    // serving the web UI looked at the LUN, so show its state on the other nodes afterwards.
+    addLVMStorage: function (values, failure) {
+        let me = this;
+        let params = { type: 'lvm', shared: 1, content: 'images,rootdir', ...values };
+        if (!params.nodes) {
+            delete params.nodes;
+        }
+        Proxmox.Utils.API2Request({
+            url: '/storage',
+            method: 'POST',
+            params,
+            waitMsgTarget: me,
+            failure,
+            success: function () {
+                let wwid = me.down('#luns').getSelection().wwid;
+                me.close();
+                Ext.create('PVE.window.SANLunState', {
+                    wwid,
+                    storage: values.storage,
+                    autoShow: true,
+                });
+            },
+        });
+    },
+
+    multipathSummary: function (lun) {
+        // an explicit entry configures the map, also of a LUN of the connection storage
+        if (lun.multipath === 'manual') {
+            return PVE.SANUtils.multipathText('manual');
+        }
+        return PVE.SANUtils.multipathText('storage', this.connection.storage);
+    },
+
+    updateSummary: function () {
+        let me = this;
+        let values = me.volumeSettings();
+        let lun = me.down('#luns').getSelection();
+        let rows = [
+            [gettext('Connection Storage'), me.connection.storage],
+            [gettext('Storage ID'), values.storage],
+            [gettext('Volume Group'), values.vgname],
+            ['WWID', lun.wwid],
+            [gettext('Multipath'), me.multipathSummary(lun)],
+            [gettext('Size'), Proxmox.Utils.format_size(lun.size)],
+            [gettext('Nodes'), values.nodes || gettext('All (No restrictions)')],
+            [
+                gettext('Allow Snapshots as Volume-Chain'),
+                Proxmox.Utils.format_boolean(values['snapshot-as-volume-chain']),
+            ],
+        ];
+        me.down('#summary')
+            .getStore()
+            .setData(rows.map(([key, value]) => ({ key, value })));
+    },
+
+    finish: function () {
+        let me = this;
+        let values = me.volumeSettings();
+        let lun = me.down('#luns').getSelection();
+        me.down('#submit').disable();
+        PVE.storage.wizard.createIScsiLVM(me, values, lun);
+    },
+
+    initComponent: function () {
+        let me = this;
+        me.subject = PVE.storage.wizard.subject(me.wizardType);
+        me.title = Proxmox.Utils.dialog_title(me.subject, true, true);
+        let common = PVE.panel.StorageBase.commonFields(true);
+        let snapshots = PVE.panel.StorageBase.volumeChainFields(true, 'lvm');
+        let settings = {
+            xtype: 'inputpanel',
+            title: gettext('Volume Group'),
+            onlineHelp: 'storage_multipath',
+            items: [
+                { ...common.id, fieldLabel: gettext('Storage ID') },
+                {
+                    xtype: 'textfield',
+                    name: 'vgname',
+                    fieldLabel: gettext('Volume Group'),
+                    allowBlank: false,
+                    vtype: 'StorageId',
+                },
+                snapshots.checkbox,
+                snapshots.hint,
+            ],
+        };
+        me.items = [
+            { xtype: 'pveStorageWizardIScsiTarget', title: gettext('Target'), itemId: 'target' },
+            {
+                xtype: 'pveStorageWizardLunSelect',
+                title: 'LUN',
+                itemId: 'luns',
+                onlineHelp: 'storage_multipath',
+            },
+            settings,
+            {
+                title: gettext('Confirm'),
+                layout: 'fit',
+                items: [
+                    {
+                        xtype: 'grid',
+                        itemId: 'summary',
+                        store: { fields: ['key', 'value'] },
+                        columns: [
+                            {
+                                text: gettext('Setting'),
+                                dataIndex: 'key',
+                                width: 280,
+                                renderer: Ext.htmlEncode,
+                            },
+                            {
+                                text: gettext('Value'),
+                                dataIndex: 'value',
+                                flex: 1,
+                                cellWrap: true,
+                                renderer: Ext.htmlEncode,
+                            },
+                        ],
+                    },
+                ],
+                listeners: { activate: () => me.updateSummary() },
+                onSubmit: () => me.finish(),
+            },
+        ];
+        me.callParent();
+        let tabs = me.down('#wizcontent');
+        tabs.on('tabchange', function (tp, tab) {
+            if (tab === me.down('#luns')) {
+                me.down('#back').disable();
+            }
+            me.down('#submit').setText(
+                tab === me.down('#target') ? gettext('Next') : gettext('Finish'),
+            );
+        });
+        me.down('#submit').setText(gettext('Next'));
+        me.on('destroy', () => me.reloadCallback?.());
+    },
+});
diff --git a/www/manager6/window/SANLunState.js b/www/manager6/window/SANLunState.js
new file mode 100644
index 000000000..154836f3b
--- /dev/null
+++ b/www/manager6/window/SANLunState.js
@@ -0,0 +1,111 @@
+Ext.define('pve-san-lun-node', {
+    extend: 'Ext.data.Model',
+    idProperty: 'node',
+    fields: ['node', 'state', 'paths-active', 'paths-total', 'paths-expected'],
+});
+
+// Shows the state of the LUN of a new storage on each of its nodes, from the cluster-wide status.
+Ext.define('PVE.window.SANLunState', {
+    extend: 'Ext.window.Window',
+
+    modal: true,
+    width: 550,
+    height: 400,
+    layout: { type: 'vbox', align: 'stretch' },
+    bodyPadding: 10,
+
+    initComponent: function () {
+        let me = this;
+        if (!me.wwid || !me.storage) {
+            throw 'no LUN or storage specified';
+        }
+        me.title = Ext.String.format(gettext('Storage {0}: LUN State'), me.storage);
+        // The other nodes set up a new LUN with their next status updates.
+        let pendingUntil = Date.now() + 60000;
+        let rstore = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: 'san-lun-state',
+            model: 'pve-san-lun-node',
+            interval: 3000,
+            proxy: {
+                type: 'proxmox',
+                url: '/api2/json/cluster/multipath/status',
+                reader: {
+                    type: 'json',
+                    rootProperty: 'data',
+                    transform: function (raw) {
+                        let lun = raw.data?.luns?.find((entry) => entry.wwid === me.wwid);
+                        let nodes = Object.entries(lun?.nodes ?? {});
+                        return { ...raw, data: nodes.map(([node, state]) => ({ ...state, node })) };
+                    },
+                },
+            },
+        });
+        let store = Ext.create('Proxmox.data.DiffStore', {
+            rstore,
+            sorters: ['node'],
+            sortAfterUpdate: true,
+        });
+        me.items = [
+            {
+                xtype: 'component',
+                margin: '0 0 10 0',
+                html: Ext.htmlEncode(
+                    Ext.String.format(
+                        gettext(
+                            'Storage "{0}" was added. Guests on this storage cannot run on a node that stays on "Missing": check its access to the LUN on the array.',
+                        ),
+                        me.storage,
+                    ),
+                ),
+            },
+            {
+                xtype: 'grid',
+                flex: 1,
+                store,
+                disableSelection: true,
+                emptyText: gettext('No node reported this LUN yet.'),
+                columns: [
+                    {
+                        text: gettext('Node'),
+                        dataIndex: 'node',
+                        flex: 1,
+                        renderer: Ext.htmlEncode,
+                    },
+                    {
+                        text: gettext('State'),
+                        dataIndex: 'state',
+                        flex: 1,
+                        renderer: function (value, metaData, rec) {
+                            if (value === 'missing' && Date.now() < pendingUntil) {
+                                let tip = gettext(
+                                    'Not reported by the node yet; the SAN view shows that as "Missing".',
+                                );
+                                metaData.tdAttr = `data-qtip="${Ext.htmlEncode(Ext.htmlEncode(tip))}"`;
+                                return `<i class="fa fa-fw fa-spinner fa-pulse"></i> ${Ext.htmlEncode(gettext('Pending'))}`;
+                            }
+                            return PVE.SANUtils.renderState(
+                                PVE.SANUtils.lunState(value, rec.get('paths-total')),
+                            );
+                        },
+                    },
+                    {
+                        text: gettext('Active Paths'),
+                        dataIndex: 'paths-active',
+                        width: 120,
+                        renderer: (value, metaData, rec) =>
+                            value === undefined
+                                ? ''
+                                : Ext.htmlEncode(PVE.SANUtils.pathCount(rec.data)),
+                    },
+                ],
+            },
+        ];
+        me.callParent();
+        Proxmox.Utils.monStoreErrors(me.down('grid'), rstore);
+        me.on('destroy', function () {
+            store.destroy();
+            rstore.destroy();
+        });
+        rstore.startUpdate();
+    },
+});




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 35/36] ui: dc: san: add a guided setup for shared LVM on Fibre Channel
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (33 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 34/36] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-13  3:00 ` [PATCH v4 manager 36/36] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
  2026-11-16  1:28 ` superseded: [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Fibre Channel LUNs show up as block devices on the nodes, without a
storage that connects to them, so Datacenter > Storage > Add has no
dialog to start from. Add a Fibre Channel entry to the guided setup of
the SAN view: select the LUN, name the volume group and storage,
confirm.

The setup enables multipath for the LUN if needed and waits for its map,
then creates the volume group through the node serving the web UI and
adds the shared LVM storage. It adds the storage itself instead of
letting the node disk API do so, as that would add it for all nodes and
without the snapshot setting, to be changed afterwards.

A Fibre Channel LUN has no storage that knows how many paths a node
should have. So an entry the setup adds expects as many paths as the map
has on that node, and a node zoned to fewer fabrics or one that lost a
path shows the LUN as degraded.

A LUN with a volume group cannot be selected again, so the setup
checks that the storage ID is free before it changes anything.

Nodes do not scan for a LUN that is mapped to them after their login
to the array, so the LUN step names the rescan of the Fibre Channel
hosts, which the documentation describes, and so does the closing
window for a node that stays missing.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/Makefile                       |   1 +
 www/manager6/dc/SAN.js                      |   5 +-
 www/manager6/storage/wizard/FibreChannel.js | 162 ++++++++++++++++++++
 www/manager6/storage/wizard/LunSelect.js    |  25 ++-
 www/manager6/storage/wizard/Wizard.js       |  90 ++++++++++-
 www/manager6/window/SANLunState.js          |  10 +-
 6 files changed, 279 insertions(+), 14 deletions(-)
 create mode 100644 www/manager6/storage/wizard/FibreChannel.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index c7cefeacc..ebdc3f802 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -389,6 +389,7 @@ JSSRC= 							\
 	storage/wizard/LunSelect.js			\
 	storage/wizard/NodeIdentities.js		\
 	storage/wizard/IScsi.js				\
+	storage/wizard/FibreChannel.js			\
 	Workspace.js					\
 # end of JSSRC list
 
diff --git a/www/manager6/dc/SAN.js b/www/manager6/dc/SAN.js
index fa60a1e6f..6b32926c7 100644
--- a/www/manager6/dc/SAN.js
+++ b/www/manager6/dc/SAN.js
@@ -105,9 +105,10 @@ Ext.define('PVE.dc.SANView', {
                 autoShow: true,
                 apiCallDone: (success) => success && reload(),
             });
-        let setupItem = (wizardType) => ({
+        let setupItem = (wizardType, disabled) => ({
             text: PVE.storage.wizard.subject(wizardType),
             iconCls: 'fa fa-fw fa-building',
+            disabled,
             handler: () =>
                 Ext.create('PVE.storage.wizard.SAN', {
                     wizardType,
@@ -119,7 +120,7 @@ Ext.define('PVE.dc.SANView', {
             {
                 text: gettext('Add Storage'),
                 disabled: !allCaps.storage['Datastore.Allocate'],
-                menu: [setupItem('iscsi')],
+                menu: [setupItem('iscsi'), setupItem('fc', !canModify)],
             },
         ];
         me.items = [
diff --git a/www/manager6/storage/wizard/FibreChannel.js b/www/manager6/storage/wizard/FibreChannel.js
new file mode 100644
index 000000000..950add8e5
--- /dev/null
+++ b/www/manager6/storage/wizard/FibreChannel.js
@@ -0,0 +1,162 @@
+PVE.storage.wizard.createFC = function (wizard, values, lun) {
+    let fail = (response) => wizard.showError(response.htmlStatus);
+    let create = function (row) {
+        if (wizard.destroyed) {
+            return;
+        }
+        Proxmox.Utils.API2Request({
+            url: `/nodes/${Proxmox.NodeName}/disks/lvm`,
+            method: 'POST',
+            params: { name: values.vgname, device: row['by-id'] || row.devpath },
+            waitMsgTarget: wizard,
+            failure: fail,
+            success: function (response) {
+                if (wizard.destroyed) {
+                    return;
+                }
+                wizard.waitForTask(response.result.data, () =>
+                    wizard.addLVMStorage(values, (res) =>
+                        wizard.stopWithError(
+                            res.htmlStatus +
+                                '<br>' +
+                                gettext(
+                                    'The volume group was created, but adding the storage failed. Add it under Datacenter > Storage > Add > LVM with Shared enabled.',
+                                ),
+                        ),
+                    ),
+                );
+            },
+        });
+    };
+    let hasMultipath = (row) =>
+        ['manual', 'storage', 'unmanaged', 'native'].includes(row.multipath);
+    // Fibre Channel has no storage that knows how many paths a node should have, so an entry the
+    // setup adds expects the paths of this node. A node with fewer paths then shows as degraded.
+    // The wizard remembers the entry it added, so that a retry completes the count first.
+    let expectPaths = function (row) {
+        if (!(row['paths-total'] >= 2)) {
+            delete wizard.addedEntry;
+            create(row);
+            return;
+        }
+        Proxmox.Utils.API2Request({
+            url: `/cluster/multipath/wwid/${encodeURIComponent(lun.wwid)}`,
+            method: 'PUT',
+            params: { 'paths-expected': row['paths-total'] },
+            waitMsgTarget: wizard,
+            failure: fail,
+            success: () => {
+                delete wizard.addedEntry;
+                create(row);
+            },
+        });
+    };
+    let waitForMap = function () {
+        if (wizard.destroyed) {
+            return;
+        }
+        let store = Ext.create('Proxmox.data.UpdateStore', {
+            storeid: 'san-wizard-map',
+            model: 'pve-san-lun',
+            interval: 3000,
+            proxy: { type: 'proxmox', url: `/api2/json/nodes/${Proxmox.NodeName}/scan/san-luns` },
+        });
+        let timer = Ext.defer(function () {
+            store.destroy();
+            if (!wizard.destroyed) {
+                wizard.setLoading(false);
+                wizard.showError(
+                    gettext(
+                        'The multipath map did not appear within 90 seconds. Check Node > SAN, then reload the LUN list.',
+                    ),
+                );
+            }
+        }, 90000);
+        wizard.on(
+            'destroy',
+            () => {
+                clearTimeout(timer);
+                if (!store.destroyed) {
+                    store.destroy();
+                }
+            },
+            null,
+            { single: true },
+        );
+        wizard.setLoading(gettext('Waiting for the multipath map...'));
+        store.on('load', function (s, records, success, operation) {
+            if (wizard.destroyed) {
+                return;
+            }
+            let row = records?.find((rec) => rec.get('wwid') === lun.wwid)?.data;
+            if (!success || (row && hasMultipath(row))) {
+                clearTimeout(timer);
+                store.destroy();
+                wizard.setLoading(false);
+                if (success) {
+                    wizard.down('#luns').down('grid').getSelection()[0].set(row);
+                    if (wizard.addedEntry === lun.wwid) {
+                        expectPaths(row);
+                    } else {
+                        create(row);
+                    }
+                } else {
+                    wizard.showError(Proxmox.Utils.getResponseErrorMessage(operation.getError()));
+                }
+            }
+        });
+        store.startUpdate();
+    };
+    let setup = function () {
+        if (hasMultipath(lun)) {
+            if (wizard.addedEntry === lun.wwid) {
+                expectPaths(lun);
+            } else {
+                create(lun);
+            }
+        } else if (lun.multipath === 'pending' || wizard.addedEntry === lun.wwid) {
+            waitForMap();
+        } else {
+            let params = { wwid: lun.wwid };
+            if (values.nodes) {
+                params.nodes = values.nodes;
+            }
+            Proxmox.Utils.API2Request({
+                url: '/cluster/multipath/wwid',
+                method: 'POST',
+                params,
+                waitMsgTarget: wizard,
+                failure: fail,
+                success: () => {
+                    wizard.addedEntry = lun.wwid;
+                    waitForMap();
+                },
+            });
+        }
+    };
+    // The storage is added last. Its ID has to be free before anything is created, as the LUN
+    // cannot be selected again once it has a volume group.
+    Proxmox.Utils.API2Request({
+        url: '/storage',
+        method: 'GET',
+        waitMsgTarget: wizard,
+        failure: fail,
+        success: function (response) {
+            if (wizard.destroyed) {
+                return;
+            }
+            if (response.result.data.some((entry) => entry.storage === values.storage)) {
+                wizard.showError(
+                    Ext.htmlEncode(
+                        Ext.String.format(
+                            gettext('Storage ID "{0}" is already in use. Choose another ID.'),
+                            values.storage,
+                        ),
+                    ),
+                );
+                return;
+            }
+            setup();
+        },
+    });
+};
diff --git a/www/manager6/storage/wizard/LunSelect.js b/www/manager6/storage/wizard/LunSelect.js
index 1156a4eee..a34b95d29 100644
--- a/www/manager6/storage/wizard/LunSelect.js
+++ b/www/manager6/storage/wizard/LunSelect.js
@@ -22,6 +22,10 @@ Ext.define('PVE.storage.wizard.LunSelect', {
         let wizard = me.up('window');
         let grid = me.down('grid');
         me.rstore.stopUpdate();
+        if (!wizard.connection) {
+            me.rstore.startUpdate();
+            return;
+        }
         me.store.setFilters([
             { property: 'iscsi-target', value: wizard.connection.target, exactMatch: true },
         ]);
@@ -67,6 +71,15 @@ Ext.define('PVE.storage.wizard.LunSelect', {
                     'A LUN used by a storage cannot be selected. A LUN with other data has to be wiped under Node > SAN first.',
                 ),
             },
+            ...(me.rescanNote
+                ? [
+                      {
+                          xtype: 'component',
+                          margin: '0 0 10 0',
+                          html: `<span class="pmx-hint">${Ext.htmlEncode(gettext('Note:'))}</span> ${me.rescanNote}`,
+                      },
+                  ]
+                : []),
             {
                 xtype: 'grid',
                 flex: 1,
@@ -148,7 +161,17 @@ Ext.define('PVE.storage.wizard.LunSelect', {
         me.callParent();
         Proxmox.Utils.monStoreErrors(me.down('grid'), me.rstore);
         me.mon(me.rstore, 'load', updateSelection);
-        me.on('activate', () => me.reload());
+        me.on('activate', function () {
+            if (me.up('window').wizardType === 'fc') {
+                me.down('gridcolumn[dataIndex=iscsi-lun]').hide();
+                me.store.setFilters([
+                    {
+                        filterFn: (rec) => ['fc', 'fcoe', 'nvme-fc'].includes(rec.get('transport')),
+                    },
+                ]);
+            }
+            me.reload();
+        });
         me.on('deactivate', () => me.rstore.stopUpdate());
         me.on('destroy', () => {
             me.store.destroy();
diff --git a/www/manager6/storage/wizard/Wizard.js b/www/manager6/storage/wizard/Wizard.js
index 3062cfa99..9d4e6a256 100644
--- a/www/manager6/storage/wizard/Wizard.js
+++ b/www/manager6/storage/wizard/Wizard.js
@@ -1,7 +1,10 @@
 Ext.ns('PVE.storage.wizard');
 
 PVE.storage.wizard.subject = (type) =>
-    Ext.String.format(gettext('LVM on {0}'), PVE.Utils.format_storage_type(type));
+    Ext.String.format(
+        gettext('LVM on {0}'),
+        type === 'fc' ? gettext('Fibre Channel') : PVE.Utils.format_storage_type(type),
+    );
 
 PVE.storage.wizard.validateNodes = function () {
     let nodes = [].concat(this.getValue() || []).filter(Boolean);
@@ -20,6 +23,11 @@ Ext.define('PVE.storage.wizard.SAN', {
     width: 1050,
     height: 620,
 
+    stopWithError: function (message) {
+        this.close();
+        Ext.Msg.alert(gettext('Error'), message);
+    },
+
     showError: function (message) {
         if (this.destroyed) {
             return;
@@ -28,6 +36,24 @@ Ext.define('PVE.storage.wizard.SAN', {
         Ext.Msg.alert(gettext('Error'), message);
     },
 
+    waitForTask: function (upid, next) {
+        let me = this;
+        Ext.create('Proxmox.window.TaskProgress', {
+            upid,
+            autoShow: true,
+            taskDone: function (success) {
+                if (me.destroyed) {
+                    return;
+                }
+                if (success) {
+                    next();
+                } else {
+                    me.down('#submit').enable();
+                }
+            },
+        });
+    },
+
     volumeSettings: function () {
         let me = this;
         let value = (name) => me.down(`field[name=${name}]`).getValue();
@@ -35,7 +61,13 @@ Ext.define('PVE.storage.wizard.SAN', {
             storage: value('storage'),
             vgname: value('vgname'),
             'snapshot-as-volume-chain': value('snapshot-as-volume-chain') ? 1 : 0,
-            nodes: me.connection.nodes,
+            nodes:
+                me.wizardType === 'fc'
+                    ? []
+                          .concat(value('nodes') || [])
+                          .filter(Boolean)
+                          .join(',')
+                    : me.connection.nodes,
         };
     },
 
@@ -59,6 +91,7 @@ Ext.define('PVE.storage.wizard.SAN', {
                 Ext.create('PVE.window.SANLunState', {
                     wwid,
                     storage: values.storage,
+                    fc: me.wizardType === 'fc',
                     autoShow: true,
                 });
             },
@@ -66,11 +99,18 @@ Ext.define('PVE.storage.wizard.SAN', {
     },
 
     multipathSummary: function (lun) {
+        let me = this;
         // an explicit entry configures the map, also of a LUN of the connection storage
         if (lun.multipath === 'manual') {
             return PVE.SANUtils.multipathText('manual');
         }
-        return PVE.SANUtils.multipathText('storage', this.connection.storage);
+        if (me.connection) {
+            return PVE.SANUtils.multipathText('storage', me.connection.storage);
+        }
+        // the Fibre Channel setup adds an entry for a LUN without multipath
+        return lun.multipath === 'none'
+            ? gettext('Explicit entry, added by this setup')
+            : PVE.SANUtils.multipathText(lun.multipath, lun['multipath-storage']);
     },
 
     updateSummary: function () {
@@ -78,7 +118,6 @@ Ext.define('PVE.storage.wizard.SAN', {
         let values = me.volumeSettings();
         let lun = me.down('#luns').getSelection();
         let rows = [
-            [gettext('Connection Storage'), me.connection.storage],
             [gettext('Storage ID'), values.storage],
             [gettext('Volume Group'), values.vgname],
             ['WWID', lun.wwid],
@@ -90,6 +129,9 @@ Ext.define('PVE.storage.wizard.SAN', {
                 Proxmox.Utils.format_boolean(values['snapshot-as-volume-chain']),
             ],
         ];
+        if (me.connection) {
+            rows.unshift([gettext('Connection Storage'), me.connection.storage]);
+        }
         me.down('#summary')
             .getStore()
             .setData(rows.map(([key, value]) => ({ key, value })));
@@ -100,11 +142,19 @@ Ext.define('PVE.storage.wizard.SAN', {
         let values = me.volumeSettings();
         let lun = me.down('#luns').getSelection();
         me.down('#submit').disable();
-        PVE.storage.wizard.createIScsiLVM(me, values, lun);
+        if (me.wizardType === 'fc') {
+            PVE.storage.wizard.createFC(me, values, lun);
+        } else {
+            PVE.storage.wizard.createIScsiLVM(me, values, lun);
+        }
     },
 
     initComponent: function () {
         let me = this;
+        if (!['iscsi', 'fc'].includes(me.wizardType)) {
+            throw 'no SAN storage type specified';
+        }
+        let iscsi = me.wizardType === 'iscsi';
         me.subject = PVE.storage.wizard.subject(me.wizardType);
         me.title = Proxmox.Utils.dialog_title(me.subject, true, true);
         let common = PVE.panel.StorageBase.commonFields(true);
@@ -126,13 +176,35 @@ Ext.define('PVE.storage.wizard.SAN', {
                 snapshots.hint,
             ],
         };
+        if (!iscsi) {
+            settings.advancedItems = [
+                { ...common.nodes, validator: PVE.storage.wizard.validateNodes },
+            ];
+        }
         me.items = [
-            { xtype: 'pveStorageWizardIScsiTarget', title: gettext('Target'), itemId: 'target' },
+            ...(iscsi
+                ? [
+                      {
+                          xtype: 'pveStorageWizardIScsiTarget',
+                          title: gettext('Target'),
+                          itemId: 'target',
+                      },
+                  ]
+                : []),
             {
                 xtype: 'pveStorageWizardLunSelect',
                 title: 'LUN',
                 itemId: 'luns',
                 onlineHelp: 'storage_multipath',
+                // the nodes only see a newly mapped Fibre Channel LUN after a rescan
+                rescanNote: iscsi
+                    ? undefined
+                    : Ext.String.format(
+                          gettext(
+                              'After mapping a new LUN on the array, rescan the Fibre Channel hosts of each node (<a href="{0}" target="_blank" rel="noopener noreferrer">documentation</a>).',
+                          ),
+                          Ext.htmlEncode(Proxmox.Utils.get_help_link('storage_multipath')),
+                      ),
             },
             settings,
             {
@@ -167,14 +239,16 @@ Ext.define('PVE.storage.wizard.SAN', {
         me.callParent();
         let tabs = me.down('#wizcontent');
         tabs.on('tabchange', function (tp, tab) {
-            if (tab === me.down('#luns')) {
+            if (iscsi && tab === me.down('#luns')) {
                 me.down('#back').disable();
             }
             me.down('#submit').setText(
                 tab === me.down('#target') ? gettext('Next') : gettext('Finish'),
             );
         });
-        me.down('#submit').setText(gettext('Next'));
+        if (iscsi) {
+            me.down('#submit').setText(gettext('Next'));
+        }
         me.on('destroy', () => me.reloadCallback?.());
     },
 });
diff --git a/www/manager6/window/SANLunState.js b/www/manager6/window/SANLunState.js
index 154836f3b..a0a6d514d 100644
--- a/www/manager6/window/SANLunState.js
+++ b/www/manager6/window/SANLunState.js
@@ -51,9 +51,13 @@ Ext.define('PVE.window.SANLunState', {
                 margin: '0 0 10 0',
                 html: Ext.htmlEncode(
                     Ext.String.format(
-                        gettext(
-                            'Storage "{0}" was added. Guests on this storage cannot run on a node that stays on "Missing": check its access to the LUN on the array.',
-                        ),
+                        me.fc
+                            ? gettext(
+                                  'Storage "{0}" was added. Guests on this storage cannot run on a node that stays on "Missing": check its access to the LUN on the array and rescan its Fibre Channel hosts.',
+                              )
+                            : gettext(
+                                  'Storage "{0}" was added. Guests on this storage cannot run on a node that stays on "Missing": check its access to the LUN on the array.',
+                              ),
                         me.storage,
                     ),
                 ),




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 manager 36/36] ui: storage: point the iSCSI and LVM add dialogs to the SAN view
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (34 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 35/36] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
@ 2026-11-13  3:00 ` Thomas Lamprecht
  2026-11-16  1:28 ` superseded: [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-13  3:00 UTC (permalink / raw)
  To: pve-devel

Admins new to Proxmox VE look for adding their SAN under Datacenter >
Storage > Add. There, the iSCSI dialog connects a target without a
volume group on top and, by default, without multipath, so they end up
with neither a storage that can allocate guest disks nor path
redundancy. The guided setups that do both are in the SAN view, which
nothing in these dialogs mentions.

Add a note to the add dialogs of iSCSI and LVM that names the SAN view.
Its link closes the dialog and opens the view. The dialogs stay as they
are for attaching existing targets and volume groups. The storage panel
base shows the note for panels that set one, so the NVMe over Fabrics
dialog can use it as well.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/SANUtils.js          | 38 +++++++++++++++++++++++++++++++
 www/manager6/storage/Base.js      |  5 ++++
 www/manager6/storage/IScsiEdit.js |  3 +++
 www/manager6/storage/LVMEdit.js   |  3 +++
 4 files changed, 49 insertions(+)

diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
index 8947d83e5..c08ac2a1a 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -103,6 +103,44 @@ Ext.define('PVE.SANUtils', {
         return Ext.htmlEncode(PVE.SANUtils.usageText(rec.data));
     },
 
+    // Selects Datacenter > Storage > SAN, as the TFA entry of the user menu does for its panel.
+    showSANView: function () {
+        Ext.state.Manager.getProvider().set('dctab', { value: 'san' }, true);
+        Ext.ComponentQuery.query('pveStdWorkspace')[0]?.selectById('root');
+    },
+
+    // A note for the add dialogs of storages on a SAN, which points to the guided setups of the
+    // SAN view. Its link closes the dialog and opens the view.
+    sanViewNote: function (text) {
+        let path = `${gettext('Datacenter')} > ${gettext('Storage')} > SAN`;
+        let link = `<a href="#" style="white-space: nowrap;">${Ext.htmlEncode(path)}</a>`;
+        return {
+            xtype: 'component',
+            margin: '5 0 0 0',
+            html:
+                `<span class="pmx-hint">${Ext.htmlEncode(gettext('Note:'))}</span> ` +
+                Ext.String.format(Ext.htmlEncode(text), link),
+            listeners: {
+                afterrender: function (cmp) {
+                    let follow = function (event) {
+                        event.stopEvent();
+                        cmp.up('window')?.close();
+                        PVE.SANUtils.showSANView();
+                    };
+                    cmp.mon(cmp.getEl(), 'click', follow, null, { delegate: 'a' });
+                    // an edit window handles Enter for its default button, so no click follows it
+                    cmp.mon(
+                        cmp.getEl(),
+                        'keydown',
+                        (event) => event.getKey() === event.ENTER && follow(event),
+                        null,
+                        { delegate: 'a' },
+                    );
+                },
+            },
+        };
+    },
+
     renderSanTransport: function (value) {
         return Ext.htmlEncode(
             {
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 04f5f706f..58e77c05c 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -131,6 +131,11 @@ Ext.define('PVE.panel.StorageBase', {
             me.advancedColumnB.unshift(volumeChain.hint);
         }
 
+        // the add dialog of a SAN storage points to the guided setups of the SAN view
+        if (me.isCreate && me.sanNote) {
+            me.columnB = [...(me.columnB ?? []), PVE.SANUtils.sanViewNote(me.sanNote)];
+        }
+
         me.callParent();
     },
 });
diff --git a/www/manager6/storage/IScsiEdit.js b/www/manager6/storage/IScsiEdit.js
index 0725edad0..f11995585 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -75,6 +75,9 @@ Ext.define('PVE.storage.IScsiInputPanel', {
 
     onlineHelp: 'storage_open_iscsi',
 
+    // TRANSLATORS: "Add Storage" is a button of the SAN view, {0} the menu path of that view.
+    sanNote: gettext('To set up shared LVM with multipath on a LUN, use Add Storage in {0}.'),
+
     // Loading sets the value before its original value, so use the dirty state.
     updateMultipathActivation: function () {
         let me = this;
diff --git a/www/manager6/storage/LVMEdit.js b/www/manager6/storage/LVMEdit.js
index 0c56455df..9c4df2609 100644
--- a/www/manager6/storage/LVMEdit.js
+++ b/www/manager6/storage/LVMEdit.js
@@ -148,6 +148,9 @@ Ext.define('PVE.storage.LVMInputPanel', {
 
     onlineHelp: 'storage_lvm',
 
+    // TRANSLATORS: "Add Storage" is a button of the SAN view, {0} the menu path of that view.
+    sanNote: gettext('To set up shared LVM on a SAN LUN, use Add Storage in {0}.'),
+
     column1: [
         {
             xtype: 'pveBaseStorageSelector',




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* superseded: [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM
  2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (35 preceding siblings ...)
  2026-11-13  3:00 ` [PATCH v4 manager 36/36] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
@ 2026-11-16  1:28 ` Thomas Lamprecht
  36 siblings, 0 replies; 38+ messages in thread
From: Thomas Lamprecht @ 2026-11-16  1:28 UTC (permalink / raw)
  To: pve-devel

superseded-by: https://lore.proxmox.com/pve-devel/20261116012355.3187417-1-t.lamprecht@proxmox.com/




^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2026-11-16  1:30 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  3:00 [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 cluster 01/36] cfs: observe the multipath configuration files Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 02/36] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 03/36] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 04/36] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 05/36] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 06/36] iscsi: factor out session device map from device list Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 07/36] multipath: add a library around multipathd Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 08/36] diskmanage: add helper to list multipath devices Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 09/36] multipath: add a cluster-wide configuration Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 10/36] iscsi: add an option to manage storage LUNs with multipath Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 11/36] lvm: activate a missing base volume before using the volume group Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 12/36] multipath: apply the configuration on every node Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 13/36] multipath: publish per-node status Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 14/36] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 15/36] api: multipath: add the cluster-wide health status Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 16/36] api: scan: add a SAN LUN inventory Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 17/36] pvesm: expose the " Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 18/36] api: add node-level iSCSI status Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 19/36] disks: lvm: drop unused imports Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 20/36] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 21/36] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 storage 22/36] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 docs 23/36] storage: document the cluster-wide multipath management Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 24/36] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 25/36] report: add the managed multipath configuration Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 26/36] api: cluster: add the multipath endpoints Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 27/36] api: nodes: expose the iSCSI status Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 28/36] ui: dc: add a SAN view Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 29/36] ui: storage: iscsi: add the multipath option Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 30/36] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 31/36] ui: node: add SAN LUNs panel Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 32/36] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 33/36] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 34/36] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 35/36] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
2026-11-13  3:00 ` [PATCH v4 manager 36/36] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
2026-11-16  1:28 ` superseded: [PATCH v4 cluster,storage,docs,manager 00/36] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht

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