public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM
@ 2026-11-18  6:52 Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 cluster 01/42] cfs: observe the multipath configuration files Thomas Lamprecht
                   ` (42 more replies)
  0 siblings, 43 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

This is v6 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].

v6 is v5 [3] rebased onto current master, where plugin API 17 with the
volume types, the plugin metadata for the web UI and the property
isolation for plugins landed underneath, plus what an independent review
of v5 turned up:

 - The status update no longer waits for the missing map of an LVM base
   volume, nor asks a hanging multipathd for its paths. With three such
   storages a pass took 32 seconds instead of 1.2 in my lab. Activating
   a volume for a guest still waits.
 - An existing volume group on a partition of a multipath map can be
   added again, also with the Multipath option of the iSCSI storage.
 - The node disk API only creates the storage of a volume group on a
   LUN; v5 could join a storage added meanwhile with another volume
   group.
 - The Fibre Channel setup waits for the volume group task itself and
   cannot be closed meanwhile. Closing the task window ended it with a
   volume group and no storage.
 - The setup menu also needs Datastore.Audit or Datastore.AllocateSpace.
 - The first status pass removed a drop-in with one of the generated
   names under /etc/multipath/conf.d, also one that Proxmox VE had not
   written. Such a file now stays, and the node reports an error while
   it needs that name.
 - The volume group creation and the wipe also refuse a LUN that is in
   use through another of its SCSI paths, for example by a guest started
   before the map existed. A name in the request has to lead to the same
   device after the LUN lookup still.
 - A node only reported the first of the storages that request a map.
 - Node > Disks > LVM creates a shared storage on a SAN LUN, on a single
   path for a Fibre Channel LUN without a map. Its dialog now points to
   the guided setup.
 - Enable Multipath under Node > SAN opens the entry dialog, where the
   admin sees and chooses the nodes, instead of adding an entry for all.
 - Smaller ones: partition bases and LUNs reached through two targets
   are attributed to their storage, Node > SAN shows the path counts of
   a degraded LUN, and the SAN view names the nodes in Unknown.
 - let the disk wipe take by-id, dm-N and mapper names for any device,
   so it also wiped a logical volume with a guest disk by such a name.
   These names are now accepted for a LUN only.

BlockBridge was very reactive here and tested v5 with 1000 LUNs or
namespaces on a node, one per guest disk. For them LUN inventory took
over ten seconds. New patches 16 and 17 look the disks up by name and
read the udev data with one call, which brought it to under a second for
1000 NVMe/TCP namespaces in my lab. The test also showed the disks of
running guests as unused, as no storage references them. New patches 25,
27, 41 and 42 show the guest or process that has a LUN open for writing,
and a hidden column for the iSCSI target, which names the volume for a
plugin with one target per volume. They come last in their repositories,
so that they can be left out; the NVMe over Fabrics series then applies
up to its last manager patch. A LUN that stays attached with nothing
holding it, for example after a failed detach, still shows as unused:
telling whose it is needs the plugin, and I left that for later.

What I left as is for now: lsblk for the usage of a LUN, as it opens no
device without a udev entry (measured again); 'auto_resize grow_only'
for all maps of a node, as multipath has no other form of it, documented
with how to turn it off; a node that drops the new option when it writes
storage.cfg before it is upgraded, which the chapter covers; and an
empty volume group that another node wipes right after its creation.

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 Proxmox VE
   manages or has a storage on, 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 Guided Setup menu leads 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 and end with the state of the LUN on every node.
 - Datacenter > Storage > Add keeps its dialogs. The iSCSI one gets a
   Multipath option and the LVM one enables Shared for a base storage,
   and both point to the SAN view.
 - 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 rules the series follows since v4: nodes add WWIDs and maps but
never remove them, a write is checked where it happens, lists do not
probe devices, there are no new iSCSI operations, the guided setup makes
the API calls an admin would make by hand, and multipath management is
turned on by the admin. The v4 cover [7] has the reasons.

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. And Fibre Channel starts at a LUN the nodes already see; the
chapter gives the commands to list WWPNs and rescan the HBAs.

How it works:

 - /etc/pve/multipath.cfg holds explicit entries per WWID,
   /etc/pve/multipath-overrides.conf array settings; patch 01
   registers both. An iSCSI storage with the 'managed-multipath' option
   supplies its LUNs without entries. The option is not named
   'multipath', as third-party plugins use that name, and the storage
   layer leaves out a third-party plugin that declares a property of
   another plugin.
 - 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, reloads multipathd after a change,
   and publishes the state of the maps that Proxmox VE manages or that a
   storage builds on through the node key-value store.
 - /cluster/multipath/status aggregates these reports;
   /cluster/multipath/{wwid,overrides} edit the two files;
   /nodes/{node}/scan/san-luns lists the LUNs of a node and
   /nodes/{node}/iscsi its sessions.
 - The volumes of an iSCSI storage with the option are named after the
   multipath map, so an LVM storage uses them through 'base' as before.
 - Volume group creation and wipe run under a cluster lock per LUN. They
   refuse a LUN that a storage uses or a process of the node has open,
   also through another path. Opens through another device node, such as
   one of a container, and users on other hosts are not seen.

Patches:

 - cluster 01: register the two configuration files
 - storage 02-25: 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 disk
   list of many disks, the LUN inventory, the read-only iSCSI status,
   volume groups on LUNs, the wipe and the process that has a LUN open
 - docs 26-27: the multipath chapter, rewritten around tasks, and the
   paragraph for a LUN that a process has open
 - manager 28-42: the pvestatd call, report and API mounts, then the
   views, the two dialog changes, the two guided setups, the note in the
   add dialogs, and the guest or process and the target of a LUN

Other changes since v5 [3]:

 - rebased onto current master in all four repositories, with the plugin
   metadata for the iSCSI option and its entry in the pinned property
   list
 - the setup menu is named Guided Setup instead of Add Storage, as three
   different things in two views were called add
 - search fields in the LUN lists and the iSCSI tree, which on a node
   also match path devices and WWPNs, for example one from the kernel
   log
 - the process check compares device numbers, and the volume group check
   refuses a volume group that any storage names
 - style fixes, warnings of three test files, and shorter commit
   messages

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. pve-manager also needs the
pve-doc-generator (build) and pve-docs with the multipath chapter, for
its help links. If the bound for LVM status commands [4] gets applied
too, whichever is applied second has to pass the status cache to the two
lvm_vgs() calls of the base volume activation, as they can block a
status pass otherwise. Both mark the cache of the status update with
'status_only', in the same line.

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 on the lab of v4 [7] and v5: a six-node nested cluster with a
NetApp AFF A20 (three iSCSI portals, NVMe/TCP), Linux LIO targets and
software FCoE, upgraded from the v5 build, with the NVMe over Fabrics
series and [4] on top. Most review fixes ran as drills against the fault
they fix, a few have unit tests only. Both guided setups ended optimal
on six nodes, the Fibre Channel one also with a failing task, delayed
and cut-off status requests and Escape pressed during the wait. A guest
on NetApp, Fibre Channel and NVMe/TCP disks went through snapshots, live
migrations, a path cut under I/O, an online resize and a node reboot
with checksums compared. The scale test ran with 1000 NVMe/TCP
namespaces and with 1000 iSCSI LUNs with maps; the disk list and the LUN
inventory gave the same result with the one udev call and with a query
per disk, also on the other five nodes. Guests with a NetApp map, a
Fibre Channel LUN or an NVMe/TCP namespace as disk, also on one path of
a map, showed in the LUN lists, and the wipe and the volume group
creation refused these LUNs. Most of this ran on builds before the last
fixes, which got drills of their own. I looked at each changed view and
dialog in the web UI.

Not repeated for v6: a path cut on Fibre Channel, the CLI procedure, a
LUN that one node is not allowed to see, all paths down with queued I/O,
the SAN views with a stopped multipathd, the multipath status of a node
with 1000 foreign maps and the series installed alone.

[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/20261116012355.3187417-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/
[7]: https://lore.proxmox.com/pve-devel/20261113030146.1559030-1-t.lamprecht@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 (16):
      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
      diskmanage: look up the requested disks by name
      diskmanage: read the udev data of all disks with one call
      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
      api: scan: report the process that has a SAN LUN open

 debian/control                                |   3 +-
 src/PVE/API2/Disks.pm                         |  46 +-
 src/PVE/API2/Disks/LVM.pm                     |  77 ++-
 src/PVE/API2/ISCSI.pm                         | 166 ++++++
 src/PVE/API2/Makefile                         |   2 +
 src/PVE/API2/Multipath.pm                     | 451 +++++++++++++++
 src/PVE/API2/Storage/Scan.pm                  | 216 ++++++++
 src/PVE/CLI/pvesm.pm                          |  14 +
 src/PVE/Diskmanage.pm                         | 375 +++++++++++--
 src/PVE/ISCSI/Topology.pm                     |  88 +++
 src/PVE/Makefile                              |   6 +
 src/PVE/Multipath.pm                          | 213 ++++++++
 src/PVE/Multipath/Config.pm                   | 204 +++++++
 src/PVE/Multipath/Generator.pm                | 120 ++++
 src/PVE/Multipath/Identity.pm                 |  44 ++
 src/PVE/Multipath/Status.pm                   | 215 ++++++++
 src/PVE/Storage.pm                            |   2 +-
 src/PVE/Storage/ISCSIPlugin.pm                | 219 +++++---
 src/PVE/Storage/LVMPlugin.pm                  | 151 ++++-
 src/PVE/Storage/Makefile                      |   3 +-
 src/PVE/Storage/SAN.pm                        | 409 ++++++++++++++
 src/test/Makefile                             |  37 +-
 src/test/disk_api_test.pm                     | 314 +++++++++++
 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                     | 175 +++++-
 src/test/multipath-three-states.json          |  52 ++
 src/test/plugin_properties_test.pm            |   1 +
 src/test/run_disk_api_tests.pl                |  11 +
 src/test/run_iscsi_activation_tests.pl        | 109 ++++
 src/test/run_lun_identity_tests.pl            |  57 ++
 src/test/run_multipath_api_tests.pl           | 515 ++++++++++++++++++
 src/test/run_multipath_tests.pl               | 169 ++++++
 src/test/run_san_api_tests.pl                 |  94 ++++
 src/test/run_san_library_tests.pl             | 135 +++++
 src/test/run_san_lun_scan_tests.pl            | 252 +++++++++
 src/test/run_san_nvme_tests.pl                | 120 ++++
 src/test/run_san_taint_tests.pl               |  60 ++
 src/test/run_san_wipe_tests.pl                | 255 +++++++++
 src/test/run_san_write_check_tests.pl         | 205 +++++++
 src/test/run_test_lvm_base_activation.pl      | 121 ++++
 src/test/run_test_lvm_base_volume.pl          |  12 +-
 src/test/run_test_lvm_create.pl               |  46 ++
 126 files changed, 6224 insertions(+), 194 deletions(-)

pve-docs:

Thomas Lamprecht (2):
      storage: document the cluster-wide multipath management
      storage: multipath: describe the use shown for an open LUN

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

pve-manager:

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

Thomas Lamprecht (13):
      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
      ui: san: show the guest or process that has a LUN open
      ui: node: san: add a column for the iSCSI target of a LUN

 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                      | 202 ++++++++++
 www/manager6/Utils.js                         |  19 +
 www/manager6/dc/Config.js                     |  23 +-
 www/manager6/dc/MultipathWwidEdit.js          |  81 ++++
 www/manager6/dc/SAN.js                        | 374 ++++++++++++++++++
 www/manager6/node/Config.js                   |  24 ++
 www/manager6/node/ISCSITargets.js             | 150 +++++++
 www/manager6/node/LVM.js                      |   3 +
 www/manager6/node/SANLuns.js                  | 229 +++++++++++
 www/manager6/storage/Base.js                  |   5 +
 www/manager6/storage/IScsiEdit.js             |  46 +++
 www/manager6/storage/LVMEdit.js               |   6 +
 www/manager6/storage/wizard/FibreChannel.js   | 175 ++++++++
 www/manager6/storage/wizard/IScsi.js          | 274 +++++++++++++
 www/manager6/storage/wizard/LunSelect.js      | 177 +++++++++
 www/manager6/storage/wizard/NodeIdentities.js |  83 ++++
 www/manager6/storage/wizard/Wizard.js         | 299 ++++++++++++++
 www/manager6/window/SANLunState.js            | 115 ++++++
 www/manager6/window/SANLunWipe.js             |  52 +++
 24 files changed, 2367 insertions(+), 6 deletions(-)




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

* [PATCH v6 cluster 01/42] cfs: observe the multipath configuration files
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 02/42] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
                   ` (41 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 6ace846..176865f 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 8538d8b..334566a 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] 44+ messages in thread

* [PATCH v6 storage 02/42] diskmanage: collect disk transport type from lsblk
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 cluster 01/42] cfs: observe the multipath configuration files Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 03/42] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
                   ` (40 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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] 44+ messages in thread

* [PATCH v6 storage 03/42] diskmanage: qualify NVMe over fabrics transport
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 cluster 01/42] cfs: observe the multipath configuration files Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 02/42] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 04/42] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
                   ` (39 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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, as the multipath
 devices it was part of follow later; mention the new values in the
 transport description; call the wrapped test function with arrow
 syntax]
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..c7374fd5 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] 44+ messages in thread

* [PATCH v6 storage 04/42] diskmanage: optionally include iSCSI session devices in disk enumeration
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (2 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 03/42] diskmanage: qualify NVMe over fabrics transport Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 05/42] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
                   ` (38 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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                         | 61 +++++++++----------
 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, 94 insertions(+), 37 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..c342abcd 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,23 +270,25 @@ sub get_zfs_devices {
 }
 
 sub get_lvm_devices {
-    my ($lsblk_info) = @_;
+    my ($lsblk_info, $no_probe) = @_;
     my $res = {};
-    eval {
-        run_command(
-            [$PVS, '--noheadings', '--readonly', '-o', 'pv_name'],
-            outfunc => sub {
-                my ($line) = @_;
-                $line = trim($line);
-                if ($line =~ m|^/dev/|) {
-                    $res->{$line} = 1;
-                }
-            },
-        );
-    };
+    if (!$no_probe) {
+        eval {
+            run_command(
+                [$PVS, '--noheadings', '--readonly', '-o', 'pv_name'],
+                outfunc => sub {
+                    my ($line) = @_;
+                    $line = trim($line);
+                    if ($line =~ m|^/dev/|) {
+                        $res->{$line} = 1;
+                    }
+                },
+            );
+        };
 
-    # if something goes wrong, we do not want to give up, but indicate an error has occurred
-    warn "$@\n" if $@;
+        # if something goes wrong, we do not want to give up, but indicate an error has occurred
+        warn "$@\n" if $@;
+    }
 
     my $uuids = {
         "e6d6d379-f507-44c2-a23c-238f2a3df928" => 1,
@@ -495,16 +504,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 +556,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 +565,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 +609,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 c7374fd5..4c85d9e9 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");
+# only the disks of the iscsi test case are session devices, 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] 44+ messages in thread

* [PATCH v6 storage 05/42] diskmanage: collect native NVMe multipath path state
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (3 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 04/42] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 06/42] iscsi: factor out session device map from device list Thomas Lamprecht
                   ` (37 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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; call the wrapped test function with
 arrow syntax]
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 c342abcd..516c108d 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -818,6 +818,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 4c85d9e9..a7c00d2d 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] 44+ messages in thread

