diff --git a/Makefile b/Makefile index 0022660..522393c 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,9 @@ prepare: package: ./build_template_rpm $(TEMPLATE_NAME) +vm: prepare rootimg-build + ./create_vm_from_qubeized_image.sh + rpms: prepare rootimg-build package ./create_template_list.sh || : diff --git a/create_vm_from_qubeized_image.sh b/create_vm_from_qubeized_image.sh new file mode 100755 index 0000000..8532d1a --- /dev/null +++ b/create_vm_from_qubeized_image.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +IMG_DIR=qubeized_images/$TEMPLATE_NAME +if [ ! -d $IMG_DIR ] ; then + echo "dir not found: $IMG_DIR" + exit 1 +fi +IMG_FILE=$IMG_DIR/root.img +if [ ! -e $IMG_FILE ] ; then + echo "file not found: $IMG_FILE" + exit 1 +fi + +# TODO env overrides +TPL_VMNAME=$TEMPLATE_NAME-`date +%Y%m%d` +TPL_LABEL=purple + +HAVE=`qvm-ls -O NAME | grep "$TPL_VMNAME"` +TPL_SUFF=0 +TPL_OVMNAME=$TPL_VMNAME +TPL_VMNAME=` +( echo $TPL_VMNAME +while echo "$HAVE" | grep "^$TPL_VMNAME$" &> /dev/null; do + let TPL_SUFF=$TPL_SUFF+1 + TPL_VMNAME="$TPL_OVMNAME-$TPL_SUFF" + echo $TPL_VMNAME +done ) | tail -1 +` +#echo TPL_VMNAME: $TPL_VMNAME +echo "--> Creating $TPL_VMNAME ..." +qvm-create --label $TPL_LABEL --class TemplateVM $TPL_VMNAME || exit 1 + +echo "--> Setting $TPL_VMNAME properties ..." +# TODO proper shell escape protection +cat tplspec.$TEMPLATE_NAME $IMG_DIR/template.cfg | +grep -E "^(prop|feat) [-a-z_]* [a-z0-9A-Z_()/.]*$" | +while read t k v ; do + echo "SPEC '$t' '$k' '$v'" + if [ "x$t" == "xprop" ] ; then + qvm-prefs $TPL_VMNAME $k "$v" + elif [ "x$t" == "xfeat" ] ; then + qvm-features $TPL_VMNAME $k "$v" + else + echo BAD TAG $t + fi +done + +echo "--> Copying root.img to $TPL_VMNAME:root ..." +qrexec-client-vm $TPL_VMNAME admin.vm.volume.Import+root < $IMG_FILE + +exit 0 + diff --git a/tplspec.mirage-firewall b/tplspec.mirage-firewall new file mode 100644 index 0000000..6972e6d --- /dev/null +++ b/tplspec.mirage-firewall @@ -0,0 +1,9 @@ +prop virt_mode pv +prop memory 42 +prop vcpus 1 +prop kernelopts (hd0)/boot/grub/menu.lst +prop kernel pvgrub +prop provides_network True +feat no-default-kernelopts 1 +feat gui +feat qrexec 1 diff --git a/tplspec.mirage-ssh-agent b/tplspec.mirage-ssh-agent new file mode 100644 index 0000000..f72a8cc --- /dev/null +++ b/tplspec.mirage-ssh-agent @@ -0,0 +1,9 @@ +prop virt_mode pv +prop memory 23 +prop maxmem 42 +prop vcpus 1 +prop kernelopts (hd0)/boot/grub/menu.lst +prop kernel pvgrub +feat no-default-kernelopts 1 +feat gui +feat qrexec 1