[pve-devel] [PATCH V4 pve-container 2/7] adapt behavior for detaching/removing a mount point
Fiona Ebner
f.ebner at proxmox.com
Tue Dec 13 14:08:07 CET 2022
Am 25.11.22 um 15:40 schrieb Stefan Hrdlicka:
> detach of a mount point with a removed underlying storage causes it to
> be labeled as a an 'unused disk'
> remove of a 'unused disk' with a removed underlying storage causes it to
> be removed from the configuration
>
> Signed-off-by: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
> ---
> src/PVE/LXC/Config.pm | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
> index b1f779b..e8fbd86 100644
> --- a/src/PVE/LXC/Config.pm
> +++ b/src/PVE/LXC/Config.pm
> @@ -1421,13 +1421,17 @@ sub vmconfig_apply_pending {
> foreach my $opt (sort keys %$pending_delete_hash) {
> next if $selection && !$selection->{$opt};
> eval {
> + my ($storeid, $volname) = PVE::Storage::parse_volume_id($conf->{$opt});
Nit: I'd prefer my ($storeid, undef) to avoid introducing an unused variable
$conf->{opt} is not necessarily a volume ID. That's only true with the
current format for unused entries. Please use $class->parse_volume() to
get the volume ID first.
> 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+)$/) {
> + } elsif (
> + $opt =~ m/^unused(\d+)$/
> + && PVE::Storage::storage_config($storecfg, $storeid, 1)
> + ) {
> PVE::LXC::delete_mountpoint_volume($storecfg, $vmid, $conf->{$opt})
> if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
Please also change the parameter to is_volume_in_use() to use $volid
rather than $conf->{opt} (should be a separate patch).
> }
More information about the pve-devel
mailing list