* [PATCH v6 storage 06/42] iscsi: factor out session device map from device list
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (4 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 05/42] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 07/42] multipath: add a library around multipathd Thomas Lamprecht
                   ` (36 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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,
 with signatures, instead of the plugin; drop the fallback for old
 kernels]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/ISCSI/Topology.pm      |  69 +++++++++++++++++++++
 src/PVE/Makefile               |   1 +
 src/PVE/Storage/ISCSIPlugin.pm | 107 +++++++++------------------------
 3 files changed, 100 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..4ebfaccd
--- /dev/null
+++ b/src/PVE/ISCSI/Topology.pm
@@ -0,0 +1,69 @@
+package PVE::ISCSI::Topology;
+
+use v5.36;
+
+use PVE::Tools qw(dir_glob_foreach dir_glob_regex file_read_firstline);
+
+our $SYSFS = '/sys';
+
+# 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.
+sub foreach_session_lun($sessiondir, $code) {
+    dir_glob_foreach(
+        $sessiondir,
+        'target\d+:\d+:\d+',
+        sub($targetdir) {
+            dir_glob_foreach(
+                "$sessiondir/$targetdir",
+                '\d+:(\d+):(\d+):(\d+)',
+                sub($hctl, $channel, $id, $lun) {
+                    $code->("$sessiondir/$targetdir/$hctl", $channel, $id, $lun);
+                },
+            );
+        },
+    );
+}
+
+sub sessions($sysfs = undef) {
+    $sysfs //= $SYSFS;
+    my $res = {};
+    dir_glob_foreach(
+        "$sysfs/class/iscsi_session",
+        'session(\d+)',
+        sub($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($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($sysfs = undef) {
+    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 1e349cde..8ba96bed 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] 44+ messages in thread

* [PATCH v6 storage 07/42] multipath: add a library around multipathd
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (5 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 06/42] iscsi: factor out session device map from device list Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 08/42] diskmanage: add helper to list multipath devices Thomas Lamprecht
                   ` (35 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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                 | 136 +++++++++++++++++++++++++++
 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, 303 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 4abf489c..d10dfb23 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..84c4901e
--- /dev/null
+++ b/src/PVE/Multipath.pm
@@ -0,0 +1,136 @@
+package PVE::Multipath;
+
+use v5.36;
+
+use Encode qw(decode encode);
+use JSON qw(decode_json);
+
+use PVE::Tools qw(run_command file_read_firstline dir_glob_foreach);
+
+use PVE::Diskmanage;
+
+my $MULTIPATH = '/sbin/multipath';
+my $MULTIPATHD = '/sbin/multipathd';
+
+sub parse_dm_uuid($uuid) {
+    my ($part, $wwid) = ($uuid // '') =~ /^(?:part([1-9][0-9]*)-)?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 8ba96bed..3b9f748d 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
@@ -588,7 +589,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 b2676762..3f388a07 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream
+test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -52,3 +52,6 @@ test_sensitive_properties: run_sensitive_properties_tests.pl
 
 test_import_stream: run_import_stream_tests.pl
 	./run_import_stream_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] 44+ messages in thread

* [PATCH v6 storage 08/42] diskmanage: add helper to list multipath devices
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (6 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 07/42] multipath: add a library around multipathd Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 09/42] multipath: add a cluster-wide configuration Thomas Lamprecht
                   ` (34 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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; call the wrapped test function with arrow
 syntax]
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 516c108d..f1a5cd18 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}
     };
@@ -818,6 +819,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 a7c00d2d..15068aba 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");
 # only the disks of the iscsi test case are session devices, the sysfs of the host must not count




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

* [PATCH v6 storage 09/42] multipath: add a cluster-wide configuration
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (7 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 08/42] diskmanage: add helper to list multipath devices Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 10/42] iscsi: add an option to manage storage LUNs with multipath Thomas Lamprecht
                   ` (33 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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, even after the kernel has 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       | 177 ++++++++++++++++++++++++++++++
 src/test/Makefile                 |   5 +-
 src/test/run_multipath_tests.pl   |  39 +++++++
 src/test/run_san_library_tests.pl |  47 ++++++++
 5 files changed, 268 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..cb89663e
--- /dev/null
+++ b/src/PVE/Multipath/Config.pm
@@ -0,0 +1,177 @@
+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 = '(?!-|[0-9]+:-?[0-9])[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) {
+    if ($key eq 'nodes') {
+        my @nodes = PVE::Tools::split_list($value);
+        return { map { $_ => 1 } grep { PVE::JSONSchema::pve_verify_node_name($_) } @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 3f388a07..a267c7ba 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath
+test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -55,3 +55,6 @@ test_import_stream: run_import_stream_tests.pl
 
 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] 44+ messages in thread

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

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

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

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

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

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




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

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

Activating an LVM storage activates its base storage, but not the
base volume. Right after the login, the device of the base volume can
still be appearing, for example while multipathd assembles the map. 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. The
status update does not wait for the device. So there, the storage
stays inactive until a later pass finds its volume group.

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 | 121 +++++++++++++++++++++++
 3 files changed, 154 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 16a3d65f..f9c72764 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -1653,11 +1653,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 lists of the cache can predate the device; add, as an incomplete listing must not hide
+    # volume groups found before
+    $cache->{vgs} = { $cache->{vgs}->%*, lvm_vgs()->%* };
+    delete $cache->{lvs};
+    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} = { $cache->{vgs}->%*, lvm_vgs()->%* };
+    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 904f2b29..72e306f7 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries test_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_sensitive_properties test_import_stream test_multipath test_san_libraries test_lun_identity test_lvm_base_activation
 
 test_zfspoolplugin: run_test_zfspoolplugin.pl
 	./run_test_zfspoolplugin.pl
@@ -62,3 +62,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..a5e641fe
--- /dev/null
+++ b/src/test/run_test_lvm_base_activation.pl
@@ -0,0 +1,121 @@
+#!/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 that vgs lists with its device hints, and those that only a listing without
+# hints 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');
+$cache = { vgs => { vgold => {} } };
+activate($with_base, $cache, ['vg1']);
+ok($cache->{vgs}->{vgold}, 'a volume group found before stays in the list');
+
+# another node created the volume group after this node probed the device, which it had before
+$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] 44+ messages in thread

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

Each node needs the cluster-wide configuration as local multipath.conf
drop-ins. It also needs 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. Missing WWIDs are added, but none is ever removed.

The generated defaults set 'auto_resize grow_only', so that a map
follows a grown LUN. multipath only knows this setting for all maps of
a node. So once a node has something to apply, maps that Proxmox VE
does not manage also grow when all their paths have grown.
'auto_resize never' in a defaults section of the overrides file keeps
the resize manual, as multipath reads that file after the generated
defaults.

A drop-in with a generated name that Proxmox VE did not write is left
alone. If the node needs that file, applying fails until it is
renamed. 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      | 120 ++++++++++++++++++++++++++
 src/PVE/Multipath/Identity.pm       |   2 +-
 src/PVE/Storage/ISCSIPlugin.pm      |  16 ++++
 src/test/Makefile                   |   8 +-
 src/test/run_multipath_api_tests.pl | 129 ++++++++++++++++++++++++++++
 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, 344 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 1caadee1..ec417381 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -5,7 +5,7 @@ use v5.36;
 use Encode qw(decode encode);
 use JSON qw(decode_json);
 
-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);
 
 use PVE::Diskmanage;
 use PVE::Multipath::Config;
@@ -169,4 +169,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..1224c0a8
--- /dev/null
+++ b/src/PVE/Multipath/Generator.pm
@@ -0,0 +1,120 @@
+package PVE::Multipath::Generator;
+
+use v5.36;
+
+use File::Path qw(make_path);
+
+use PVE::INotify;
+use PVE::Tools qw(file_get_contents file_set_contents);
+
+use PVE::Multipath;
+use PVE::Multipath::Config;
+use PVE::Multipath::Identity;
+
+# 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->{'managed-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;
+    # a file of this name that an administrator wrote stays
+    if (length($old) && $old !~ m/\A#[^\n]*managed by Proxmox VE/i) {
+        die "cannot replace '$path' - it was not written by Proxmox VE, rename it\n"
+            if length($content);
+        return;
+    }
+    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 bc40c67b..8669e7dd 100644
--- a/src/PVE/Multipath/Identity.pm
+++ b/src/PVE/Multipath/Identity.pm
@@ -29,7 +29,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 2209891a..70ac2346 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 72e306f7..bfef56d6 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries test_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_sensitive_properties test_import_stream 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
@@ -65,3 +65,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..a3d7f3e6
--- /dev/null
+++ b/src/test/run_multipath_api_tests.pl
@@ -0,0 +1,129 @@
+#!/usr/bin/perl
+
+use v5.36;
+our $NOW;
+
+BEGIN {
+    $NOW = 1000;
+    *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 'drop-ins of the same name that an administrator wrote stay' => sub {
+    my $dir = tempdir('multipath-foreign-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 $mp = Test::MockModule->new('PVE::Multipath');
+    my $reloads = 0;
+    $mp->mock(list_etc_multipath_wwids => sub { [] });
+    $mp->mock(add_wwid => sub { });
+    $mp->mock(reconfigure => sub { $reloads++ });
+    my $own = "defaults {\n\tfind_multipaths strict\n}\n";
+    my $admin = "devices {\n\tdevice {\n\t\tvendor \"NETAPP\"\n\t}\n}\n";
+    PVE::Tools::file_set_contents("$dir/overrides", $admin);
+
+    my $res = PVE::Multipath::Generator::regenerate({ ids => {} }, '', {});
+    is(PVE::Tools::file_get_contents("$dir/overrides"), $admin, 'kept on an unconfigured node');
+    ok(!$res->{error} && !$reloads, 'without error or reload');
+    $res = PVE::Multipath::Generator::regenerate({ ids => {} }, $own, {});
+    is(PVE::Tools::file_get_contents("$dir/overrides"), $admin, 'kept when overrides are set');
+    like($res->{error}, qr/not written by Proxmox VE, rename it/, 'with an error');
+    is($reloads, 0, 'and no reload');
+
+    unlink("$dir/overrides");
+    $res = PVE::Multipath::Generator::regenerate({ ids => {} }, $own, {});
+    like(
+        PVE::Tools::file_get_contents("$dir/overrides"),
+        qr/^# Managed by Proxmox VE\./,
+        'written once the name is free',
+    );
+    $res = PVE::Multipath::Generator::regenerate({ ids => {} }, '', {});
+    ok(!-e "$dir/overrides" && !$res->{error}, 'removed again when no longer needed');
+};
+
+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', 'managed-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] 44+ messages in thread

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

Path health differs between nodes. Add the function for the status
daemon to call on each node. It applies the multipath configuration
and publishes the state of the maps of the node in the cluster
key-value store. Besides the maps, a report has the iSCSI initiator
name, which an admin needs for the access rules on the array, and the
error of a failed configuration run. If multipath is not usable, the
report has the reason instead of the maps.

A node can have hundreds of maps that something else set up, for
example a storage plugin with one LUN per guest disk. But a value of
the key-value store is limited to 32 KiB. So a map only gets a row if
the node manages it, if it is the base volume of an LVM storage or if
it holds the volume group of a storage. The other maps are only
counted. A report that is still too large drops the list of maps and
reports an error instead. An unchanged report is sent again once a
minute, so that readers can tell a stale one.

The volume groups come from the hint file of LVM, where a volume group
on a partition of a map counts for the map. LVM leaves the file empty
while it sees duplicate PVs. A node that leaves maps out then says so
in its report, as it cannot tell whether one of them holds the volume
group of a storage. The file can also be outdated. After the LVM hints
are turned off, it stays until the node reboots or someone removes
it. And it lacks a physical volume that another node added to a shared
volume group until LVM scans the devices of the node again.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Makefile                    |   1 +
 src/PVE/Multipath/Status.pm         |  99 ++++++++++++++++
 src/PVE/Storage/ISCSIPlugin.pm      |  16 +++
 src/PVE/Storage/LVMPlugin.pm        |  24 +++-
 src/test/run_multipath_api_tests.pl | 176 ++++++++++++++++++++++++++++
 src/test/run_san_library_tests.pl   |  55 +++++++++
 6 files changed, 370 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..cd049795
--- /dev/null
+++ b/src/PVE/Multipath/Status.pm
@@ -0,0 +1,99 @@
+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 = { %$data, error => 'too many LUNs to report' };
+        delete $data->{luns};
+        $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();
+        # A node can have many maps that something else set up, for example a storage plugin with
+        # one LUN per guest disk. Only the maps that the node manages, that are the base volume of a
+        # storage or hold its volume group get a row, the others are counted.
+        require PVE::Storage;
+        my $wanted = $apply->{wwids};
+        my $storages = eval { PVE::Storage::config()->{ids} };
+        my (%storage_vgs, %base);
+        for my $scfg (values %{ $storages // {} }) {
+            $storage_vgs{ $scfg->{vgname} } = 1 if defined($scfg->{vgname});
+            $base{$1} = 1
+                if ($scfg->{base} // '') =~ m/(?:^|\.)dm-uuid-(?:part\d+-)?mpath-(\S+)$/;
+        }
+        # without the wanted WWIDs or the storages nothing tells the maps apart
+        my $all = !$wanted || !$storages;
+        for my $map (PVE::Multipath::get_maps()->@*) {
+            my $wwid = $map->{wwid} // next;
+            my $vg = defined($map->{sysfs}) ? ($pv_vgs // {})->{"/dev/$map->{sysfs}"} : undef;
+            if (!$all && !$wanted->{$wwid} && !$base{$wwid} && !$storage_vgs{ $vg // '' }) {
+                $report->{'other-maps'}++;
+                next;
+            }
+            my $info = ($wanted // {})->{$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->{storages} = $info->{storages} if $info->{storages};
+            $lun->{vgname} = $vg if defined($vg);
+            push $report->{luns}->@*, $lun;
+        }
+        # the volume groups come from the hint file of LVM, which it does not always have
+        $report->{'vgs-unknown'} = 1 if !$pv_vgs && $report->{'other-maps'};
+    };
+    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 70ac2346..9136c7c9 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 f9c72764..451e20ba 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -19,7 +19,7 @@ use PVE::INotify;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Multipath;
 use PVE::RESTEnvironment qw(log_warn);
-use PVE::Tools qw(run_command file_read_firstline trim);
+use PVE::Tools qw(run_command file_get_contents file_read_firstline trim);
 
 use PVE::Storage::Common;
 use PVE::Storage::Plugin;
@@ -140,6 +140,28 @@ sub lvm_pv_info {
     return $pvinfo;
 }
 
+sub cached_pv_volume_groups {
+    my $data = eval { file_get_contents('/run/lvm/hints') } // '';
+    # LVM leaves the file without content when devices change and while it sees duplicate PVs
+    return undef if $data !~ m/^hints_version: 2\./m;
+    my $res = {};
+    while ($data =~ m/^scan:(\/dev\/\S+) pvid:\S+ devn:\d+:\d+ vg:([a-zA-Z0-9+_.-]+)$/mg) {
+        next if $2 eq '-';
+        my ($device, $vg) = (abs_path($1) // $1, $2);
+        $res->{$device} = $vg;
+        # a volume group on a partition of a multipath map counts for the map as well
+        my $sysdir = '/sys/class/block/' . basename($device);
+        my $map = PVE::Multipath::parse_dm_uuid(file_read_firstline("$sysdir/dm/uuid"));
+        next if !$map || !$map->{partition};
+        PVE::Tools::dir_glob_foreach(
+            "$sysdir/slaves",
+            'dm-\d+',
+            sub { $res->{"/dev/$_[0]"} //= $vg },
+        );
+    }
+    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 a3d7f3e6..7d671458 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -9,9 +9,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);
@@ -126,4 +128,178 @@ 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)], 'iscsi-initiator-name' => 'iqn.2026-11.test:n1' });
+    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');
+    is(
+        $sent[-1]->{'iscsi-initiator-name'},
+        'iqn.2026-11.test:n1',
+        'which keeps the node identity',
+    );
+};
+
+subtest 'only managed maps and those under a storage get a row' => 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 $storage = Test::MockModule->new('PVE::Storage');
+    my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    my $report;
+    $status->mock(publish => sub { $report = $_[0] });
+    $iscsi->mock(read_initiator_info => sub { undef });
+    $mp->mock(is_supported => sub { 1 }, is_running => sub { 1 });
+    $mp->mock(
+        get_maps => sub {
+            return [
+                map { {
+                    wwid => "3600$_",
+                    sysfs => "dm-$_",
+                    'paths-active' => 2,
+                    'paths-total' => 2,
+                } } 1 .. 5
+            ];
+        },
+    );
+    $gen->mock(sync => sub { { wwids => { '36001' => {} } } });
+    $lvm->mock(
+        cached_pv_volume_groups => sub { { '/dev/dm-2' => 'vgsan', '/dev/dm-3' => 'vgother' } },
+    );
+    my $ids = {
+        san => { type => 'lvm', vgname => 'vgsan' },
+        based =>
+            { type => 'lvm', vgname => 'vgbase', base => 'conn:0.0.0.dm-uuid-mpath-36004' },
+    };
+    $storage->mock(config => sub { { ids => $ids } });
+    PVE::Multipath::Status::update_node_status();
+    is_deeply(
+        [map { $_->{wwid} } $report->{luns}->@*],
+        ['36001', '36002', '36004'],
+        'a wanted map, one with the volume group of a storage and a base volume',
+    );
+    is($report->{'other-maps'}, 2, 'the other maps are counted');
+    ok(!exists($report->{'vgs-unknown'}), 'volume groups known from the hints of LVM');
+    $lvm->mock(cached_pv_volume_groups => sub { undef });
+    PVE::Multipath::Status::update_node_status();
+    is_deeply(
+        [map { $_->{wwid} } $report->{luns}->@*],
+        ['36001', '36004'],
+        'without hints only the maps that the configuration names',
+    );
+    is($report->{'other-maps'}, 3, 'the map of the volume group counts as other');
+    ok($report->{'vgs-unknown'}, 'and the report says that volume groups are unknown');
+    $storage->mock(config => sub { die "no configuration\n" });
+    PVE::Multipath::Status::update_node_status();
+    is(scalar($report->{luns}->@*), 5, 'all maps without the storage configuration');
+    ok(!exists($report->{'other-maps'}), 'and no count');
+    $storage->mock(config => sub { { ids => $ids } });
+    $mp->mock(get_maps => sub { [] });
+    PVE::Multipath::Status::update_node_status();
+    ok(!exists($report->{'vgs-unknown'}),
+        'unknown volume groups only matter for left out maps');
+};
+
+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', 'all maps while the wanted ones are unknown');
+    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..f7ae68d1 100755
--- a/src/test/run_san_library_tests.pl
+++ b/src/test/run_san_library_tests.pl
@@ -50,4 +50,59 @@ 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" });
+    $lvm->redefine(
+        file_read_firstline => sub { $_[0] =~ m{/dm-3/dm/uuid$} ? 'part1-mpath-36001' : undef },
+    );
+    my $tools = Test::MockModule->new('PVE::Tools');
+    $tools->redefine(
+        dir_glob_foreach => sub { $_[2]->('dm-2') if $_[0] eq '/sys/class/block/dm-3/slaves' });
+    my $head = "# Created by vgs pid 1\nhints_version: 2.1\n";
+    for my $case (
+        [undef, undef, 'missing file'],
+        ['', undef, 'empty file'],
+        ["# Created empty by vgs pid 1\n", undef, 'file that LVM left without content'],
+        ["scan:/dev/sda pvid:abc devn:8:0 vg:data\n", undef, 'no version line'],
+        [
+            "hints_version: 3.0\nscan:/dev/sda pvid:abc devn:8:0 vg:data\n",
+            undef,
+            'other format version',
+        ],
+        [$head, {}, 'no PVs'],
+        ["${head}scan=/dev/sda pvid=abc devn=8:0 vg=data\n", {}, 'different format'],
+        ["${head}scan:/dev/sda pvid:abc devn:8:0 vg:-\n", {}, 'orphan PV'],
+        ["${head}scan:/dev/sda pvid:abc devn:8:0 vg:[unknown]\n", {}, 'unknown VG'],
+        [
+            "${head}scan:/dev/sda pvid:abc devn:8:0 vg:data\n",
+            { '/dev/sda' => 'data' },
+            'cached VG',
+        ],
+        [
+            "${head}scan:/dev/disk/by-id/test pvid:abc devn:253:0 vg:data\n",
+            { '/dev/dm-0' => 'data' },
+            'resolved device name',
+        ],
+        [
+            "${head}scan:/dev/dm-3 pvid:abc devn:253:3 vg:data\n",
+            { '/dev/dm-3' => 'data', '/dev/dm-2' => 'data' },
+            'partition of a multipath map',
+        ],
+    ) {
+        $contents = $case->[0];
+        is_deeply(PVE::Storage::LVMPlugin::cached_pv_volume_groups(), $case->[1], $case->[2]);
+    }
+};
+
 done_testing();




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

