[pve-devel] [PATCH container v5 2/4] lxc: get volid through parse_volume()

Michael Köppl m.koeppl at proxmox.com
Tue May 13 10:03:53 CEST 2025


The value in $conf->{opt} is not necessarily a volume ID. To ensure that
a valid volume ID is used, it is retrieved by calling parse_volume().

Co-authored-by: Stefan Hrdlicka
Signed-off-by: Michael Köppl <m.koeppl at proxmox.com>
---
 src/PVE/LXC/Config.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 0740e8c..7f76b34 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1557,15 +1557,16 @@ 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+)$/) {
 		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