[pve-devel] [PATCH 3/3] template_create : add template:1 option.

Alexandre Derumier aderumier at odiso.com
Thu Apr 18 17:05:31 CEST 2013


Also allow template create of non base-xxx renamable storage

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7c20f55..1352e24 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4448,17 +4448,8 @@ sub template_create {
 	return if $disk && $ds ne $disk;
 
 	my $volid = $drive->{file};
-	die "volume '$volid' does not support template/clone\n" 
-	    if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
-    });
+	return if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
 
-    foreach_drive($conf, sub {
-	my ($ds, $drive) = @_;
-
-	return if drive_is_cdrom($drive);
-	return if $disk && $ds ne $disk;
-
-	my $volid = $drive->{file};
 	my $voliddst = PVE::Storage::vdisk_create_base($storecfg, $volid);
 	$drive->{file} = $voliddst;
 	$conf->{$ds} = PVE::QemuServer::print_drive($vmid, $drive);
@@ -4468,9 +4459,10 @@ sub template_create {
     if($conf->{snapshots}){
 	delete $conf->{parent};
 	delete $conf->{snapshots};
-	PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
 	#fixme : do we need to delete disks snapshots ?
     }
+    $conf->{template} = 1;
+    PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
 }
 
 sub is_template {
-- 
1.7.10.4




More information about the pve-devel mailing list