From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdcV8-0001y2-1Y for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:00:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdcV0-00012V-2K for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:00:41 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:40908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdcUz-00010S-3U for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:00:33 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Nov 2013 14:30:28 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id A93EA3940057 for ; Tue, 5 Nov 2013 14:30:03 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rA590LqF42008786 for ; Tue, 5 Nov 2013 14:30:21 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rA590NQr016636 for ; Tue, 5 Nov 2013 14:30:23 +0530 Message-ID: <5278B3A9.1040201@linux.vnet.ibm.com> Date: Tue, 05 Nov 2013 17:00:25 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1383611706-22107-1-git-send-email-mreitz@redhat.com> <1383611706-22107-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1383611706-22107-3-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-iotests: Add test for unbacked mirroring List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi ÓÚ 2013/11/5 8:35, Max Reitz дµÀ: > Add a new test for mirroring unbacked images in "absolute-paths" mode. > This should work, if possible, but most importantly, qemu should never > crash. > > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/070 | 91 ++++++++++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/070.out | 33 +++++++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 125 insertions(+) > create mode 100755 tests/qemu-iotests/070 > create mode 100644 tests/qemu-iotests/070.out > > diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070 > new file mode 100755 > index 0000000..25ecf99 > --- /dev/null > +++ b/tests/qemu-iotests/070 > @@ -0,0 +1,91 @@ > +#!/bin/bash > +# > +# Test mirroring block device without backing file in absolute-paths mode > +# > +# 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=mreitz@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 qed qcow2 qcow2 vmdk > +_supported_proto file > +_supported_os Linux > + > +function do_run_qemu() > +{ > + echo Testing: "$@" | _filter_imgfmt > + $QEMU -nographic -qmp stdio -serial none "$@" > + echo > +} > + > +function run_qemu() > +{ > + # Filter out empty returns and the SHUTDOWN event, because these may occur > + # interleaved with the block job events (in a non-deterministic manner). > + # Also, filter out the "Formatting" message which is emitted when the target > + # image is created - it contains format-specific information. > + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp |\ > + grep -v '{"return": {}}' | grep -v '"event": "SHUTDOWN"' |\ > + grep -v '^Formatting' > +} > + > +size=128K > + > +_make_test_img $size > + > +for sync in full top none > +do > + > +echo > +echo "=== Mirroring non-backed image in absolute-paths mode with sync=$sync ===" > +echo > + > +run_qemu -drive file="$TEST_IMG",format="$IMGFMT",if=none,id=disk \ > + -device virtio-blk-pci,drive=disk,id=virtio0 < +{ "execute": "qmp_capabilities" } > +{ "execute": "drive-mirror", > + "arguments": { "device": "disk", "target": "$TEST_IMG.target", > + "format": "$IMGFMT", "mode": "absolute-paths", > + "sync": "$sync" } } > +{ "execute": "quit" } > +EOF > + > +rm -f $TEST_IMG.target > + > +done > + > +# success, all done > +echo "*** done" > +rm -f $seq.full > +status=0 > diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out > new file mode 100644 > index 0000000..246b0f1 > --- /dev/null > +++ b/tests/qemu-iotests/070.out > @@ -0,0 +1,33 @@ > +QA output created by 070 > +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 > + > +=== Mirroring non-backed image in absolute-paths mode with sync=full === > + > +Testing: -drive file=TEST_DIR/t.IMGFMT,format=IMGFMT,if=none,id=disk -device virtio-blk-pci,drive=disk,id=virtio0 > +QMP_VERSION > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > + > + > +=== Mirroring non-backed image in absolute-paths mode with sync=top === > + > +Testing: -drive file=TEST_DIR/t.IMGFMT,format=IMGFMT,if=none,id=disk -device virtio-blk-pci,drive=disk,id=virtio0 > +QMP_VERSION > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > + > + > +=== Mirroring non-backed image in absolute-paths mode with sync=none === > + > +Testing: -drive file=TEST_DIR/t.IMGFMT,format=IMGFMT,if=none,id=disk -device virtio-blk-pci,drive=disk,id=virtio0 > +QMP_VERSION > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > + > +*** done > diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group > index c57ff35..b18b241 100644 > --- a/tests/qemu-iotests/group > +++ b/tests/qemu-iotests/group > @@ -75,3 +75,4 @@ > 067 rw auto > 068 rw auto > 069 rw auto > +070 rw auto > The code seems fine, but why not use python code as 056? I think for cases that need start qemu, python is better since the infras is ready and easier to talk with qmp protocol.