public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>
To: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>,
	<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH qemu-server 3/3] removed some unnecessary undef checks.
Date: Wed, 05 Aug 2026 10:24:22 +0200	[thread overview]
Message-ID: <DKGV6RJWLF4Z.10DCXKKFDXC0E@proxmox.com> (raw)
In-Reply-To: <20260803121300.138287-4-t.ellmenreich@proxmox.com>

Summary
-------
* classify_drive_file() and drive_has_absolute_path() are not prepared
  to handle undef values, and therefore removing the undef checks causes
  a change in behaviour

* commit message should be imperative, e.g., "remove some unnecessary
undef checks"

On Mon Aug 3, 2026 at 2:12 PM CEST, Thomas Ellmenreich wrote:
> Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
> ---
>  src/PVE/QemuServer.pm | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
> index 0e998cbe..3141b298 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -1818,11 +1818,10 @@ sub destroy_vm {
>              { include_unused => 1 },
>              sub {
>                  my ($ds, $drive) = @_;
> -                return if drive_is_cdrom($drive);
>  
> -                my $volid = $drive->{file};
> -                return if !$volid || drive_has_absolute_path($drive);

I think this might result in an edge case where $drive->{file} can be undef,
causing the underlying function classify_drive_file() that drive_has_absolute_path()
calls, to emit a warning.

To my understanding, classify_drive_file() is currently unpreparted to
receive undef values. I believe a guard clause in classify_drive_file()
resolves this.

e.g., in classify_drive_file:

my ($volid) = @_;
return '' if (!$volid);

> +                return if drive_is_cdrom($drive) || drive_has_absolute_path($drive);
>  
> +                my $volid = $drive->{file};
>                  my $result = eval { PVE::Storage::volume_is_base_and_used($storecfg, $volid) };
>                  # early check, removal of volume will fail later anyway, so warning here is fine
>                  log_warn("failed to check if volume '$volid' is used by linked clones: $@")
> @@ -1839,8 +1838,7 @@ sub destroy_vm {
>          return if drive_is_cdrom($drive, 1);
>  
>          my $volid = $drive->{file};
> -        return if !$volid || drive_has_absolute_path($drive);

same here.

> -        return if $volids->{$volid};
> +        return if drive_has_absolute_path($drive) || $volids->{$volid};
>  
>          my ($path, $owner) = eval { PVE::Storage::path($storecfg, $volid) };
>          log_warn("failed to get path and owner of volume '$volid': $@") if $@;
> @@ -6510,11 +6508,9 @@ my $restore_cleanup_oldconf = sub {
>          sub {
>              my ($ds, $drive) = @_;
>  
> -            return if drive_is_cdrom($drive, 1);
> +            return if drive_is_cdrom($drive, 1) || drive_has_absolute_path($drive);
>  
>              my $volid = $drive->{file};
> -            return if !$volid || drive_has_absolute_path($drive);

same here.

> -
>              my ($path, $owner) = PVE::Storage::path($storecfg, $volid);
>              return if !$path || !$owner || ($owner != $vmid);
>  





  reply	other threads:[~2026-08-05  8:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 12:12 [PATCH qemu-server 0/3] refactor of volume_id classification Thomas Ellmenreich
2026-08-03 12:12 ` [PATCH qemu-server 1/3] moved verify_volume_id_or_* format registrations Thomas Ellmenreich
2026-08-04 14:09   ` Elias Huhsovitz
2026-08-03 12:12 ` [PATCH qemu-server 2/3] add new classify_drive_file utility Thomas Ellmenreich
2026-08-04 14:23   ` Elias Huhsovitz
2026-08-03 12:12 ` [PATCH qemu-server 3/3] removed some unnecessary undef checks Thomas Ellmenreich
2026-08-05  8:24   ` Elias Huhsovitz [this message]
2026-08-05  9:55     ` Fiona Ebner
2026-08-05  8:22 ` superseded: [PATCH qemu-server 0/3] refactor of volume_id classification Thomas Ellmenreich

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=DKGV6RJWLF4Z.10DCXKKFDXC0E@proxmox.com \
    --to=e.huhsovitz@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.ellmenreich@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