Lines Matching +full:fixed +full:- +full:length
35 rm -f "$TEST_IMG".v{2,3}.orig
36 rm -f "$TEST_DIR"/sn{0,1,2}{,-pre,-extra,-post}
44 # This tests qcow2-specific low-level functionality
89 if [ $extra_len -ge 8 ]; then
92 if [ $extra_len -ge 16 ]; then
95 if [ $extra_len -ge 24 ]; then
98 if [ $extra_len -gt 24 ]; then
100 "$(peek_file_raw "$1" $((extra_ofs + 16)) $((extra_len - 16)) \
101 | tr -d '\0')"
121 while [ $cluster -lt $ecluster ]; do
122 if [ $cluster -ge 32768 ]; then
139 # [2]: Has the 64-bit VM state size, but not the disk size (again,
143 $QEMU_IMG snapshot -c sn0 "$TEST_IMG.v2.orig"
144 $QEMU_IMG snapshot -c sn1 "$TEST_IMG.v2.orig"
145 $QEMU_IMG snapshot -c sn2 "$TEST_IMG.v2.orig"
153 # len: Total entry length
171 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn0-pre" bs=1 skip=$sn0_ofs count=40 \
173 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn1-pre" bs=1 skip=$sn1_ofs count=40 \
175 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn2-pre" bs=1 skip=$sn2_ofs count=40 \
179 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn0-extra" bs=1 \
181 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn1-extra" bs=1 \
183 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn2-extra" bs=1 \
187 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn0-post" bs=1 \
190 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn1-post" bs=1 \
193 dd if="$TEST_IMG.v2.orig" of="$TEST_DIR/sn2-post" bs=1 \
199 poke_file "$TEST_DIR/sn0-pre" 36 '\x00\x00\x00\x00'
200 truncate -s 0 "$TEST_DIR/sn0-extra"
201 # Grow sn0-post to pad
202 truncate -s $(($(snapshot_table_entry_size "$TEST_DIR/sn0-pre") - 40)) \
203 "$TEST_DIR/sn0-post"
206 poke_file "$TEST_DIR/sn1-pre" 36 '\x00\x00\x00\x32'
207 truncate -s 50 "$TEST_DIR/sn1-extra"
208 poke_file "$TEST_DIR/sn1-extra" 24 'very important data'
209 # Grow sn1-post to pad
210 truncate -s $(($(snapshot_table_entry_size "$TEST_DIR/sn1-pre") - 90)) \
211 "$TEST_DIR/sn1-post"
214 poke_file "$TEST_DIR/sn2-pre" 36 '\x00\x00\x00\x08'
215 truncate -s 8 "$TEST_DIR/sn2-extra"
216 # Grow sn2-post to pad
217 truncate -s $(($(snapshot_table_entry_size "$TEST_DIR/sn2-pre") - 48)) \
218 "$TEST_DIR/sn2-post"
221 cat "$TEST_DIR"/sn0-{pre,extra,post} \
222 "$TEST_DIR"/sn1-{pre,extra,post} \
223 "$TEST_DIR"/sn2-{pre,extra,post} \
236 $QEMU_IMG amend -o compat=1.1 "$TEST_IMG.v3.orig"
251 # Increase header length (necessary for v3)
256 _check_test_img -r all
265 if echo "$IMGOPTS" | grep -q 'compat=\(0\.10\|v2\)' 2> /dev/null; then
276 $QEMU_IMG snapshot -c sn3 "$TEST_IMG"
285 echo "--- $sn ---"
288 $QEMU_IMG snapshot -d $sn "$TEST_IMG"
298 $QEMU_IMG snapshot -c sn3 "$TEST_IMG"
319 _check_test_img -r all
327 # Fill a snapshot with 1 kB of extra data, a 65535-char ID, and a
328 # 65535-char name, and repeat it as many times as necessary to fill
333 # Full size (fixed + extra + ID + name + padding)
336 # We only need the fixed part, though.
337 truncate -s 40 "$TEST_DIR/sn0"
339 # 65535-char ID string
341 # 65535-char name
355 while [ $size_written -le $((64 * 1048576)) ]; do
362 truncate -s "$offset" "$TEST_IMG"
368 poke_file "$TEST_IMG" $((offset - sn_size + 0)) \
370 poke_file "$TEST_IMG" $((offset - sn_size + 8)) \
374 poke_file "$TEST_IMG" $((1048576 - 2 * 65536)) \
378 # - The snapshot table
379 # - The last snapshot's L1 and L2 table
380 refblock0_allocate $((1048576 - 2 * 65536)) $offset
383 "$(printf '%08x' $sn_count | sed -e 's/\(..\)/\\x\1/g')"
392 _check_test_img -r all
395 echo "$((sn_count - 1)) snapshots should remain:"
396 echo " qemu-img info reports $(_img_info | grep -c '^ \{30\}') snapshots"
406 # - (a number of snapshot table entries)
407 # - One snapshot with $extra_data_size extra data
408 # - One normal snapshot that breaks the 64 MB boundary
409 # - One normal snapshot beyond the 64 MB boundary
419 # $old_offset to get the current image's real length
420 old_offset=$((offset - sn_size))
426 offset=$((offset - 3 * sn_size))
427 sn_count=$((sn_count - 3))
431 size_written=$((size_written - 2 * sn_size))
434 # (The -1024 comes from the 1 kB of extra data we already have)
435 extra_data_size=$((64 * 1048576 + 8 - sn_size - (size_written - 1024)))
438 "$(printf '%08x' $extra_data_size | sed -e 's/\(..\)/\\x\1/g')"
440 offset=$((offset + sn_size - 1024 + extra_data_size))
441 size_written=$((size_written - 1024 + extra_data_size))
460 truncate -s $offset "$TEST_IMG"
464 "$(printf '%08x' $sn_count | sed -e 's/\(..\)/\\x\1/g')"
474 _check_test_img -r all
480 # Create a v2 image, for speeds' sake: All-zero snapshot table entries
489 # 40-byte all-zero snapshot table entries are valid snapshots, but
492 truncate -s $((1048576 + 40 * 131072)) "$TEST_IMG"
504 poke_file "$TEST_IMG" $((1048576 - 2 * 65536)) \
508 # - The snapshot table
509 # - The last snapshot's L1 and L2 table
510 refblock0_allocate $((1048576 - 2 * 65536)) $((1048576 + 40 * 131072))
519 _check_test_img -r all
523 echo " qemu-img info reports $(_img_info | grep -c '^ \{30\}') snapshots"