[{"id":1778621,"web_url":"http://patchwork.ozlabs.org/comment/1778621/","msgid":"<ae5bcf8e-57de-68c2-8a1a-6599f0e5c9ea@redhat.com>","list_archive_url":null,"date":"2017-10-02T21:27:01","subject":"Re: [Qemu-devel] [PATCH v4 23/23] qemu-io: Relax 'alloc' now that\n\tblock-status doesn't assert","submitter":{"id":64343,"url":"http://patchwork.ozlabs.org/api/people/64343/","name":"John Snow","email":"jsnow@redhat.com"},"content":"On 09/13/2017 12:03 PM, Eric Blake wrote:\n> Previously, the alloc command required that input parameters be\n> sector-aligned and clamped to 32 bits, because the underlying\n> bdrv_is_allocated used a 32-bit parameter and asserted aligned\n> inputs.  But now that we have fixed block status to report a\n> 64-bit bytes value, and to properly round requests on behalf of\n> guests, we can pass any values, and can use qemu-io to add\n> coverage that our rounding is correct regardless of the guest\n> alignment constraints.\n> \n> Update iotest 177 to intentionally probe block status at\n> unaligned boundaries as well as with a bytes value that does not\n> map to 32-bit sectors, which also required tweaking the image\n> prep to leave an unallocated portion to the image under test.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> \n> ---\n> v3: also test huge bytes value, R-b dropped\n> v2: new patch\n> ---\n>  qemu-io-cmds.c             | 13 -------------\n>  tests/qemu-iotests/177     | 12 ++++++++++--\n>  tests/qemu-iotests/177.out | 19 ++++++++++++++-----\n>  3 files changed, 24 insertions(+), 20 deletions(-)\n> \n> diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c\n> index 2811a89099..d9a32f3bed 100644\n> --- a/qemu-io-cmds.c\n> +++ b/qemu-io-cmds.c\n> @@ -1769,10 +1769,6 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)\n>      if (offset < 0) {\n>          print_cvtnum_err(offset, argv[1]);\n>          return 0;\n> -    } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {\n> -        printf(\"%\" PRId64 \" is not a sector-aligned value for 'offset'\\n\",\n> -               offset);\n> -        return 0;\n>      }\n> \n>      if (argc == 3) {\n> @@ -1780,19 +1776,10 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)\n>          if (count < 0) {\n>              print_cvtnum_err(count, argv[2]);\n>              return 0;\n> -        } else if (count > INT_MAX * BDRV_SECTOR_SIZE) {\n> -            printf(\"length argument cannot exceed %llu, given %s\\n\",\n> -                   INT_MAX * BDRV_SECTOR_SIZE, argv[2]);\n> -            return 0;\n>          }\n>      } else {\n>          count = BDRV_SECTOR_SIZE;\n>      }\n> -    if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {\n> -        printf(\"%\" PRId64 \" is not a sector-aligned value for 'count'\\n\",\n> -               count);\n> -        return 0;\n> -    }\n> \n>      remaining = count;\n>      sum_alloc = 0;\n> diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177\n> index f8ed8fb86b..28990977f1 100755\n> --- a/tests/qemu-iotests/177\n> +++ b/tests/qemu-iotests/177\n> @@ -51,7 +51,7 @@ echo \"== setting up files ==\"\n>  TEST_IMG=\"$TEST_IMG.base\" _make_test_img $size\n>  $QEMU_IO -c \"write -P 11 0 $size\" \"$TEST_IMG.base\" | _filter_qemu_io\n>  _make_test_img -b \"$TEST_IMG.base\"\n> -$QEMU_IO -c \"write -P 22 0 $size\" \"$TEST_IMG\" | _filter_qemu_io\n> +$QEMU_IO -c \"write -P 22 0 110M\" \"$TEST_IMG\" | _filter_qemu_io\n> \n>  # Limited to 64k max-transfer\n>  echo\n> @@ -82,6 +82,13 @@ $QEMU_IO -c \"open -o $options,$limits blkdebug::$TEST_IMG\" \\\n>           -c \"discard 80000001 30M\" | _filter_qemu_io\n> \n>  echo\n> +echo \"== block status smaller than alignment ==\"\n> +limits=align=4k\n> +$QEMU_IO -c \"open -o $options,$limits blkdebug::$TEST_IMG\" \\\n> +\t -c \"alloc 1 1\" -c \"alloc 0x6dffff0 1000\" -c \"alloc 127m 5P\" \\\n> +\t -c map | _filter_qemu_io\n> +\n> +echo\n>  echo \"== verify image content ==\"\n> \n>  function verify_io()\n> @@ -103,7 +110,8 @@ function verify_io()\n>      echo read -P 0 32M 32M\n>      echo read -P 22 64M 13M\n>      echo read -P $discarded 77M 29M\n> -    echo read -P 22 106M 22M\n> +    echo read -P 22 106M 4M\n> +    echo read -P 11 110M 18M\n>  }\n> \n>  verify_io | $QEMU_IO -r \"$TEST_IMG\" | _filter_qemu_io\n> diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out\n> index 43a777836c..f788b55e20 100644\n> --- a/tests/qemu-iotests/177.out\n> +++ b/tests/qemu-iotests/177.out\n> @@ -5,8 +5,8 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728\n>  wrote 134217728/134217728 bytes at offset 0\n>  128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n>  Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base\n> -wrote 134217728/134217728 bytes at offset 0\n> -128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> +wrote 115343360/115343360 bytes at offset 0\n> +110 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> \n>  == constrained alignment and max-transfer ==\n>  wrote 131072/131072 bytes at offset 1000\n> @@ -26,6 +26,13 @@ wrote 33554432/33554432 bytes at offset 33554432\n>  discard 31457280/31457280 bytes at offset 80000001\n>  30 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> \n> +== block status smaller than alignment ==\n> +1/1 bytes allocated at offset 1 bytes\n> +16/1000 bytes allocated at offset 110 MiB\n> +0/1048576 bytes allocated at offset 127 MiB\n> +110 MiB (0x6e00000) bytes     allocated at offset 0 bytes (0x0)\n> +18 MiB (0x1200000) bytes not allocated at offset 110 MiB (0x6e00000)\n> +\n>  == verify image content ==\n>  read 1000/1000 bytes at offset 0\n>  1000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> @@ -43,12 +50,14 @@ read 13631488/13631488 bytes at offset 67108864\n>  13 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n>  read 30408704/30408704 bytes at offset 80740352\n>  29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> -read 23068672/23068672 bytes at offset 111149056\n> -22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> +read 4194304/4194304 bytes at offset 111149056\n> +4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n> +read 18874368/18874368 bytes at offset 115343360\n> +18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n>  Offset          Length          File\n>  0               0x800000        TEST_DIR/t.IMGFMT\n>  0x900000        0x2400000       TEST_DIR/t.IMGFMT\n>  0x3c00000       0x1100000       TEST_DIR/t.IMGFMT\n> -0x6a00000       0x1600000       TEST_DIR/t.IMGFMT\n> +0x6a00000       0x400000        TEST_DIR/t.IMGFMT\n>  No errors were found on the image.\n>  *** done\n> \n\naaand I'll hold off on this one until the respin so I don't have to\nreview the test twice.\n\nI'll say I'm done for v4 for now :)\n\nThanks,\n--js","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org;\n\treceiver=<UNKNOWN>)","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jsnow@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y5ZyB3RBVz9t4X\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  3 Oct 2017 08:27:45 +1100 (AEDT)","from localhost ([::1]:54861 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org>)\n\tid 1dz8Fa-0004qT-2I\n\tfor incoming@patchwork.ozlabs.org; Mon, 02 Oct 2017 17:27:42 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55739)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dz8FA-0004os-Lz\n\tfor qemu-devel@nongnu.org; Mon, 02 Oct 2017 17:27:18 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dz8F9-0007VP-9f\n\tfor qemu-devel@nongnu.org; Mon, 02 Oct 2017 17:27:16 -0400","from mx1.redhat.com ([209.132.183.28]:58928)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <jsnow@redhat.com>)\n\tid 1dz8F5-0007Ps-Rs; Mon, 02 Oct 2017 17:27:12 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id A874CC058EB1;\n\tMon,  2 Oct 2017 21:27:10 +0000 (UTC)","from [10.10.125.14] (ovpn-125-14.rdu2.redhat.com [10.10.125.14])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 694D06031A;\n\tMon,  2 Oct 2017 21:27:07 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com A874CC058EB1","To":"Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org","References":"<20170913160333.23622-1-eblake@redhat.com>\n\t<20170913160333.23622-24-eblake@redhat.com>","From":"John Snow <jsnow@redhat.com>","Message-ID":"<ae5bcf8e-57de-68c2-8a1a-6599f0e5c9ea@redhat.com>","Date":"Mon, 2 Oct 2017 17:27:01 -0400","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170913160333.23622-24-eblake@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tMon, 02 Oct 2017 21:27:10 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v4 23/23] qemu-io: Relax 'alloc' now that\n\tblock-status doesn't assert","X-BeenThere":"qemu-devel@gnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.gnu.org>","List-Unsubscribe":"<https://lists.gnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@gnu.org?subject=unsubscribe>","List-Archive":"<http://lists.gnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@gnu.org>","List-Help":"<mailto:qemu-devel-request@gnu.org?subject=help>","List-Subscribe":"<https://lists.gnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@gnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org,\n\tMax Reitz <mreitz@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org>"}}]