[pve-devel] kvm disk template implementation ideas

Alexandre DERUMIER aderumier at odiso.com
Wed Aug 22 09:49:25 CEST 2012


Hi,
one feature that really miss on proxmox currently is disk templates for kvm machines.
I'm currently doing it with custom scripts, but I would like to add clean implementation in proxmox in the coming months(I think users should be happy too :)

I don't know if you have already thinked about it, but here some ideas:

template feature with image copy from source (file storage, .raw files) to destination.
---------------------------------------------------------------------------------------
for each storage module, add an export and import sub.

import:
------
import is used to import existing template in the target storage

file,nfs: cp /var/lib/vz/template/qemu/template1.raw  /mnt/myimage.raw
lvm :  dd if=/var/lib/vz/template/qemu/template1.raw of=/dev/lvm/..
iscsi : dd if=/var/lib/vz/template/qemu/template1.raw of=/dev/sd 
rbd :  rbd import /var/lib/vz/template/qemu/template1.raw  myrbdimage
sheepdog: cat /var/lib/vz/template/qemu/template1.raw | collie vdi write mysheepimage
libiscsi,nexenta : LD_PRELOAD=./bin/ld_iscsi.so dd if=/var/lib/vz/template/qemu/template1.raw of=iscsi://127.0.0.1:3262/iqn.ronnie.test/2 

export:
--------
export is used to export a disk to the template storage, for creating new templates 

file,nfs: cp /mnt/myimage.raw /var/lib/vz/template/qemu/template1.raw  
lvm :  dd if=/dev/lvm/.. of=/var/lib/vz/template/qemu/template1.raw
iscsi : dd if=/dev/sd of=/var/lib/vz/template/qemu/template1.raw
rbd :  rbd export myrbdimage /var/lib/vz/template/qemu/template1.raw  
sheepdog: collie vdi read mysheepimage > /var/lib/vz/template/qemu/template1.raw
libiscsi,nexenta : LD_PRELOAD=./bin/ld_iscsi.so dd if=iscsi://127.0.0.1:3262/iqn.ronnie.test/2 of=/var/lib/vz/template/qemu/template1.raw 

then add some kind of 
qm exportdisk <vmid> <disk> <target>        : qm exportdisk vmid virtio0 /var/lib/vz/template/qemu/template1.raw
qm importdisk <vmid> <disk> <source>        : qm importdisk vmid virtio0 /var/lib/vz/template/qemu/template1.raw

or maybe can we integrate this in vzdump/vzrestore. 
So we could also make backup/restore for all storages.
I never look in vzdump code, so I don't know how it's work



template feature with image cloning
-----------------------------------
for storage which support it, add a template feature based on image snapshot/instant cloning.
currently nexenta,sheepdog and rbd(soon), lvm??? support it.

I don't know really how to implement this, as we need to see difference between vm disk and templates disk.
(And we can't have a template directory).
we can't rename volume rbd,sheepdog so maybe can we allow snapshot named "template-..."

for this features, we need to add storage sub:

snapshot_create, clone, disktemplate_list (like vdisk_list)


snapshot_create
----------------
rbd:  snap create --snap template-template1 vm-id-disk-1
sheepdog:  collie vdi snapshot -s template-template1 vm-id-disk-1
nexenta : nexenta api snap vm-id-disk-1 at template-template1


disktemplate_list (return list of templates(snapshots) and associated disk
----------------------------------------------------------------------------
sheepdog : collie vdi list
rbd : problem : can't easilly list all templates, without calling "rbd snap ls image1" for each image
nexenta: nexenta api to list templates

another solution is to maintain a list of snapshots in a text file or somewhere else, but we don't like that in proxmox.

clone 
-----

rbd: coming soon
sheepdog:  collie vdi clone -s template-template1 vm-id-disk-1 mytargetimage
nexenta : nexenta clone api vm-id-disk-1 at template-template1 mytargetimage



then add some kind of 
qm clonedisk <vmid> <disk> <template>        : qm clonedisk vmid virtio0 template-template1




What do you think about it ? Don't hesitate to comments.



More information about the pve-devel mailing list