1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2e78835b7SJeff Cody# 3e78835b7SJeff Cody# Test VHDX log replay from an image with a journal that needs to be 4e78835b7SJeff Cody# replayed 5e78835b7SJeff Cody# 6e78835b7SJeff Cody# Copyright (C) 2013 Red Hat, Inc. 7e78835b7SJeff Cody# 8e78835b7SJeff Cody# This program is free software; you can redistribute it and/or modify 9e78835b7SJeff Cody# it under the terms of the GNU General Public License as published by 10e78835b7SJeff Cody# the Free Software Foundation; either version 2 of the License, or 11e78835b7SJeff Cody# (at your option) any later version. 12e78835b7SJeff Cody# 13e78835b7SJeff Cody# This program is distributed in the hope that it will be useful, 14e78835b7SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of 15e78835b7SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16e78835b7SJeff Cody# GNU General Public License for more details. 17e78835b7SJeff Cody# 18e78835b7SJeff Cody# You should have received a copy of the GNU General Public License 19e78835b7SJeff Cody# along with this program. If not, see <http://www.gnu.org/licenses/>. 20e78835b7SJeff Cody# 21e78835b7SJeff Cody 22e78835b7SJeff Cody# creator 23e78835b7SJeff Codyowner=jcody@redhat.com 24e78835b7SJeff Cody 25e78835b7SJeff Codyseq=`basename $0` 26e78835b7SJeff Codyecho "QA output created by $seq" 27e78835b7SJeff Cody 28e78835b7SJeff Codystatus=1 # failure is the default! 29e78835b7SJeff Cody 30e78835b7SJeff Cody_cleanup() 31e78835b7SJeff Cody{ 32e78835b7SJeff Cody _cleanup_test_img 33e78835b7SJeff Cody} 34e78835b7SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 35e78835b7SJeff Cody 36e78835b7SJeff Cody# get standard environment, filters and checks 37e78835b7SJeff Cody. ./common.rc 38e78835b7SJeff Cody. ./common.filter 39e78835b7SJeff Cody 40e78835b7SJeff Cody_supported_fmt vhdx 41e78835b7SJeff Cody_supported_proto generic 42e78835b7SJeff Cody_supported_os Linux 43e78835b7SJeff Cody 44e78835b7SJeff Cody# With the log replayed, the pattern 0xa5 extends to 0xc025000 45e78835b7SJeff Cody# If the log was not replayed, it would only extend to 0xc000000 46e78835b7SJeff Cody# 47e78835b7SJeff Cody# This image is a 10G dynamic image, with 4M block size, and 1 unplayed 48e78835b7SJeff Cody# data sector in the log 49e78835b7SJeff Cody# 50e78835b7SJeff Cody# This image was created with qemu-img, however it was verified using 51e78835b7SJeff Cody# Hyper-V to properly replay the logs and give the same post-replay 52e78835b7SJeff Cody# image as qemu. 53e78835b7SJeff Cody_use_sample_img iotest-dirtylog-10G-4M.vhdx.bz2 54e78835b7SJeff Cody 55e78835b7SJeff Codyecho 56e78835b7SJeff Codyecho "=== Verify open image read-only fails, due to dirty log ===" 57e0018078SJeff Cody$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | _filter_testdir \ 58e0018078SJeff Cody | _filter_qemu_io 59e78835b7SJeff Cody 60e78835b7SJeff Codyecho "=== Verify open image replays log ===" 61e78835b7SJeff Cody$QEMU_IO -c "read -pP 0xa5 0 18M" "$TEST_IMG" | _filter_qemu_io 62e78835b7SJeff Cody 6318968ca1SJeff Cody# extract fresh sample image again 6418968ca1SJeff Cody_use_sample_img iotest-dirtylog-10G-4M.vhdx.bz2 6518968ca1SJeff Cody 6618968ca1SJeff Codyecho "=== Verify qemu-img check -r all replays log ===" 6718968ca1SJeff Cody$QEMU_IMG check -r all "$TEST_IMG" 2>&1 | _filter_testdir | _filter_qemu 6818968ca1SJeff Cody 6918968ca1SJeff Codyecho "=== Verify open image read-only succeeds after log replay ===" 7018968ca1SJeff Cody$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | _filter_testdir \ 7118968ca1SJeff Cody | _filter_qemu_io 7218968ca1SJeff Cody 7326e2da72SJeff Cody_cleanup_test_img 7426e2da72SJeff Cody_use_sample_img test-disk2vhd.vhdx.bz2 7526e2da72SJeff Cody 7626e2da72SJeff Codyecho 7726e2da72SJeff Codyecho "=== Verify image created by Disk2VHD can be opened ===" 781b53eab2SMax Reitz_img_info 7926e2da72SJeff Cody 80e78835b7SJeff Cody# success, all done 81e78835b7SJeff Codyecho "*** done" 82e78835b7SJeff Codyrm -f $seq.full 83e78835b7SJeff Codystatus=0 84