[pve-devel] RFC : template implementation for cloning

Alexandre Derumier aderumier at odiso.com
Thu Nov 29 10:37:50 CET 2012


Hi, 

This is an implementation of a template system for my next coming vm cloning (linked clones) patches.

I'm using same implementation than vmware or virtualbox, so I think it'll be easy for users to manage them.

The main idea :
A vm can be a template. We just need to flag the current config or a vm snapshot as template.
I introduce a new config param,  template: 1 , for this.

In vmware, a vm-template, is just displayed with a different icon in the gui, in the same tree than other vms.

for templates from snapshot, I think it better to use current snapshots implementation, (like for vmware,virtualbox),
so we can rollback to snapshot we want, make updates, and create new snapshots and template for them.
(For example, you can have a linux or windows template, and you can to make update with new up-to-date templates in the time)




for qcow2 or raw file:

- we can only use the current config as template

for sheepdog,rbd,nexenta:
- we can only use vm snapshots (without vmstate) as template



Before create the template, we need to protect the volume (qcow2,raw set as readonly) or a snapshot (rbd)
If we try to remove the template flag, we need to check if clones exists. (using vdisk_list).


I also add some protections:

we can't delete a snapshot if it's a template
we can't destroy a vm if template exists in the vm config 
we can't start a vm if current config is a template.(raw,qcow2)
for qcow2: we can't rollback to previous snapshot if current is a template
we can't migrate a local raw,qcow2 volume if it's a clone of a non shared parent.



I have added qm command:

qm template <vmid> --snapname --delete
(Maybe is it better to have a qm deltemplate command instead --delete arg ?)


So for cloning a vm, we could implement something like

qm create <vmid> --clonefrom vmid(@snapname)






More information about the pve-devel mailing list