]> git.proxmox.com Git - pve-container.git/commitdiff
template create: handle mountpoints besides rootfs
authorWolfgang Link <w.link@proxmox.com>
Wed, 30 May 2018 10:12:51 +0000 (12:12 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 30 May 2018 10:42:55 +0000 (12:42 +0200)
we only handled the special rootfs mount so creating a template
from a container with additional mountpoint did not work correctly.
Use foreach_mountpoint to create a base vdisk for all mount points
after checking if the storage supports it

src/PVE/LXC.pm

index 4f9674d64221437de690d95f0881478062ba7f19..bfca9c13cee7c91dbb3ac42ceb64dfb79f9fb105 100644 (file)
@@ -869,17 +869,26 @@ sub template_create {
 
     my $storecfg = PVE::Storage::config();
 
 
     my $storecfg = PVE::Storage::config();
 
-    my $rootinfo = PVE::LXC::Config->parse_ct_rootfs($conf->{rootfs});
-    my $volid = $rootinfo->{volume};
+    PVE::LXC::Config->foreach_mountpoint($conf, sub {
+       my ($ms, $mountpoint) = @_;
 
 
-    die "Template feature is not available for '$volid'\n"
-       if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
+       my $volid = $mountpoint->{volume};
 
 
-    PVE::Storage::activate_volumes($storecfg, [$volid]);
+       die "Template feature is not available for '$volid'\n"
+           if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
+    });
 
 
-    my $template_volid = PVE::Storage::vdisk_create_base($storecfg, $volid);
-    $rootinfo->{volume} = $template_volid;
-    $conf->{rootfs} = PVE::LXC::Config->print_ct_mountpoint($rootinfo, 1);
+    PVE::LXC::Config->foreach_mountpoint($conf, sub {
+       my ($ms, $mountpoint) = @_;
+
+       my $volid = $mountpoint->{volume};
+
+       PVE::Storage::activate_volumes($storecfg, [$volid]);
+
+       my $template_volid = PVE::Storage::vdisk_create_base($storecfg, $volid);
+       $mountpoint->{volume} = $template_volid;
+       $conf->{$ms} = PVE::LXC::Config->print_ct_mountpoint($mountpoint, $ms eq "rootfs");
+    });
 
     PVE::LXC::Config->write_config($vmid, $conf);
 }
 
     PVE::LXC::Config->write_config($vmid, $conf);
 }