From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 797BC1FF0EA for ; Thu, 13 Aug 2026 13:13:41 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 55F1F21581; Thu, 13 Aug 2026 13:13:40 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 13 Aug 2026 13:13:34 +0200 Message-Id: Subject: Re: [PATCH qemu-server v3 2/3] add new classify_drive_file utility From: "Thomas Ellmenreich" To: "Elias Huhsovitz" , X-Mailer: aerc 0.20.0 References: <20260812121327.145140-1-t.ellmenreich@proxmox.com> <20260812121327.145140-3-t.ellmenreich@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786619597736 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.763 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: 2Y5T65BVHF26SQCLAAYLQVFOZS52GMPY X-Message-ID-Hash: 2Y5T65BVHF26SQCLAAYLQVFOZS52GMPY X-MailFrom: t.ellmenreich@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: Thank you for having tested this! On Thu Aug 13, 2026 at 12:50 PM CEST, Elias Huhsovitz wrote: > Testing > ------- > I tested this using qm create with all affected drive types, e.g., > qm create =20 > --ide2 none,media=3Dcrom | cdrom | etc=20 > --scsi0 local-lvm:5 | etc > > and then destroying them using > qm destroy --purge > > It worked as intended. > > Small note > ---------- > Small note inline, but no change necessary IMHO. > Therefore: > > Reviewed-by: Elias Huhsovitz > Tested-by: Elias Huhsovitz [snip] >> +# Tries to classify the drive file as either 'none', 'cdrom', 'absolute= ' >> +# or 'volume'. In all other cases it will return 'unknown'. >> +sub classify_drive_file { >> + my ($volid) =3D @_; >> + >> + return 'unknown' if !$volid; >> + >> + if ($volid eq 'none') { >> + return 'none'; >> + } >> + >> + if ($volid eq 'cdrom') { >> + return 'cdrom'; >> + } >> + >> + if ($volid =3D~ m|^/|) { >> + return 'absolute'; >> + } >> + >> + return PVE::Storage::parse_volume_id($volid, 1) >> + ? 'volume' >> + : 'unknown'; >> +} > > I think the previous if-else based approach was fine here, but this is > also good. I just noticed one thing regarding this approach. Since we > are no longer mimicking a switch-case statement we could combine the the > 'none' and 'cdrom' cases into one like this: I changed the if statements based on this comment [1], by @Max, which I do agree with. The ifelse chain is more packed and not as clear or modifiable = as a chain of early returns. [1]: https://lore.proxmox.com/pve-devel/DKILUOJ6LFZ7.1X2WY1PSWHQYG@proxmox.= com/ > if ($volid eq 'none' || $volid eq 'cdrom') { > return $volid; > } > > But i think the current approach is good and you don't need to change thi= s! I actually also considered using this approach, but in the end decided agai= nst it, as I preferred having all of the possible return values written down instead of just returning the variable. (Which functionally is obviously th= e same thing). [snip]