1f95e26ddSStefan Hajnoczi#!/bin/bash 2f95e26ddSStefan Hajnoczi# 3f95e26ddSStefan Hajnoczi# Test bdrv_read/bdrv_write using BDRV_O_SNAPSHOT 4f95e26ddSStefan Hajnoczi# 5f95e26ddSStefan Hajnoczi# Copyright (C) 2013 Red Hat, Inc. 6f95e26ddSStefan Hajnoczi# 7f95e26ddSStefan Hajnoczi# This program is free software; you can redistribute it and/or modify 8f95e26ddSStefan Hajnoczi# it under the terms of the GNU General Public License as published by 9f95e26ddSStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or 10f95e26ddSStefan Hajnoczi# (at your option) any later version. 11f95e26ddSStefan Hajnoczi# 12f95e26ddSStefan Hajnoczi# This program is distributed in the hope that it will be useful, 13f95e26ddSStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of 14f95e26ddSStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15f95e26ddSStefan Hajnoczi# GNU General Public License for more details. 16f95e26ddSStefan Hajnoczi# 17f95e26ddSStefan Hajnoczi# You should have received a copy of the GNU General Public License 18f95e26ddSStefan Hajnoczi# along with this program. If not, see <http://www.gnu.org/licenses/>. 19f95e26ddSStefan Hajnoczi# 20f95e26ddSStefan Hajnoczi 21f95e26ddSStefan Hajnoczi# creator 22f95e26ddSStefan Hajnocziowner=stefanha@redhat.com 23f95e26ddSStefan Hajnoczi 24f95e26ddSStefan Hajnocziseq=`basename $0` 25f95e26ddSStefan Hajnocziecho "QA output created by $seq" 26f95e26ddSStefan Hajnoczi 27f95e26ddSStefan Hajnoczihere=`pwd` 28f95e26ddSStefan Hajnoczistatus=1 # failure is the default! 29f95e26ddSStefan Hajnoczi 30f95e26ddSStefan Hajnoczi_cleanup() 31f95e26ddSStefan Hajnoczi{ 32f95e26ddSStefan Hajnoczi _cleanup_test_img 33f95e26ddSStefan Hajnoczi} 34f95e26ddSStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15 35f95e26ddSStefan Hajnoczi 36f95e26ddSStefan Hajnoczi# get standard environment, filters and checks 37f95e26ddSStefan Hajnoczi. ./common.rc 38f95e26ddSStefan Hajnoczi. ./common.filter 39f95e26ddSStefan Hajnoczi 40f95e26ddSStefan Hajnoczi_supported_fmt generic 411f7bf7d0SPeter Lieven_supported_proto file 42f95e26ddSStefan Hajnoczi_supported_os Linux 43cf77b2d2SKevin Wolf 44cf77b2d2SKevin Wolf# Don't do O_DIRECT on tmpfs 45cf77b2d2SKevin Wolf_supported_cache_modes "writeback" "writethrough" "unsafe" 46f95e26ddSStefan Hajnoczi 47f95e26ddSStefan Hajnoczisize=128M 48f95e26ddSStefan Hajnoczi_make_test_img $size 49f95e26ddSStefan Hajnoczi 50f95e26ddSStefan Hajnocziecho 51*4e9b25fbSDaniel P. Berrangeecho "== initializing whole image ==" 52*4e9b25fbSDaniel P. Berrange$QEMU_IO -c "write -z 0 $size" "$TEST_IMG" | _filter_qemu_io 53*4e9b25fbSDaniel P. Berrange 54*4e9b25fbSDaniel P. Berrangeecho 55f95e26ddSStefan Hajnocziecho "== reading whole image ==" 56fef9c191SJeff Cody$QEMU_IO -s -c "read 0 $size" "$TEST_IMG" | _filter_qemu_io 57f95e26ddSStefan Hajnoczi 58f95e26ddSStefan Hajnocziecho 59f95e26ddSStefan Hajnocziecho "== writing whole image does not modify image ==" 60fef9c191SJeff Cody$QEMU_IO -s -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io 61fef9c191SJeff Cody$QEMU_IO -c "read -P 0 0 $size" "$TEST_IMG" | _filter_qemu_io 62f95e26ddSStefan Hajnoczi 63f95e26ddSStefan Hajnoczi# success, all done 64f95e26ddSStefan Hajnocziecho "*** done" 65f95e26ddSStefan Hajnoczirm -f $seq.full 66f95e26ddSStefan Hajnoczistatus=0 67