From patchwork Fri Feb 25 22:37:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunqiang Tang X-Patchwork-Id: 84583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id 3947BB70ED for ; Sat, 26 Feb 2011 10:07:30 +1100 (EST) Received: from localhost ([127.0.0.1]:34370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pt6g1-0004dq-J4 for incoming@patchwork.ozlabs.org; Fri, 25 Feb 2011 18:02:21 -0500 Received: from [140.186.70.92] (port=49306 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pt6SV-0006FY-Qo for qemu-devel@nongnu.org; Fri, 25 Feb 2011 17:48:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pt6SO-0004nz-2y for qemu-devel@nongnu.org; Fri, 25 Feb 2011 17:48:21 -0500 Received: from e2.ny.us.ibm.com ([32.97.182.142]:51236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pt6SN-0004hm-Vq for qemu-devel@nongnu.org; Fri, 25 Feb 2011 17:48:16 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p1PMTfEQ029925 for ; Fri, 25 Feb 2011 17:29:43 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 3A65B38C803A for ; Fri, 25 Feb 2011 17:47:52 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p1PMlq0w354566 for ; Fri, 25 Feb 2011 17:47:52 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p1PMlqi4020724 for ; Fri, 25 Feb 2011 19:47:52 -0300 Received: from localhost.localdomain ([9.59.229.24]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p1PMlp91020693; Fri, 25 Feb 2011 19:47:51 -0300 From: Chunqiang Tang To: qemu-devel@nongnu.org Date: Fri, 25 Feb 2011 17:37:43 -0500 Message-Id: <1298673486-3573-3-git-send-email-ctang@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1298673486-3573-1-git-send-email-ctang@us.ibm.com> References: <1298673486-3573-1-git-send-email-ctang@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.142 Cc: Chunqiang Tang Subject: [Qemu-devel] [PATCH 03/26] FVD: add fully automated test-qcow2.sh X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch is part of the Fast Virtual Disk (FVD) proposal. See http://wiki.qemu.org/Features/FVD. test-qcow2.sh drives 'qemu-io --auto' to perform fully automated testing for QCOW2. Signed-off-by: Chunqiang Tang --- test-qcow2.sh | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 89 insertions(+), 0 deletions(-) create mode 100755 test-qcow2.sh diff --git a/test-qcow2.sh b/test-qcow2.sh new file mode 100755 index 0000000..d1e4dc0 --- /dev/null +++ b/test-qcow2.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Drive 'qemu-io --auto' to test the QCOW2 image format. +# +# Copyright IBM, Corp. 2010 +# +# Authors: +# Chunqiang Tang +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING.LIB file in the top-level directory. + +if [ $USER != "root" ]; then + echo "This command must be run by root in order to mount tmpfs." + exit 1 +fi + +QEMU_DIR=. +QEMU_IMG=$QEMU_DIR/qemu-img +QEMU_IO=$QEMU_DIR/qemu-io + +if [ ! -e $QEMU_IMG ]; then + echo "$QEMU_IMG does not exist." + exit 1; +fi + +if [ ! -e $QEMU_IO ]; then + echo "$QEMU_IO does not exist." + exit 1; +fi + +DATA_DIR=/var/ramdisk +TRUTH_IMG=$DATA_DIR/truth.raw +TEST_IMG=$DATA_DIR/test.qcow2 +TEST_BASE=$DATA_DIR/zero-500M.raw +CMD_LOG=./test-qcow2.log + +parallel=100 +round=10000 +fail_prob=0.1 +cancel_prob=0 +instant_qemubh=true +seed=$RANDOM$RANDOM +count=0 + +function invoke() { + echo "$*" >> $CMD_LOG + $* + ret=$? + if [ $ret -ne 0 ]; then + echo "Exit with error code $ret: $*" + exit $ret + fi +} + +mount | grep $DATA_DIR > /dev/null +if [ $? -ne 0 ]; then + echo "Create tmpfs at $DATA_DIR to store testing images." + if [ ! -e $DATA_DIR ]; then mkdir -p $DATA_DIR ; fi + invoke "mount -t tmpfs none $DATA_DIR -o size=4G" + if [ $? -ne 0 ]; then exit 1; fi +fi + +/bin/rm -f $CMD_LOG $DATA_DIR/* +touch $CMD_LOG + +while [ -t ]; do +for cache in none writethrough writeback; do +for cluster_size in 65536 ; do +for io_size in 1048576 ; do + count=$[$count + 1] + echo "Round $count" >> $CMD_LOG + + # QCOW2 image is about 1G + img_size=$[(1073741824 + ($RANDOM$RANDOM$RANDOM % 104857600)) / 512 * 512] + + # base image is about 500MB + base_size=$[(536870912 + ($RANDOM$RANDOM$RANDOM % 104857600)) / 512 * 512] + + invoke "/bin/rm -rf $TRUTH_IMG $TEST_IMG $TEST_BASE" + invoke "$QEMU_IO --auto --create=$TEST_BASE --seed=$seed --block_size=1048576 --empty_block_prob=0 --empty_block_chain=1 --file_size=$base_size" + invoke "cp --sparse=always $TEST_BASE $TRUTH_IMG" + invoke "dd if=/dev/zero of=$TRUTH_IMG count=0 bs=1 seek=$img_size" + invoke "$QEMU_IMG create -f qcow2 -ocluster_size=$cluster_size,backing_fmt=blksim -b $TEST_BASE $TEST_IMG $img_size" + + invoke "$QEMU_IO --auto --cache=$cache --seed=$seed --truth=$TRUTH_IMG --format=qcow2 --test="blksim:$TEST_IMG" --verify_write=true --compare_before=false --compare_after=true --round=$round --parallel=$parallel --io_size=$io_size --fail_prob=$fail_prob --cancel_prob=$cancel_prob --instant_qemubh=$instant_qemubh" + + seed=$[$seed + 1] +done; done; done; done