From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 2DC3D1FF0ED for ; Fri, 31 Jul 2026 12:22:55 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1016521627; Fri, 31 Jul 2026 12:22:05 +0200 (CEST) From: Dietmar Maurer To: pve-devel@lists.proxmox.com Subject: [RFC pve-storage 01/27] diskmanage: collect disk transport type from lsblk Date: Fri, 31 Jul 2026 12:21:30 +0200 Message-ID: <20260731102156.3947857-2-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260731102156.3947857-1-dietmar@proxmox.com> References: <20260731102156.3947857-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.750 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: DEHD7NK7Z6BSROYCHUTPQHBT7HVAQAPA X-Message-ID-Hash: DEHD7NK7Z6BSROYCHUTPQHBT7HVAQAPA X-MailFrom: dietmar@zilli.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Expose which bus a disk is attached with (sata, sas, fc, nvme, usb) in the disk list. This allows telling SAN-attached LUNs apart from local disks, which the storage wizard needs when listing candidate devices for a shared LVM volume group. Signed-off-by: Dietmar Maurer --- 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 e707a9e..e64a391 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 bus type the disk is attached with ' + . '(for example sata, sas, fc, nvme, usb).', + 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 d9ce0d0..c04408e 100644 --- a/src/PVE/Diskmanage.pm +++ b/src/PVE/Diskmanage.pm @@ -174,7 +174,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"; }); @@ -191,6 +191,7 @@ sub get_lsblk_info { $_->{path} => { parttype => $_->{parttype}, fstype => $_->{fstype}, + tran => $_->{tran}, } } @{$list} }; @@ -625,6 +626,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 a4a1c4c..26d0d17 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 0000000..cae9819 --- /dev/null +++ b/src/test/disk_tests/sas/lsblk @@ -0,0 +1,5 @@ +{ + "blockdevices": [ + {"path":"/dev/sda", "parttype":null, "fstype":null, "tran":"sas"} + ] +} -- 2.47.3