public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
Subject: [PATCH] fix #7828: avoid parsing absolute paths as volume ids
Date: Tue, 21 Jul 2026 14:20:45 +0200	[thread overview]
Message-ID: <20260721122045.151215-1-t.ellmenreich@proxmox.com> (raw)

Just like in the case of cdroms, absolute paths to storage drives can be
skipped when beeing marked as unused as they cannot be owned by the vm.

Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
---
I'm not 100% sure that I have understood the procedure of registering
unused drives correctly, but skipping this branch in the case of an
absolute path as 'volid' seems to be the correct action.

Alternatively, placing the condition next to the `storage_config` check
could make sense, but would just achieve the same thing, as the
subsequent ownership check will never succeed with an absolute path.

 src/PVE/QemuServer.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 191ae549..782d2e7b 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1570,12 +1570,14 @@ sub vm_is_volid_owner {
 sub vmconfig_register_unused_drive {
     my ($storecfg, $vmid, $conf, $drive) = @_;
 
+    my $volid = $drive->{file};
+
     if (drive_is_cloudinit($drive)) {
-        eval { PVE::Storage::vdisk_free($storecfg, $drive->{file}) };
+        eval { PVE::Storage::vdisk_free($storecfg, $volid) };
         warn $@ if $@;
         delete $conf->{'special-sections'}->{cloudinit};
-    } elsif (!drive_is_cdrom($drive)) {
-        my $volid = $drive->{file};
+    } elsif (!drive_is_cdrom($drive) && $volid !~ m|^/|) {
+
         my ($storeid, undef) = PVE::Storage::parse_volume_id($volid);
         if (PVE::Storage::storage_config($storecfg, $storeid, 1)) {
             if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
-- 
2.47.3





             reply	other threads:[~2026-07-21 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 12:20 Thomas Ellmenreich [this message]
2026-07-21 12:43 ` [PATCH] fix #7828: avoid parsing absolute paths as volume ids Daniel Kral

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=20260721122045.151215-1-t.ellmenreich@proxmox.com \
    --to=t.ellmenreich@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