public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>
To: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>,
	<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH qemu-server v3 2/3] add new classify_drive_file utility
Date: Thu, 13 Aug 2026 13:13:34 +0200	[thread overview]
Message-ID: <DKNRSO9JMDG4.9LMTD9EI9J3E@proxmox.com> (raw)
In-Reply-To: <DKNRANN8L0Q8.30W1N0W3LYYZ3@proxmox.com>

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 <vmid> 
> --ide2 none,media=crom | cdrom | etc 
> --scsi0 local-lvm:5 | etc
>
> and then destroying them using
> qm destroy <vmid> --purge
>
> It worked as intended.
>
> Small note
> ----------
> Small note inline, but no change necessary IMHO.
> Therefore:
>
> Reviewed-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
> Tested-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>

[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) = @_;
>> +
>> +    return 'unknown' if !$volid;
>> +
>> +    if ($volid eq 'none') {
>> +        return 'none';
>> +    }
>> +
>> +    if ($volid eq 'cdrom') {
>> +        return 'cdrom';
>> +    }
>> +
>> +    if ($volid =~ 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 this!

I actually also considered using this approach, but in the end decided against
it, as I preferred having all of the possible return values written down
instead of just returning the variable. (Which functionally is obviously the
same thing).

[snip]




  reply	other threads:[~2026-08-13 11:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 12:13 [PATCH qemu-server v3 0/3] refactor of volume_id classification Thomas Ellmenreich
2026-08-12 12:13 ` [PATCH qemu-server v3 1/3] move verify_volume_id_or_* format registrations into Drive submodule Thomas Ellmenreich
2026-08-12 12:13 ` [PATCH qemu-server v3 2/3] add new classify_drive_file utility Thomas Ellmenreich
2026-08-13 10:50   ` Elias Huhsovitz
2026-08-13 11:13     ` Thomas Ellmenreich [this message]
2026-08-12 12:13 ` [PATCH qemu-server v3 3/3] remove unnecessary undef checks Thomas Ellmenreich
2026-08-13 11:21   ` Elias Huhsovitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DKNRSO9JMDG4.9LMTD9EI9J3E@proxmox.com \
    --to=t.ellmenreich@proxmox.com \
    --cc=e.huhsovitz@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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