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 9200C1FF13E for ; Wed, 01 Jul 2026 16:14:19 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 37532214DA; Wed, 01 Jul 2026 16:13:47 +0200 (CEST) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH container v10 05/10] allow pending mount point changes if storage is gone Date: Wed, 1 Jul 2026 16:13:34 +0200 Message-ID: <20260701141339.181276-6-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260701141339.181276-1-m.koeppl@proxmox.com> References: <20260701141339.181276-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: 1782915215771 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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: ILS2A65FEFH4RTW6HPVTWU5RFYDTV7LZ X-Message-ID-Hash: ILS2A65FEFH4RTW6HPVTWU5RFYDTV7LZ 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: Previously, applying a pending removal of an unused volume whose backing storage was already removed would fail with "unable to apply pending change unusedN", leaving a dangling reference that could never be cleaned up. Guard the volume deletion in vmconfig_apply_pending and vmconfig_hotplug_pending with a check to ensure that the storage exists. If the storage is gone, drop the entry with a warning instead of trying to free a volume that no longer exists. Apply the same check when a detached mount point is turned into an 'unusedN' entry, so a volume on a removed storage is not re-added as a dangling unused entry, matching VM behavior. Signed-off-by: Michael Köppl --- src/PVE/LXC/Config.pm | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 57c93e8a..8c99c931 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -1678,8 +1678,14 @@ sub vmconfig_hotplug_pending { # pass } elsif ($opt =~ m/^unused(\d+)$/) { 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); + with_checked_volid( + $storecfg, + $volid, + sub { + 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') { @@ -1780,14 +1786,26 @@ 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); + with_checked_volid( + $storecfg, + $mp->{volume}, + sub { + # 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+)$/) { 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); + with_checked_volid( + $storecfg, + $volid, + sub { + 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}); @@ -1906,8 +1924,14 @@ sub apply_pending_mountpoint { if (defined($old)) { my $mp = $class->parse_volume($opt, $old); if ($mp->{type} eq 'volume') { - $class->add_unused_volume($conf, $mp->{volume}) - if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1); + with_checked_volid( + $storecfg, + $mp->{volume}, + sub { + $class->add_unused_volume($conf, $mp->{volume}) + if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1); + }, + ); } } } -- 2.47.3