From patchwork Tue Jun 19 01:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Nagh8KEv"; dkim-atps=neutral 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 418rl00rSgz9s3C for ; Tue, 19 Jun 2018 12:00:10 +1000 (AEST) Received: from localhost ([::1]:38443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5wF-0003pu-Ad for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:00:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gy-0000Rl-VZ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gx-0007ph-PF for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:21 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gx-0007pP-JV; Mon, 18 Jun 2018 21:44:19 -0400 Received: by mail-oi0-x242.google.com with SMTP id i205-v6so16709866oib.1; Mon, 18 Jun 2018 18:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=CFPvEc2FPtnSKiImtAxMORd/d6rO0QKUrCg2a7jRC0I=; b=Nagh8KEvW6YuBcMdWKnsEwvh+HAVvsRBT8YDBY328ni0Kdq6fsXQAdlDcNZi9rGkX5 aw5kluKmj9s6+74sOYKJg1RPGerUS4GGq5PBpKmue+EbwIGZ+jMIrFYVIhYQs0czDU/h sIF1KbzWdHx3GpzV5PUmVOaiHpa0SgVywo144Ie4MQRXlf88SaSc3j1FAiIpX7BN6Ea+ dOQPvzw7rLoLX/26ELLyHpUCcmhKINc4D89BPYknG40ossc0b2rQSplo192QBOZBpBy6 bONkfmxiEMfLwmtD+LiuBFsXkLbu4409xTISPf5E8Pyrb3DGI5ExJ8Cs9niLzD4MLRls 9SOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=CFPvEc2FPtnSKiImtAxMORd/d6rO0QKUrCg2a7jRC0I=; b=p811my4JF3+ApgW0nFxrx0ik3HHynSmY0qbJXgSAckk53pZDiNRcNSxGiVZoWI5nG9 8KgP0W21djGx+xS3ocEBjnmRpBXeHyFeLjJY9TdjhnpDZSEDF/kUPO0dZqU5RrtglpNq ZFSRGoGm3xAqdMu4hn+ojrTPpXTGSRKlIuXqP40oRn34mQAaujfGPF8q3jBpQO/hs1ws ffsIo43ob0/G3J/JhGFuc22U04TlTiGR5d3JpnkQY328uIPWfrO++cpghdKLjpc1H9MZ uLOHLKXXTNbopEWnWx6jnUQl1WTDhXyZnIZ1GqbcP/0jnNFp92uIcP9rTg8xyQGiQ/qU hE4Q== X-Gm-Message-State: APt69E0Gpg6AMt163wRkLqhtTUVoHBFpXmSETwrSqvQH60Q/3k7sdTD8 QDmvbATYwujyu0sQWQ5SvQuJ6b+Y X-Google-Smtp-Source: ADUXVKKTZkDLkctn75ejlpWvaYN1lgvQXH9Ec8b9m2WyUXjRyY2mCxLWW1jWd8IvGwWsO2Y9ujQfww== X-Received: by 2002:aca:e142:: with SMTP id y63-v6mr8689732oig.128.1529372658365; Mon, 18 Jun 2018 18:44:18 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t10-v6sm8489067ota.23.2018.06.18.18.44.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:18 -0500 Message-Id: <20180619014319.28272-113-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 112/113] iotests: Add test 221 to catch qemu-img map regression 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-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Although qemu-img creates aligned files (by rounding up), it must also gracefully handle files that are not sector-aligned. Test that the bug fixed in the previous patch does not recur. It's a bit annoying that we can see the (implicit) hole past the end of the file on to the next sector boundary, so if we ever reach the point where we report a byte-accurate size rather than our current behavior of always rounding up, this test will probably need a slight modification. Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit c6a9d2f6f9bc0c163b3a3073126464a2446bad5f) Conflicts: tests/qemu-iotests/group * drop context dep on tests not present in 2.11 Signed-off-by: Michael Roth --- tests/qemu-iotests/221 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/221.out | 16 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221 new file mode 100755 index 0000000000..41c4e4bdf8 --- /dev/null +++ b/tests/qemu-iotests/221 @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Test qemu-img vs. unaligned images +# +# Copyright (C) 2018 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 . +# + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +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 raw +_supported_proto file +_supported_os Linux + +echo +echo "=== Check mapping of unaligned raw image ===" +echo + +_make_test_img 43009 # qemu-img create rounds size up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +$QEMU_IO -c 'w 43008 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +# success, all done +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out new file mode 100644 index 0000000000..a9c0190aad --- /dev/null +++ b/tests/qemu-iotests/221.out @@ -0,0 +1,16 @@ +QA output created by 221 + +=== Check mapping of unaligned raw image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=43009 +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +wrote 1/1 bytes at offset 43008 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3e688678dd..e6e793c951 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -197,3 +197,4 @@ 197 rw auto quick 198 rw auto 200 rw auto +221 rw auto quick