]> git.proxmox.com Git - pve-container.git/commitdiff
update_config: rescan volume size
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 23 Apr 2018 10:36:16 +0000 (12:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Apr 2018 07:16:51 +0000 (09:16 +0200)
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.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/LXC/Config.pm

index 7b27be17ff42afd4a2755fd5a018c1dbab34b63b..e7548ffff842774e364dcc006c416319b5374698 100644 (file)
@@ -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);