taking snaphost and creating template of Xen domain
For testing purpose I've used vmware images. One of the advantages was to be able to take snapshots of an image.
And to make these snapshots a template for furture image creation.
When developing on windows platforms all this save you a lot of time.
Now I am using Xen on latest release of Solaris. This great but I was missing snapshots and templates.
Thank to ZFS I am happy again.
The trick is simple : use ZFS volume to create your guests and just use cloning and snapshot feature of ZFS.
In this example I use a file to create the zfs pool, this is not reliable but this is enough as we are testing
1 - Create a file.
#mkfile -n 10g /my-image-file
2 - Create a pool on that file.
#zpool create mypool /my-image-file
#zpool status mypool
pool: mypool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
mypool ONLINE 0 0 0
/my-image-file ONLINE 0 0 0
3 - Create a volume on that new created pool.
#zfs create -V 10g mypool/myhostdisk
4 - Create the guest on this new volume.
virt-install --name=foo --hvm --file-size=10 --ram=1024 --os-type=windows --vnc --cdrom=win.iso --file=/dev/zvol/dsk/mypool/myhostdisk
That's it ! each time you want a snapshot, shutdown the guest and take a snapshot of the volume.
Cloning the snapshot will give templates.
Posted at 10:08AM juil. 28, 2008 by ejannett in Operating Systems | Comments[0]
relocatable binaries and scripts
Once, somebody asked me about how to relocate scripts and binaries in a safe manner . Depending on what
you do it may not be as easy as looking in argv[0]. Hope this helps somebody else.
| #!/bin/sh where_am_i () { cmd=`dirname $1` case ${cmd} in /*) cannon_cmd=${cmd} ;; */*) _pwd=`pwd 2>/dev/null` cannon_cmd="${_pwd}/${cmd}" ;; *) echo "ousp..." exit 1 ;; esac echo "$cannon_cmd" | awk -F/ '{ realpath=""; skip_it=0; for (i=NF; i>0; i--) { if ($i == ".") continue; if (length($i) == 0&& i != 1) continue; if ($i == "..") {skip_it++; continue;} if (skip_it > 0 ) { skip_it--; continue; } if (length(realpath) > 0) { realpath=$i"/"realpath; } else { realpath=$i; } } } END {print realpath}' 2>/dev/null } res=`where_am_i $0` echo "resolved command line <$res>" |
this will produce output like
#/tmp/a.sh
resolved command line </tmp/>
#/var/tmp/..//../tmp/a.sh
resolved command line </tmp/>
#/var/tmp/..//../tmp/./a.sh
resolved command line </tmp/>
@ECHO OFF .... endlocal |
use FindBin; # add our module repository to perl @INC #.... later in a sub module my ($mod_package,$mod_name) = split (/::/,__PACKAGE__); |
#include <dlfcn.h>
Dl_info dli;
dladdr((void*)&main,&dli);
printf("resolved cmd : %s\n",(char*)mydlinfo.dli_fname);
max = pathconf("/",_PC_PATH_MAX);
buf = (char*)malloc(max + 1);
end = readlink("/proc/self/exe",buf,max);
buf[end] = '\0';
printf("resolved cmd : %s\n",buf);
struct ld_info *myld_info;
loadquery(L_GETINFO, buf, size);
myld_info = (struct ld_info *)buf;
printf("resolved cmd : %s\n",myld_info->ldinfo_filename);
struct shl_descriptor *desc;
shl_gethandle(PROG_HANDLE,&desc);
//Note : may need to prepend pwd to desc->filename
printf("resolved cmd : %s\n",desc->filename);
GetModuleFileName(NULL, buffer,<buffer length>);
printf("resolved cmd : %s\n",desc->filename);
Posted at 11:16AM févr. 06, 2008 by ejannett in Operating Systems | Comments[2]
Today's Page Hits: 0