]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
9dd003a9 | 2 | # group: rw quick |
9c468a01 | 3 | # |
f33d2873 | 4 | # Test export internal snapshot by qemu-nbd, convert it by qemu-img. |
9c468a01 WX |
5 | # |
6 | # Copyright (C) 2013 IBM, Inc. | |
7 | # | |
8 | # Based on 029. | |
9 | # | |
10 | # This program is free software; you can redistribute it and/or modify | |
11 | # it under the terms of the GNU General Public License as published by | |
12 | # the Free Software Foundation; either version 2 of the License, or | |
13 | # (at your option) any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, | |
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | # GNU General Public License for more details. | |
19 | # | |
20 | # You should have received a copy of the GNU General Public License | |
21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | # | |
23 | ||
24 | # creator | |
25 | [email protected] | |
26 | ||
27 | seq=`basename $0` | |
28 | echo "QA output created by $seq" | |
29 | ||
9c468a01 WX |
30 | status=1 # failure is the default! |
31 | ||
9c468a01 WX |
32 | _export_nbd_snapshot() |
33 | { | |
e6d5d6fd | 34 | nbd_server_start_unix_socket "$TEST_IMG" -l $1 |
9c468a01 WX |
35 | } |
36 | ||
37 | _export_nbd_snapshot1() | |
38 | { | |
e6d5d6fd | 39 | nbd_server_start_unix_socket "$TEST_IMG" -l snapshot.name=$1 |
9c468a01 WX |
40 | } |
41 | ||
42 | _cleanup() | |
43 | { | |
e6d5d6fd | 44 | nbd_server_stop |
9c468a01 | 45 | _cleanup_test_img |
f91ecbd7 | 46 | _rm_test_img "$converted_image" |
9c468a01 WX |
47 | } |
48 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
49 | ||
50 | # get standard environment, filters and checks | |
51 | . ./common.rc | |
52 | . ./common.filter | |
53 | . ./common.pattern | |
e6d5d6fd | 54 | . ./common.nbd |
9c468a01 WX |
55 | |
56 | _supported_fmt qcow2 | |
57 | _supported_proto file | |
9c8ab1ae | 58 | _supported_os Linux |
9c468a01 | 59 | _require_command QEMU_NBD |
3be2024a HR |
60 | # Internal snapshots are (currently) impossible with refcount_bits=1, |
61 | # and generally impossible with external data files | |
62 | _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | |
9c468a01 | 63 | |
e6d5d6fd DB |
64 | nbd_snapshot_img="nbd:unix:$nbd_unix_socket" |
65 | ||
66 | converted_image=$TEST_IMG.converted | |
67 | ||
8f9e835f | 68 | # Use -f raw instead of -f $IMGFMT for the NBD connection |
8dff69b9 | 69 | QEMU_IO_NBD="$QEMU_IO -f raw --cache=$CACHEMODE --aio=$AIOMODE" |
8f9e835f | 70 | |
9c468a01 WX |
71 | echo |
72 | echo "== preparing image ==" | |
73 | _make_test_img 64M | |
74 | $QEMU_IO -c 'write -P 0xa 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
75 | $QEMU_IO -c 'write -P 0xb 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
76 | $QEMU_IMG snapshot -c sn1 "$TEST_IMG" | |
77 | $QEMU_IO -c 'write -P 0xc 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
78 | $QEMU_IO -c 'write -P 0xd 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
79 | _check_test_img | |
80 | ||
81 | echo | |
82 | echo "== verifying the image file with patterns ==" | |
83 | $QEMU_IO -c 'read -P 0xc 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
84 | $QEMU_IO -c 'read -P 0xd 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io | |
85 | ||
86 | _export_nbd_snapshot sn1 | |
87 | ||
88 | echo | |
89 | echo "== verifying the exported snapshot with patterns, method 1 ==" | |
1104d83c EB |
90 | $QEMU_IO_NBD -r -c 'read -P 0xa 0x1000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io |
91 | $QEMU_IO_NBD -r -c 'read -P 0xb 0x2000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io | |
9c468a01 WX |
92 | |
93 | _export_nbd_snapshot1 sn1 | |
94 | ||
95 | echo | |
96 | echo "== verifying the exported snapshot with patterns, method 2 ==" | |
1104d83c EB |
97 | $QEMU_IO_NBD -r -c 'read -P 0xa 0x1000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io |
98 | $QEMU_IO_NBD -r -c 'read -P 0xb 0x2000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io | |
9c468a01 | 99 | |
f33d2873 WX |
100 | $QEMU_IMG convert "$TEST_IMG" -l sn1 -O qcow2 "$converted_image" |
101 | ||
102 | echo | |
103 | echo "== verifying the converted snapshot with patterns, method 1 ==" | |
104 | $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$converted_image" | _filter_qemu_io | |
105 | $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$converted_image" | _filter_qemu_io | |
106 | ||
107 | $QEMU_IMG convert "$TEST_IMG" -l snapshot.name=sn1 -O qcow2 "$converted_image" | |
108 | ||
109 | echo | |
110 | echo "== verifying the converted snapshot with patterns, method 2 ==" | |
111 | $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$converted_image" | _filter_qemu_io | |
112 | $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$converted_image" | _filter_qemu_io | |
113 | ||
9c468a01 WX |
114 | # success, all done |
115 | echo "*** done" | |
116 | rm -f $seq.full | |
117 | status=0 |