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 E5F0D1FF138 for ; Mon, 29 Jun 2026 16:06:01 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id CF5BA2152C; Mon, 29 Jun 2026 16:05:18 +0200 (CEST) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH container v9 04/10] config: ensure valid volid through parse_volume() Date: Mon, 29 Jun 2026 16:04:33 +0200 Message-ID: <20260629140439.184878-5-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260629140439.184878-1-m.koeppl@proxmox.com> References: <20260629140439.184878-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782741871467 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.088 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: LIZOOIKLPWGRVKMLFAEFETV7YWGLZ3MM X-Message-ID-Hash: LIZOOIKLPWGRVKMLFAEFETV7YWGLZ3MM X-MailFrom: m.koeppl@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: Even though the value in $conf->{$opt} contains a volume ID for unused mount points at the moment, this is not guaranteed to be true in the future. To ensure that a valid volume ID is used here, run call parse_volume() first. No functional change is intended here as the values of $conf->{$opt} and $mp->{volume} are identical for unused mount points at the moment. Also add FIXME for the is_volume_in_use() check for the branch that handles mountpoint volumes that are in use. Currently, the check only works by accident. The value in $conf->{$opt} isn’t just a volume ID - it contains other things as well (such as mp=). However, the check only considers 'rootfs' and entries like 'mp0', 'mp1', etc. as valid volume IDs. As a result, the volume is not detected to be in use. Using a valid volume id with the current implementation, the check would always report that the volume is in use and the mountpoint volume would not be deleted. The correct behavior should use a valid volume id to ensure that the volume can be safely removed. Signed-off-by: Michael Köppl --- src/PVE/LXC/Config.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 80942d34..c8098538 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -1662,8 +1662,9 @@ sub vmconfig_hotplug_pending { if ($LXC_FASTPLUG_OPTIONS->{$opt}) { # pass } elsif ($opt =~ m/^unused(\d+)$/) { - PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt}) - if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1); + my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume}; + PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid) + if !$class->is_volume_in_use($conf, $volid, 1, 1); } elsif ($opt eq 'swap') { $hotplug_memory->(undef, 0); } elsif ($opt eq 'cpulimit') { @@ -1764,12 +1765,14 @@ sub vmconfig_apply_pending { if ($opt =~ m/^mp(\d+)$/) { my $mp = $class->parse_volume($opt, $conf->{$opt}); if ($mp->{type} eq 'volume') { + # FIXME: use $mp->{volume} for is_volume_in_use, fix conditions for check $class->add_unused_volume($conf, $mp->{volume}) if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1); } } elsif ($opt =~ m/^unused(\d+)$/) { - PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt}) - if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1); + my $volid = $class->parse_volume($opt, $conf->{$opt})->{volume}; + PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $volid) + if !$class->is_volume_in_use($conf, $volid, 1, 1); } elsif ($opt =~ m/^net(\d+)$/) { if ($have_sdn) { my $net = $class->parse_lxc_network($conf->{$opt}); -- 2.47.3