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