There is a check in the clone API call that prohibits cloning when a
bind or device mountpoint is present. Converting to a template also
will fail when such a mountpoint is present. In particular, that
failure will also trigger at the end of a restore operation, because
restore will also try to convert to a template again. Add a safeguard
so that users won't get into the problematic situation in the first
place.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---

Changes in v2:
    * different approach with safeguard instead of silently dropping
      bind mounts during conversion to template

Previous discussion:
https://lore.proxmox.com/pve-devel/20210402123636.27037-1-f.eb...@proxmox.com/T/#u

 src/PVE/LXC/Config.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index ce64c4c..09687ab 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1181,7 +1181,13 @@ sub update_pct_config {
        if ($opt =~ m/^mp(\d+)$/ || $opt eq 'rootfs') {
            $class->check_protection($conf, "can't update CT $vmid drive 
'$opt'");
            my $mp = $class->parse_volume($opt, $value);
-           $check_content_type->($mp) if ($mp->{type} eq 'volume');
+           if ($mp->{type} eq 'volume') {
+               $check_content_type->($mp);
+           } elsif ($class->is_template($conf)) {
+               # TODO allow bind mounts once admin-defined bind mount sources 
and corresponding ACL
+               # support is implemented
+               die "cannot add mountpoint '$opt' of type '$mp->{type}' to 
template\n";
+           }
        } elsif ($opt eq 'hookscript') {
            PVE::GuestHelpers::check_hookscript($value);
        } elsif ($opt eq 'nameserver') {
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to