From patchwork Fri Feb 22 21:23:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 222658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4F0B62C02AB for ; Sat, 23 Feb 2013 08:26:53 +1100 (EST) Received: from localhost ([::1]:45377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U908p-00063A-H8 for incoming@patchwork.ozlabs.org; Fri, 22 Feb 2013 16:26:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U906X-0002ci-Lw for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U906Q-0003nw-RO for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U906P-0003nO-UN for qemu-devel@nongnu.org; Fri, 22 Feb 2013 16:24:22 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1MLOKv3007051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Feb 2013 16:24:20 -0500 Received: from dhcp-200-207.str.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1MLNuFd010868; Fri, 22 Feb 2013 16:24:19 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 22 Feb 2013 22:23:43 +0100 Message-Id: <1361568231-18198-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1361568231-18198-1-git-send-email-kwolf@redhat.com> References: <1361568231-18198-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 14/22] qemu-iotests: Test qcow2 image creation options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Just create lots of images and try out each of the creation options that qcow2 provides (except backing_file/fmt for now) I'm not totally happy with the behaviour of qemu-img in each of the cases, but let's be explicit and update the test when we do change things later. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/049 | 123 ++++++++++++++++++++++++++ tests/qemu-iotests/049.out | 212 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 336 insertions(+) create mode 100755 tests/qemu-iotests/049 create mode 100644 tests/qemu-iotests/049.out diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049 new file mode 100755 index 0000000..6c6017e --- /dev/null +++ b/tests/qemu-iotests/049 @@ -0,0 +1,123 @@ +#!/bin/bash +# +# Check qemu-img option parsing +# +# Copyright (C) 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=kwolf@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +function filter_test_dir() +{ + sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ + -e "s#$TEST_DIR#TEST_DIR#g" +} + +function test_qemu_img() +{ + echo qemu-img "$@" | filter_test_dir + $QEMU_IMG "$@" 2>&1 | filter_test_dir + echo +} + +echo "=== Check correct interpretation of suffixes for image size ===" +echo +sizes="1024 1024b 1k 1K 1M 1G 1T " +sizes+="1024.0 1024.0b 1.5k 1.5K 1.5M 1.5G 1.5T" + +echo "== 1. Traditional size parameter ==" +echo +for s in $sizes; do + test_qemu_img create -f $IMGFMT $TEST_IMG $s +done + +echo "== 2. Specifying size via -o ==" +echo +for s in $sizes; do + test_qemu_img create -f $IMGFMT -o size=$s $TEST_IMG +done + +echo "== 3. Invalid sizes ==" +echo +sizes="-1024 -1k 1kilobyte foobar" + +for s in $sizes; do + test_qemu_img create -f $IMGFMT $TEST_IMG -- $s + test_qemu_img create -f $IMGFMT -o size=$s $TEST_IMG +done + +echo "== Check correct interpretation of suffixes for cluster size ==" +echo +sizes="1024 1024b 1k 1K 1M " +sizes+="1024.0 1024.0b 0.5k 0.5K 0.5M" + +for s in $sizes; do + test_qemu_img create -f $IMGFMT -o cluster_size=$s $TEST_IMG 64M +done + +echo "== Check compat level option ==" +echo +test_qemu_img create -f $IMGFMT -o compat=0.10 $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o compat=1.1 $TEST_IMG 64M + +test_qemu_img create -f $IMGFMT -o compat=0.42 $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o compat=foobar $TEST_IMG 64M + +echo "== Check preallocation option ==" +echo +test_qemu_img create -f $IMGFMT -o preallocation=off $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o preallocation=metadata $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o preallocation=1234 $TEST_IMG 64M + +echo "== Check encryption option ==" +echo +test_qemu_img create -f $IMGFMT -o encryption=off $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o encryption=on $TEST_IMG 64M + +echo "== Check lazy_refcounts option (only with v3) ==" +echo +test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=off $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=on $TEST_IMG 64M + +test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=off $TEST_IMG 64M +test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=on $TEST_IMG 64M + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out new file mode 100644 index 0000000..72db13f --- /dev/null +++ b/tests/qemu-iotests/049.out @@ -0,0 +1,212 @@ +QA output created by 049 +=== Check correct interpretation of suffixes for image size === + +== 1. Traditional size parameter == + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024b +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1k +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1K +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1T +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1099511627776 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0b +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5k +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5K +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1572864 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5G +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1610612736 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5T +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1649267441664 encryption=off cluster_size=65536 lazy_refcounts=off + +== 2. Specifying size via -o == + +qemu-img create -f qcow2 -o size=1024 TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1024b TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1k TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1K TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1M TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1048576 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1G TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1T TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1099511627776 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1024.0 TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1024.0b TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1.5k TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1.5K TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1.5M TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1572864 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1.5G TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1610612736 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o size=1.5T TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1649267441664 encryption=off cluster_size=65536 lazy_refcounts=off + +== 3. Invalid sizes == + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1024 +qemu-img: Image size must be less than 8 EiB! + +qemu-img create -f qcow2 -o size=-1024 TEST_DIR/t.qcow2 +qemu-img: qcow2 doesn't support shrinking images yet +qemu-img: Formatting or formatting option not supported for file format 'qcow2' +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1k +qemu-img: Image size must be less than 8 EiB! + +qemu-img create -f qcow2 -o size=-1k TEST_DIR/t.qcow2 +qemu-img: qcow2 doesn't support shrinking images yet +qemu-img: Formatting or formatting option not supported for file format 'qcow2' +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte +qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for +qemu-img: kilobytes, megabytes, gigabytes and terabytes. + +qemu-img create -f qcow2 -o size=1kilobyte TEST_DIR/t.qcow2 +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- foobar +qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for +qemu-img: kilobytes, megabytes, gigabytes and terabytes. + +qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2 +qemu-img: Parameter 'size' expects a size +qemu-img: Invalid options for file format 'qcow2'. + +== Check correct interpretation of suffixes for cluster size == + +qemu-img create -f qcow2 -o cluster_size=1024 TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1024b TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1k TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1K TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1M TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1048576 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1024.0 TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=1024.0b TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=1024 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=0.5k TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=512 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=0.5K TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=512 lazy_refcounts=off + +qemu-img create -f qcow2 -o cluster_size=0.5M TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=524288 lazy_refcounts=off + +== Check compat level option == + +qemu-img create -f qcow2 -o compat=0.10 TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='0.10' encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o compat=1.1 TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='1.1' encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o compat=0.42 TEST_DIR/t.qcow2 64M +Invalid compatibility level: '0.42' +qemu-img: TEST_DIR/t.qcow2: error while creating qcow2: Invalid argument +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='0.42' encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o compat=foobar TEST_DIR/t.qcow2 64M +Invalid compatibility level: 'foobar' +qemu-img: TEST_DIR/t.qcow2: error while creating qcow2: Invalid argument +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='foobar' encryption=off cluster_size=65536 lazy_refcounts=off + +== Check preallocation option == + +qemu-img create -f qcow2 -o preallocation=off TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 preallocation='off' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=metadata TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off + +qemu-img create -f qcow2 -o preallocation=1234 TEST_DIR/t.qcow2 64M +Invalid preallocation mode: '1234' +qemu-img: TEST_DIR/t.qcow2: error while creating qcow2: Invalid argument +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 preallocation='1234' lazy_refcounts=off + +== Check encryption option == + +qemu-img create -f qcow2 -o encryption=off TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o encryption=on TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=on cluster_size=65536 lazy_refcounts=off + +== Check lazy_refcounts option (only with v3) == + +qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=off TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='1.1' encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=on TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='1.1' encryption=off cluster_size=65536 lazy_refcounts=on + +qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=off TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='0.10' encryption=off cluster_size=65536 lazy_refcounts=off + +qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=on TEST_DIR/t.qcow2 64M +Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater) +qemu-img: TEST_DIR/t.qcow2: error while creating qcow2: Invalid argument +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat='0.10' encryption=off cluster_size=65536 lazy_refcounts=on + +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1c0dfef..fcf57e0 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -55,3 +55,4 @@ 046 rw auto aio 047 rw auto 048 img auto quick +049 rw auto