[pve-devel] applied: [PATCH container] update_config: rescan volume size

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Apr 24 09:24:21 CEST 2018


On 4/23/18 12:36 PM, Fabian Grünbichler wrote:
> otherwise the size information gets lost when detaching and reattaching
> a mountpoint volume, which is less than ideal since mountpoints without
> size information require manual information when restoring.
> 

applied, thanks!

> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
>  src/PVE/LXC/Config.pm | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
> index 7b27be1..e7548ff 100644
> --- a/src/PVE/LXC/Config.pm
> +++ b/src/PVE/LXC/Config.pm
> @@ -925,6 +925,15 @@ sub update_pct_config {
>  	    if !$storage_config->{content}->{rootdir};
>      };
>  
> +    my $rescan_volume = sub {
> +	my ($mp) = @_;
> +	eval {
> +	    $mp->{size} = PVE::Storage::volume_size_info($storecfg, $mp->{volume}, 5)
> +		if !defined($mp->{size});
> +	};
> +	warn "Could not rescan volume size - $@\n" if $@;
> +    };
> +
>      foreach my $opt (keys %$param) {
>  	my $value = $param->{$opt};
>  	my $check_protection_msg = "can't update CT $vmid drive '$opt'";
> @@ -977,8 +986,11 @@ sub update_pct_config {
>  	    if ($mp->{type} eq 'volume') {
>  		&$check_content_type($mp);
>  		$used_volids->{$mp->{volume}} = 1;
> +		&$rescan_volume($mp);
> +		$conf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp);
> +	    } else {
> +		$conf->{$opt} = $value;
>  	    }
> -	    $conf->{$opt} = $value;
>  	    if (defined($old)) {
>  		my $mp = PVE::LXC::Config->parse_ct_mountpoint($old);
>  		if ($mp->{type} eq 'volume') {
> @@ -990,11 +1002,14 @@ sub update_pct_config {
>  	    next if $hotplug_error->($opt);
>  	    PVE::LXC::Config->check_protection($conf, $check_protection_msg);
>  	    my $old = $conf->{$opt};
> -	    $conf->{$opt} = $value;
>  	    my $mp = PVE::LXC::Config->parse_ct_rootfs($value);
>  	    if ($mp->{type} eq 'volume') {
>  		&$check_content_type($mp);
>  		$used_volids->{$mp->{volume}} = 1;
> +		&$rescan_volume($mp);
> +		$conf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp, 1);
> +	    } else {
> +		$conf->{$opt} = $value;
>  	    }
>  	    if (defined($old)) {
>  		my $mp = PVE::LXC::Config->parse_ct_rootfs($old);
> 






More information about the pve-devel mailing list