From: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>
To: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>,
<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH qemu-server v3 3/3] remove unnecessary undef checks
Date: Thu, 13 Aug 2026 13:21:57 +0200 [thread overview]
Message-ID: <DKNRZ346OKI1.OXQS7A2P78PT@proxmox.com> (raw)
In-Reply-To: <20260812121327.145140-4-t.ellmenreich@proxmox.com>
I tested this patch by in injecting
die "ASSERT: undefined or empty drive file for '$ds'\n"
if !defined($volid) || $volid eq '';
Then i created/destroyed/restored on the default 'local' and
'local-lvm' storages.
Valid configurations never caused $volid to be undef.
Reviewed-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
Tested-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
On Wed Aug 12, 2026 at 2:13 PM CEST, Thomas Ellmenreich wrote:
> The surrounding code guarantees that the value is always defined,
> making these checks unnecessary.
>
> 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 d9d76ab3..0bedd334 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -1831,11 +1831,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);
> + 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: $@")
> @@ -1852,8 +1851,7 @@ sub destroy_vm {
> return if drive_is_cdrom($drive, 1);
>
> my $volid = $drive->{file};
> - return if !$volid || drive_has_absolute_path($drive);
> - 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 $@;
> @@ -6523,11 +6521,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);
> -
> my ($path, $owner) = PVE::Storage::path($storecfg, $volid);
> return if !$path || !$owner || ($owner != $vmid);
>
prev parent reply other threads:[~2026-08-13 11:22 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
2026-08-12 12:13 ` [PATCH qemu-server v3 3/3] remove unnecessary undef checks Thomas Ellmenreich
2026-08-13 11:21 ` Elias Huhsovitz [this message]
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=DKNRZ346OKI1.OXQS7A2P78PT@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