* [PATCH v6 storage 14/42] api: add endpoints for the cluster-wide multipath configuration
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (12 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 13/42] multipath: publish per-node status Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 15/42] api: multipath: add the cluster-wide health status Thomas Lamprecht
                   ` (28 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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           | 350 ++++++++++++++++++++++++++++
 src/PVE/Multipath/Config.pm         |  27 +++
 src/test/run_multipath_api_tests.pl |  36 +++
 4 files changed, 414 insertions(+)
 create mode 100644 src/PVE/API2/Multipath.pm

diff --git a/src/PVE/API2/Makefile b/src/PVE/API2/Makefile
index 01b7b28f..bb52a93f 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 Multipath.pm ${DESTDIR}${PERLDIR}/PVE/API2/Multipath.pm
 	make -C Storage install
 	make -C Disks install
 	make -C Plugins install
diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
new file mode 100644
index 00000000..27309680
--- /dev/null
+++ b/src/PVE/API2/Multipath.pm
@@ -0,0 +1,350 @@
+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($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($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' has no explicit multipath entry\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 'managed-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($param) {
+        my $wwid = extract_param($param, 'wwid');
+        my $digest = extract_param($param, 'digest');
+
+        edit_config_locked(
+            $digest,
+            "adding WWID '$wwid' failed",
+            sub($cfg) {
+                raise_param_exc({
+                    wwid => "WWID '$wwid' already has an explicit multipath entry" })
+                    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($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($cfg) {
+                my $section = $cfg->{ids}->{$wwid}
+                    or die "WWID '$wwid' has no explicit multipath entry, 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($param) {
+        my $wwid = $param->{wwid};
+        my $digest = extract_param($param, 'digest');
+
+        edit_config_locked(
+            $digest,
+            "removing WWID '$wwid' failed",
+            sub($cfg) {
+                if (!$cfg->{ids}->{$wwid}) {
+                    die "WWID '$wwid' has no explicit multipath entry - a LUN of a"
+                        . " multipath-enabled storage is managed through that storage's"
+                        . " 'managed-multipath' option\n";
+                }
+                delete $cfg->{ids}->{$wwid};
+            },
+        );
+        return undef;
+    },
+});
+
+1;
diff --git a/src/PVE/Multipath/Config.pm b/src/PVE/Multipath/Config.pm
index cb89663e..dcdaaae5 100644
--- a/src/PVE/Multipath/Config.pm
+++ b/src/PVE/Multipath/Config.pm
@@ -2,6 +2,8 @@ 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;
@@ -133,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);
@@ -161,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)->@*) {
@@ -174,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 7d671458..cc811dea 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -10,11 +10,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] 44+ messages in thread

* [PATCH v6 storage 15/42] api: multipath: add the cluster-wide health status
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (13 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 14/42] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 16/42] diskmanage: look up the requested disks by name Thomas Lamprecht
                   ` (27 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

Combine the reports of the nodes into one view: the state of each
node, and per LUN the state of its map on each node with the worst one
as summary. A report older than three minutes, or of an offline node,
is ignored.

A node should have a LUN if an explicit entry, the iSCSI storage that
requests the map or a shared LVM storage on the LUN covers the node.
If such a node does not report the LUN, the LUN counts as missing
there. It counts as unknown if the node has no current report or no
usable multipath. The same holds if the node left maps out because it
does not know their volume groups, and knows the LUN only through the
volume group of a storage. Nodes also report the number of paths they
expect for each map, so that a map with fewer paths can show how many
are missing.

Each LUN also names the enabled iSCSI storage with multipath that
requests its map. This tells a map without an explicit entry apart
from one that nothing in Proxmox VE asked for. Storage admins can read
the status as well, as they need the initiator names for the access
rules on the array.

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

diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
index 27309680..d9700d75 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,107 @@ __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 },
+        'other-maps' => {
+            type => 'integer',
+            minimum => 1,
+            optional => 1,
+            description => 'The number of multipath maps that the node leaves out of its LUN'
+                . ' list. It lists the maps that Proxmox VE manages and the ones it knows to be the'
+                . ' base volume of a storage or to hold its volume group.',
+        },
+        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,
+                            description =>
+                                'The storage that uses the LUN: as its base volume or through'
+                                . ' the volume group on it, or as an iSCSI storage that serves'
+                                . ' the LUNs of its target as images.',
+                        },
+                        '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 cd049795..20efb71f 100644
--- a/src/PVE/Multipath/Status.pm
+++ b/src/PVE/Multipath/Status.pm
@@ -8,11 +8,22 @@ 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();
@@ -81,6 +92,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->{storages} = $info->{storages} if $info->{storages};
+            $lun->{'paths-expected'} = $info->{'paths-expected'}
+                if defined($info->{'paths-expected'});
             $lun->{vgname} = $vg if defined($vg);
             push $report->{luns}->@*, $lun;
         }
@@ -96,4 +109,107 @@ 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);
+    # the nodes that list a map because the configuration names it for them
+    my (%managed, %unhinted);
+    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;
+        my $requests = $scfg && $scfg->{type} eq 'iscsi' && $scfg->{'managed-multipath'};
+        return 0 if !$requests || $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}->{$_} = $managed{$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-(?:part\d+-)?mpath-(\S+)$/;
+        next if !defined($wwid);
+        $luns{$wwid} //= { wwid => $wwid, explicit => 0 };
+        $luns{$wwid}->{'used-by-storage'} //= $sid;
+        $managed{$wwid}->{$_} = 1 for @$all_nodes;
+        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});
+        my $offline = exists($members->{$node}) && !$members->{$node}->{online};
+        next if $offline || !defined($report->{time}) || time() - $report->{time} > 180;
+        my @keys = qw(error apply-error iscsi-initiator-name other-maps);
+        $entry->{$_} = $report->{$_} for grep { defined($report->{$_}) } @keys;
+        $entry->{state} = defined($report->{error}) ? 'unavailable' : 'ok';
+        $unhinted{$node} = 1 if $report->{'vgs-unknown'};
+        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)->@*;
+            }
+            for my $sid (($lun->{storages} // [])->@*) {
+                my $scfg = $storage->{ids}->{$sid} // next;
+                $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)->@* : ();
+                $managed{$wwid}->{$_} = 1
+                    for $requests_maps->($sid) ? $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}) {
+                my $listed = $nodes{$node}->{state} eq 'ok';
+                # without the hint file of LVM a node leaves a map out that it only knows through
+                # the volume group of a storage
+                $listed = 0 if $unhinted{$node} && !$managed{$wwid}->{$node};
+                $row->{nodes}->{$node} = { state => $listed ? '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 cc811dea..40db0be6 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -9,7 +9,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;
@@ -46,7 +46,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',
     );
 };
@@ -335,7 +335,181 @@ 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', 'all maps while the wanted ones are unknown');
+    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,
+                    storages => ['iscsi'],
+                    vgname => 'vgfc',
+                },
+                {
+                    wwid => '3600d',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storages => ['off'],
+                    vgname => 'vgshared',
+                },
+                {
+                    wwid => '3600f',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storages => ['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 });
+    my $entries = { '3600a' => { type => 'wwid' } };
+    $config->mock(read_config => sub { { ids => $entries } });
+    $storage->mock(
+        config => sub { {
+            ids => {
+                iscsi => { type => 'iscsi', 'managed-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', 'managed-multipath' => 1, nodes => { departed => 1 } },
+                lvmgone => { type => 'lvm', base => 'gone:0.0.0.dm-uuid-mpath-3600e' },
+                scoped => { type => 'iscsi', 'managed-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');
+    {
+        local $raw{n2} = encode_json({ time => $NOW, luns => [], 'vgs-unknown' => 1 });
+        my %unhinted = map { $_->{wwid} => $_ } PVE::API2::Multipath->status({})->{luns}->@*;
+        is(
+            $unhinted{'3600d'}->{nodes}->{n2}->{state},
+            'unknown',
+            'a node without LVM hints may have left out the map of a volume group',
+        );
+        is($unhinted{'3600a'}->{nodes}->{n2}->{state}, 'missing', 'but for one with an entry');
+        is(
+            $unhinted{'3600f'}->{nodes}->{n2}->{state},
+            'missing',
+            'and for one that an iSCSI storage requests there',
+        );
+        local $entries->{'3600d'} = { type => 'wwid', nodes => { n1 => 1 } };
+        %unhinted = map { $_->{wwid} => $_ } PVE::API2::Multipath->status({})->{luns}->@*;
+        is(
+            $unhinted{'3600d'}->{nodes}->{n2}->{state},
+            'unknown',
+            'an entry for other nodes does not change that',
+        );
+    }
+    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',
+    );
+};
+
+subtest 'every storage that requests a map counts' => 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)] });
+    $cluster->mock(get_members => sub { {} });
+    my $lun = {
+        wwid => '3600x',
+        state => 'optimal',
+        'paths-total' => 2,
+        'paths-active' => 2,
+        storages => [qw(s1 s2)],
+    };
+    my %raw = map { $_ => encode_json({ time => $NOW, luns => [$lun] }) } qw(n1 n2);
+    $raw{n3} = encode_json({ time => $NOW, luns => [] });
+    $cluster->mock(get_node_kv => sub { \%raw });
+    $config->mock(read_config => sub { { ids => {} } });
+    $storage->mock(
+        config => sub { {
+            ids => {
+                s1 =>
+                    { type => 'iscsi', 'managed-multipath' => 1, nodes => { n1 => 1, n2 => 1 } },
+                s2 => {
+                    type => 'iscsi',
+                    'managed-multipath' => 1,
+                    nodes => { n3 => 1 },
+                    content => { images => 1 },
+                },
+            },
+        } },
+    );
+    my ($row) = PVE::Multipath::Status::cluster_status()->{luns}->@*;
+    is($row->{nodes}->{n3}->{state}, 'missing', 'a node of the second storage expects the map');
+    is($row->{'used-by-storage'}, 's2', 'which serves its LUNs');
+};
+
 done_testing();




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

