Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 131 lines (102 sloc) 2.757 kb
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
1 #!/bin/bash
2 #
3 # Copyright (c) Citrix Systems 2008. All rights reserved.
4 #
5 # **
6 # ** Only run this script if instructed to do so by Citrix support
7 # **
8 # Script to wrap a xentrace invocation to log it to a block-attached
9 # VDI in dom0, so it does not fill up dom0.
10 # The VDI has the other_config:xentrace flag set to 1, so these can be
11 # identified later on as xentrace records.
12 # The VDI contains a ext3 fs (no partition table) and single file "trace.bz2"
13
14 TIME=5
15 SIZE_GB=1
16 while getopts "ht:s:" opt ; do
17 case $opt in
18 h)
19 echo "Usage: $0 [-t time (sec)] [-s size (GB)]"
20 exit 1
21 ;;
22 t) TIME=$OPTARG
23 ;;
24 s) SIZE_GB=$OPTARG
25 ;;
26 *) echo "Invalid option"; exit 1
27 ;;
28 esac
29 done
30
31 SIZE=$((${SIZE_GB} * 1024 * 1024 * 1024))
32
13b8348 @jonludlam Move everything over to using Fhs.ml / @ substitution
jonludlam authored
33 if [ ! -e @INVENTORY@ ]; then
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
34 echo Must run on a XenServer host.
35 exit 1
36 fi
37
13b8348 @jonludlam Move everything over to using Fhs.ml / @ substitution
jonludlam authored
38 . @INVENTORY@
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
39
13b8348 @jonludlam Move everything over to using Fhs.ml / @ substitution
jonludlam authored
40 XE="@BINDIR@/xe"
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
41
42 crashdump_sr=$(${XE} host-list params=crash-dump-sr-uuid --minimal uuid=${INSTALLATION_UUID})
43
44 if [ -z "${crashdump_sr}" ]; then
45 echo No crashdump storage repository defined for the host.
46 exit 1
47 fi
48
49 vdi_date=$(date +%c)
50 vdi_name="Xentrace results at ${vdi_date}"
51
52 echo -n "Creating VDI: "
53 vdi_uuid=$(${XE} vdi-create sr-uuid=${crashdump_sr} name-label="${vdi_name}" type=system virtual-size=${SIZE})
54 echo ${vdi_uuid}
55
56 if [ $? -ne 0 -o -z "${vdi_uuid}" ]; then
57 echo error creating VDI in the crashdump storage repository
58 exit 1
59 fi
60
61 ${XE} vdi-param-set uuid=${vdi_uuid} other-config:xentrace=1
62
63 mnt=
64 function cleanup {
65 if [ ! -z "${vdi_uuid}" ]; then
66 ${XE} vdi-destroy uuid=${vdi_uuid}
67 fi
68
69 if [ ! -z "${mnt}" ]; then
70 umount ${mnt}
71 rmdir ${mnt}
72 fi
73
74 if [ ! -z "${vbd_uuid}" ]; then
75 ${XE} vbd-unplug uuid=${vbd_uuid}
76 ${XE} vbd-destroy uuid=${vbd_uuid}
77 fi
78 }
79
80 echo -n "Creating VBD: "
81 vbd_uuid=$(${XE} vbd-create vm-uuid=${CONTROL_DOMAIN_UUID} vdi-uuid=${vdi_uuid} device=autodetect)
82 echo ${vbd_uuid}
83
84 if [ $? -ne 0 -o -z "${vbd_uuid}" ]; then
85 echo error creating VBD
86 cleanup
87 exit 1
88 fi
89
90 echo -n "Plugging VBD: "
91 ${XE} vbd-plug uuid=${vbd_uuid}
92 device=/dev/$(${XE} vbd-param-get uuid=${vbd_uuid} param-name=device)
93
94 if [ ! -b ${device} ]; then
95 echo ${device}: not a block special
96 cleanup
97 exit 1
98 fi
99
100 echo ${device}
101
102 echo -n "Creating filesystem: "
103 mkfs.ext3 -j -F ${device} > /dev/null 2>&1
104 echo "done"
105
106 echo -n "Mounting filesystem: "
107 mnt=/var/run/crashdump-${vdi_uuid}
108 mkdir -p ${mnt}
109
110 mount ${device} ${mnt}
111
112 if [ $? -ne 0 ]; then
113 echo mount to ${mnt} failed
114 cleanup
115 exit 1
116 fi
117
118 echo "done"
119
120 echo "Xentrace: starting"
121 /usr/bin/xentrace -D -e all -r 1 ${mnt}/trace -T ${TIME}
122
123 echo "Xentrace: compressing"
124 bzip2 -9 ${mnt}/trace
125
126 echo "Xentrace: done"
127 echo "Trace recorded to VDI: ${vdi_uuid}"
128
129 vdi_uuid=""
130 cleanup
Something went wrong with that request. Please try again.