From patchwork Fri Apr 15 03:28:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8844741 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13B75C0553 for ; Fri, 15 Apr 2016 03:43:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9C6D202F0 for ; Fri, 15 Apr 2016 03:43:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09741202A1 for ; Fri, 15 Apr 2016 03:43:08 +0000 (UTC) Received: from localhost ([::1]:53048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquex-0007Yd-GO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Apr 2016 23:43:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquRT-0005e2-Ch for qemu-devel@nongnu.org; Thu, 14 Apr 2016 23:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aquRR-0003Fz-Jt for qemu-devel@nongnu.org; Thu, 14 Apr 2016 23:29:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquRM-0003Ew-Sk; Thu, 14 Apr 2016 23:29:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B84264073; Fri, 15 Apr 2016 03:29:04 +0000 (UTC) Received: from lemon.nay.redhat.com (dhcp-14-170.nay.redhat.com [10.66.14.170]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3F3S2Ra008188; Thu, 14 Apr 2016 23:29:01 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Apr 2016 11:28:07 +0800 Message-Id: <1460690887-32751-18-git-send-email-famz@redhat.com> In-Reply-To: <1460690887-32751-1-git-send-email-famz@redhat.com> References: <1460690887-32751-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Apr 2016 03:29:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.7 v2 17/17] qemu-iotests: Add test case 152 for image locking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , Markus Armbruster , Max Reitz , den@openvz.org, pbonzini@redhat.com, John Snow Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Fam Zheng --- tests/qemu-iotests/152 | 106 ++++++++++++++++++++ tests/qemu-iotests/152.out | 237 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 344 insertions(+) create mode 100755 tests/qemu-iotests/152 create mode 100644 tests/qemu-iotests/152.out diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152 new file mode 100755 index 0000000..552a0f0 --- /dev/null +++ b/tests/qemu-iotests/152 @@ -0,0 +1,106 @@ +#!/bin/bash +# +# Test image locking +# +# Copyright (C) 2016 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=famz@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 + rm -f "${TEST_IMG}.base" + rm -f "${TEST_IMG}.convert" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +size=32M + +_run_cmd() +{ + echo + (echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir +} + +for opts1 in "" "readonly=on" "lock-image=off"; do + echo + echo "== Creating base image ==" + TEST_IMG="${TEST_IMG}.base" _make_test_img $size + + echo + echo "== Creating test image ==" + $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create + + echo + echo "== Launching QEMU $opts1 ==" + _launch_qemu -drive file="${TEST_IMG}",if=none,$opts1 + h=$QEMU_HANDLE + + for opts2 in "" "lock-image=on" "lock-image=off" "lock-image=on,readonly=on"; do + echo + echo "== Launching another QEMU $opts2 ==" + echo "quit" | \ + $QEMU -nographic -monitor stdio \ + -drive file="${TEST_IMG}",if=none,$opts2 2>&1 1>/dev/null | \ + _filter_testdir | _filter_qemu + done + + for L in "" "-L"; do + + echo + echo "== Running utility commands $(test -n "$L" && echo "(lock disabled)") ==" + _run_cmd $QEMU_IO $L -c "read 0 512" "${TEST_IMG}" + _run_cmd $QEMU_IO $L -r -c "read 0 512" "${TEST_IMG}" + _run_cmd $QEMU_IMG info $L "${TEST_IMG}" + _run_cmd $QEMU_IMG check $L "${TEST_IMG}" + _run_cmd $QEMU_IMG compare $L "${TEST_IMG}" "${TEST_IMG}" + _run_cmd $QEMU_IMG map $L "${TEST_IMG}" + _run_cmd $QEMU_IMG amend $L "${TEST_IMG}" -o "" + _run_cmd $QEMU_IMG commit $L "${TEST_IMG}" + _run_cmd $QEMU_IMG resize $L "${TEST_IMG}" $size + _run_cmd $QEMU_IMG rebase $L "${TEST_IMG}" -b "${TEST_IMG}.base" + _run_cmd $QEMU_IMG snapshot -l $L "${TEST_IMG}" + _run_cmd $QEMU_IMG convert $L "${TEST_IMG}" "${TEST_IMG}.convert" + done + _send_qemu_cmd $h 'quit' "" + echo + echo "Round done" + _cleanup_qemu +done + + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/152.out b/tests/qemu-iotests/152.out new file mode 100644 index 0000000..fa4f86e --- /dev/null +++ b/tests/qemu-iotests/152.out @@ -0,0 +1,237 @@ +QA output created by 152 + +== Creating base image == +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=33554432 + +== Creating test image == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t.IMGFMT.base + +== Launching QEMU == + +== Launching another QEMU == +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to lock image + +== Launching another QEMU lock-image=on == +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,lock-image=on: Failed to lock image + +== Launching another QEMU lock-image=off == + +== Launching another QEMU lock-image=on,readonly=on == +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,lock-image=on,readonly=on: Failed to lock image + +== Running utility commands == + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to lock image +no file open, try 'help open' + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to lock image +no file open, try 'help open' + +_qemu_img_wrapper info TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper check TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper map TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper amend TEST_DIR/t.qcow2 -o +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +== Running utility commands (lock disabled) == + +_qemu_io_wrapper -L -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -L -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_img_wrapper info -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -L TEST_DIR/t.qcow2 -o + +_qemu_img_wrapper commit -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper resize -L TEST_DIR/t.qcow2 32M + +_qemu_img_wrapper rebase -L TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +Round done + +== Creating base image == +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=33554432 + +== Creating test image == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t.IMGFMT.base + +== Launching QEMU readonly=on == + +== Launching another QEMU == +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to lock image + +== Launching another QEMU lock-image=on == +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,lock-image=on: Failed to lock image + +== Launching another QEMU lock-image=off == + +== Launching another QEMU lock-image=on,readonly=on == + +== Running utility commands == + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to lock image +no file open, try 'help open' + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_img_wrapper info TEST_DIR/t.qcow2 + +_qemu_img_wrapper check TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend TEST_DIR/t.qcow2 -o +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to lock image + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +== Running utility commands (lock disabled) == + +_qemu_io_wrapper -L -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -L -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_img_wrapper info -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -L TEST_DIR/t.qcow2 -o + +_qemu_img_wrapper commit -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper resize -L TEST_DIR/t.qcow2 32M + +_qemu_img_wrapper rebase -L TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +Round done + +== Creating base image == +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=33554432 + +== Creating test image == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t.IMGFMT.base + +== Launching QEMU lock-image=off == + +== Launching another QEMU == + +== Launching another QEMU lock-image=on == + +== Launching another QEMU lock-image=off == + +== Launching another QEMU lock-image=on,readonly=on == + +== Running utility commands == + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_img_wrapper info TEST_DIR/t.qcow2 + +_qemu_img_wrapper check TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend TEST_DIR/t.qcow2 -o + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +== Running utility commands (lock disabled) == + +_qemu_io_wrapper -L -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -L -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_img_wrapper info -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -L TEST_DIR/t.qcow2 -o + +_qemu_img_wrapper commit -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper resize -L TEST_DIR/t.qcow2 32M + +_qemu_img_wrapper rebase -L TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l -L TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -L TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +Round done +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 2952b9d..822953b 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -152,3 +152,4 @@ 148 rw auto quick 149 rw auto sudo 150 rw auto quick +152 rw auto quick