* [PATCH v6 storage 16/42] diskmanage: look up the requested disks by name
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (14 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 15/42] api: multipath: add the cluster-wide health status Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 17/42] diskmanage: read the udev data of all disks with one call Thomas Lamprecht
                   ` (26 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

get_disks() turned the requested disks into one regular expression for
its walk over /sys/block. The partition lookup of each disk in that
walk goes through the same match with another expression, so perl
compiled the expression with all names again for every disk.

Other callers ask about a few disks only. But the SAN LUN inventory
that follows asks about every disk that is not a path of a multipath
map. On a lab node, the compiling cost 0.3 seconds for 1000 iSCSI
disks and 1.2 seconds for 2000. A disk name is no pattern, so look it
up as it is.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Diskmanage.pm     | 11 +++++++----
 src/test/disklist_test.pm |  2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index f1a5cd18..c4b4ce68 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -572,7 +572,7 @@ sub get_disks {
 
     my $lvmhash = get_lvm_devices($lsblk_info, $san_inventory);
 
-    my $disk_regex = ".*";
+    my $wanted;
     if (defined($disks)) {
         if (!ref($disks)) {
             $disks = [$disks];
@@ -583,21 +583,24 @@ sub get_disks {
         $_ =~ s|cciss/|cciss!| for @$disks;
 
         if ($include_partitions) {
-            # Proper blockdevice is needed for the regex, use parent for partitions.
+            # Proper blockdevice is needed for the lookup, use parent for partitions.
             for my $disk ($disks->@*) {
                 next if !is_partition("/dev/$disk");
                 $disk = strip_dev(get_blockdev("/dev/$disk"));
             }
         }
 
-        $disk_regex = "(?:" . join('|', @$disks) . ")";
+        # Not as one regex of all names: the lookup of the partitions of each disk below goes
+        # through the same match, so perl would compile that regex again for every disk.
+        $wanted = { map { $_ => 1 } @$disks };
     }
 
     dir_glob_foreach(
         '/sys/block',
-        $disk_regex,
+        '.*',
         sub {
             my ($dev) = @_;
+            return if $wanted && !$wanted->{$dev};
             # whitelisting following devices
             # - hdX         ide block device
             # - sdX         scsi/sata block device
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index 15068aba..dde3d29f 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -222,6 +222,8 @@ sub test_disk_list {
                 $expected_disk_list->{$disk},
                 "disk $disk should be the same",
             );
+            $testcount++;
+            is_deeply([keys %$disk_tmp], [$disk], "only disk $disk gets returned");
 
             # test wrong parameter
             eval { PVE::Diskmanage::get_disks({ test => 1 }); };




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

* [PATCH v6 storage 17/42] diskmanage: read the udev data of all disks with one call
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (15 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 16/42] diskmanage: look up the requested disks by name Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 18/42] api: scan: add a SAN LUN inventory Thomas Lamprecht
                   ` (25 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

The disk list asks udevadm about each disk on its own, which takes a
few milliseconds per disk. That adds up on a node with many disks, for
example with a storage plugin that uses one LUN per guest disk. The
SAN LUN inventory that follows lists every SAN disk outside of a
multipath map. On a lab node with 1000 NVMe/TCP namespaces, it took
6.6 seconds.

Read the udev database of all block devices with one call instead. Its
entries have the format of the query for a single device, also for a
device that udev has not processed yet. On that node, the inventory
then took 0.9 seconds.

But reading the database gets slower with every block device of a
node, also with those that are not listed. On a node with 1000
multipath maps over 2000 iSCSI paths, reading it took 0.47 seconds,
while asking about the 14 disks of its list took 0.1 seconds. So the
disk list asks about single disks until that took about as long as
reading the database would, counting one query as 40 block devices.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/Diskmanage.pm     | 63 +++++++++++++++++++++++++++++--------
 src/test/disklist_test.pm | 66 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 115 insertions(+), 14 deletions(-)

diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index c4b4ce68..07694e2e 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -370,21 +370,50 @@ sub get_ceph_volume_infos {
     return $result;
 }
 
+# Returns the udev information of all block devices by their kernel name, in the format that
+# 'udevadm info --query all' prints for a single device. One call for all devices takes a fraction
+# of the time that a call per device takes on a node with many disks.
+sub get_udev_db {
+    my $db = {};
+    my $entry = '';
+    my $add = sub {
+        my ($name) = $entry =~ m|^P: .*/([^/\n]+)$|m;
+        $db->{$name} = $entry if defined($name);
+        $entry = '';
+    };
+    eval {
+        run_command(
+            ['udevadm', 'info', '--export-db', '--subsystem-match=block'],
+            outfunc => sub {
+                my ($line) = @_;
+                return $add->() if $line eq '';
+                $entry .= "$line\n";
+            },
+        );
+    };
+    # every entry ends with an empty line, so one that a failed command cut off is left out
+    warn $@ if $@;
+    return $db;
+}
+
 sub get_udev_info {
-    my ($dev) = @_;
+    my ($dev, $udev_db) = @_;
 
-    my $info = "";
+    # a device that showed up after the database got read is not in there
+    my $info = $udev_db ? $udev_db->{ basename($dev) } // '' : '';
     my $data = {};
-    eval {
-        run_command(
-            ['udevadm', 'info', '-p', $dev, '--query', 'all'],
-            outfunc => sub {
-                my ($line) = @_;
-                $info .= "$line\n";
-            },
-        );
-    };
-    warn $@ if $@;
+    if (!$info) {
+        eval {
+            run_command(
+                ['udevadm', 'info', '-p', $dev, '--query', 'all'],
+                outfunc => sub {
+                    my ($line) = @_;
+                    $info .= "$line\n";
+                },
+            );
+        };
+        warn $@ if $@;
+    }
     return if !$info;
 
     return if $info !~ m/^E: DEVTYPE=(disk|partition)$/m;
@@ -594,6 +623,13 @@ sub get_disks {
         # through the same match, so perl would compile that regex again for every disk.
         $wanted = { map { $_ => 1 } @$disks };
     }
+    # Reading the database of all block devices takes about as long as asking about every 40th
+    # device that lsblk lists on its own, and a node with multipath maps or many volumes has far
+    # more of those than disks to list. So ask about single disks until that took as long as
+    # reading the database would, and about the first few in any case.
+    my ($udev_db, $udev_queries) = (undef, 0);
+    my $udev_single = scalar(keys %$lsblk_info) / 40;
+    $udev_single = 4 if $udev_single < 4;
 
     dir_glob_foreach(
         '/sys/block',
@@ -615,7 +651,8 @@ sub get_disks {
 
             return if !$san_inventory && is_iscsi_device($dev);
 
-            my $data = get_udev_info("/sys/block/$dev") // return;
+            $udev_db //= get_udev_db() if ++$udev_queries > $udev_single;
+            my $data = get_udev_info("/sys/block/$dev", $udev_db) // return;
             my $devpath = $data->{devpath};
 
             my $sysdir = "/sys/block/$dev";
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index dde3d29f..4e0b12ae 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -19,6 +19,7 @@ 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 $udev_single_queries = 0; # udevadm calls for one device
 
 my $multipath_aliases = {
     '/dev/mapper/mpatha' => '/dev/dm-0',
@@ -33,7 +34,18 @@ sub mocked_run_command {
 
     my $outputlines = [];
     if (my $ref = ref($cmd)) {
-        if ($cmd->[0] =~ m/udevadm/i) {
+        if ($cmd->[0] =~ m/udevadm/i && grep { $_ eq '--export-db' } @$cmd) {
+            # simulate the database of all devices, an empty line ends an entry
+            for my $file (sort glob("disk_tests/$testcasedir/*_udevadm")) {
+                my ($name) = $file =~ m|/([^/]+)$|;
+                my @lines = split(/\n/, read_test_file($name));
+                # the database is keyed by the device path, which older fixtures lack
+                unshift @lines, 'P: /devices/virtual/block/' . ($name =~ s/_udevadm$//r)
+                    if !grep { m/^P: / } @lines;
+                push @$outputlines, @lines, '';
+            }
+        } elsif ($cmd->[0] =~ m/udevadm/i) {
+            $udev_single_queries++;
             # simulate udevadm output
             my $dev = $cmd->[3];
             $dev =~ s|/sys/block/||;
@@ -275,6 +287,58 @@ sub test_disk_list {
             is_deeply($status, $expected_status, 'nvme path status should be the same');
         }
 
+        if ($testcasedir eq 'multipath') {
+            my $db = PVE::Diskmanage::get_udev_db();
+            $testcount++;
+            is_deeply(
+                [sort keys %$db],
+                [qw(nvme8n1 nvme9n1 sda sdb sdc sdd)],
+                'udev database has one entry per device',
+            );
+            $udev_single_queries = 0;
+            my $info = PVE::Diskmanage::get_udev_info('/sys/block/sdb', $db);
+            $testcount++;
+            is($info->{serial}, 'SSERb', 'disk found in the udev database');
+            $testcount++;
+            is($udev_single_queries, 0, 'without a query of its own');
+            PVE::Diskmanage::get_udev_info('/sys/block/sdb', {});
+            $testcount++;
+            is(
+                $udev_single_queries,
+                1,
+                'a disk that is not in the database is asked for on its own',
+            );
+
+            $udev_single_queries = 0;
+            my $listed = PVE::Diskmanage::get_disks();
+            $testcount++;
+            is(scalar(keys %$listed), 6, 'all disks listed');
+            $testcount++;
+            is(
+                $udev_single_queries,
+                4,
+                'the database replaces the queries after the first disks',
+            );
+
+            # six disks: 240 block devices are just enough to ask about each of them on its own
+            for my $count (240, 239) {
+                $diskmanage_module->mock(
+                    get_lsblk_info => sub {
+                        return { map { ("/dev/dm-$_" => {}) } 1 .. $count };
+                    },
+                );
+                $udev_single_queries = 0;
+                PVE::Diskmanage::get_disks();
+                $diskmanage_module->unmock('get_lsblk_info');
+                $testcount++;
+                is(
+                    $udev_single_queries,
+                    $count == 240 ? 6 : 5,
+                    "single queries for six disks among $count block devices",
+                );
+            }
+        }
+
         done_testing($testcount);
     };
 }




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

* [PATCH v6 storage 18/42] api: scan: add a SAN LUN inventory
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (16 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 17/42] diskmanage: read the udev data of all disks with one call Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 19/42] pvesm: expose the " Thomas Lamprecht
                   ` (24 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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.

The paths of a map are left out of the disk list, which reads sysfs
for each disk it returns. A node with a thousand LUNs has several
thousand of them, and the views poll this list every few seconds.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Storage/Scan.pm                  | 202 +++++++++++++++++
 src/PVE/Diskmanage.pm                         |   7 +
 src/PVE/Multipath.pm                          |  24 ++
 src/PVE/Storage/Makefile                      |   3 +-
 src/PVE/Storage/SAN.pm                        | 196 ++++++++++++++++
 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            | 211 ++++++++++++++++++
 11 files changed, 852 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 d8bd0a96..0e7667c8 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' },
         ];
 
@@ -375,6 +377,206 @@ __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: as its base volume or"
+                        . " 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: 'manual' for a"
+                        . " map with an explicit entry, 'storage' for the map of an iSCSI storage"
+                        . " with the 'managed-multipath' option, 'unmanaged' for any other map,"
+                        . " 'pending' while a map that an entry, a storage or the allow-list of"
+                        . " the node requests does not exist yet, 'none' without a map or"
+                        . " request, 'native' for the kernel-native multipath of an NVMe"
+                        . " namespace.",
+                    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 07694e2e..c31cf991 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -554,6 +554,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 ec417381..027e6a53 100644
--- a/src/PVE/Multipath.pm
+++ b/src/PVE/Multipath.pm
@@ -2,7 +2,9 @@ package PVE::Multipath;
 
 use v5.36;
 
+use Cwd qw(abs_path);
 use Encode qw(decode encode);
+use File::Basename qw(basename);
 use JSON qw(decode_json);
 
 use PVE::Tools qw(run_command file_get_contents file_read_firstline dir_glob_foreach);
@@ -19,6 +21,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(
@@ -159,6 +167,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..788bb577
--- /dev/null
+++ b/src/PVE/Storage/SAN.pm
@@ -0,0 +1,196 @@
+package PVE::Storage::SAN;
+
+use v5.36;
+
+use Cwd qw(abs_path);
+use File::Basename qw(basename);
+
+use PVE::INotify;
+use PVE::Tools qw(file_read_firstline dir_glob_foreach);
+
+use PVE::Diskmanage;
+use PVE::ISCSI::Topology;
+use PVE::Multipath;
+use PVE::Multipath::Config;
+use PVE::Multipath::Generator;
+use PVE::Multipath::Identity;
+use PVE::Storage;
+use PVE::Storage::LVMPlugin;
+
+sub scan_luns($cfg) {
+    my $ids = PVE::Multipath::Identity::collect(all => 1);
+    my $map_info = PVE::Multipath::map_info();
+    my $members = PVE::Multipath::member_map($map_info);
+    # A map stands for its paths, of which a node with many LUNs has thousands. Leave them out of
+    # the disk list, which reads the sysfs attributes and partitions of each disk it returns.
+    my @names;
+    dir_glob_foreach(
+        '/sys/block',
+        '(?:sd[a-z]+|nvme\d+n\d+)',
+        sub($name, @) { push @names, $name if !$members->{$name} },
+    );
+    my $disks = PVE::Diskmanage::get_disks(\@names, 1, 0, 1);
+    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, %targets);
+
+    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-(?:part\d+-)?mpath-(.+)$/;
+    }
+
+    my %rows;
+    my $add = sub($disk, $map = 0) {
+        my $name = basename(abs_path($disk->{devpath}) // $disk->{devpath});
+        my $info =
+            { map => $map, transport => $disk->{transport}, session => $sessions->{$name} };
+        return if !is_san_device($disk->{devpath}, $info);
+        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+$/ && $nvme->{$name};
+        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;
+            $targets{$wwid}->{ $session->{target} } = 1;
+            $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 ($target) =
+            map { $target_owner{$_} // () } sort keys(($targets{ $row->{wwid} } // {})->%*);
+        my $owner = $base_owner{ $row->{wwid} } // $vg_owner{ $row->{vgname} // '' } // $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;
+        my $map = PVE::Multipath::device_map($path);
+        # the partitions of a LUN are handled like local devices, also the ones that kpartx maps
+        return 0 if PVE::Diskmanage::is_partition($path) || ($map && $map->{partition});
+        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 => $map,
+            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 bfef56d6..2f6f4cd7 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries test_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_sensitive_properties test_import_stream 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
@@ -71,3 +71,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 4e0b12ae..dbc1d855 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -82,6 +82,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";
         }
@@ -278,6 +280,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'));
@@ -362,8 +374,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..abfdfa28
--- /dev/null
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -0,0 +1,211 @@
+#!/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) };
+    },
+);
+my @listed;
+$scan->redefine(
+    dir_glob_foreach => sub {
+        my ($dir, $regex, $code) = @_;
+        return PVE::Tools::dir_glob_foreach($dir, $regex, $code) if $dir ne '/sys/block';
+        $code->($_) for grep { /^$regex$/ } qw(sda sdb sdc sdd sde sdf dm-0 loop0 nvme0n1);
+    },
+);
+$disk->mock(
+    get_disks => sub {
+        ok($_[3], 'SAN inventory opts into iSCSI');
+        @listed = sort $_[0]->@*;
+        return $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');
+is_deeply(
+    \@listed,
+    [qw(nvme0n1 sda sdb sdc sde)],
+    'the paths of a map are left out of the disk list',
+);
+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 = "hints_version: 2.1\nscan:/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}, 'none', 'NVMe without native multipath paths');
+$disk->mock(
+    get_nvme_path_status => sub {
+        { nvme0n1 =>
+            { active => 1, paths => [{ device => '/dev/nvme0c0n1', state => 'live' }] } };
+    },
+);
+$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');
+$disk->mock(is_partition => sub { 0 });
+my $mp_module = Test::MockModule->new('PVE::Multipath');
+$mp_module->redefine(device_map => sub { { wwid => '3600a', partition => 1 } });
+ok(!PVE::Storage::SAN::is_san_device('/dev/dm-5'), 'neither is one that kpartx maps');
+$mp_module->redefine(device_map => sub { { wwid => '3600a' } });
+ok(PVE::Storage::SAN::is_san_device('/dev/dm-4'), 'while the map itself is');
+
+done_testing();




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

* [PATCH v6 storage 19/42] pvesm: expose the SAN LUN inventory
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (17 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 18/42] api: scan: add a SAN LUN inventory Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 20/42] api: add node-level iSCSI status Thomas Lamprecht
                   ` (23 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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..5dc433eb 100755
--- a/src/test/run_san_api_tests.pl
+++ b/src/test/run_san_api_tests.pl
@@ -2,9 +2,11 @@
 
 use strict;
 use warnings;
+use Test::MockModule;
 use Test::More;
 use lib qw(. ..);
 use PVE::API2::Storage::Scan;
+use PVE::CLI::pvesm;
 
 for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
     my ($class, @names) = @$case;
@@ -21,4 +23,18 @@ for my $case (['PVE::API2::Storage::Scan', 'sanlunscan']) {
     }
 }
 
+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] 44+ messages in thread

* [PATCH v6 storage 20/42] api: add node-level iSCSI status
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (18 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 19/42] pvesm: expose the " Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 21/42] disks: lvm: drop unused imports Thomas Lamprecht
                   ` (22 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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          | 166 +++++++++++++++++++++++++++++++++
 src/PVE/API2/Makefile          |   1 +
 src/PVE/ISCSI/Topology.pm      |  19 ++++
 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..005e6809
--- /dev/null
+++ b/src/PVE/API2/ISCSI.pm
@@ -0,0 +1,166 @@
+package PVE::API2::ISCSI;
+
+use v5.36;
+
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTHandler;
+
+use PVE::ISCSI::Topology;
+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 bb52a93f..c3066fa0 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 4ebfaccd..f975f94f 100644
--- a/src/PVE/ISCSI/Topology.pm
+++ b/src/PVE/ISCSI/Topology.pm
@@ -35,8 +35,18 @@ sub sessions($sysfs = undef) {
             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($devdir, $channel, $id, $lun) {
@@ -66,4 +76,13 @@ sub device_map($sysfs = undef) {
     return $res;
 }
 
+sub normalize_portal($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 9136c7c9..217892bf 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 5dc433eb..66e28d41 100755
--- a/src/test/run_san_api_tests.pl
+++ b/src/test/run_san_api_tests.pl
@@ -5,10 +5,59 @@ use warnings;
 use Test::MockModule;
 use Test::More;
 use lib qw(. ..);
+use PVE::API2::ISCSI;
 use PVE::API2::Storage::Scan;
 use PVE::CLI::pvesm;
 
-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(
@@ -22,6 +71,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',
+);
 
 my $formatter = Test::MockModule->new('PVE::CLIFormatter');
 my $data = [{ wwid => '3600abc', devpath => '/dev/sda', serial => 'S1' }];




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

* [PATCH v6 storage 21/42] disks: lvm: drop unused imports
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (19 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 20/42] api: add node-level iSCSI status Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 22/42] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
                   ` (21 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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] 44+ messages in thread

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

The node disk API creates volume groups on local disks only. It
treats a Fibre Channel LUN as a local disk, refuses 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 for all nodes. Refuse an
existing storage ID for a LUN, and never join a storage that got
added with that ID meanwhile. Joining is meant for local volume groups
of the same name, and on a LUN would combine two different volume
groups in one shared storage. The partitions of a LUN, also the ones
that kpartx maps, stay local devices as before, so that an LVM storage
can still be added for a volume group on one of them.

Initializing a LUN, here or as base volume of an LVM storage that is
being added, takes a cluster-wide lock per WWID. It refuses a LUN that
a storage references through its volume group, as base volume, also
through a partition, or as iSCSI target serving images. The name of a
map can pass to another map while the lock is awaited. So the LUN is
held open by its stable name, and creation stops if a name used for
the checks and the LVM commands no longer leads to the held device.
The lookup of the LUN also resolves the requested name again after its
scan, and stops if the name leads to another device by then.

A LUN that a process of the node has open is refused too. A guest
that got the LUN as disk from a third-party storage plugin, or by its
device path, is neither a holder nor a storage reference, and its disk
can look empty. The check goes by the open files of the processes, so
it misses an open through another device node, for example the one of
a container. Also refused is a LUN whose other SCSI paths or their
partitions are mounted, held by a block device other than the map of
the LUN, or open for writing. An open for reading does not count, as
multipathd keeps the paths open read-only.

Co-authored-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks/LVM.pm             |  68 ++++---
 src/PVE/Diskmanage.pm                 |  45 +++++
 src/PVE/Storage/LVMPlugin.pm          |  81 ++++++++-
 src/PVE/Storage/SAN.pm                | 149 ++++++++++++++++
 src/test/Makefile                     |  11 +-
 src/test/disk_api_test.pm             | 247 ++++++++++++++++++++++++++
 src/test/run_disk_api_tests.pl        |  11 ++
 src/test/run_san_library_tests.pl     |  27 +++
 src/test/run_san_nvme_tests.pl        | 104 +++++++++++
 src/test/run_san_taint_tests.pl       |  26 +++
 src/test/run_san_write_check_tests.pl | 205 +++++++++++++++++++++
 src/test/run_test_lvm_create.pl       |  46 +++++
 12 files changed, 985 insertions(+), 35 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
 create mode 100755 src/test/run_san_write_check_tests.pl

diff --git a/src/PVE/API2/Disks/LVM.pm b/src/PVE/API2/Disks/LVM.pm
index 6101743b..790891b3 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,10 +131,13 @@ __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",
+                description => "Configure storage using the Volume Group. On a SAN LUN, this"
+                    . " adds a new shared storage for all nodes, otherwise a storage for this node"
+                    . " only.",
                 type => 'boolean',
                 optional => 1,
                 default => 0,
@@ -152,48 +156,62 @@ __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 $@;
+            }
+
+            # the given name, which the LUN lookup resolves once more after its scan
+            PVE::Storage::LVMPlugin::lvm_create_volume_group(
+                $san ? $param->{device} : $dev,
+                $name,
+                $san,
+            );
+
+            PVE::Diskmanage::udevadm_trigger($dev);
+
+            if ($param->{add_storage} && $san) {
+                # must not join a storage that someone added with this ID in the meantime
+                PVE::API2::Storage::Config->create({%$storage_params});
+            } elsif ($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/Diskmanage.pm b/src/PVE/Diskmanage.pm
index c31cf991..7c85f892 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -1157,6 +1157,51 @@ sub change_parttype {
     run_command(['sgdisk', "-t${partnum}:${parttype}", $blockdev], errmsg => $err);
 }
 
+# Returns the PID and command name of a process for each of the block devices that a process has
+# open, as hash by the resolved path of the device. With 'writable', a process that opened the
+# device only for reading does not count. Only detects an open through the device nodes in /dev
+# of the host, not one through the device node that a container has of its own.
+sub device_openers {
+    my ($devices, %param) = @_;
+
+    # the device number tells a device from a file of that name in another mount namespace
+    my %nodes;
+    for my $path (grep { defined($_) } map { abs_path($_) } @$devices) {
+        my $st = stat($path) // next;
+        $nodes{$path} = $st->rdev;
+    }
+    my $openers = {};
+    return $openers if !%nodes;
+
+    opendir(my $proc, '/proc') or return $openers;
+    for my $pid (grep { m/^\d+$/ && $_ != $$ } readdir($proc)) {
+        opendir(my $fds, "/proc/$pid/fd") or next;
+        for my $fd (readdir($fds)) {
+            my $target = readlink("/proc/$pid/fd/$fd") // next;
+            next if !defined($nodes{$target}) || $openers->{$target};
+            my $st = stat("/proc/$pid/fd/$fd") // next;
+            next if $st->rdev != $nodes{$target};
+            if ($param{writable}) {
+                # the permissions of the link are the access mode of the open file
+                my $link = lstat("/proc/$pid/fd/$fd") // next;
+                next if !($link->mode & S_IWUSR);
+            }
+            my $comm = file_read_firstline("/proc/$pid/comm") // 'unknown';
+            $openers->{$target} = { pid => $pid, command => $comm };
+        }
+    }
+    return $openers;
+}
+
+# Returns the PID and command name of a process that has one of the block devices open, if any.
+sub device_opener {
+    my (@devices) = @_;
+
+    my $openers = device_openers(\@devices);
+    my ($opener) = map { $openers->{$_} } sort keys %$openers;
+    return $opener ? "$opener->{pid} ($opener->{command})" : undef;
+}
+
 # Wipes all labels and the first 200 MiB of a disk/partition (or the whole if it is smaller).
 # 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().
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 451e20ba..a32779cd 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -162,6 +162,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;
 
@@ -172,10 +203,17 @@ 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, $device) if $lun;
+    };
+    $check_name->();
     my $refuse_data = sub {
         my (@types) = @_;
         die "device '$device' contains data ("
@@ -193,7 +231,8 @@ 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-/) {
+    my $map = PVE::Multipath::parse_dm_uuid($uuid);
+    if ($map && !$map->{partition}) {
         # A queueing map without a running path can stall even a read-only probe.
         my $running = 0;
         PVE::Tools::dir_glob_foreach(
@@ -220,6 +259,8 @@ sub lvm_create_volume_group {
     }
     my %signatures = map { $_->{type} => 1 } $probe->@*;
     my $res = lvm_pv_info($device, $signatures{LVM2_member});
+    # also a volume group that exists already only counts if the probes looked at the held LUN
+    $check_name->();
 
     # A PV without metadata copies can belong to a VG whose other devices are not visible. The
     # sentinel is not a VG name or orphan proof, even if the use flag contradicts it.
@@ -262,26 +303,52 @@ 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
+    if ($lun) {
+        my $exempt = $guard ? $guard->{exempt} : undef;
+        PVE::Storage::SAN::assert_lun_unreferenced(PVE::Storage::config(), $lun, $exempt);
+        PVE::Storage::SAN::assert_lun_paths_unused($lun);
+        # a guest with the LUN as disk has it open, without being a holder or a storage reference
+        my $opener = PVE::Diskmanage::device_opener($device);
+        die "cannot create volume group on '$device' - process $opener has it open\n"
+            if defined($opener);
+    }
+
+    $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) = @_;
 
@@ -1161,7 +1228,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 788bb577..bf33e330 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::Tools qw(file_read_firstline dir_glob_foreach);
 
@@ -193,4 +194,152 @@ sub is_san_device($device, $info = undef) {
         || PVE::Diskmanage::is_remote_transport($info->{transport}) ? 1 : 0;
 }
 
+sub lun_for_device($name) {
+    my $device = PVE::Diskmanage::verify_blockdev_path($name);
+    return undef if !is_san_device($device);
+    my $rows = scan_luns(PVE::Storage::config());
+    # the device behind a name such as a by-id one can pass to another LUN during the scan
+    die "cannot use '$device' - the device behind '$name' changed\n"
+        if (abs_path($name) // '') ne $device;
+    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}->%*;
+    $targets{ $lun->{'iscsi-target'} } = 1 if defined($lun->{'iscsi-target'});
+    for my $sid (sort keys $cfg->{ids}->%*) {
+        next if defined($exempt) && $sid eq $exempt;
+        my $scfg = $cfg->{ids}->{$sid};
+        my $type = $scfg->{type};
+        if ($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-(?:part\d+-)?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 $@;
+}
+
+# Device names can pass to another device while a LUN waits for its lock or is worked on. All
+# names used for it have to mean the device that is held open.
+sub assert_same_device($lun, $fh, @names) {
+    my @held = stat($fh);
+    for my $name ($lun->{'by-id'}, $lun->{devpath}, @names) {
+        my @named = stat($name);
+        die "cannot use '$lun->{devpath}' - the device behind '$name' changed\n"
+            if !@held || !@named || $held[6] != $named[6];
+    }
+}
+
+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
+    ];
+}
+
+# The other paths of a LUN reach the same data, but neither the exclusive open of the LUN nor the
+# checks of its device cover them.
+sub assert_lun_paths_unused($lun) {
+    my $device = basename(abs_path($lun->{devpath}) // $lun->{devpath});
+    my %devices; # the paths and their partitions
+    for my $path (grep { basename($_) ne $device } lun_paths($lun)->@*) {
+        if (my $mounted = PVE::Diskmanage::is_mounted($path)) {
+            die "cannot use '$lun->{devpath}' - the LUN is mounted through '$mounted'\n";
+        }
+        my $name = basename($path);
+        $devices{$path} = 1;
+        dir_glob_foreach(
+            "/sys/class/block/$name",
+            "\Q$name\E\\d+",
+            sub($part, @) {
+                $devices{"/dev/$part"} = 1;
+            },
+        );
+    }
+    for my $path (sort keys %devices) {
+        dir_glob_foreach(
+            '/sys/class/block/' . basename($path) . '/holders',
+            '[^.].*',
+            sub($holder, @) {
+                die "cannot use '$lun->{devpath}' - another block device uses the LUN through"
+                    . " '$path'\n"
+                    if $holder ne $device;
+            },
+        );
+    }
+    my $openers = PVE::Diskmanage::device_openers([sort keys %devices], writable => 1);
+    for my $path (sort keys %$openers) {
+        my $opener = $openers->{$path};
+        die "cannot use '$lun->{devpath}' - process $opener->{pid} ($opener->{command}) has the"
+            . " LUN open through '$path'\n";
+    }
+}
+
 1;
diff --git a/src/test/Makefile b/src/test/Makefile
index 2f6f4cd7..0d866d91 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,6 +1,6 @@
 all: test
 
-test: test_iscsi test_zfspoolplugin test_lvmplugin test_lvm_create test_lvm_lock_retry test_lvm_base_volume test_lvm_hints test_disklist test_bwlimit test_plugin test_ovf test_volume_access test_remote_command test_sensitive_properties test_import_stream test_multipath test_san_libraries test_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_sensitive_properties test_import_stream 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
@@ -9,9 +9,10 @@ test_lvmplugin: run_test_lvmplugin.pl run_test_lvm_throughput.pl
 	./run_test_lvmplugin.pl
 	./run_test_lvm_throughput.pl
 
-test_lvm_create: run_test_lvm_create.pl run_test_lvm_base_conflicts.pl
+test_lvm_create: run_test_lvm_create.pl run_test_lvm_base_conflicts.pl run_san_write_check_tests.pl
 	./run_test_lvm_create.pl
 	./run_test_lvm_base_conflicts.pl
+	./run_san_write_check_tests.pl
 
 test_lvm_lock_retry: run_test_lvm_lock_retry.pl
 	./run_test_lvm_lock_retry.pl
@@ -75,5 +76,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..474ad663
--- /dev/null
+++ b/src/test/disk_api_test.pm
@@ -0,0 +1,247 @@
+package PVE::API2::Disks::Test;
+
+use v5.36;
+
+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($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($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, @registered);
+    $config_api->mock(
+        create_or_update => sub {
+            push @registered, $_[5] ? 'check' : 'create or update';
+            push @params, $_[3];
+        },
+        create => sub {
+            push @registered, 'create';
+            push @params, $_[1];
+        },
+    );
+    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');
+    is_deeply(
+        \@registered,
+        ['check', 'create'],
+        'and only gets created: it never joins a storage added in the meantime',
+    );
+    @registered = ();
+    @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');
+    is_deeply(\@registered, ['check', 'create or update'], 'and may join one of its name');
+    @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');
+    my @mocked = qw(
+        locked_disk_action verify_blockdev_path assert_disk_unused is_partition udevadm_trigger
+    );
+    $disk->unmock($_) for @mocked;
+};
+
+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_library_tests.pl b/src/test/run_san_library_tests.pl
index f7ae68d1..d961b87c 100755
--- a/src/test/run_san_library_tests.pl
+++ b/src/test/run_san_library_tests.pl
@@ -105,4 +105,31 @@ subtest 'LVM hints are optional cached display metadata' => sub {
     }
 };
 
+subtest 'the names of a held LUN have to mean the held device' => sub {
+    require PVE::Storage::SAN;
+    open(my $fh, '<', '/dev/null') or die "cannot open /dev/null - $!\n";
+    my $lun = { 'by-id' => '/dev/null', devpath => '/dev/null' };
+    my $check = sub {
+        eval { PVE::Storage::SAN::assert_same_device(@_) };
+        return $@;
+    };
+    is($check->($lun, $fh, '/dev/null'), '', 'same device behind all names');
+    like(
+        $check->({ %$lun, 'by-id' => '/dev/zero' }, $fh),
+        qr/'\/dev\/zero' changed/,
+        'by-id name',
+    );
+    like(
+        $check->({ %$lun, devpath => '/dev/zero' }, $fh),
+        qr/'\/dev\/zero' changed/,
+        'device path',
+    );
+    like(
+        $check->($lun, $fh, '/dev/zero'),
+        qr/'\/dev\/zero' changed/,
+        'name used for the commands',
+    );
+    like($check->($lun, $fh, '/dev/gone'), qr/'\/dev\/gone' changed/, 'name without a device');
+};
+
 done_testing();
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
new file mode 100755
index 00000000..9f243563
--- /dev/null
+++ b/src/test/run_san_nvme_tests.pl
@@ -0,0 +1,104 @@
+#!/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 });
+$disk->mock(device_opener => sub { undef });
+$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');
+my $model_link = '/dev/disk/by-id/nvme-NetApp_ONTAP_Controller_81Mkq_1';
+is_deeply(PVE::Storage::SAN::lun_for_device($model_link), $lun, 'any name of the namespace');
+{
+    # the name passes to another device while the LUNs are scanned
+    my $scanned = 0;
+    $san->mock(scan_luns => sub { $scanned = 1; [$lun] });
+    $san->mock(abs_path => sub { $_[0] eq $model_link && $scanned ? '/dev/nvme9n1' : $device });
+    eval { PVE::Storage::SAN::lun_for_device($model_link) };
+    like($@, qr/the device behind '\Q$model_link\E' changed/, 'a name that changed refuses');
+    $san->mock(scan_luns => sub { [$lun] });
+    $san->mock(abs_path => sub { $device });
+}
+$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_san_write_check_tests.pl b/src/test/run_san_write_check_tests.pl
new file mode 100755
index 00000000..a4210fba
--- /dev/null
+++ b/src/test/run_san_write_check_tests.pl
@@ -0,0 +1,205 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use lib qw(..);
+use Test::More;
+use Test::MockModule;
+use PVE::Storage::SAN;
+
+my $scan = Test::MockModule->new('PVE::Storage::SAN');
+my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+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');
+my $paths = sub {
+    {
+        paths => {
+            sdb => { wwid => '3600+abc', target => 'iqn.test' },
+            sdc => { wwid => '3600+abc', target => 'iqn.second' },
+            sdd => { wwid => '3600+other', target => 'iqn.other' },
+        },
+    };
+};
+$identity->mock(collect => $paths);
+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 custom)) {
+    $vgs = ['data'];
+    $cfg->{ids} = {
+        data => {
+            type => $type,
+            vgname => 'data',
+            shared => 1,
+            disable => 1,
+            nodes => { other => 1 },
+        },
+    };
+    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($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');
+{
+    # multipathd does not answer and udev knows the path by another identity
+    local $lun->{'iscsi-target'} = 'iqn.other';
+    $identity->mock(collect => sub { { paths => {} } });
+    like($check->(), qr/storage 'direct' serves images/, 'the target of the LUN itself counts');
+    $identity->mock(collect => $paths);
+}
+$cfg->{ids}->{direct}->{target} = 'iqn.test';
+$cfg->{ids}->{direct}->{content} = { none => 1 };
+is($check->(), '', 'connection-only storage permits use');
+
+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.dm-uuid-part1-mpath-3600+abc';
+like($check->(), qr/base volume/, 'a partition of the map as base 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 },
+    device_opener => 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' });
+$scan->mock(assert_lun_paths_unused => sub { push @order, 'paths'; die "path in use\n" });
+@order = ();
+eval {
+    PVE::Storage::LVMPlugin::lvm_create_volume_group(
+        '/dev/null',
+        'data',
+        1,
+        { exempt => 'new' },
+    );
+};
+like($@, qr/path in use/, 'a LUN that is in use through another path refuses');
+is_deeply(\@order, [qw(lock check paths)], 'before the first write');
+$scan->mock(assert_lun_paths_unused => sub { push @order, 'paths' });
+@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 paths 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..13058fe2 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' });
@@ -43,6 +46,7 @@ $lvm->mock(
             if $_[0] =~ m{/(?:uevent|size)/partition$};
         return $partitioned ? '1' : undef if $_[0] =~ m{/partition$};
         return $holder_uuid if $_[0] =~ m{/dm-5/dm/uuid$};
+        return 'part1-mpath-3600abc' if $map eq 'partition' && $_[0] =~ m{/uuid$};
         return $map ? 'mpath-3600abc' : undef if $_[0] =~ m{/uuid$};
         return $running ? 'running' : 'offline' if $_[0] =~ m{/state$};
         die "unexpected read $_[0]";
@@ -119,6 +123,10 @@ for my $case (
     is_deeply(\@probes, [], "$case->[0]: no device reads");
     is_deeply(\@writes, [], "$case->[0]: no writes");
 }
+reset_case();
+($map, $running) = ('partition', 0);
+is(create(), '', 'the partition of a map has the map as member, not its paths');
+is(scalar(@writes), 3, 'so it is set up like a local partition');
 
 reset_case();
 my $storage_checks = 0;
@@ -170,6 +178,44 @@ 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{the device behind '/dev/sda' changed},
+    'a device name that no longer means the held LUN is refused',
+);
+is_deeply(\@writes, [], 'changed device: no writes');
+$san->mock(assert_same_device => sub { });
+like(create(), qr/contains data \(PMBR, gpt\)/, 'a partitioned LUN that is no map is data too');
+is_deeply(\@writes, [], 'partitioned LUN: no writes');
+reset_case();
+my $opener = '4711 (kvm)';
+$disk->mock(device_opener => sub { $opener });
+$san->mock(assert_lun_unreferenced => sub { });
+my $storage = Test::MockModule->new('PVE::Storage');
+$storage->mock(config => sub { { ids => {} } });
+like(create(), qr/process 4711 \(kvm\) has it open/, 'a LUN that a process has open is refused');
+is_deeply(\@writes, [], 'open LUN: no writes');
+$opener = undef;
+is(create(), '', 'a LUN that no process has open is initialized');
+is(scalar(@writes), 3, 'unused LUN: initialized');
+reset_case();
+$signatures = [{ type => 'LVM2_member' }];
+$label = '/dev/sda: LVM2 PV';
+$pv = '/dev/sda:1024:test:aaaaaa-bbbb-cccc-dddd-eeee-ffff-gggggg:1';
+my $checked = 0;
+$san->mock(assert_same_device => sub { die "device changed\n" if ++$checked == 2 });
+like(create(), qr/device changed/, 'an existing volume group only counts on the held LUN');
+$san->unmock('assert_lun_unreferenced');
+$san->unmock('assert_same_device');
+$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] 44+ messages in thread

* [PATCH v6 storage 23/42] disks: lvm: refuse to destroy the volume group of a shared storage
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (21 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 22/42] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 24/42] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
                   ` (19 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 is configured with a volume
group of that name, also one restricted to other nodes, as this node
can see its LUN as well. 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 |  8 ++++++++
 src/test/disk_api_test.pm | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/PVE/API2/Disks/LVM.pm b/src/PVE/API2/Disks/LVM.pm
index 790891b3..9dfa8278 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;
@@ -265,6 +266,13 @@ __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' is"
+                        . " configured with a volume group of that name\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 474ad663..6fa2a2e3 100644
--- a/src/test/disk_api_test.pm
+++ b/src/test/disk_api_test.pm
@@ -244,4 +244,25 @@ subtest 'volume group creation leaves SAN locking to the LVM helper' => sub {
     $disk->unmock($_) for @mocked;
 };
 
+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] 44+ messages in thread

* [PATCH v6 storage 24/42] disks: allow wiping a SAN LUN that no storage uses
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (22 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 23/42] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 storage 25/42] api: scan: report the process that has a SAN LUN open Thomas Lamprecht
                   ` (18 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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. As for the
volume group creation, the wipe also refuses a LUN or partition that
a process of the node has open, and a LUN in use through another of
its paths. It removes the partition mappings of a multipath map and
writes through an exclusively opened descriptor. LVM keeps listing a
wiped PV in its hint file until two more LVM commands have run, and
the LUN list takes the volume groups from that file. So the wipe
removes the file afterwards and lets LVM write it again.

A LUN can also be given by its by-id or mapper name. Other devices,
including the kernel partitions of a LUN, are wiped as before, and
only by the names that were accepted so far. A by-id, mapper or dm-N
name could also select a logical volume or a partition that kpartx
maps for a multipath map, which the mount and holder checks do not
protect. The wipe of the map covers such a partition.

A device name can pass to another device while the wipe looks up the
LUN, waits for the lock or runs, on nodes where maps come and go
quickly. So, as for the volume group creation, the lookup checks the
requested name again after its scan, and the wipe holds the LUN open
by its by-id name. Before each command for a partition and before the
exclusive open, the names of the LUN must still lead to the held
device, and each partition must still belong to the LUN. A command
that takes a name still cannot be made atomic with its check.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Disks.pm          |  39 +++--
 src/PVE/Diskmanage.pm          |  44 ++++--
 src/PVE/Storage/LVMPlugin.pm   |   7 +
 src/PVE/Storage/SAN.pm         |  51 ++++++-
 src/test/Makefile              |   3 +-
 src/test/disk_api_test.pm      |  46 ++++++
 src/test/run_san_nvme_tests.pl |  16 +++
 src/test/run_san_wipe_tests.pl | 255 +++++++++++++++++++++++++++++++++
 8 files changed, 438 insertions(+), 23 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..16530429 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;
@@ -295,8 +297,9 @@ __PACKAGE__->register_method({
             node => get_standard_option('pve-node'),
             disk => {
                 type => 'string',
-                description => "Block device name",
-                pattern => '^/dev/[a-zA-Z0-9\/]+$',
+                description =>
+                    "Block device name. A SAN LUN can also be given by a by-id or mapper name.",
+                pattern => '^/dev/[a-zA-Z0-9._:+/-]+$',
             },
         },
     },
@@ -306,18 +309,38 @@ __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($param->{disk});
+        if (!$lun) {
+            # A by-id, mapper or dm-N name could also select a logical volume or a partition of a
+            # multipath map, which the checks for mounts and holders do not protect.
+            if ($param->{disk} !~ m{^/dev/[a-zA-Z0-9/]+$}) {
+                die "cannot wipe '$param->{disk}' - a name of this form is only accepted for a"
+                    . " SAN LUN\n";
+            }
 
-        my $held = PVE::Diskmanage::has_holder($disk);
-        die "disk/partition '${held}' has a holder\n" if $held;
+            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 $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 7c85f892..c7f7ea5c 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -1206,7 +1206,7 @@ sub device_opener {
 # 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");
@@ -1218,30 +1218,48 @@ sub wipe_blockdev {
     my $count = ($size < 200) ? $size : 200;
 
     my $to_wipe = [];
-    dir_glob_foreach(
-        "/sys/class/block/${devname}",
-        "${devname}.+",
-        sub {
-            my ($part) = @_;
-            push $to_wipe->@*, "/dev/${part}" if -b "/dev/${part}";
-        },
-    );
+    if (!defined($writepath)) {
+        dir_glob_foreach(
+            "/sys/class/block/${devname}",
+            "${devname}.+",
+            sub {
+                my ($part) = @_;
+                push $to_wipe->@*, "/dev/${part}" if -b "/dev/${part}";
+            },
+        );
+    }
 
     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 a32779cd..a0067040 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -162,6 +162,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
+# have run. 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 bf33e330..3d681fbb 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -3,11 +3,12 @@ package PVE::Storage::SAN;
 use v5.36;
 
 use Cwd qw(abs_path);
+use Fcntl qw(O_RDWR O_EXCL);
 use File::Basename qw(basename);
 
 use PVE::Cluster;
 use PVE::INotify;
-use PVE::Tools qw(file_read_firstline dir_glob_foreach);
+use PVE::Tools qw(file_read_firstline dir_glob_foreach run_command);
 
 use PVE::Diskmanage;
 use PVE::ISCSI::Topology;
@@ -296,6 +297,7 @@ sub assert_same_device($lun, $fh, @names) {
     }
 }
 
+# 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 [
@@ -342,4 +344,51 @@ sub assert_lun_paths_unused($lun) {
     }
 }
 
+sub wipe_lun($lun) {
+    assert_lun_unreferenced(PVE::Storage::config(), $lun);
+    assert_lun_paths_unused($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);
+    }
+    # a guest with the LUN as disk has it open, without being a holder or a storage reference
+    my $opener = PVE::Diskmanage::device_opener($device, @$parts);
+    die "cannot wipe '$device' - process $opener has it open\n" if defined($opener);
+    sysopen(my $fh, $lun->{'by-id'}, O_RDWR) or die "cannot open '$device' - $!\n";
+    # the name of a partition can pass to another device as well, since it got listed
+    my $check_part = sub($part) {
+        assert_same_device($lun, $fh, $device);
+        die "cannot wipe '$device' - '$part' is no longer one of its partitions\n"
+            if !grep { $_ eq $part } lun_partitions($lun)->@*;
+    };
+    for my $part (@$parts) {
+        $check_part->($part);
+        run_command(['wipefs', '--all', $part], timeout => 10);
+        if ($part =~ m{^/dev/dm-}) {
+            $check_part->($part);
+            run_command(['dmsetup', 'remove', '--retry', $part], timeout => 10);
+        }
+    }
+    assert_same_device($lun, $fh, $device);
+    # claim what was checked: the first descriptor stays open until the exclusive one is compared
+    sysopen(my $claim, $lun->{'by-id'}, O_RDWR | O_EXCL) or die "cannot claim '$device' - $!\n";
+    die "cannot wipe '$device' - the device behind '$lun->{'by-id'}' changed\n"
+        if (stat($claim))[6] != (stat($fh))[6];
+    close($fh);
+    my $path = '/proc/' . $$ . '/fd/' . fileno($claim);
+    PVE::Diskmanage::wipe_blockdev($device, $path);
+}
+
 1;
diff --git a/src/test/Makefile b/src/test/Makefile
index 0d866d91..279ba1ee 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -76,8 +76,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/disk_api_test.pm b/src/test/disk_api_test.pm
index 6fa2a2e3..2c73199a 100644
--- a/src/test/disk_api_test.pm
+++ b/src/test/disk_api_test.pm
@@ -265,4 +265,50 @@ subtest 'shared volume groups cannot be destroyed' => sub {
     is_deeply(\@writes, ['data'], 'node-local deletion still works');
 };
 
+subtest 'wipe takes by-id and mapper names for a LUN only' => sub {
+    my $san = Test::MockModule->new('PVE::Storage::SAN');
+    my $rpc = Test::MockModule->new('PVE::RPCEnvironment');
+    $rpc->mock(get => sub { bless {}, 'MultipathTestRPC' });
+    my ($lun, @wiped);
+    $san->mock(
+        lun_for_device => sub { $lun },
+        with_lun_lock => sub { push @wiped, $_[0]->{wwid} },
+        lun_paths => sub { [] },
+    );
+    $diskmanage_module->mock(
+        verify_blockdev_path => sub { $_[0] },
+        is_mounted => sub { },
+        has_holder => sub { },
+        wipe_blockdev => sub { push @wiped, $_[0] },
+        udevadm_trigger => sub { },
+    );
+    my $api = Test::MockModule->new('PVE::API2::Disks');
+    $api->mock(run_command => sub { });
+    my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    $lvm->mock(refresh_cached_pv_volume_groups => sub { });
+    my $wipe = sub($name) {
+        return
+            eval { PVE::API2::Disks->wipe_disk({ node => 'n1', disk => $name }); 1 } ? '' : $@;
+    };
+
+    my @other = qw(
+        /dev/dm-7 /dev/mapper/3600a-part1 /dev/disk/by-id/dm-uuid-part1-mpath-3600a
+        /dev/pve/vm-100-disk-0
+    );
+    for my $name (@other) {
+        like($wipe->($name), qr/only accepted for a SAN LUN/, "$name is refused");
+    }
+    is($wipe->('/dev/sdb1'), '', 'a partition by its kernel name is wiped');
+    $lun = { wwid => '3600a' };
+    is(
+        $wipe->('/dev/disk/by-id/dm-uuid-mpath-3600a'),
+        '',
+        'a LUN by the name of its map is wiped',
+    );
+    is_deeply(\@wiped, ['/dev/sdb1', '3600a'], 'nothing else got wiped');
+
+    my @mocked = qw(verify_blockdev_path is_mounted has_holder wipe_blockdev udevadm_trigger);
+    $diskmanage_module->unmock($_) for @mocked;
+};
+
 done_testing();
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
index 9f243563..51236f87 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 });
@@ -45,6 +46,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(
@@ -77,6 +79,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..18d0eee8
--- /dev/null
+++ b/src/test/run_san_wipe_tests.pl
@@ -0,0 +1,255 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+our (@open_modes, $claim_other);
+
+BEGIN {
+    *CORE::GLOBAL::sysopen = sub (*$$;$) {
+        push @open_modes, $_[2];
+        # lets a name mean another device by the time it is opened exclusively
+        my $exclusive = $_[2] & Fcntl::O_EXCL();
+        my $name = $exclusive && defined($claim_other) ? $claim_other : $_[1];
+        return @_ == 4
+            ? CORE::sysopen($_[0], $name, $_[2], $_[3])
+            : CORE::sysopen($_[0], $name, $_[2]);
+    };
+}
+
+use lib qw(..);
+use Cwd qw(abs_path);
+use Fcntl qw(O_RDWR O_EXCL);
+use File::Temp qw(tempfile);
+use Test::MockModule;
+use Test::More;
+use PVE::Storage::SAN;
+
+{
+    my ($fh, $name) = tempfile(UNLINK => 1);
+    my ($tmp, $read_name) = tempfile(UNLINK => 1);
+    open(my $read_fh, '<', $read_name) or die "cannot open '$read_name' - $!\n";
+    close($tmp);
+    my $pid = fork() // die "fork failed - $!\n";
+    if (!$pid) {
+        sleep(60);
+        exit(0);
+    }
+    like(PVE::Diskmanage::device_opener($name), qr/^$pid \(/, 'a process with the file open');
+    my $all = PVE::Diskmanage::device_openers([$name, $read_name, "$name-none"]);
+    is_deeply(
+        [sort keys %$all],
+        [sort map { abs_path($_) } $name, $read_name],
+        'each open file has a process, by its resolved path',
+    );
+    my $writers = PVE::Diskmanage::device_openers([$name, $read_name], writable => 1);
+    is_deeply([keys %$writers], [abs_path($name)], 'a file open for reading can be left out');
+    kill('TERM', $pid);
+    waitpid($pid, 0);
+    is(PVE::Diskmanage::device_opener($name), undef, 'the current process does not count');
+}
+
+my ($file, $name) = tempfile('san-wipe-XXXX', DIR => '.', UNLINK => 1);
+close($file);
+my $lun = { devpath => $name, '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 });
+my $path_used = 0;
+$san->mock(assert_lun_paths_unused => sub { die "path in use\n" if $path_used });
+$san->mock(lun_partitions => sub { [@parts] });
+$san->mock(dir_glob_foreach => sub { });
+my $canonical = $name;
+$disk->mock(verify_blockdev_path => sub { $canonical });
+$disk->mock(is_mounted => sub { 0 });
+$disk->mock(has_holder => sub { 0 });
+my $opener;
+$disk->mock(device_opener => sub { $opener });
+$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;
+$path_used = 1;
+eval { PVE::Storage::SAN::wipe_lun($lun) };
+like($@, qr/path in use/, 'a LUN in use through another path is refused');
+is_deeply([\@commands, \@open_modes], [[], []], 'before the device is opened or written');
+$path_used = 0;
+$opener = '4711 (kvm)';
+eval { PVE::Storage::SAN::wipe_lun($lun) };
+like($@, qr/process 4711 \(kvm\) has it open/, 'a LUN that a process has open is refused');
+is_deeply([\@commands, \@open_modes], [[], []], 'before the device is opened or written');
+$opener = undef;
+
+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');
+
+@parts = ('/dev/dm-1');
+@commands = ();
+eval { PVE::Storage::SAN::wipe_lun({ %$lun, devpath => '/dev/null' }) };
+like($@, qr{the device behind '/dev/null' changed}, 'a path that means another device refuses');
+is_deeply(\@commands, [], 'before a partition or the device is wiped');
+my $listed = 0;
+$san->mock(lun_partitions => sub { $listed++ ? [] : ['/dev/dm-1'] });
+eval { PVE::Storage::SAN::wipe_lun($lun) };
+like($@, qr{'/dev/dm-1' is no longer one of its partitions}, 'a partition name that passed on');
+is_deeply(\@commands, [], 'is not wiped');
+$san->mock(lun_partitions => sub { [@parts] });
+@parts = ();
+my $err = do {
+    local $claim_other = '/dev/zero';
+    eval { PVE::Storage::SAN::wipe_lun($lun) };
+    $@;
+};
+like(
+    $err,
+    qr{the device behind '\Q$name\E' changed},
+    'a by-id name that passed on before the claim',
+);
+is_deeply(\@commands, [], 'is not wiped either');
+$canonical = '/dev/null';
+eval { PVE::Storage::SAN::wipe_lun($lun) };
+like($@, qr{the device behind '/dev/null' changed}, 'a resolved name that no longer means the LUN');
+is_deeply(\@commands, [], 'refuses before a write as well');
+$canonical = $name;
+
+$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',
+);
+
+# the other paths of a LUN: sdd beside sdb without a map, both below the map dm-3
+$san->unmock('assert_lun_paths_unused');
+my ($mounted, %holders, $writers, $asked) = (undef, ());
+$disk->mock(is_mounted => sub { $_[0] eq '/dev/sdd' ? $mounted : undef });
+$san->mock(
+    dir_glob_foreach => sub {
+        my ($dir, $regex, $code) = @_;
+        $code->($_) for ($holders{$dir} // [])->@*;
+    },
+);
+$disk->mock(
+    device_openers => sub {
+        my ($devices, %param) = @_;
+        $asked = [$devices, $param{writable}];
+        return $writers // {};
+    },
+);
+$san->mock(abs_path => sub { $_[0] });
+my $path_lun = { %$lun, devpath => '/dev/sdb' };
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+is($@, '', 'unused paths pass');
+is_deeply($asked, [['/dev/sdd'], 1], 'writers on the other paths, multipathd only reads them');
+$mounted = '/dev/sdd1';
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+like($@, qr{the LUN is mounted through '/dev/sdd1'}, 'a mounted path or partition refuses');
+$mounted = undef;
+$holders{'/sys/class/block/sdd/holders'} = ['dm-3'];
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+like($@, qr{another block device uses the LUN through '/dev/sdd'}, 'a held path refuses');
+$holders{'/sys/class/block/sdd/holders'} = [];
+$holders{'/sys/class/block/sdd'} = ['sdd1'];
+$holders{'/sys/class/block/sdd1/holders'} = ['dm-7'];
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+like($@, qr{uses the LUN through '/dev/sdd1'}, 'so does a held partition of a path');
+$holders{'/sys/class/block/sdd1/holders'} = [];
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+is_deeply($asked->[0], ['/dev/sdd', '/dev/sdd1'], 'writers on the partitions of a path count');
+$holders{'/sys/class/block/sdb/holders'} = ['dm-3'];
+eval { PVE::Storage::SAN::assert_lun_paths_unused({ %$lun, devpath => '/dev/dm-3' }) };
+is($@, '', 'the map of the LUN holds its paths');
+%holders = ();
+$writers = { '/dev/sdd' => { pid => 4711, command => 'kvm' } };
+eval { PVE::Storage::SAN::assert_lun_paths_unused($path_lun) };
+like($@, qr{process 4711 \(kvm\) has the LUN open through '/dev/sdd'},
+    'a writer on a path refuses');
+
+done_testing();




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

* [PATCH v6 storage 25/42] api: scan: report the process that has a SAN LUN open
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (23 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 24/42] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 docs 26/42] storage: document the cluster-wide multipath management Thomas Lamprecht
                   ` (17 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

The LUN inventory shows a LUN as unused if no storage references it
and it has no signature. A guest can still have such a LUN as disk,
by its device path or from a third-party storage plugin. Wiping the
LUN or creating a volume group on it is then refused, as both check
for a process that has the device open. But the list gave no hint of
that.

Report a process that has the LUN open for writing, also through
another path of the LUN, and the virtual machine that the control
group of the process names. A process that only reads does not count:
the status query of an LVM storage reads its physical volumes every
few seconds, so their LUNs would show up as in use at times.

The list needs one pass over the open files of all processes. That
took 2 ms on an idle lab node and 106 ms with 1000 more processes that
have 64 files open each.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Storage/Scan.pm       | 14 ++++++++++
 src/PVE/CLI/pvesm.pm               |  2 +-
 src/PVE/Storage/SAN.pm             | 17 ++++++++++++-
 src/test/run_san_lun_scan_tests.pl | 41 ++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Storage/Scan.pm b/src/PVE/API2/Storage/Scan.pm
index 0e7667c8..586bfe53 100644
--- a/src/PVE/API2/Storage/Scan.pm
+++ b/src/PVE/API2/Storage/Scan.pm
@@ -527,6 +527,20 @@ __PACKAGE__->register_method({
                     type => 'string',
                     optional => 1,
                 },
+                'used-by-process' => {
+                    description => "A process of the node that has the device of the LUN open"
+                        . " for writing, as PID followed by the command name in parentheses. A"
+                        . " guest shows up like this if it has the LUN as disk by its device"
+                        . " path or from a third-party storage plugin.",
+                    type => 'string',
+                    optional => 1,
+                },
+                'used-by-guest' => {
+                    description =>
+                        "The ID of the virtual machine that this process belongs to.",
+                    type => 'integer',
+                    optional => 1,
+                },
                 wwid => {
                     description => "The LUN WWID.",
                     type => 'string',
diff --git a/src/PVE/CLI/pvesm.pm b/src/PVE/CLI/pvesm.pm
index 347fbffa..7b9d035b 100755
--- a/src/PVE/CLI/pvesm.pm
+++ b/src/PVE/CLI/pvesm.pm
@@ -745,7 +745,7 @@ our $cmddef = {
                 my ($data, $schema, $options) = @_;
                 my $columns =
                     [qw(devpath name size transport state paths-active paths-expected multipath
-                        usage vgname used-by-storage wwid)];
+                        usage vgname used-by-storage used-by-guest used-by-process wwid)];
                 PVE::CLIFormatter::print_api_result($data, $schema, $columns, $options);
             },
             $PVE::RESTHandler::standard_output_options,
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index 3d681fbb..c7717415 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -42,7 +42,7 @@ sub scan_luns($cfg) {
         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, %targets);
+    my (%storage, %expected, %vg_owner, %target_owner, %base_owner, %targets, %paths);
 
     for my $sid (sort keys %$derived) {
         for my $wwid (keys $derived->{$sid}->{wwids}->%*) {
@@ -105,6 +105,7 @@ sub scan_luns($cfg) {
             $row->{$key} //= $value if defined($value) && $value ne 'unknown';
         }
         for my $member (map { basename($_) } ($disk->{slaves} // [$disk->{devpath}])->@*) {
+            $paths{$wwid}->{"/dev/$member"} = 1;
             my $session = $sessions->{$member} // next;
             $targets{$wwid}->{ $session->{target} } = 1;
             $row->{'iscsi-target'} //= $session->{target};
@@ -146,7 +147,21 @@ sub scan_luns($cfg) {
         $add->($disk);
     }
     $add->($maps->{$_}, 1) for sort keys %$maps;
+    # A guest can have a LUN as disk by its device path or from a third-party storage plugin, also
+    # by one of its paths. The scans of LVM and udev only read a device, and are gone again a
+    # moment later.
+    my %devices = map { $_ => 1 } (map { $_->{devpath} } values %rows),
+        map { keys %$_ } values %paths;
+    my $openers = PVE::Diskmanage::device_openers([sort keys %devices], writable => 1);
     for my $row (values %rows) {
+        my ($opener) = map { $openers->{$_} // () } abs_path($row->{devpath}) // $row->{devpath},
+            sort keys(($paths{ $row->{wwid} } // {})->%*);
+        if ($opener) {
+            $row->{'used-by-process'} = "$opener->{pid} ($opener->{command})";
+            # a virtual machine runs in a control group of its own that is named after its ID
+            my $cgroup = file_read_firstline("/proc/$opener->{pid}/cgroup") // '';
+            $row->{'used-by-guest'} = int($1) if $cgroup =~ m{^0::/qemu\.slice/(\d+)\.scope$};
+        }
         if (defined($row->{'paths-active'})) {
             $row->{state} = PVE::Multipath::derive_health(
                 $row->{'paths-active'},
diff --git a/src/test/run_san_lun_scan_tests.pl b/src/test/run_san_lun_scan_tests.pl
index abfdfa28..1794af26 100755
--- a/src/test/run_san_lun_scan_tests.pl
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -58,7 +58,9 @@ $scan->redefine(
         $code->($_) for grep { /^$regex$/ } qw(sda sdb sdc sdd sde sdf dm-0 loop0 nvme0n1);
     },
 );
+my ($openers, @opener_query) = ({});
 $disk->mock(
+    device_openers => sub { @opener_query = @_; return $openers },
     get_disks => sub {
         ok($_[3], 'SAN inventory opts into iSCSI');
         @listed = sort $_[0]->@*;
@@ -113,6 +115,45 @@ is($row{'3600plain'}->{'used-by-storage'}, 'direct', 'a storage serving the LUNs
     my %plain = map { $_->{wwid} => $_ } PVE::Storage::SAN::scan_luns($cfg)->@*;
     is($plain{'3600plain'}->{'used-by-storage'}, undef, 'a connection storage does not');
 }
+{
+    # a process has a map open by the device it resolves to
+    $scan->mock(abs_path => sub { $_[0] eq '/dev/mapper/lun' ? '/dev/dm-0' : $_[0] });
+    my $cgroup = '0::/qemu.slice/100.scope';
+    $scan->mock(
+        file_read_firstline => sub {
+            return $_[0] eq '/proc/4242/cgroup' ? $cgroup : PVE::Tools::file_read_firstline(@_);
+        },
+    );
+    local $openers->{'/dev/dm-0'} = { pid => 4242, command => 'kvm' };
+    my %open = map { $_->{wwid} => $_ } PVE::Storage::SAN::scan_luns($cfg)->@*;
+    is($open{'3600map'}->{'used-by-process'}, '4242 (kvm)', 'a process with the map open');
+    is($open{'3600map'}->{'used-by-guest'}, 100, 'that belongs to a virtual machine');
+    ok(!exists($open{'3600plain'}->{'used-by-process'}), 'no process for the other LUN');
+    my ($devices, %param) = @opener_query;
+    is_deeply(
+        [sort @$devices],
+        [qw(/dev/mapper/lun /dev/sdb /dev/sdc /dev/sdd /dev/sdf)],
+        'asked once for all LUNs and their paths',
+    );
+    ok($param{writable}, 'a process that only reads a LUN does not use it');
+    {
+        local $openers->{'/dev/sdc'} = { pid => 4243, command => 'kvm' };
+        local $openers->{'/dev/sdf'} = { pid => 4244, command => 'kvm' };
+        my %path = map { $_->{wwid} => $_ } PVE::Storage::SAN::scan_luns($cfg)->@*;
+        is($path{'3600plain'}->{'used-by-process'}, '4243 (kvm)', 'a process with another path');
+        is($path{'3600map'}->{'used-by-process'}, '4242 (kvm)', 'the map before its paths');
+    }
+    my $schema = PVE::API2::Storage::Scan->map_method_by_name('sanlunscan')->{returns};
+    eval { PVE::JSONSchema::validate([values %open], $schema) };
+    is($@, '', 'rows with a process match the public schema');
+
+    $cgroup = '0::/system.slice/100.scope';
+    ($open{'3600map'}) = grep { $_->{wwid} eq '3600map' } PVE::Storage::SAN::scan_luns($cfg)->@*;
+    is($open{'3600map'}->{'used-by-process'}, '4242 (kvm)', 'a process of no guest');
+    ok(!exists($open{'3600map'}->{'used-by-guest'}), 'has no guest ID');
+    $scan->unmock('file_read_firstline');
+    $scan->mock(abs_path => sub { $_[0] });
+}
 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');




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

* [PATCH v6 docs 26/42] storage: document the cluster-wide multipath management
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (24 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 storage 25/42] api: scan: report the process that has a SAN LUN open Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 docs 27/42] storage: multipath: describe the use shown for an open LUN Thomas Lamprecht
                   ` (16 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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   | 301 +++++++++++++++++++++++++++++++++++
 pvesm.adoc                   |  18 ++-
 6 files changed, 331 insertions(+), 6 deletions(-)
 create mode 100644 pve-storage-multipath.adoc

diff --git a/pmxcfs.adoc b/pmxcfs.adoc
index 1128425..2ab3fb3 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..2dcc196 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.
 
+managed-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 multipath, through this option
+or set up by hand. 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..97b0979 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 `managed-multipath`.
 
 .Configuration Example (`/etc/pve/storage.cfg`)
 ----
diff --git a/pve-storage-lvm.adoc b/pve-storage-lvm.adoc
index b148832..66d896e 100644
--- a/pve-storage-lvm.adoc
+++ b/pve-storage-lvm.adoc
@@ -143,6 +143,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..ac8b4cf
--- /dev/null
+++ b/pve-storage-multipath.adoc
@@ -0,0 +1,301 @@
+[[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 *Guided Setup -> 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.
+  It then waits for the map on the node serving the web UI and sets *Expected
+  Paths* of that entry to the number of paths of the map, if that is at least
+  two. Existing entries and maps stay as they are; a map that was set up by
+  hand gets no entry, so check that the other nodes have it as well. 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, or for all nodes of
+  a reused connection storage. 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. Before the setup or the wipe writes to a
+LUN, the node checks for processes that have it open, also through another of
+its paths, for example a guest that uses it as a disk. This does not find every
+user: not one that opened the LUN through another device node, and none on other
+hosts. To keep a volume group that a LUN already holds, do not wipe the LUN: add
+the volume group under *Datacenter -> Storage -> Add -> LVM* with *Shared*
+enabled. 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 --managed-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. It lists the LUNs that {pve} manages or uses: those with an
+explicit entry, those of an iSCSI storage with *Multipath* enabled, and those
+that are the base volume of a storage or hold its volume group. Other maps of a
+node, for example the ones of a third-party storage plugin, are only counted
+under *Other Maps*; *Node -> SAN* lists them as well. The volume groups come
+from the hint file of LVM. While LVM has none, for example because it sees
+duplicate PVs, a node cannot tell which of its other maps hold the volume group
+of a storage and leaves them all out. A LUN that is only listed for its volume
+group then shows *Unknown* for that node, or is not listed if no node reports
+it.
+
+The *State* of a LUN is the worst state among its nodes. For a state other than
+*Optimal*, it names the nodes in that state, unless all nodes are in it. Nodes
+in *Unknown* do not count for it and are named after it. 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*, a
+degraded or failed LUN shows its usable and expected paths; expand it 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.
+
+The status report of a node is limited to 32 KiB, which is enough for about 180
+listed LUNs with typical names. A node with more reports `too many LUNs to
+report` and no LUNs: those that the configuration expects on it show *Unknown*
+for that node, and LUNs that only this node reports are missing from the list.
+
+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 as *Degraded* while its lost paths 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
+    }
+}
+----
+
+The generated configuration sets `auto_resize grow_only` for the growing of
+LUNs. `multipath` only has this setting for all maps of a node, so it also
+applies to maps that {pve} does not manage, for example the ones of a
+third-party storage plugin: they grow once all their paths have grown. To keep
+the resize manual on all nodes, add this to the overrides:
+
+----
+defaults {
+    auto_resize never
+}
+----
+
+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.
+. Wait until *Datacenter -> Storage -> SAN* shows the LUNs of these storages on
+  every node. Then 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 07a7917..f7de231 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 *Guided Setup* under
+*Datacenter -> Storage -> SAN* instead. It creates the storages that are needed
+and enables multipath for the LUN.
+
 
 Storage Pools
 ~~~~~~~~~~~~~
@@ -500,6 +504,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]
@@ -542,6 +548,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] 44+ messages in thread

* [PATCH v6 docs 27/42] storage: multipath: describe the use shown for an open LUN
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (25 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 docs 26/42] storage: document the cluster-wide multipath management Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 28/42] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
                   ` (15 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

The LUN list of a node names the virtual machine or process that has
a LUN open for writing, and has a column for the iSCSI target. Both
help to find out what a LUN of a third-party storage plugin belongs
to.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 pve-storage-multipath.adoc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pve-storage-multipath.adoc b/pve-storage-multipath.adoc
index ac8b4cf..722c4b1 100644
--- a/pve-storage-multipath.adoc
+++ b/pve-storage-multipath.adoc
@@ -218,6 +218,14 @@ of a storage and leaves them all out. A LUN that is only listed for its volume
 group then shows *Unknown* for that node, or is not listed if no node reports
 it.
 
+*Used By* under *Node -> SAN* names the storage that uses a LUN. Without one,
+it names the virtual machine or other process that has the LUN open for
+writing, for example a guest that has it as disk from a third-party storage
+plugin. Such a LUN can neither be wiped nor selected in a guided setup. A
+process that only reads the LUN is not shown, but a wipe is refused for it too.
+A column that is hidden by default shows the iSCSI target that a LUN is
+attached through.
+
 The *State* of a LUN is the worst state among its nodes. For a state other than
 *Optimal*, it names the nodes in that state, unless all nodes are in it. Nodes
 in *Unknown* do not count for it and are named after it. Hover over it for the




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

* [PATCH v6 manager 28/42] pvestatd: apply the multipath configuration and report the node status
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (26 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 docs 27/42] storage: multipath: describe the use shown for an open LUN Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 29/42] report: add the managed multipath configuration Thomas Lamprecht
                   ` (14 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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] 44+ messages in thread

* [PATCH v6 manager 29/42] report: add the managed multipath configuration
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (27 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 28/42] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 30/42] api: cluster: add the multipath endpoints Thomas Lamprecht
                   ` (13 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

The report shows multipath.conf, the WWID allow-list and the map
topology of a node, but not the configuration that Proxmox VE manages.
Add the LUN entries and the overrides file kept in /etc/pve, and the
drop-ins that pvestatd generates from them. 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 704001d11..bad0b890a 100644
--- a/PVE/Report.pm
+++ b/PVE/Report.pm
@@ -245,7 +245,10 @@ my $init_report_cmds = sub {
 
     if (cmd_exists('multipath')) {
         push @{ $report_def->{'block devices'}->{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] 44+ messages in thread

* [PATCH v6 manager 30/42] api: cluster: add the multipath endpoints
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (28 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 29/42] report: add the managed multipath configuration Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 31/42] api: nodes: expose the iSCSI status Thomas Lamprecht
                   ` (12 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 aaec3ec3d..1bb99f074 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -36,6 +36,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;
@@ -101,6 +102,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',
@@ -170,6 +176,7 @@ __PACKAGE__->register_method({
             { name => 'log' },
             { name => 'mapping' },
             { name => 'metrics' },
+            { name => 'multipath' },
             { name => 'notifications' },
             { name => 'nextid' },
             { name => 'options' },




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

* [PATCH v6 manager 31/42] api: nodes: expose the iSCSI status
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (29 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 30/42] api: cluster: add the multipath endpoints Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 32/42] ui: dc: add a SAN view Thomas Lamprecht
                   ` (11 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

From: Dietmar Maurer <dietmar@proxmox.com>

The web UI needs the initiator name of a node and its iSCSI targets and
sessions, to show how the node is connected to an array. Mount the
read-only iSCSI API at /nodes/{node}/iscsi for that.

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] 44+ messages in thread

* [PATCH v6 manager 32/42] ui: dc: add a SAN view
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (30 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 31/42] api: nodes: expose the iSCSI status Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 33/42] ui: storage: iscsi: add the multipath option Thomas Lamprecht
                   ` (10 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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.

A LUN state other than optimal names the nodes that report it, unless
all nodes of the LUN do. A tooltip has the path counts of all nodes. A
node can be in the state Unknown for a LUN, for example without a
current report or with multipath unavailable. Such a node does not count
for the state of the LUN, but is named after it. A LUN with a single
path reads "OK (1 path)" instead of optimal: it works, but has no path
to fail over to.

The LUN list has the LUNs that Proxmox VE manages or that a storage
builds on. A node can have many more maps, for example from a storage
plugin with one LUN per guest disk. The node list only counts these
other maps. The explicit multipath entries and the overrides file are
edited from the LUN list. Its Multipath column says whether an explicit
entry, a storage or nothing in Proxmox VE manages the multipath of a
LUN. A plain yes or no for an explicit entry would make healthy LUNs of
iSCSI storages look unprotected.

The node list has the iSCSI initiator names to copy for the access rules
of an array. 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             |  60 +++++
 www/manager6/Utils.js                |  19 ++
 www/manager6/dc/Config.js            |  23 +-
 www/manager6/dc/MultipathWwidEdit.js |  81 +++++++
 www/manager6/dc/SAN.js               | 350 +++++++++++++++++++++++++++
 6 files changed, 530 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 e8e2bd0b4..9f5beb5f1 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..1900386c3
--- /dev/null
+++ b/www/manager6/SANUtils.js
@@ -0,0 +1,60 @@
+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;
+    },
+
+    // Deselects the rows of a grid that the filters of its store hide. The buttons of a toolbar
+    // act on the selected row, which must not be one that a search does not show.
+    deselectHidden: function (grid) {
+        let selModel = grid.getSelectionModel();
+        let store = grid.getStore();
+        selModel.deselect(selModel.getSelection().filter((rec) => !store.contains(rec)));
+    },
+
+    // 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 c616ab9bc..64269755d 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1130,6 +1130,25 @@ 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}`,
+                        ),
+                    ),
+                );
+            // the browser has no clipboard API for a page that is not served securely
+            try {
+                navigator.clipboard.writeText(text).catch(fail);
+            } catch (err) {
+                fail(err);
+            }
+        },
+
         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..b32243fd9
--- /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 than expected shows the LUN as degraded, even after the kernel has 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..e8d3614f2
--- /dev/null
+++ b/www/manager6/dc/SAN.js
@@ -0,0 +1,350 @@
+Ext.define('pve-san-status', {
+    extend: 'Ext.data.Model',
+    fields: [
+        'id',
+        'kind',
+        'node',
+        'state',
+        'error',
+        'apply-error',
+        'time',
+        'iscsi-initiator-name',
+        'other-maps',
+        '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('Other Maps'),
+                        tooltip: gettext(
+                            'Maps of the node that the LUN list leaves out. They can still be in use, for example by a storage plugin.',
+                        ),
+                        dataIndex: 'other-maps',
+                        width: 110,
+                        // shown once a node has such maps
+                        hidden: true,
+                    },
+                    {
+                        text: gettext('Last Report'),
+                        dataIndex: 'time',
+                        width: 160,
+                        renderer: Proxmox.Utils.render_timestamp,
+                        hidden: true,
+                    },
+                ],
+            },
+            {
+                xtype: 'grid',
+                title: gettext('LUNs'),
+                itemId: 'luns',
+                store: lunStore,
+                flex: 3,
+                viewConfig: { enableTextSelection: true },
+                tbar: {
+                    overflowHandler: 'scroller',
+                    items: [
+                        { text: gettext('Add'), disabled: !canModify, handler: () => edit() },
+                        {
+                            xtype: 'proxmoxButton',
+                            text: gettext('Edit'),
+                            disabled: true,
+                            enableFn: (rec) => canEdit && !!rec.get('explicit'),
+                            handler: (button, event, rec) => edit(rec),
+                        },
+                        {
+                            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, event, rec) {
+                                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(),
+                                }),
+                        },
+                        '->',
+                        gettext('Search') + ':',
+                        ' ',
+                        {
+                            xtype: 'pveRecordSearchField',
+                            emptyText: gettext('Name, WWID, Storage'),
+                            searchFields: ['name', 'wwid', 'used-by-storage', 'multipath-storage'],
+                            targetStore: lunStore,
+                        },
+                    ],
+                },
+                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';
+                            }
+                            // a node in Unknown does not count for the state, it is named after it
+                            let unknown = nodes.filter(([, s]) => s === 'unknown').map(([n]) => n);
+                            let suffix =
+                                value !== 'unknown' && unknown.length
+                                    ? `, ${PVE.SANUtils.renderState('unknown')} (${Ext.htmlEncode(unknown.join(', '))})`
+                                    : '';
+                            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 - unknown.length
+                            ) {
+                                return PVE.SANUtils.renderState(value) + suffix;
+                            }
+                            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}${suffix}`;
+                            }
+                            return `${PVE.SANUtils.renderState(value)} (${names})${suffix}`;
+                        },
+                    },
+                    {
+                        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.mon(lunStore, 'refresh', () => PVE.SANUtils.deselectHidden(me.down('#luns')));
+        me.mon(me.rstore, 'load', () =>
+            me
+                .down('gridcolumn[dataIndex=other-maps]')
+                .setHidden(!me.rstore.getRange().some((rec) => rec.get('other-maps'))),
+        );
+        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] 44+ messages in thread

* [PATCH v6 manager 33/42] ui: storage: iscsi: add the multipath option
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (31 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 32/42] ui: dc: add a SAN view Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 34/42] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
                   ` (9 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 670077e05..7929a13b3 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -77,6 +77,15 @@ Ext.define('PVE.storage.IScsiInputPanel', {
 
     lunContent: 'images',
 
+    // Loading sets the value before its original value, so use the dirty state.
+    updateMultipathActivation: function () {
+        let me = this;
+        let field = me.down('field[name=managed-multipath]');
+        me.lookup('multipathActivation').setHidden(
+            me.isCreate || !field.getValue() || !field.isDirty(),
+        );
+    },
+
     onGetValues: function (values) {
         let me = this;
 
@@ -156,5 +165,39 @@ Ext.define('PVE.storage.IScsiInputPanel', {
             checked: true,
             fieldLabel: gettext('Use LUNs directly'),
         },
+        {
+            xtype: 'proxmoxcheckbox',
+            name: 'managed-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] 44+ messages in thread

* [PATCH v6 manager 34/42] ui: lvm: enable shared when a base storage is selected
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (32 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 33/42] ui: storage: iscsi: add the multipath option Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 35/42] ui: node: add SAN LUNs panel Thomas Lamprecht
                   ` (8 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

A volume group on a LUN of a base storage is reachable from every node
that uses the base storage. Without the shared flag, each node treats it
as a local volume group of its own. Allocations are then only serialized
per node, and a migration copies the disks as if they were local. The
checkbox is off by default and easy to miss. Selecting a base storage
checks it, and the admin can still uncheck it.

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 9308ef4eb..688130b19 100644
--- a/www/manager6/storage/LVMEdit.js
+++ b/www/manager6/storage/LVMEdit.js
@@ -211,6 +211,9 @@ Ext.define('PVE.storage.LVMInputPanel', {
 
                     vgNameField.setVisible(!!value);
                     vgNameField.setDisabled(!value);
+
+                    // a volume group on a LUN of a base storage is meant to be shared
+                    me.up('inputpanel').down('field[name=shared]').setValue(!!value);
                 },
             },
         },




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

* [PATCH v6 manager 35/42] ui: node: add SAN LUNs panel
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (33 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 34/42] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 36/42] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
                   ` (7 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

Show the LUNs that a node sees from a SAN under Node > SAN, separate
from the local disks, with the state of every path in the expanded row.
Admins no longer need "multipath -ll" or sysfs to check a node. A
degraded or failed LUN shows its usable and expected paths, as the
kernel removes a lost path after a while.

A node can see many more LUNs than Proxmox VE uses, for example from a
storage plugin with one LUN per guest disk. So the list has a search
field, which also matches the devices, WWPNs and addresses of the paths.
This way, the LUN of a path device named in the kernel log is easy to
find.

For a LUN not reached over iSCSI, such as a Fibre Channel LUN, Enable
Multipath opens the dialog of an explicit entry with the WWID filled in.
The entry applies to all nodes unless restricted, which the dialog
shows. 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     |  95 ++++++++++++++++
 www/manager6/node/Config.js  |  15 +++
 www/manager6/node/SANLuns.js | 202 +++++++++++++++++++++++++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 www/manager6/node/SANLuns.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 9f5beb5f1..a1d4d5493 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 1900386c3..564c87374 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -1,3 +1,47 @@
+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',
+        'paths-expected',
+        'path-list',
+        'usage',
+        'vgname',
+        'detail',
+        'used-by-storage',
+        'multipath',
+        'multipath-storage',
+        'iscsi-target',
+        'iscsi-lun',
+        // what identifies the paths, as text for the search
+        {
+            name: 'path-search',
+            depends: ['path-list'],
+            calculate: (data) =>
+                (data['path-list'] ?? [])
+                    .flatMap((path) => [
+                        path.device,
+                        path['host-wwpn'],
+                        path['target-wwpn'],
+                        path.address,
+                    ])
+                    .filter(Boolean)
+                    .join(' '),
+        },
+    ],
+});
+
 Ext.define('PVE.SANUtils', {
     singleton: true,
 
@@ -57,4 +101,55 @@ Ext.define('PVE.SANUtils', {
         let [icon, label] = display ?? ['question-circle faded', value];
         return `<i class="fa fa-fw fa-${icon}"></i> ${Ext.htmlEncode(label)}`;
     },
+
+    // The path counts tell why a LUN is degraded while all of its listed paths are usable: the
+    // kernel removes a lost path after a while.
+    renderLunState: function (value, metaData, rec) {
+        let state = PVE.SANUtils.lunState(value, rec.get('paths-total'));
+        let text = PVE.SANUtils.renderState(state);
+        if (['degraded', 'failed'].includes(state) && rec.get('paths-active') !== undefined) {
+            text += ` (${Ext.htmlEncode(PVE.SANUtils.pathCount(rec.data))})`;
+        }
+        return text;
+    },
+
+    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..c5b22f72f
--- /dev/null
+++ b/www/manager6/node/SANLuns.js
@@ -0,0 +1,202 @@
+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: 140,
+            renderer: PVE.SANUtils.renderLunState,
+        },
+        {
+            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;
+        let noLunsText = me.emptyText;
+        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 = {
+            overflowHandler: 'scroller',
+            items: [
+                { 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')),
+                    // the entry is for all nodes unless restricted, which the dialog shows
+                    handler: (button, event, rec) =>
+                        Ext.create('PVE.dc.MultipathWwidEdit', {
+                            wwid: rec.get('wwid'),
+                            isCreate: true,
+                            autoShow: true,
+                            apiCallDone: (success) => success && reload(),
+                        }),
+                },
+                '->',
+                gettext('Search') + ':',
+                ' ',
+                {
+                    xtype: 'pveRecordSearchField',
+                    emptyText: gettext('Name, WWID, Storage'),
+                    searchFields: [
+                        'name',
+                        'wwid',
+                        'used-by-storage',
+                        'vgname',
+                        'detail',
+                        'multipath-storage',
+                        'devpath',
+                        'path-search',
+                        'vendor',
+                        'model',
+                        'serial',
+                    ],
+                    targetStore: me.store,
+                    listeners: {
+                        // no hit for a search is no sign of a connection problem
+                        searchchange: (field, query) =>
+                            me.rendered &&
+                            me.setEmptyText(
+                                query ? gettext('No LUNs match the search.') : noLunsText,
+                            ),
+                    },
+                },
+            ],
+        };
+        me.callParent();
+        Proxmox.Utils.monStoreErrors(me, me.rstore);
+        me.mon(me.store, 'refresh', () => PVE.SANUtils.deselectHidden(me));
+        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] 44+ messages in thread

* [PATCH v6 manager 36/42] ui: node: san: wipe a LUN that no storage uses
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (34 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 35/42] ui: node: add SAN LUNs panel Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 37/42] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
                   ` (6 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 that the node does for 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      | 15 +++++++++
 www/manager6/window/SANLunWipe.js | 52 +++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 www/manager6/window/SANLunWipe.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index a1d4d5493..14020e8db 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 c5b22f72f..c26f9c6f3 100644
--- a/www/manager6/node/SANLuns.js
+++ b/www/manager6/node/SANLuns.js
@@ -158,6 +158,21 @@ Ext.define('PVE.node.SANLunList', {
                             apiCallDone: (success) => 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(),
+                        }),
+                },
                 '->',
                 gettext('Search') + ':',
                 ' ',
diff --git a/www/manager6/window/SANLunWipe.js b/www/manager6/window/SANLunWipe.js
new file mode 100644
index 000000000..ecf7c592b
--- /dev/null
+++ b/www/manager6/window/SANLunWipe.js
@@ -0,0 +1,52 @@
+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} using node "{1}"? All data on the LUN will be lost, for every host that accesses it!',
+                        ),
+                        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: `${gettext('Please enter the ID to confirm')} (${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] 44+ messages in thread

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

From: Dietmar Maurer <dietmar@proxmox.com>

The LUN list cannot show how a node is connected to an iSCSI target. Add
a view below 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. If open-iscsi is not installed, the view says
so instead of showing an empty tree.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
[TL: keep the view read-only, without rescan, logout, record removal
 and session details; add the search field; 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 | 150 ++++++++++++++++++++++++++++++
 4 files changed, 170 insertions(+), 7 deletions(-)
 create mode 100644 www/manager6/node/ISCSITargets.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 14020e8db..4a6c8af72 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 564c87374..9f11aa0f7 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -97,6 +97,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..23cb7d0ff
--- /dev/null
+++ b/www/manager6/node/ISCSITargets.js
@@ -0,0 +1,150 @@
+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);
+                        me.sessions = res.result.data;
+                        me.updateTree();
+                    },
+                });
+            },
+        });
+    },
+
+    // Shows the loaded portals that match the search text, in one of their own values or in a
+    // device of their session, below their targets.
+    updateTree: function () {
+        let me = this;
+        if (!me.sessions) {
+            return;
+        }
+        let query = (me.down('pveRecordSearchField').getValue() ?? '').toLowerCase();
+        let matches = (row) =>
+            !query ||
+            [row.target, row.portal, row['used-by-storage'], ...row.devices.map((d) => d.devpath)]
+                .filter(Boolean)
+                .some((value) => value.toLowerCase().includes(query));
+        let targets = {};
+        for (let row of me.sessions.filter(matches)) {
+            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 = {
+            overflowHandler: 'scroller',
+            items: [
+                { 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()),
+                },
+                ' ',
+                gettext('Search') + ':',
+                ' ',
+                {
+                    xtype: 'pveRecordSearchField',
+                    emptyText: gettext('Target, Portal, Storage'),
+                    listeners: { searchchange: () => me.updateTree() },
+                },
+            ],
+        };
+        me.callParent();
+    },
+});




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

