[pve-devel] [Patch container] fix #1778: check storage support templates
Wolfgang Link
w.link at proxmox.com
Wed Jun 6 12:00:29 CEST 2018
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 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index f555b84..896e8dc 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1166,6 +1166,16 @@ __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 $cfg = PVE::Storage::config();
+ PVE::LXC::Config->foreach_mountpoint($conf, sub {
+ my ($ms, $mountpoint) = @_;
+
+ my ($sid) =
+ PVE::Storage::parse_volume_id($mountpoint->{volume}, 0);
+ die "Storage \'$sid\' do not support templates!\n"
+ if $cfg->{ids}->{$sid}->{path};
+ });
+
my $realcmd = sub {
PVE::LXC::template_create($vmid, $conf);
--
2.11.0
More information about the pve-devel
mailing list