[pve-devel] [PATCH container v6 2/4] config: apply_pending: get unused volid through parse_volume()
Michael Köppl
m.koeppl at proxmox.com
Tue May 20 11:08:13 CEST 2025
The volume ID returned by parse_volume() is used here as opposed to
$conf->{$opt} used for regular mount points because $conf->{$opt} is not
necessarily a valid volume ID in this case. This distinction is
important because is_volume_in_use does internally not consider
'unused*' a valid volume key and does not check it. parse_volume knows
about 'unused*' and returns a valid volume ID.
No functional changes intended.
Originally-by: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
Signed-off-by: Michael Köppl <m.koeppl at proxmox.com>
---
src/PVE/LXC/Config.pm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 0740e8c..a7c1023 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1557,15 +1557,20 @@ sub vmconfig_apply_pending {
foreach my $opt (sort keys %$pending_delete_hash) {
next if $selection && !$selection->{$opt};
eval {
+ my $mp = $class->parse_volume($opt, $conf->{$opt});
+
if ($opt =~ m/^mp(\d+)$/) {
- my $mp = $class->parse_volume($opt, $conf->{$opt});
if ($mp->{type} eq 'volume') {
$class->add_unused_volume($conf, $mp->{volume})
if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
}
} elsif ($opt =~ m/^unused(\d+)$/) {
+ # $mp->{volume} is used for is_volume_in_use() because parse_volume()
+ # knows about 'unused*' and will return a valid volume ID whereas
+ # $conf->{$opt} is not guaranteed to contain a valid volume ID in this
+ # case.
PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt})
- if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
+ if !$class->is_volume_in_use($conf, $mp->{volume}, 1, 1);
} elsif ($opt =~ m/^net(\d+)$/) {
if ($have_sdn) {
my $net = $class->parse_lxc_network($conf->{$opt});
--
2.39.5
More information about the pve-devel
mailing list