* [PATCH v6 manager 38/42] ui: dc: san: add a guided setup for shared LVM on iSCSI
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (36 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 37/42] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 39/42] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
                   ` (4 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 setup 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. Its menu is named Guided Setup, as
in the documentation, so that it is not taken for an Add menu or button.
Continuing from the target step creates or reuses the connection storage
before the confirm step, so the target step says so.

The menu needs Datastore.Allocate. It also needs Datastore.Audit or
Datastore.AllocateSpace, as the setup reads the storage list and the
LUNs of the connection storage.

The LUN list comes from the node serving the web UI, and a LUN that a
storage uses cannot be selected. For a shared storage it matters whether
the other nodes see the LUN as well. So the setup ends with the state of
the LUN on each node of the storage, from the cluster-wide status. Nodes
set up a new LUN with their next status updates, so for the first minute
a node without the LUN shows as pending and not as 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                        |  25 +-
 www/manager6/storage/wizard/IScsi.js          | 274 ++++++++++++++++++
 www/manager6/storage/wizard/LunSelect.js      | 156 ++++++++++
 www/manager6/storage/wizard/NodeIdentities.js |  83 ++++++
 www/manager6/storage/wizard/Wizard.js         | 184 ++++++++++++
 www/manager6/window/SANLunState.js            | 111 +++++++
 7 files changed, 837 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 4a6c8af72..09a02a9c4 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				\
@@ -385,6 +386,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 e8d3614f2..9255d2f6a 100644
--- a/www/manager6/dc/SAN.js
+++ b/www/manager6/dc/SAN.js
@@ -50,9 +50,15 @@ 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'];
+        // the setups also read the storage list and the LUNs of the connection storage
+        let storageCaps = allCaps.storage;
+        let canSetup =
+            !!storageCaps['Datastore.Allocate'] &&
+            !!(storageCaps['Datastore.Audit'] || storageCaps['Datastore.AllocateSpace']);
         me.rstore = Ext.create('Proxmox.data.UpdateStore', {
             storeid: 'dc-san-status',
             model: 'pve-san-status',
@@ -105,6 +111,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('Guided Setup'),
+                disabled: !canSetup,
+                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..94d914092
--- /dev/null
+++ b/www/manager6/storage/wizard/IScsi.js
@@ -0,0 +1,274 @@
+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',
+            'managed-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;
+            // the step does not come back, the cluster status of its initiator names is not needed
+            me.down('pveStorageWizardNodeIdentities').rstore.stopUpdate();
+            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['managed-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: gettext('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..dbf789f4e
--- /dev/null
+++ b/www/manager6/storage/wizard/LunSelect.js
@@ -0,0 +1,156 @@
+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 inUse = (row) => row['used-by-storage'];
+        let updateSelection = function () {
+            let row = me.getSelection();
+            me.down('#selection').setValue(row && !inUse(row) ? 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 that is in use cannot be selected. A LUN with data that is no longer needed 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) => (inUse(rec.data) ? 'x-item-disabled' : ''),
+                },
+                listeners: {
+                    beforeselect: (sm, rec) => !inUse(rec.data),
+                    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: 140,
+                        renderer: PVE.SANUtils.renderLunState,
+                    },
+                    {
+                        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..1f3975b75
--- /dev/null
+++ b/www/manager6/storage/wizard/Wizard.js
@@ -0,0 +1,184 @@
+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 () {
+                // the storage is added, also if the setup got closed in the meantime
+                if (me.destroyed) {
+                    return;
+                }
+                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 takes precedence, also for 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] 44+ messages in thread

* [PATCH v6 manager 39/42] ui: dc: san: add a guided setup for shared LVM on Fibre Channel
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (37 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 38/42] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 40/42] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
                   ` (3 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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. The entry offers SCSI LUNs only. An NVMe/FC namespace uses
the native multipath of the kernel and has no storage that connects it,
so the cluster-wide status could not show its state on the nodes.

The setup enables multipath for the LUN if needed, so its menu entry
needs Sys.Modify as well. Then the setup creates the volume group
through the node serving the web UI and adds the shared LVM storage
itself. The node disk API would add the storage for all nodes and
without the snapshot setting. Before it changes anything, the setup
checks that the storage ID is free, as it cannot create the volume group
a second time.

As the setup adds the storage, it waits for the volume group task on its
own, not in a task window. Closing a task window would end the setup
with a volume group and no storage. For the same reason, the setup
cannot be closed until the wait is over. If the task state cannot be
read for a while, the setup ends and says how to add the storage by
hand, as the task may still succeed and must not be started again.

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

Nodes do not scan for a LUN that gets mapped to them after their login
to the array, so the setup points to the rescan of the Fibre Channel
hosts.

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 | 175 ++++++++++++++++++++
 www/manager6/storage/wizard/LunSelect.js    |  23 ++-
 www/manager6/storage/wizard/Wizard.js       | 131 ++++++++++++++-
 www/manager6/window/SANLunState.js          |  10 +-
 6 files changed, 331 insertions(+), 14 deletions(-)
 create mode 100644 www/manager6/storage/wizard/FibreChannel.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 09a02a9c4..1644e1d41 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -390,6 +390,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 9255d2f6a..165411314 100644
--- a/www/manager6/dc/SAN.js
+++ b/www/manager6/dc/SAN.js
@@ -111,9 +111,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,
@@ -125,7 +126,7 @@ Ext.define('PVE.dc.SANView', {
             {
                 text: gettext('Guided Setup'),
                 disabled: !canSetup,
-                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..200e7d83a
--- /dev/null
+++ b/www/manager6/storage/wizard/FibreChannel.js
@@ -0,0 +1,175 @@
+PVE.storage.wizard.createFC = function (wizard, values, lun) {
+    let fail = (response) => wizard.showError(response.htmlStatus);
+    let create = function (row) {
+        if (wizard.destroyed) {
+            return;
+        }
+        // the request starts the task that waitForTask() then waits for, so keep the setup open
+        let keepOpen = () => false;
+        wizard.on('beforeclose', keepOpen);
+        Proxmox.Utils.API2Request({
+            url: `/nodes/${Proxmox.NodeName}/disks/lvm`,
+            method: 'POST',
+            params: { name: values.vgname, device: row['by-id'] || row.devpath },
+            waitMsgTarget: wizard,
+            callback: () => wizard.un('beforeclose', keepOpen),
+            failure: fail,
+            success: function (response) {
+                if (wizard.destroyed) {
+                    return;
+                }
+                let addStorage = () =>
+                    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 lost = (status) =>
+                    wizard.stopWithError(
+                        status +
+                            '<br>' +
+                            gettext(
+                                'Could not read the task status. The volume group creation task may still be running. Check its log under Node > Task History. If it succeeds, add the volume group under Datacenter > Storage > Add > LVM with Shared enabled.',
+                            ),
+                    );
+                let message = gettext('Creating the volume group...');
+                wizard.waitForTask(response.result.data, message, addStorage, lost);
+            },
+        });
+    };
+    let hasMultipath = (row) => ['manual', 'storage', 'unmanaged'].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 still sets the expected paths before
+    // it creates the volume group.
+    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: once the volume
+    // group exists, the setup cannot create it again.
+    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 dbf789f4e..0a6d5c4a4 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 },
         ]);
@@ -68,6 +72,15 @@ Ext.define('PVE.storage.wizard.LunSelect', {
                     'A LUN that is in use cannot be selected. A LUN with data that is no longer needed 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,
@@ -146,7 +159,15 @@ 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'].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 1f3975b75..2affda528 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,65 @@ Ext.define('PVE.storage.wizard.SAN', {
         Ext.Msg.alert(gettext('Error'), message);
     },
 
+    // Waits for a task with the setup masked and continues with next() once it succeeded. A task
+    // window of its own could be closed while the task runs, which would end the setup there. The
+    // setup cannot be closed during the wait either, for example with the Escape key.
+    // If the state of the task cannot be read for some time, lost() gets the error: the task may
+    // still be running then, so the setup must not start it again.
+    waitForTask: function (upid, message, next, lost) {
+        let me = this;
+        let task = Proxmox.Utils.parse_task_upid(upid);
+        let failures = 0;
+        let keepOpen = () => false;
+        let done = function (error) {
+            if (me.destroyed) {
+                return;
+            }
+            me.un('beforeclose', keepOpen);
+            me.setLoading(false);
+            if (error === undefined) {
+                next();
+            } else {
+                me.showError(error);
+            }
+        };
+        let poll = function () {
+            if (me.destroyed) {
+                return;
+            }
+            Proxmox.Utils.API2Request({
+                url: `/nodes/${task.node}/tasks/${encodeURIComponent(upid)}/status`,
+                method: 'GET',
+                failure: function (response) {
+                    if (me.destroyed) {
+                        return;
+                    }
+                    if (++failures < 5) {
+                        Ext.defer(poll, 2000);
+                        return;
+                    }
+                    me.un('beforeclose', keepOpen);
+                    me.setLoading(false);
+                    lost(response.htmlStatus);
+                },
+                success: function (response) {
+                    failures = 0;
+                    let { status, exitstatus } = response.result.data;
+                    if (status !== 'stopped') {
+                        Ext.defer(poll, 1000);
+                        return;
+                    }
+                    let result = Proxmox.Utils.parse_task_status(exitstatus);
+                    let failed = result === 'error' || result === 'unknown';
+                    done(failed ? Ext.htmlEncode(exitstatus) : undefined);
+                },
+            });
+        };
+        me.on('beforeclose', keepOpen);
+        me.setLoading(message);
+        poll();
+    },
+
     volumeSettings: function () {
         let me = this;
         let value = (name) => me.down(`field[name=${name}]`).getValue();
@@ -35,7 +102,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,
         };
     },
 
@@ -63,6 +136,7 @@ Ext.define('PVE.storage.wizard.SAN', {
                 Ext.create('PVE.window.SANLunState', {
                     wwid,
                     storage: values.storage,
+                    fc: me.wizardType === 'fc',
                     autoShow: true,
                 });
             },
@@ -70,11 +144,18 @@ Ext.define('PVE.storage.wizard.SAN', {
     },
 
     multipathSummary: function (lun) {
+        let me = this;
         // an explicit entry takes precedence, also for 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 () {
@@ -82,7 +163,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],
@@ -94,6 +174,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 })));
@@ -104,11 +187,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);
@@ -130,13 +221,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,
             {
@@ -171,14 +284,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] 44+ messages in thread

