debuggers.hg

view tools/blktap2/drivers/xmsnap @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 1c627434605e
children
line source
1 #!/bin/bash
3 usage () { echo "USAGE: xmsnap <VM ID> <Backing File>"; }
5 #
6 # Check Usage
7 #
8 if [ -n "$1" ]
9 then
10 vmid=$1
11 else
12 usage
13 exit 1
14 fi
16 if [ -n "$2" ]
17 then
18 target=$2
19 else
20 usage
21 exit 1
22 fi
24 if [ -e "$target" ]
25 then
26 echo "Creating snapshot of file $target for VM $vmid."
27 else
28 usage
29 echo "File $target not found."
30 exit 1
31 fi
33 #
34 # Find the snapshot name
35 #
36 directory=`dirname "$target"`
37 target=`basename "$target"`
39 let maxidx=0
40 if [ -e $directory/${target}.snap1 ]
41 then
42 for idx in $(ls $directory/${target}.snap*)
43 do
44 let idx=${idx#$directory/${target}.snap}
45 if [ "$idx" -gt "$maxidx" ]
46 then
47 let maxidx=$idx
48 fi
49 done
50 fi
52 snap=${target}.snap`expr $maxidx + 1`
54 #
55 # Pause VM
56 #
57 xm pause $vmid
58 if [ "$?" -ne "0" ]; then
59 exit 1
60 fi
63 #
64 # Snap and reposition the files
65 #
66 mv $directory/$target $directory/$snap
67 if [ "$?" -ne "0" ]; then
68 exit 1
69 fi
71 qcow-create 0 $directory/$target $directory/$snap
73 #
74 # Unpause
75 #
76 xm unpause $vmid
78 exit