forked from xen-project/xen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
check-xl-disk-parse
executable file
·207 lines (171 loc) · 4.11 KB
/
check-xl-disk-parse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
set -e
if [ -x ./xl ] ; then
export LD_LIBRARY_PATH=.:../libxc:../xenstore
XL=./xl
else
XL=xl
fi
fprefix=tmp.check-xl-disk-parse
expected () {
cat >$fprefix.expected
}
failures=0
one () {
expected_rc=$1; shift
printf "test case %s...\n" "$*"
set +e
${XL} -N block-attach 0 "$@" </dev/null >$fprefix.actual 2>/dev/null
actual_rc=$?
diff -u $fprefix.expected $fprefix.actual
diff_rc=$?
set -e
if [ $actual_rc != $expected_rc ] || [ $diff_rc != 0 ]; then
echo >&2 "test case \`$*' failed ($actual_rc $diff_rc)"
failures=$(( $failures + 1 ))
fi
}
complete () {
if [ "$failures" = 0 ]; then
echo all ok.; exit 0
else
echo "$failures tests failed."; exit 1
fi
}
e=1
#---------- test data ----------
#
# culled from docs/misc/xl-disk-configuration.txt
expected </dev/null
one $e foo
expected <<END
disk: {
"pdev_path": "/dev/vg/guest-volume",
"vdev": "hda",
"format": "raw",
"readwrite": 1
}
END
one 0 /dev/vg/guest-volume,,hda
one 0 /dev/vg/guest-volume,raw,hda,rw
one 0 "format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume"
one 0 format=raw vdev=hda access=rw target=/dev/vg/guest-volume
one 0 raw:/dev/vg/guest-volume,hda,w
expected <<END
disk: {
"pdev_path": "/root/image.iso",
"vdev": "hdc",
"format": "raw",
"removable": 1,
"is_cdrom": 1
}
END
one 0 /root/image.iso,,hdc,cdrom
one 0 /root/image.iso,,hdc,,cdrom
one 0 /root/image.iso,raw,hdc,devtype=cdrom
one 0 "format=raw, vdev=hdc, access=ro, devtype=cdrom, target=/root/image.iso"
one 0 format=raw vdev=hdc access=ro devtype=cdrom target=/root/image.iso
one 0 raw:/root/image.iso,hdc:cdrom,ro
expected <<EOF
disk: {
"pdev_path": "/dev/vg/guest-volume",
"vdev": "xvdb",
"backend": "phy",
"format": "raw",
"readwrite": 1
}
EOF
one 0 backendtype=phy,vdev=xvdb,access=w,target=/dev/vg/guest-volume
expected <<EOF
disk: {
"pdev_path": "",
"vdev": "hdc",
"format": "empty",
"removable": 1,
"is_cdrom": 1
}
EOF
one 0 devtype=cdrom,,,hdc
one 0 ,,hdc:cdrom,r
one 0 ,hdc:cdrom,r
one 0 vdev=hdc,access=r,devtype=cdrom,target=
one 0 ,empty,hdc:cdrom,r
expected <<EOF
disk: {
"vdev": "hdc",
"format": "empty",
"removable": 1,
"is_cdrom": 1
}
EOF
one 0 vdev=hdc,access=r,devtype=cdrom,format=empty
one 0 vdev=hdc,access=r,devtype=cdrom
expected <<EOF
disk: {
"pdev_path": "iqn.2001-05.com.equallogic:0-8a0906-23fe93404-c82797962054a96d-examplehost",
"vdev": "xvda",
"format": "raw",
"script": "block-iscsi",
"readwrite": 1
}
EOF
# http://backdrift.org/xen-block-iscsi-script-with-multipath-support
one 0 iscsi:iqn.2001-05.com.equallogic:0-8a0906-23fe93404-c82797962054a96d-examplehost,xvda,w
one 0 vdev=xvda,access=w,script=block-iscsi,target=iqn.2001-05.com.equallogic:0-8a0906-23fe93404-c82797962054a96d-examplehost
expected <<EOF
disk: {
"pdev_path": "app01",
"vdev": "hda",
"format": "raw",
"script": "block-drbd",
"readwrite": 1
}
EOF
# http://lists.linbit.com/pipermail/drbd-user/2008-September/010221.html
# http://www.drbd.org/users-guide-emb/s-xen-configure-domu.html
one 0 drbd:app01,hda,w
expected <<END
disk: {
"pdev_path": "/some/disk/image.raw",
"vdev": "hda",
"format": "raw",
"readwrite": 1,
"discard_enable": "True"
}
END
one 0 discard vdev=hda target=/some/disk/image.raw
one 0 discard vdev=hda target=/some/disk/image.raw
expected <<END
disk: {
"pdev_path": "/some/disk/image.iso",
"vdev": "hda",
"format": "raw",
"removable": 1,
"is_cdrom": 1,
"discard_enable": "False"
}
END
one 0 cdrom no-discard vdev=hda target=/some/disk/image.iso
# test setting trusted
expected <<END
disk: {
"pdev_path": "/some/disk/image.raw",
"vdev": "hda",
"format": "raw",
"readwrite": 1,
"trusted": "True"
}
END
one 0 trusted vdev=hda target=/some/disk/image.raw
# test setting untrusted
expected <<END
disk: {
"pdev_path": "/some/disk/image.raw",
"vdev": "hda",
"format": "raw",
"readwrite": 1,
"trusted": "False"
}
END
one 0 untrusted vdev=hda target=/some/disk/image.raw
complete