From 0402a80b77aa25befe86b36d4b50bc781f3eefb8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 22 Apr 2013 07:05:54 +0200 Subject: [PATCH] do not allow template creation if there are snapshots. --- PVE/API2/Qemu.pm | 6 +++++- PVE/QemuServer.pm | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 8197070..3cc35a2 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2392,8 +2392,12 @@ __PACKAGE__->register_method({ PVE::QemuServer::check_lock($conf); - die "you can't convert a template to a template" + die "unable to create template, because VM contains snapshots\n" + if $conf->{snapshots}; + + die "you can't convert a template to a template\n" if PVE::QemuServer::is_template($conf) && !$disk; + my $realcmd = sub { PVE::QemuServer::template_create($vmid, $conf, $disk); }; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index afc9976..ba75975 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4462,11 +4462,6 @@ sub template_create { PVE::QemuServer::update_config_nolock($vmid, $conf, 1); }); - if($conf->{snapshots}){ - delete $conf->{parent}; - delete $conf->{snapshots}; - #fixme : do we need to delete disks snapshots ? - } $conf->{template} = 1; PVE::QemuServer::update_config_nolock($vmid, $conf, 1); } -- 2.39.2