[pve-devel] [Patch V2 container 1/2] template create: handle mountpoints besides rootfs
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed May 30 13:09:01 CEST 2018
On 5/30/18 12:12 PM, Wolfgang Link wrote:
> 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
> ---
>
> Patch V2:
> reword commit message as t.lamprecht suggest.
> remove redundant volume parsing.
>
> src/PVE/LXC.pm | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 4f9674d..bfca9c1 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -869,17 +869,26 @@ sub template_create {
>
> 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);
> }
>
applied series, thanks.
Some non directly related problems I found during testing these:
* If I set the RO (readonly) flag of a mountpoint from a template
the respective MP's size will set to '0T'.
* If I set RO of a MP all other following mountpoints are read only too
(besides rootfs) even if not set to RO.
E.g., I have rootfs, mp0 and mp1. If I set ro for mp0 then mp1 is also ro.
If I set ro for mp1 only it works: mp1 is ro, mp0 is not.
Funny stuff ^^ Could you confirm and eventually take a look at this?
More information about the pve-devel
mailing list