From patchwork Mon Jun 8 05:56:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 481795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D15CA1400A0 for ; Mon, 8 Jun 2015 16:01:28 +1000 (AEST) Received: from localhost ([::1]:56069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1q7j-00086Z-4E for incoming@patchwork.ozlabs.org; Mon, 08 Jun 2015 02:01:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1q3S-0000YY-77 for qemu-devel@nongnu.org; Mon, 08 Jun 2015 01:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1q3R-0000RL-45 for qemu-devel@nongnu.org; Mon, 08 Jun 2015 01:57:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1q3M-0000Nj-7x; Mon, 08 Jun 2015 01:56:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id C7A6796C4; Mon, 8 Jun 2015 05:56:55 +0000 (UTC) Received: from ad.nay.redhat.com (dhcp-14-104.nay.redhat.com [10.66.14.104]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t585uEsW007462; Mon, 8 Jun 2015 01:56:51 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 8 Jun 2015 13:56:13 +0800 Message-Id: <1433742974-20128-8-git-send-email-famz@redhat.com> In-Reply-To: <1433742974-20128-1-git-send-email-famz@redhat.com> References: <1433742974-20128-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , qemu-stable@nongnu.org, Stefan Hajnoczi , pbonzini@redhat.com, jsnow@redhat.com, wangxiaolong@ucloud.cn Subject: [Qemu-devel] [PATCH v7 7/8] qemu-iotests: Add test case for mirror with unmap 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 This checks that the discard on mirror source that effectively zeroes data is also reflected by the data of target. Signed-off-by: Fam Zheng Reviewed-by: John Snow --- tests/qemu-iotests/132 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/132.out | 5 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 65 insertions(+) create mode 100644 tests/qemu-iotests/132 create mode 100644 tests/qemu-iotests/132.out diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132 new file mode 100644 index 0000000..f53ef6e --- /dev/null +++ b/tests/qemu-iotests/132 @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Test mirror with unmap +# +# Copyright (C) 2015 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 . +# + +import time +import os +import iotests +from iotests import qemu_img, qemu_io + +test_img = os.path.join(iotests.test_dir, 'test.img') +target_img = os.path.join(iotests.test_dir, 'target.img') + +class TestSingleDrive(iotests.QMPTestCase): + image_len = 2 * 1024 * 1024 # MB + + def setUp(self): + # Write data to the image so we can compare later + qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestSingleDrive.image_len)) + qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 0 2M', test_img) + + self.vm = iotests.VM().add_drive(test_img, 'discard=unmap') + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + try: + os.remove(target_img) + except OSError: + pass + + def test_mirror_discard(self): + result = self.vm.qmp('drive-mirror', device='drive0', sync='full', + target=target_img) + self.assert_qmp(result, 'return', {}) + self.vm.hmp_qemu_io('drive0', 'discard 0 64k') + self.complete_and_wait('drive0') + self.vm.shutdown() + self.assertTrue(iotests.compare_images(test_img, target_img), + 'target image does not match source after mirroring') + +if __name__ == '__main__': + iotests.main(supported_fmts=['raw', 'qcow2']) diff --git a/tests/qemu-iotests/132.out b/tests/qemu-iotests/132.out new file mode 100644 index 0000000..ae1213e --- /dev/null +++ b/tests/qemu-iotests/132.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 0b817ca..757ac1b 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -129,4 +129,5 @@ 129 rw auto quick 130 rw auto quick 131 rw auto quick +132 rw auto quick 134 rw auto quick