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 C1E7F1FF0C0 for ; Wed, 04 Nov 2026 20:05:10 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B8A5121735; Wed, 04 Nov 2026 20:04:00 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH e2e-tests 06/38] lib: pveinstance: look up disks by their SCSI serial Date: Wed, 4 Nov 2026 20:03:13 +0100 Message-ID: <20261104190345.2573464-7-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261104190345.2573464-1-m.koeppl@proxmox.com> References: <20261104190345.2573464-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793819033781 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.224 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: G35OMPH5SHX6YDVOM3WKEBJ34XNVKEHU X-Message-ID-Hash: G35OMPH5SHX6YDVOM3WKEBJ34XNVKEHU X-MailFrom: m.koeppl@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: The disk list of the API reports the serial from udev's ID_SERIAL_SHORT. For QEMU SCSI disks, udev derives that from the device identifier, which is the drive name such as 'drive-scsi1', not the serial the plan set. get_disk_by_serial() could therefore never find a disk by the serial a plan assigned to it. Similarly to setup-zfs-storage.sh, look the disk up by ID_SCSI_SERIAL instead. Signed-off-by: Michael Köppl --- Could be fixed by [0], but that might be better to postpone for a major version. [0] https://lore.proxmox.com/pve-devel/20261028190713.2788477-1-m.koeppl@proxmox.com Proxmox/Test/PVEInstance.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Proxmox/Test/PVEInstance.pm b/Proxmox/Test/PVEInstance.pm index 7f82171..dc40489 100644 --- a/Proxmox/Test/PVEInstance.pm +++ b/Proxmox/Test/PVEInstance.pm @@ -28,16 +28,19 @@ sub new_local { return $class->SUPER::new($nodename, $config, 8006, 'PVEAuthCookie'); } +# Return the device node of the SCSI disk the plan gave the serial $serial, or undef if there is +# none. sub get_disk_by_serial { my ($self, $serial) = @_; - my $node = $self->get_nodename(); - my $res = $self->client()->get("nodes/$node/disks/list", {}); + my ($out) = + $self->run_command('for disk in /dev/sd?; do' + . ' echo "$disk $(udevadm info --query=property --name="$disk"' + . ' | sed -n "s/^ID_SCSI_SERIAL=//p")"; done'); - for my $item ($res->@*) { - if ($item->{serial} eq $serial) { - return $item->{devpath}; - } + for my $line (split(/\n/, $out // '')) { + my ($dev, $dev_serial) = split(/\s+/, $line, 2); + return $dev if defined($dev_serial) && $dev_serial eq $serial; } return undef; -- 2.47.3