]> git.proxmox.com Git - pve-container.git/commitdiff
apply pending mountpoint: also hotplug non-volume mount points
authorFiona Ebner <f.ebner@proxmox.com>
Mon, 8 Aug 2022 12:36:42 +0000 (14:36 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 12 Aug 2022 07:10:28 +0000 (09:10 +0200)
Previously, bind and device mount points were applied to the
configuration, but not actually hot-plugged/mounted, causing a
mismatch for running containers.

Reported in the community forum:
https://forum.proxmox.com/threads/113364/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/LXC/Config.pm

index b4b0261d413ab6cfb454e60f67b09e88aea160ea..23c1ba7452fe53aab59f795d3ec53c024b88033e 100644 (file)
@@ -1471,40 +1471,38 @@ sub apply_pending_mountpoint {
 
     my $mp = $class->parse_volume($opt, $conf->{pending}->{$opt});
     my $old = $conf->{$opt};
-    if ($mp->{type} eq 'volume') {
-       if ($mp->{volume} =~ $PVE::LXC::NEW_DISK_RE) {
-           my $original_value = $conf->{pending}->{$opt};
-           my $vollist = PVE::LXC::create_disks(
-               $storecfg,
-               $vmid,
-               { $opt => $original_value },
-               $conf,
-               1,
-           );
-           if ($running) {
-               # Re-parse mount point:
-               my $mp = $class->parse_volume($opt, $conf->{pending}->{$opt});
-               eval {
-                   PVE::LXC::mountpoint_hotplug($vmid, $conf, $opt, $mp, $storecfg);
-               };
-               my $err = $@;
-               if ($err) {
-                   PVE::LXC::destroy_disks($storecfg, $vollist);
-                   # The pending-changes code collects errors but keeps on looping through further
-                   # pending changes, so unroll the change in $conf as well if destroy_disks()
-                   # didn't die().
-                   $conf->{pending}->{$opt} = $original_value;
-                   die $err;
-               }
-           }
-       } else {
-           die "skip\n" if $running && defined($old); # TODO: "changing" mount points?
-           $rescan_volume->($storecfg, $mp);
-           if ($running) {
+    if ($mp->{type} eq 'volume' && $mp->{volume} =~ $PVE::LXC::NEW_DISK_RE) {
+       my $original_value = $conf->{pending}->{$opt};
+       my $vollist = PVE::LXC::create_disks(
+           $storecfg,
+           $vmid,
+           { $opt => $original_value },
+           $conf,
+           1,
+       );
+       if ($running) {
+           # Re-parse mount point:
+           my $mp = $class->parse_volume($opt, $conf->{pending}->{$opt});
+           eval {
                PVE::LXC::mountpoint_hotplug($vmid, $conf, $opt, $mp, $storecfg);
+           };
+           my $err = $@;
+           if ($err) {
+               PVE::LXC::destroy_disks($storecfg, $vollist);
+               # The pending-changes code collects errors but keeps on looping through further
+               # pending changes, so unroll the change in $conf as well if destroy_disks()
+               # didn't die().
+               $conf->{pending}->{$opt} = $original_value;
+               die $err;
            }
-           $conf->{pending}->{$opt} = $class->print_ct_mountpoint($mp);
        }
+    } else {
+       die "skip\n" if $running && defined($old); # TODO: "changing" mount points?
+       $rescan_volume->($storecfg, $mp) if $mp->{type} eq 'volume';
+       if ($running) {
+           PVE::LXC::mountpoint_hotplug($vmid, $conf, $opt, $mp, $storecfg);
+       }
+       $conf->{pending}->{$opt} = $class->print_ct_mountpoint($mp);
     }
 
     if (defined($old)) {