* [PATCH v6 manager 40/42] ui: storage: point the iSCSI and LVM add dialogs to the SAN view
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (38 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 39/42] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 41/42] ui: san: show the guest or process that has a LUN open Thomas Lamprecht
                   ` (2 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 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 that names the SAN view to the add dialogs of iSCSI and LVM,
which stay as they are for attaching existing targets and volume groups.
The dialog that creates a volume group under Node > Disks gets the note
as well. On a SAN LUN, its Add Storage option adds a shared storage for
all nodes, but no multipath entry. So for a Fibre Channel LUN without a
map, the volume group lands on a single path.

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

diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
index 9f11aa0f7..e972a5072 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -138,6 +138,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/node/LVM.js b/www/manager6/node/LVM.js
index 11b03612d..9c4f42694 100644
--- a/www/manager6/node/LVM.js
+++ b/www/manager6/node/LVM.js
@@ -42,6 +42,9 @@ Ext.define('PVE.node.CreateLVM', {
                     fieldLabel: gettext('Add Storage'),
                     value: '1',
                 },
+                PVE.SANUtils.sanViewNote(
+                    gettext('To set up shared LVM on a SAN LUN, use Guided Setup in {0}.'),
+                ),
             ],
         });
 
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 439cfeb88..979f34cfa 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -154,6 +154,11 @@ Ext.define('PVE.panel.StorageBase', {
             me.advancedColumn1 = [];
         }
 
+        // 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 7929a13b3..c20aa2896 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -77,6 +77,9 @@ Ext.define('PVE.storage.IScsiInputPanel', {
 
     lunContent: 'images',
 
+    // TRANSLATORS: "Guided Setup" 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 Guided Setup 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 688130b19..d3f068166 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: "Guided Setup" 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 Guided Setup in {0}.'),
+
     onGetValues: function (values) {
         let me = this;
 




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

* [PATCH v6 manager 41/42] ui: san: show the guest or process that has a LUN open
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (39 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 40/42] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18  6:52 ` [PATCH v6 manager 42/42] ui: node: san: add a column for the iSCSI target of a LUN Thomas Lamprecht
  2026-11-18 20:28 ` superseded: [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

A LUN that a guest uses by its device path, or through a third-party
storage plugin, showed up as unused or with the volume group that the
guest created on it. The LUN inventory reports the process that has the
device open for writing and the virtual machine of that process. Show
the guest, or else the process, in the Used By column. Such a LUN can
neither be wiped nor selected in a guided setup, as the backend refuses
both.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/SANUtils.js                 | 6 ++++++
 www/manager6/node/SANLuns.js             | 6 +++++-
 www/manager6/storage/wizard/LunSelect.js | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/www/manager6/SANUtils.js b/www/manager6/SANUtils.js
index e972a5072..07cdd9b3d 100644
--- a/www/manager6/SANUtils.js
+++ b/www/manager6/SANUtils.js
@@ -20,6 +20,8 @@ Ext.define('pve-san-lun', {
         'vgname',
         'detail',
         'used-by-storage',
+        'used-by-guest',
+        'used-by-process',
         'multipath',
         'multipath-storage',
         'iscsi-target',
@@ -123,6 +125,10 @@ Ext.define('PVE.SANUtils', {
     usageText: function (row) {
         return (
             row['used-by-storage'] ||
+            // also if the LUN has a volume group, which then is one of the guest
+            (row['used-by-guest'] && `VM ${row['used-by-guest']}`) ||
+            (row['used-by-process'] &&
+                Ext.String.format(gettext('Process {0}'), row['used-by-process'])) ||
             row.vgname ||
             row.detail ||
             {
diff --git a/www/manager6/node/SANLuns.js b/www/manager6/node/SANLuns.js
index c26f9c6f3..e55bdf1bd 100644
--- a/www/manager6/node/SANLuns.js
+++ b/www/manager6/node/SANLuns.js
@@ -164,7 +164,9 @@ Ext.define('PVE.node.SANLunList', {
                     iconCls: 'fa fa-eraser',
                     disabled: true,
                     enableFn: (rec) =>
-                        Proxmox.UserName === 'root@pam' && !rec.get('used-by-storage'),
+                        Proxmox.UserName === 'root@pam' &&
+                        !rec.get('used-by-storage') &&
+                        !rec.get('used-by-process'),
                     handler: (button, event, rec) =>
                         Ext.create('PVE.window.SANLunWipe', {
                             node: me.nodename,
@@ -183,6 +185,8 @@ Ext.define('PVE.node.SANLunList', {
                         'name',
                         'wwid',
                         'used-by-storage',
+                        'used-by-guest',
+                        'used-by-process',
                         'vgname',
                         'detail',
                         'multipath-storage',
diff --git a/www/manager6/storage/wizard/LunSelect.js b/www/manager6/storage/wizard/LunSelect.js
index 0a6d5c4a4..7b4986136 100644
--- a/www/manager6/storage/wizard/LunSelect.js
+++ b/www/manager6/storage/wizard/LunSelect.js
@@ -51,7 +51,7 @@ Ext.define('PVE.storage.wizard.LunSelect', {
             proxy: { type: 'proxmox', url: `/api2/json/nodes/${Proxmox.NodeName}/scan/san-luns` },
         });
         me.store = Ext.create('Proxmox.data.DiffStore', { rstore: me.rstore });
-        let inUse = (row) => row['used-by-storage'];
+        let inUse = (row) => row['used-by-storage'] || row['used-by-process'];
         let updateSelection = function () {
             let row = me.getSelection();
             me.down('#selection').setValue(row && !inUse(row) ? row.wwid : '');




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

* [PATCH v6 manager 42/42] ui: node: san: add a column for the iSCSI target of a LUN
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (40 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 41/42] ui: san: show the guest or process that has a LUN open Thomas Lamprecht
@ 2026-11-18  6:52 ` Thomas Lamprecht
  2026-11-18 20:28 ` superseded: [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18  6:52 UTC (permalink / raw)
  To: pve-devel

The inventory reports the target a LUN is attached through, but the
list did not show it. The name tells where a LUN comes from, which
helps most with an array or a storage plugin that exports one target
per volume and names it after that volume. Hidden by default, the
search covers it either way.

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

diff --git a/www/manager6/node/SANLuns.js b/www/manager6/node/SANLuns.js
index e55bdf1bd..2c55ba23f 100644
--- a/www/manager6/node/SANLuns.js
+++ b/www/manager6/node/SANLuns.js
@@ -96,6 +96,13 @@ Ext.define('PVE.node.SANLunList', {
             width: 100,
             renderer: PVE.SANUtils.renderSanTransport,
         },
+        {
+            text: gettext('Target'),
+            dataIndex: 'iscsi-target',
+            flex: 2,
+            hidden: true,
+            renderer: Ext.htmlEncode,
+        },
         { text: 'LUN', dataIndex: 'iscsi-lun', width: 60, hidden: true },
         {
             text: gettext('Vendor'),
@@ -191,6 +198,7 @@ Ext.define('PVE.node.SANLunList', {
                         'detail',
                         'multipath-storage',
                         'devpath',
+                        'iscsi-target',
                         'path-search',
                         'vendor',
                         'model',




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

* superseded: [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM
  2026-11-18  6:52 [PATCH v6 cluster,storage,docs,manager 00/42] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
                   ` (41 preceding siblings ...)
  2026-11-18  6:52 ` [PATCH v6 manager 42/42] ui: node: san: add a column for the iSCSI target of a LUN Thomas Lamprecht
@ 2026-11-18 20:28 ` Thomas Lamprecht
  42 siblings, 0 replies; 44+ messages in thread
From: Thomas Lamprecht @ 2026-11-18 20:28 UTC (permalink / raw)
  To: pve-devel

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




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

end of thread, other threads:[~2026-11-18 20:34 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal