]> git.proxmox.com Git - pve-container.git/commitdiff
fix #1778: check if storage support templates
authorWolfgang Link <w.link@proxmox.com>
Wed, 6 Jun 2018 13:21:45 +0000 (15:21 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Jun 2018 13:34:00 +0000 (15:34 +0200)
LXC can only create templates on storages which support linked clones.
To prevent this, we will check before we convert to a template if the
storage support this.

src/PVE/API2/LXC.pm

index f555b847b2cbcbd22b64513a6435d4beff3ef128..651138fe6bc42faa7f5c5f6cb577169bb768824c 100644 (file)
@@ -1166,6 +1166,15 @@ __PACKAGE__->register_method({
            die "you can't convert a CT to template if the CT is running\n"
                if PVE::LXC::check_running($vmid);
 
+           my $scfg = PVE::Storage::config();
+           PVE::LXC::Config->foreach_mountpoint($conf, sub {
+               my ($ms, $mp) = @_;
+
+               my ($sid) =PVE::Storage::parse_volume_id($mp->{volume}, 0);
+               die "Storage '$sid' does not support templates!\n"
+                   if $scfg->{ids}->{$sid}->{path};
+           });
+
            my $realcmd = sub {
                PVE::LXC::template_create($vmid, $conf);