diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 3cc35a22..84112932 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2401,9 +2401,11 @@ __PACKAGE__->register_method({ my $realcmd = sub { PVE::QemuServer::template_create($vmid, $conf, $disk); }; - return $rpcenv->fork_worker('qmtemplate', $vmid, $authuser, $realcmd); + $conf->{template} = 1; PVE::QemuServer::update_config_nolock($vmid, $conf, 1); + + return $rpcenv->fork_worker('qmtemplate', $vmid, $authuser, $realcmd); }; PVE::QemuServer::lock_config($vmid, $updatefn); diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index ba759752..194b678d 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4445,7 +4445,6 @@ sub template_create { die "you can't convert a vm to template if vm is running vm\n" if $running; my $storecfg = PVE::Storage::config(); - my $i = 0; foreach_drive($conf, sub { my ($ds, $drive) = @_; @@ -4460,10 +4459,7 @@ sub template_create { $drive->{file} = $voliddst; $conf->{$ds} = PVE::QemuServer::print_drive($vmid, $drive); PVE::QemuServer::update_config_nolock($vmid, $conf, 1); - }); - $conf->{template} = 1; - PVE::QemuServer::update_config_nolock($vmid, $conf, 1); } sub is_template {