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 671421FF0E1 for ; Mon, 10 Aug 2026 10:51:13 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id F1C2B215DC; Mon, 10 Aug 2026 10:51:12 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Aug 2026 10:51:07 +0200 Message-Id: Subject: Re: [PATCH qemu-server v2 2/3] add new classify_drive_file utility From: "Elias Huhsovitz" To: "Thomas Ellmenreich" , X-Mailer: aerc 0.20.0 References: <20260805082122.43184-1-t.ellmenreich@proxmox.com> <20260805082122.43184-3-t.ellmenreich@proxmox.com> In-Reply-To: <20260805082122.43184-3-t.ellmenreich@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786351856390 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.888 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: LXD2V5CBTJXTFGERHY7CR5TGVB2ICEOT X-Message-ID-Hash: LXD2V5CBTJXTFGERHY7CR5TGVB2ICEOT X-MailFrom: e.huhsovitz@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: Good refactor. 1 small nit inline. On Wed Aug 5, 2026 at 10:21 AM CEST, Thomas Ellmenreich wrote: > To more easily and clearly branch off different types of drive files a > new utility function is introduced that classifies such a drive file. > The return options are 'none', 'cdrom', 'absolute' and 'volume'. In any > other case the function returns 'unknown'. > > Signed-off-by: Thomas Ellmenreich > --- > src/PVE/QemuServer.pm | 29 ++++++++++++++++++----------- > src/PVE/QemuServer/Drive.pm | 25 +++++++++++++++++++++++++ > 2 files changed, 43 insertions(+), 11 deletions(-) > > diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm > index fdef20dc..0e998cbe 100644 [...] > +# Tries to classify the drive file as either 'none', 'cdrom', 'absolute' > +# or 'volume'. In all other cases it will return undef. nit: Subroutine returns 'unknown' in default path. Comments states that `undef` is returned. > +sub classify_drive_file { > + my ($volid) =3D @_; > + > + if ($volid eq 'none') { > + return 'none'; > + } elsif ($volid eq 'cdrom') { > + return 'cdrom'; > + } elsif ($volid =3D~ m|^/|) { > + return 'absolute'; > + } elsif (PVE::Storage::parse_volume_id($volid, 1)) { > + return 'volume'; > + } > + > + return 'unknown'; > +} > + > sub drive_is_cloudinit { > my ($drive) =3D @_; > return $drive->{file} =3D~ m@[:/](?:vm-\d+-)?cloudinit(?:\.$QEMU_FOR= MAT_RE)?$@; > @@ -794,6 +814,11 @@ sub drive_is_cdrom { > return $drive && $drive->{media} && ($drive->{media} eq 'cdrom'); > } > =20 > +sub drive_has_absolute_path { > + my ($drive) =3D @_; > + return classify_drive_file($drive->{file}) eq "absolute"; > +} > + > sub parse_drive_interface { > my ($key) =3D @_; > =20