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} && scalar(keys %{$conf->{snapshots}});
+
+ die "you can't convert a template to a template\n"
if PVE::QemuServer::is_template($conf) && !$disk;
+
+ die "you can't convert a VM to template if VM is running\n"
+ if check_running($vmid);
+
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);