add template_create

qm template <vmid> [-disk virtio0]

convert a full vm to a template (or only a disk if specify)

we orignal disk to /base (file) or base- (lvm,rbd,sheepdog,nexenta)
we create a snapshot @base if storage need it for clone
we protect the volume or snapshot

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
add is_template sub

return 1 if vm is a full template (all disks are base image)
return 2 if vm is a semi-tempalte (mix of base and non-base image)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
forbid snapshot delete if it's a template

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
forbid rollback if current config is a template.

if a qcow2 current is a template, we can't rollback to a previous snapshot.

(note that file readonly protection do already the job, but we need a clear error message for user)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
forbid vm_start if current config is a template.

if files (raw,qcow2) are a template, we forbid vm_start.

note : the readonly protection do already the job, but we need a clear message for users

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
forbid offline migration of a non shared volume if it's a clone

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
forbid snapshot create if current it's a template

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
move template checks up one level

To avoid multiple/repeated calls to load_config().
vmstatus : return template if vm is a template

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
is_template: always return a defined value

use 0 instead of undef
template_create: check for 'clone' feature
remove wrong permission check