{"id":813533,"url":"http://patchwork.ozlabs.org/api/patches/813533/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913160333.23622-24-eblake@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170913160333.23622-24-eblake@redhat.com>","list_archive_url":null,"date":"2017-09-13T16:03:33","name":"[v4,23/23] qemu-io: Relax 'alloc' now that block-status doesn't assert","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"43031d5a2b98c80c0003241df981e6908395d58a","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/?format=json","name":"Eric Blake","email":"eblake@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913160333.23622-24-eblake@redhat.com/mbox/","series":[{"id":2944,"url":"http://patchwork.ozlabs.org/api/series/2944/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2944","date":"2017-09-13T16:03:10","name":"make bdrv_get_block_status byte-based","version":4,"mbox":"http://patchwork.ozlabs.org/series/2944/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813533/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813533/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@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 3xsnCj63R2z9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 02:28:33 +1000 (AEST)","from localhost ([::1]:43486 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@nongnu.org>)\n\tid 1dsAWd-0000vj-Vz\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 12:28:32 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46867)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsAB5-0003gv-WE\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:06:17 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsAB4-0007O2-H4\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:06:15 -0400","from mx1.redhat.com ([209.132.183.28]:36778)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dsAAz-0007IJ-8a; Wed, 13 Sep 2017 12:06:09 -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 4DF71C04B941;\n\tWed, 13 Sep 2017 16:06:08 +0000 (UTC)","from red.redhat.com (ovpn-120-201.rdu2.redhat.com [10.10.120.201])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6E0155C47C;\n\tWed, 13 Sep 2017 16:05:59 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 4DF71C04B941","From":"Eric Blake <eblake@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Wed, 13 Sep 2017 11:03:33 -0500","Message-Id":"<20170913160333.23622-24-eblake@redhat.com>","In-Reply-To":"<20170913160333.23622-1-eblake@redhat.com>","References":"<20170913160333.23622-1-eblake@redhat.com>","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.31]);\n\tWed, 13 Sep 2017 16:06:08 +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":"[Qemu-devel] [PATCH v4 23/23] qemu-io: Relax 'alloc' now that\n\tblock-status doesn't assert","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, jsnow@redhat.com, famz@redhat.com,\n\tqemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Previously, the alloc command required that input parameters be\nsector-aligned and clamped to 32 bits, because the underlying\nbdrv_is_allocated used a 32-bit parameter and asserted aligned\ninputs.  But now that we have fixed block status to report a\n64-bit bytes value, and to properly round requests on behalf of\nguests, we can pass any values, and can use qemu-io to add\ncoverage that our rounding is correct regardless of the guest\nalignment constraints.\n\nUpdate iotest 177 to intentionally probe block status at\nunaligned boundaries as well as with a bytes value that does not\nmap to 32-bit sectors, which also required tweaking the image\nprep to leave an unallocated portion to the image under test.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n\n---\nv3: also test huge bytes value, R-b dropped\nv2: 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(-)","diff":"diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c\nindex 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;\ndiff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177\nindex 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\ndiff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out\nindex 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","prefixes":["v4","23/23"]}