xref: /openbmc/qemu/tests/qemu-iotests/070 (revision e78835b7)
1*e78835b7SJeff Cody#!/bin/bash
2*e78835b7SJeff Cody#
3*e78835b7SJeff Cody# Test VHDX log replay from an image with a journal that needs to be
4*e78835b7SJeff Cody# replayed
5*e78835b7SJeff Cody#
6*e78835b7SJeff Cody# Copyright (C) 2013 Red Hat, Inc.
7*e78835b7SJeff Cody#
8*e78835b7SJeff Cody# This program is free software; you can redistribute it and/or modify
9*e78835b7SJeff Cody# it under the terms of the GNU General Public License as published by
10*e78835b7SJeff Cody# the Free Software Foundation; either version 2 of the License, or
11*e78835b7SJeff Cody# (at your option) any later version.
12*e78835b7SJeff Cody#
13*e78835b7SJeff Cody# This program is distributed in the hope that it will be useful,
14*e78835b7SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e78835b7SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e78835b7SJeff Cody# GNU General Public License for more details.
17*e78835b7SJeff Cody#
18*e78835b7SJeff Cody# You should have received a copy of the GNU General Public License
19*e78835b7SJeff Cody# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20*e78835b7SJeff Cody#
21*e78835b7SJeff Cody
22*e78835b7SJeff Cody# creator
23*e78835b7SJeff Codyowner=jcody@redhat.com
24*e78835b7SJeff Cody
25*e78835b7SJeff Codyseq=`basename $0`
26*e78835b7SJeff Codyecho "QA output created by $seq"
27*e78835b7SJeff Cody
28*e78835b7SJeff Codyhere=`pwd`
29*e78835b7SJeff Codytmp=/tmp/$$
30*e78835b7SJeff Codystatus=1	# failure is the default!
31*e78835b7SJeff Cody
32*e78835b7SJeff Cody_cleanup()
33*e78835b7SJeff Cody{
34*e78835b7SJeff Cody    _cleanup_test_img
35*e78835b7SJeff Cody}
36*e78835b7SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
37*e78835b7SJeff Cody
38*e78835b7SJeff Cody# get standard environment, filters and checks
39*e78835b7SJeff Cody. ./common.rc
40*e78835b7SJeff Cody. ./common.filter
41*e78835b7SJeff Cody
42*e78835b7SJeff Cody_supported_fmt vhdx
43*e78835b7SJeff Cody_supported_proto generic
44*e78835b7SJeff Cody_supported_os Linux
45*e78835b7SJeff Cody
46*e78835b7SJeff Cody# With the log replayed, the pattern 0xa5 extends to 0xc025000
47*e78835b7SJeff Cody# If the log was not replayed, it would only extend to 0xc000000
48*e78835b7SJeff Cody#
49*e78835b7SJeff Cody# This image is a 10G dynamic image, with 4M block size, and 1 unplayed
50*e78835b7SJeff Cody# data sector in the log
51*e78835b7SJeff Cody#
52*e78835b7SJeff Cody# This image was created with qemu-img, however it was verified using
53*e78835b7SJeff Cody# Hyper-V to properly replay the logs and give the same post-replay
54*e78835b7SJeff Cody# image as qemu.
55*e78835b7SJeff Cody_use_sample_img iotest-dirtylog-10G-4M.vhdx.bz2
56*e78835b7SJeff Cody
57*e78835b7SJeff Codyecho
58*e78835b7SJeff Codyecho "=== Verify open image read-only fails, due to dirty log ==="
59*e78835b7SJeff Cody$QEMU_IO -r -c "read -pP 0xa5 0 18M" "$TEST_IMG" 2>&1 | grep -o "Permission denied"
60*e78835b7SJeff Cody
61*e78835b7SJeff Codyecho "=== Verify open image replays log  ==="
62*e78835b7SJeff Cody$QEMU_IO  -c "read -pP 0xa5 0 18M" "$TEST_IMG" | _filter_qemu_io
63*e78835b7SJeff Cody
64*e78835b7SJeff Cody# success, all done
65*e78835b7SJeff Codyecho "*** done"
66*e78835b7SJeff Codyrm -f $seq.full
67*e78835b7SJeff Codystatus=0
68