get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1307034/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1307034,
    "url": "http://patchwork.ozlabs.org/api/patches/1307034/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/898d88297e4d81aa744b5a39974224f3ae5c0543.1591801197.git.berto@igalia.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "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": "<898d88297e4d81aa744b5a39974224f3ae5c0543.1591801197.git.berto@igalia.com>",
    "list_archive_url": null,
    "date": "2020-06-10T15:03:12",
    "name": "[v8,34/34] iotests: Add tests for qcow2 images with extended L2 entries",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "26b0f6525d0cd5de08475cb1d4e6515de9e2b653",
    "submitter": {
        "id": 65704,
        "url": "http://patchwork.ozlabs.org/api/people/65704/?format=api",
        "name": "Alberto Garcia",
        "email": "berto@igalia.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/898d88297e4d81aa744b5a39974224f3ae5c0543.1591801197.git.berto@igalia.com/mbox/",
    "series": [
        {
            "id": 182563,
            "url": "http://patchwork.ozlabs.org/api/series/182563/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=182563",
            "date": "2020-06-10T15:02:49",
            "name": "Add subcluster allocation to qcow2",
            "version": 8,
            "mbox": "http://patchwork.ozlabs.org/series/182563/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1307034/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1307034/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 spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=none (p=none dis=none) header.from=igalia.com",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256\n header.s=20170329 header.b=diycCUxf;\n\tdkim-atps=neutral"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49hrTP3BxKz9sRW\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 11 Jun 2020 01:27:37 +1000 (AEST)",
            "from localhost ([::1]:39442 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1jj2db-0003NI-3d\n\tfor incoming@patchwork.ozlabs.org; Wed, 10 Jun 2020 11:27:35 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10]:36222)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <berto@igalia.com>)\n id 1jj2H8-0002sr-Rk; Wed, 10 Jun 2020 11:04:22 -0400",
            "from fanzine.igalia.com ([178.60.130.6]:58262)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <berto@igalia.com>)\n id 1jj2Gs-0006wn-Ib; Wed, 10 Jun 2020 11:04:22 -0400",
            "from [81.0.38.199] (helo=perseus.local)\n by fanzine.igalia.com with esmtpsa\n (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim)\n id 1jj2GR-0007hN-Se; Wed, 10 Jun 2020 17:03:40 +0200",
            "from berto by perseus.local with local (Exim 4.92)\n (envelope-from <berto@igalia.com>)\n id 1jj2GC-0007O0-MA; Wed, 10 Jun 2020 17:03:24 +0200"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n s=20170329;\n h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;\n bh=ZwDzi5uaxFAOzfR6dicifFsQBpy+3gaEWdPBJEIrhjE=;\n b=diycCUxfZbUi0zWw0v7xKeKnkxCi9nCvriSOxRmggtKU/kMhollvFsiuWWI9oViLZt+sCoQ7XzxnNfhb95CyMttGPgKwjiyXxKgg/XVtPHKH7PbAWAyTz6I78aC85v+supGweJmn3FwrvZWq/yuyot8iJFkJSOfnS+OsMXJW78e7y9P7Hhai2AV2Qv8M8px2PZeuyxr57q7ixXqXnAoOjzftgygpESB/VLAwMuHmqe1NkfV80IyUznFDTzDxWnqCrfJ+9tiWOeXk9xdJU5Jg3fNl04pt34paKccjwgA+zM41w1523EeMM5ivU/iLbfTJgL1heObKO0DGsubTHwmBug==;",
        "From": "Alberto Garcia <berto@igalia.com>",
        "To": "qemu-devel@nongnu.org",
        "Subject": "[PATCH v8 34/34] iotests: Add tests for qcow2 images with extended L2\n entries",
        "Date": "Wed, 10 Jun 2020 17:03:12 +0200",
        "Message-Id": "\n <898d88297e4d81aa744b5a39974224f3ae5c0543.1591801197.git.berto@igalia.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<cover.1591801197.git.berto@igalia.com>",
        "References": "<cover.1591801197.git.berto@igalia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=178.60.130.6; envelope-from=berto@igalia.com;\n helo=fanzine.igalia.com",
        "X-detected-operating-system": "by eggs.gnu.org: First seen = 2020/06/10 11:03:39",
        "X-ACL-Warn": "Detected OS   = Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy]",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=_AUTOLEARN",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.23",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://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 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "Kevin Wolf <kwolf@redhat.com>,\n Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n Alberto Garcia <berto@igalia.com>, qemu-block@nongnu.org,\n Derek Su <dereksu@qnap.com>, Max Reitz <mreitz@redhat.com>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "Signed-off-by: Alberto Garcia <berto@igalia.com>\n---\n tests/qemu-iotests/271     | 801 +++++++++++++++++++++++++++++++++++++\n tests/qemu-iotests/271.out | 676 +++++++++++++++++++++++++++++++\n tests/qemu-iotests/group   |   1 +\n 3 files changed, 1478 insertions(+)\n create mode 100755 tests/qemu-iotests/271\n create mode 100644 tests/qemu-iotests/271.out",
    "diff": "diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271\nnew file mode 100755\nindex 0000000000..9c1f50a5b8\n--- /dev/null\n+++ b/tests/qemu-iotests/271\n@@ -0,0 +1,801 @@\n+#!/bin/bash\n+#\n+# Test qcow2 images with extended L2 entries\n+#\n+# Copyright (C) 2019-2020 Igalia, S.L.\n+# Author: Alberto Garcia <berto@igalia.com>\n+#\n+# This program is free software; you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation; either version 2 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+#\n+\n+# creator\n+owner=berto@igalia.com\n+\n+seq=\"$(basename $0)\"\n+echo \"QA output created by $seq\"\n+\n+here=\"$PWD\"\n+status=1\t# failure is the default!\n+\n+_cleanup()\n+{\n+        _cleanup_test_img\n+        rm -f \"$TEST_IMG.raw\"\n+}\n+trap \"_cleanup; exit \\$status\" 0 1 2 3 15\n+\n+# get standard environment, filters and checks\n+. ./common.rc\n+. ./common.filter\n+\n+_supported_fmt qcow2\n+_supported_proto file nfs\n+_supported_os Linux\n+_unsupported_imgopts extended_l2 compat=0.10 cluster_size data_file\n+\n+l2_offset=$((0x40000))\n+\n+_verify_img()\n+{\n+    $QEMU_IMG compare \"$TEST_IMG\" \"$TEST_IMG.raw\" | grep -v 'Images are identical'\n+    $QEMU_IMG check \"$TEST_IMG\" | _filter_qemu_img_check | \\\n+        grep -v 'No errors were found on the image'\n+}\n+\n+# Compare the bitmap of an extended L2 entry against an expected value\n+_verify_l2_bitmap()\n+{\n+    entry_no=\"$1\"            # L2 entry number, starting from 0\n+    expected_alloc=\"$alloc\"  # Space-separated list of allocated subcluster indexes\n+    expected_zero=\"$zero\"    # Space-separated list of zero subcluster indexes\n+\n+    offset=$(($l2_offset + $entry_no * 16))\n+    entry=$(peek_file_be \"$TEST_IMG\" $offset 8)\n+    offset=$(($offset + 8))\n+    bitmap=$(peek_file_be \"$TEST_IMG\" $offset 8)\n+\n+    expected_bitmap=0\n+    for bit in $expected_alloc; do\n+        expected_bitmap=$(($expected_bitmap | (1 << $bit)))\n+    done\n+    for bit in $expected_zero; do\n+        expected_bitmap=$(($expected_bitmap | (1 << (32 + $bit))))\n+    done\n+    printf -v expected_bitmap \"%llu\" $expected_bitmap # Convert to unsigned\n+\n+    printf \"L2 entry #%d: 0x%016lx %016lx\\n\" \"$entry_no\" \"$entry\" \"$bitmap\"\n+    if [ \"$bitmap\" != \"$expected_bitmap\" ]; then\n+        printf \"ERROR: expecting bitmap       0x%016lx\\n\" \"$expected_bitmap\"\n+    fi\n+}\n+\n+# This should be called as _run_test c=XXX sc=XXX off=XXX len=XXX cmd=XXX\n+# c:   cluster number (0 if unset)\n+# sc:  subcluster number inside cluster @c (0 if unset)\n+# off: offset inside subcluster @sc, in kilobytes (0 if unset)\n+# len: request length, passed directly to qemu-io (e.g: 256, 4k, 1M, ...)\n+# cmd: the command to pass to qemu-io, must be one of\n+#      write    -> write\n+#      zero     -> write -z\n+#      unmap    -> write -z -u\n+#      compress -> write -c\n+#      discard  -> discard\n+_run_test()\n+{\n+    unset c sc off len cmd\n+    for var in \"$@\"; do eval \"$var\"; done\n+    case \"${cmd:-write}\" in\n+        zero)\n+            cmd=\"write -q -z\";;\n+        unmap)\n+            cmd=\"write -q -z -u\";;\n+        compress)\n+            pat=$((${pat:-0} + 1))\n+            cmd=\"write -q -c -P ${pat}\";;\n+        write)\n+            pat=$((${pat:-0} + 1))\n+            cmd=\"write -q -P ${pat}\";;\n+        discard)\n+            cmd=\"discard -q\";;\n+        *)\n+            echo \"Unknown option $cmd\"\n+            exit 1;;\n+    esac\n+    c=\"${c:-0}\"\n+    sc=\"${sc:-0}\"\n+    off=\"${off:-0}\"\n+    offset=\"$(($c * 64 + $sc * 2 + $off))\"\n+    [ \"$offset\" != 0 ] && offset=\"${offset}k\"\n+    cmd=\"$cmd ${offset} ${len}\"\n+    raw_cmd=$(echo $cmd | sed s/-c//) # Raw images don't support -c\n+    echo $cmd | sed 's/-P [0-9][0-9]\\?/-P PATTERN/'\n+    $QEMU_IO -c \"$cmd\" \"$TEST_IMG\" | _filter_qemu_io\n+    $QEMU_IO -c \"$raw_cmd\" -f raw \"$TEST_IMG.raw\" | _filter_qemu_io\n+    _verify_img\n+    _verify_l2_bitmap \"$c\"\n+}\n+\n+_reset_img()\n+{\n+    size=\"$1\"\n+    $QEMU_IMG create -f raw \"$TEST_IMG.raw\" \"$size\" | _filter_img_create\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        $QEMU_IMG create -f raw \"$TEST_IMG.base\" \"$size\" | _filter_img_create\n+        $QEMU_IO -c \"write -q -P 0xFF 0 $size\" -f raw \"$TEST_IMG.base\" | _filter_qemu_io\n+        $QEMU_IO -c \"write -q -P 0xFF 0 $size\" -f raw \"$TEST_IMG.raw\" | _filter_qemu_io\n+        _make_test_img -o extended_l2=on -F raw -b \"$TEST_IMG.base\" \"$size\"\n+    else\n+        _make_test_img -o extended_l2=on \"$size\"\n+    fi\n+}\n+\n+# Test that writing to an image with subclusters produces the expected\n+# results, in images with and without backing files\n+for use_backing_file in yes no; do\n+    echo\n+    echo \"### Standard write tests (backing file: $use_backing_file) ###\"\n+    echo\n+    _reset_img 1M\n+    ### Write subcluster #0 (beginning of subcluster) ###\n+    alloc=\"0\"; zero=\"\"\n+    _run_test sc=0 len=1k\n+\n+    ### Write subcluster #1 (middle of subcluster) ###\n+    alloc=\"0 1\"; zero=\"\"\n+    _run_test sc=1 off=1 len=512\n+\n+    ### Write subcluster #2 (end of subcluster) ###\n+    alloc=\"0 1 2\"; zero=\"\"\n+    _run_test sc=2 off=1 len=1k\n+\n+    ### Write subcluster #3 (full subcluster) ###\n+    alloc=\"0 1 2 3\"; zero=\"\"\n+    _run_test sc=3 len=2k\n+\n+    ### Write subclusters #4-6 (full subclusters) ###\n+    alloc=\"$(seq 0 6)\"; zero=\"\"\n+    _run_test sc=4 len=6k\n+\n+    ### Write subclusters #7-9 (partial subclusters) ###\n+    alloc=\"$(seq 0 9)\"; zero=\"\"\n+    _run_test sc=7 off=1 len=4k\n+\n+    ### Write subcluster #16 (partial subcluster) ###\n+    alloc=\"$(seq 0 9) 16\"; zero=\"\"\n+    _run_test sc=16 len=1k\n+\n+    ### Write subcluster #31-#33 (cluster overlap) ###\n+    alloc=\"$(seq 0 9) 16 31\"; zero=\"\"\n+    _run_test sc=31 off=1 len=4k\n+    alloc=\"0 1\" ; zero=\"\"\n+    _verify_l2_bitmap 1\n+\n+    ### Zero subcluster #1\n+    alloc=\"0 $(seq 2 9) 16 31\"; zero=\"1\"\n+    _run_test sc=1 len=2k cmd=zero\n+\n+    ### Zero cluster #0\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test sc=0 len=64k cmd=zero\n+\n+    ### Fill cluster #0 with data\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test sc=0 len=64k\n+\n+    ### Zero and unmap half of cluster #0 (this won't unmap it)\n+    alloc=\"$(seq 16 31)\"; zero=\"$(seq 0 15)\"\n+    _run_test sc=0 len=32k cmd=unmap\n+\n+    ### Zero and unmap cluster #0\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test sc=0 len=64k cmd=unmap\n+\n+    ### Write subcluster #1 (middle of subcluster)\n+    alloc=\"1\"; zero=\"0 $(seq 2 31)\"\n+    _run_test sc=1 off=1 len=512\n+\n+    ### Fill cluster #0 with data\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test sc=0 len=64k\n+\n+    ### Discard cluster #0\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test sc=0 len=64k cmd=discard\n+\n+    ### Write compressed data to cluster #0\n+    alloc=\"\"; zero=\"\"\n+    _run_test sc=0 len=64k cmd=compress\n+\n+    ### Write subcluster #1 (middle of subcluster)\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test sc=1 off=1 len=512\n+done\n+\n+# calculate_l2_meta() checks if none of the clusters affected by a\n+# write operation need COW or changes to their L2 metadata and simply\n+# returns when they don't. This is a test for that optimization.\n+# Here clusters #0-#3 are overwritten but only #1 and #2 need changes.\n+echo\n+echo '### Overwriting several clusters without COW ###'\n+echo\n+use_backing_file=\"no\" _reset_img 1M\n+# Write cluster #0, subclusters #12-#31\n+alloc=\"$(seq 12 31)\"; zero=\"\"\n+_run_test sc=12 len=40k\n+\n+# Write cluster #1, subcluster #13\n+alloc=\"13\"; zero=\"\"\n+_run_test c=1 sc=13 len=2k\n+\n+# Zeroize cluster #2, subcluster #14\n+alloc=\"14\"; zero=\"\"\n+_run_test c=2 sc=14 len=2k\n+alloc=\"\"; zero=\"14\"\n+_run_test c=2 sc=14 len=2k cmd=zero\n+\n+# Write cluster #3, subclusters #0-#17\n+alloc=\"$(seq 0 16)\"; zero=\"\"\n+_run_test c=3 sc=0 len=34k\n+\n+# Write from cluster #0, subcluster #12 to cluster #3, subcluster #11\n+alloc=\"$(seq 12 31)\"; zero=\"\"\n+_run_test sc=12 len=192k\n+alloc=\"$(seq 0 31)\"; zero=\"\"\n+_verify_l2_bitmap 1\n+_verify_l2_bitmap 2\n+\n+alloc=\"$(seq 0 16)\"; zero=\"\"\n+_verify_l2_bitmap 3\n+\n+# Test different patterns of writing zeroes\n+for use_backing_file in yes no; do\n+    echo\n+    echo \"### Writing zeroes 1: unallocated clusters (backing file: $use_backing_file) ###\"\n+    echo\n+    # Note that the image size is not a multiple of the cluster size\n+    _reset_img 2083k\n+\n+    # Cluster-aligned request from clusters #0 to #2\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test c=0 sc=0 len=192k cmd=zero\n+    _verify_l2_bitmap 1\n+    _verify_l2_bitmap 2\n+\n+    # Subcluster-aligned request from clusters #3 to #5\n+    alloc=\"\"; zero=\"$(seq 16 31)\"\n+    _run_test c=3 sc=16 len=128k cmd=zero\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 4\n+    alloc=\"\"; zero=\"$(seq 0 15)\"\n+    _verify_l2_bitmap 5\n+\n+    # Unaligned request from clusters #6 to #8\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"15\"; zero=\"$(seq 16 31)\" # copy-on-write happening here\n+    else\n+        alloc=\"\"; zero=\"$(seq 15 31)\"\n+    fi\n+    _run_test c=6 sc=15 off=1 len=128k cmd=zero\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 7\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"15\"; zero=\"$(seq 0 14)\" # copy-on-write happening here\n+    else\n+        alloc=\"\"; zero=\"$(seq 0 15)\"\n+    fi\n+    _verify_l2_bitmap 8\n+\n+    echo\n+    echo \"### Writing zeroes 2: allocated clusters (backing file: $use_backing_file) ###\"\n+    echo\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=9 sc=0 len=576k\n+    _verify_l2_bitmap 10\n+    _verify_l2_bitmap 11\n+    _verify_l2_bitmap 12\n+    _verify_l2_bitmap 13\n+    _verify_l2_bitmap 14\n+    _verify_l2_bitmap 15\n+    _verify_l2_bitmap 16\n+    _verify_l2_bitmap 17\n+\n+    # Cluster-aligned request from clusters #9 to #11\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test c=9 sc=0 len=192k cmd=zero\n+    _verify_l2_bitmap 10\n+    _verify_l2_bitmap 11\n+\n+    # Subcluster-aligned request from clusters #12 to #14\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=12 sc=16 len=128k cmd=zero\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 13\n+    alloc=\"$(seq 16 31)\"; zero=\"$(seq 0 15)\"\n+    _verify_l2_bitmap 14\n+\n+    # Unaligned request from clusters #15 to #17\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=15 sc=15 off=1 len=128k cmd=zero\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 16\n+    alloc=\"$(seq 15 31)\"; zero=\"$(seq 0 14)\"\n+    _verify_l2_bitmap 17\n+\n+    echo\n+    echo \"### Writing zeroes 3: compressed clusters (backing file: $use_backing_file) ###\"\n+    echo\n+    alloc=\"\"; zero=\"\"\n+    for c in $(seq 18 28); do\n+        _run_test c=$c sc=0 len=64k cmd=compress\n+    done\n+\n+    # Cluster-aligned request from clusters #18 to #20\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test c=18 sc=0 len=192k cmd=zero\n+    _verify_l2_bitmap 19\n+    _verify_l2_bitmap 20\n+\n+    # Subcluster-aligned request from clusters #21 to #23.\n+    # We cannot partially zero a compressed cluster so the code\n+    # returns -ENOTSUP, which means copy-on-write of the compressed\n+    # data and fill the rest with actual zeroes on disk.\n+    # TODO: cluster #22 should use the 'all zeroes' bits.\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=21 sc=16 len=128k cmd=zero\n+    _verify_l2_bitmap 22\n+    _verify_l2_bitmap 23\n+\n+    # Unaligned request from clusters #24 to #26\n+    # In this case QEMU internally sends a 1k request followed by a\n+    # subcluster-aligned 128k request. The first request decompresses\n+    # cluster #24, but that's not enough to perform the second request\n+    # efficiently because it partially writes to cluster #26 (which is\n+    # compressed) so we hit the same problem as before.\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=24 sc=15 off=1 len=129k cmd=zero\n+    _verify_l2_bitmap 25\n+    _verify_l2_bitmap 26\n+\n+    # Unaligned request from clusters #27 to #29\n+    # Similar to the previous case, but this time the tail of the\n+    # request does not correspond to a compressed cluster, so it can\n+    # be zeroed efficiently.\n+    # Note that the very last subcluster is partially written, so if\n+    # there's a backing file we need to perform cow.\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=27 sc=15 off=1 len=128k cmd=zero\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 28\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"15\"; zero=\"$(seq 0 14)\" # copy-on-write happening here\n+    else\n+        alloc=\"\"; zero=\"$(seq 0 15)\"\n+    fi\n+    _verify_l2_bitmap 29\n+\n+    echo\n+    echo \"### Writing zeroes 4: other tests (backing file: $use_backing_file) ###\"\n+    echo\n+    # Unaligned request in the middle of cluster #30.\n+    # If there's a backing file we need to allocate and do\n+    # copy-on-write on the partially zeroed subclusters.\n+    # If not we can set the 'all zeroes' bit on them.\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"15 19\"; zero=\"$(seq 16 18)\" # copy-on-write happening here\n+    else\n+        alloc=\"\"; zero=\"$(seq 15 19)\"\n+    fi\n+    _run_test c=30 sc=15 off=1 len=8k cmd=zero\n+\n+    # Fill the last cluster with zeroes, up to the end of the image\n+    # (the image size is not a multiple of the cluster or subcluster size).\n+    alloc=\"\"; zero=\"$(seq 0 17)\"\n+    _run_test c=32 sc=0 len=35k cmd=zero\n+done\n+\n+# Zero + unmap\n+for use_backing_file in yes no; do\n+    echo\n+    echo \"### Zero + unmap 1: allocated clusters (backing file: $use_backing_file) ###\"\n+    echo\n+    # Note that the image size is not a multiple of the cluster size\n+    _reset_img 2083k\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=9 sc=0 len=576k\n+    _verify_l2_bitmap 10\n+    _verify_l2_bitmap 11\n+    _verify_l2_bitmap 12\n+    _verify_l2_bitmap 13\n+    _verify_l2_bitmap 14\n+    _verify_l2_bitmap 15\n+    _verify_l2_bitmap 16\n+    _verify_l2_bitmap 17\n+\n+    # Cluster-aligned request from clusters #9 to #11\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test c=9 sc=0 len=192k cmd=unmap\n+    _verify_l2_bitmap 10\n+    _verify_l2_bitmap 11\n+\n+    # Subcluster-aligned request from clusters #12 to #14\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=12 sc=16 len=128k cmd=unmap\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 13\n+    alloc=\"$(seq 16 31)\"; zero=\"$(seq 0 15)\"\n+    _verify_l2_bitmap 14\n+\n+    # Unaligned request from clusters #15 to #17\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=15 sc=15 off=1 len=128k cmd=unmap\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 16\n+    alloc=\"$(seq 15 31)\"; zero=\"$(seq 0 14)\"\n+    _verify_l2_bitmap 17\n+\n+    echo\n+    echo \"### Zero + unmap 2: compressed clusters (backing file: $use_backing_file) ###\"\n+    echo\n+    alloc=\"\"; zero=\"\"\n+    for c in $(seq 18 28); do\n+        _run_test c=$c sc=0 len=64k cmd=compress\n+    done\n+\n+    # Cluster-aligned request from clusters #18 to #20\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _run_test c=18 sc=0 len=192k cmd=unmap\n+    _verify_l2_bitmap 19\n+    _verify_l2_bitmap 20\n+\n+    # Subcluster-aligned request from clusters #21 to #23.\n+    # We cannot partially zero a compressed cluster so the code\n+    # returns -ENOTSUP, which means copy-on-write of the compressed\n+    # data and fill the rest with actual zeroes on disk.\n+    # TODO: cluster #22 should use the 'all zeroes' bits.\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=21 sc=16 len=128k cmd=unmap\n+    _verify_l2_bitmap 22\n+    _verify_l2_bitmap 23\n+\n+    # Unaligned request from clusters #24 to #26\n+    # In this case QEMU internally sends a 1k request followed by a\n+    # subcluster-aligned 128k request. The first request decompresses\n+    # cluster #24, but that's not enough to perform the second request\n+    # efficiently because it partially writes to cluster #26 (which is\n+    # compressed) so we hit the same problem as before.\n+    alloc=\"$(seq 0 31)\"; zero=\"\"\n+    _run_test c=24 sc=15 off=1 len=129k cmd=unmap\n+    _verify_l2_bitmap 25\n+    _verify_l2_bitmap 26\n+\n+    # Unaligned request from clusters #27 to #29\n+    # Similar to the previous case, but this time the tail of the\n+    # request does not correspond to a compressed cluster, so it can\n+    # be zeroed efficiently.\n+    # Note that the very last subcluster is partially written, so if\n+    # there's a backing file we need to perform cow.\n+    alloc=\"$(seq 0 15)\"; zero=\"$(seq 16 31)\"\n+    _run_test c=27 sc=15 off=1 len=128k cmd=unmap\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 28\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"15\"; zero=\"$(seq 0 14)\" # copy-on-write happening here\n+    else\n+        alloc=\"\"; zero=\"$(seq 0 15)\"\n+    fi\n+    _verify_l2_bitmap 29\n+done\n+\n+# Test qcow2_cluster_discard() with full and normal discards\n+for use_backing_file in yes no; do\n+    echo\n+    echo \"### Discarding clusters with non-zero bitmaps (backing file: $use_backing_file) ###\"\n+    echo\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        _make_test_img -o extended_l2=on -F raw -b \"$TEST_IMG.base\" 1M\n+    else\n+        _make_test_img -o extended_l2=on 1M\n+    fi\n+    # Write clusters #0-#2 and then discard them\n+    $QEMU_IO -c 'write -q 0 128k' \"$TEST_IMG\"\n+    $QEMU_IO -c 'discard -q 0 128k' \"$TEST_IMG\"\n+    # 'qemu-io discard' doesn't do a full discard, it zeroizes the\n+    # cluster, so both clusters have all zero bits set now\n+    alloc=\"\"; zero=\"$(seq 0 31)\"\n+    _verify_l2_bitmap 0\n+    _verify_l2_bitmap 1\n+    # Now mark the 2nd half of the subclusters from cluster #0 as unallocated\n+    poke_file \"$TEST_IMG\" $(($l2_offset+8)) \"\\x00\\x00\"\n+    # Discard cluster #0 again to see how the zero bits have changed\n+    $QEMU_IO -c 'discard -q 0 64k' \"$TEST_IMG\"\n+    # And do a full discard of cluster #1 by shrinking and growing the image\n+    $QEMU_IMG resize --shrink \"$TEST_IMG\" 64k\n+    $QEMU_IMG resize \"$TEST_IMG\" 1M\n+    # A normal discard sets all 'zero' bits only if the image has a\n+    # backing file, otherwise it won't touch them.\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"\"; zero=\"$(seq 0 31)\"\n+    else\n+        alloc=\"\"; zero=\"$(seq 0 15)\"\n+    fi\n+    _verify_l2_bitmap 0\n+    # A full discard should clear the L2 entry completely. However\n+    # when growing an image with a backing file the new clusters are\n+    # zeroized to hide the stale data from the backing file\n+    if [ \"$use_backing_file\" = \"yes\" ]; then\n+        alloc=\"\"; zero=\"$(seq 0 31)\"\n+    else\n+        alloc=\"\"; zero=\"\"\n+    fi\n+    _verify_l2_bitmap 1\n+done\n+\n+# Test that corrupted L2 entries are detected in both read and write\n+# operations\n+for corruption_test_cmd in read write; do\n+    echo\n+    echo \"### Corrupted L2 entries - $corruption_test_cmd test (allocated) ###\"\n+    echo\n+    echo \"# 'cluster is zero' bit set on the standard cluster descriptor\"\n+    echo\n+    # We actually don't consider this a corrupted image.\n+    # The 'cluster is zero' bit is unused in extended L2 entries so\n+    # QEMU ignores it.\n+    # TODO: maybe treat the image as corrupted and make qemu-img check fix it?\n+    _make_test_img -o extended_l2=on 1M\n+    $QEMU_IO -c 'write -q -P 0x11 0 2k' \"$TEST_IMG\"\n+    poke_file \"$TEST_IMG\" $(($l2_offset+7)) \"\\x01\"\n+    alloc=\"0\"; zero=\"\"\n+    _verify_l2_bitmap 0\n+    $QEMU_IO -c \"$corruption_test_cmd -q -P 0x11 0 1k\" \"$TEST_IMG\"\n+    if [ \"$corruption_test_cmd\" = \"write\" ]; then\n+        alloc=\"0\"; zero=\"\"\n+    fi\n+    _verify_l2_bitmap 0\n+\n+    echo\n+    echo \"# Both 'subcluster is zero' and 'subcluster is allocated' bits set\"\n+    echo\n+    _make_test_img -o extended_l2=on 1M\n+    # Write from the middle of cluster #0 to the middle of cluster #2\n+    $QEMU_IO -c 'write -q 32k 128k' \"$TEST_IMG\"\n+    # Corrupt the L2 entry from cluster #1\n+    poke_file_be \"$TEST_IMG\" $(($l2_offset+24)) 4 1\n+    alloc=\"$(seq 0 31)\"; zero=\"0\"\n+    _verify_l2_bitmap 1\n+    $QEMU_IO -c \"$corruption_test_cmd 0 192k\" \"$TEST_IMG\"\n+\n+    echo\n+    echo \"### Corrupted L2 entries - $corruption_test_cmd test (unallocated) ###\"\n+    echo\n+    echo \"# 'cluster is zero' bit set on the standard cluster descriptor\"\n+    echo\n+    # We actually don't consider this a corrupted image.\n+    # The 'cluster is zero' bit is unused in extended L2 entries so\n+    # QEMU ignores it.\n+    # TODO: maybe treat the image as corrupted and make qemu-img check fix it?\n+    _make_test_img -o extended_l2=on 1M\n+    # We want to modify the (empty) L2 entry from cluster #0,\n+    # but we write to #4 in order to initialize the L2 table first\n+    $QEMU_IO -c 'write -q 256k 1k' \"$TEST_IMG\"\n+    poke_file \"$TEST_IMG\" $(($l2_offset+7)) \"\\x01\"\n+    alloc=\"\"; zero=\"\"\n+    _verify_l2_bitmap 0\n+    $QEMU_IO -c \"$corruption_test_cmd -q 0 1k\" \"$TEST_IMG\"\n+    if [ \"$corruption_test_cmd\" = \"write\" ]; then\n+        alloc=\"0\"; zero=\"\"\n+    fi\n+    _verify_l2_bitmap 0\n+\n+    echo\n+    echo \"# 'subcluster is allocated' bit set\"\n+    echo\n+    _make_test_img -o extended_l2=on 1M\n+    # We want to corrupt the (empty) L2 entry from cluster #0,\n+    # but we write to #4 in order to initialize the L2 table first\n+    $QEMU_IO -c 'write -q 256k 1k' \"$TEST_IMG\"\n+    poke_file \"$TEST_IMG\" $(($l2_offset+15)) \"\\x01\"\n+    alloc=\"0\"; zero=\"\"\n+    _verify_l2_bitmap 0\n+    $QEMU_IO -c \"$corruption_test_cmd 0 1k\" \"$TEST_IMG\"\n+\n+    echo\n+    echo \"# Both 'subcluster is zero' and 'subcluster is allocated' bits set\"\n+    echo\n+    _make_test_img -o extended_l2=on 1M\n+    # We want to corrupt the (empty) L2 entry from cluster #1,\n+    # but we write to #4 in order to initialize the L2 table first\n+    $QEMU_IO -c 'write -q 256k 1k' \"$TEST_IMG\"\n+    # Corrupt the L2 entry from cluster #1\n+    poke_file_be \"$TEST_IMG\" $(($l2_offset+24)) 8 $(((1 << 32) | 1))\n+    alloc=\"0\"; zero=\"0\"\n+    _verify_l2_bitmap 1\n+    $QEMU_IO -c \"$corruption_test_cmd 0 192k\" \"$TEST_IMG\"\n+\n+    echo\n+    echo \"### Compressed cluster with subcluster bitmap != 0 - $corruption_test_cmd test ###\"\n+    echo\n+    # We actually don't consider this a corrupted image.\n+    # The bitmap in compressed clusters is unused so QEMU should just ignore it.\n+    _make_test_img -o extended_l2=on 1M\n+    $QEMU_IO -c 'write -q -P 11 -c 0 64k' \"$TEST_IMG\"\n+    # Change the L2 bitmap to allocate subcluster #31 and zeroize subcluster #0\n+    poke_file \"$TEST_IMG\" $(($l2_offset+11)) \"\\x01\\x80\"\n+    alloc=\"31\"; zero=\"0\"\n+    _verify_l2_bitmap 0\n+    $QEMU_IO -c \"$corruption_test_cmd -P 11 0 64k\" \"$TEST_IMG\" | _filter_qemu_io\n+    # Writing allocates a new uncompressed cluster so we get a new bitmap\n+    if [ \"$corruption_test_cmd\" = \"write\" ]; then\n+        alloc=\"$(seq 0 31)\"; zero=\"\"\n+    fi\n+    _verify_l2_bitmap 0\n+done\n+\n+echo\n+echo \"### Image creation options ###\"\n+echo\n+echo \"# cluster_size < 16k\"\n+_make_test_img -o extended_l2=on,cluster_size=8k 1M\n+\n+echo \"# backing file and preallocation=metadata\"\n+# For preallocation with backing files, create a backing file first\n+$QEMU_IMG create -f raw \"$TEST_IMG.base\" 1M | _filter_img_create\n+$QEMU_IO -c \"write -q -P 0xff 0 1M\" -f raw \"$TEST_IMG.base\" | _filter_qemu_io\n+\n+_make_test_img -o extended_l2=on,preallocation=metadata -F raw -b \"$TEST_IMG.base\" 512k\n+$QEMU_IMG resize \"$TEST_IMG\" 1M\n+$QEMU_IO -c 'read -P 0xff    0 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 512k 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG map \"$TEST_IMG\" | _filter_testdir\n+\n+echo \"# backing file and preallocation=falloc\"\n+_make_test_img -o extended_l2=on,preallocation=falloc -F raw -b \"$TEST_IMG.base\" 512k\n+$QEMU_IMG resize \"$TEST_IMG\" 1M\n+$QEMU_IO -c 'read -P 0xff    0 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 512k 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG map \"$TEST_IMG\" | _filter_testdir\n+\n+echo \"# backing file and preallocation=full\"\n+_make_test_img -o extended_l2=on,preallocation=full -F raw -b \"$TEST_IMG.base\" 512k\n+$QEMU_IMG resize \"$TEST_IMG\" 1M\n+$QEMU_IO -c 'read -P 0xff    0 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 512k 512k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG map \"$TEST_IMG\" | _filter_testdir\n+\n+echo\n+echo \"### Image resizing with preallocation and backing files ###\"\n+echo\n+# In this case the new subclusters must have the 'all zeroes' bit set\n+echo \"# resize --preallocation=metadata\"\n+_make_test_img -o extended_l2=on -F raw -b \"$TEST_IMG.base\" 503k\n+$QEMU_IMG resize --preallocation=metadata \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+# In this case and the next one the new subclusters must be allocated\n+echo \"# resize --preallocation=falloc\"\n+_make_test_img -o extended_l2=on -F raw -b \"$TEST_IMG.base\" 503k\n+$QEMU_IMG resize --preallocation=falloc \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+echo \"# resize --preallocation=full\"\n+_make_test_img -o extended_l2=on -F raw -b \"$TEST_IMG.base\" 503k\n+$QEMU_IMG resize --preallocation=full \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+echo\n+echo \"### Image resizing with preallocation without backing files ###\"\n+echo\n+# In this case the new subclusters must have the 'all zeroes' bit set\n+echo \"# resize --preallocation=metadata\"\n+_make_test_img -o extended_l2=on 503k\n+$QEMU_IO -c 'write -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG resize --preallocation=metadata \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+# In this case and the next one the new subclusters must be allocated\n+echo \"# resize --preallocation=falloc\"\n+_make_test_img -o extended_l2=on 503k\n+$QEMU_IO -c 'write -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG resize --preallocation=falloc \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+echo \"# resize --preallocation=full\"\n+_make_test_img -o extended_l2=on 503k\n+$QEMU_IO -c 'write -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG resize --preallocation=full \"$TEST_IMG\" 1013k\n+$QEMU_IO -c 'read -P 0xff    0 503k' \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IO -c 'read -P 0x00 503k 510k' \"$TEST_IMG\" | _filter_qemu_io\n+\n+echo\n+echo \"### qemu-img measure ###\"\n+echo\n+echo \"# 512MB, extended_l2=off\" # This needs one L2 table\n+$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=off\n+echo \"# 512MB, extended_l2=on\"  # This needs two L2 tables\n+$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=on\n+\n+echo \"# 16K clusters, 64GB, extended_l2=off\" # This needs one full L1 table cluster\n+$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=off\n+echo \"# 16K clusters, 64GB, extended_l2=on\"  # This needs two full L2 table clusters\n+$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=on\n+\n+echo \"# 8k clusters\" # This should fail\n+$QEMU_IMG measure --size 1M -O qcow2 -o cluster_size=8k,extended_l2=on\n+\n+echo \"# 1024 TB\" # Maximum allowed size with extended_l2=on and 64K clusters\n+$QEMU_IMG measure --size 1024T -O qcow2 -o extended_l2=on\n+echo \"# 1025 TB\" # This should fail\n+$QEMU_IMG measure --size 1025T -O qcow2 -o extended_l2=on\n+\n+echo\n+echo \"### qemu-img amend ###\"\n+echo\n+_make_test_img -o extended_l2=on 1M\n+$QEMU_IMG amend -o extended_l2=off \"$TEST_IMG\" && echo \"Unexpected pass\"\n+\n+_make_test_img -o extended_l2=off 1M\n+$QEMU_IMG amend -o extended_l2=on \"$TEST_IMG\" && echo \"Unexpected pass\"\n+\n+echo\n+echo \"### Test copy-on-write on an image with snapshots ###\"\n+echo\n+_make_test_img -o extended_l2=on 1M\n+\n+# For each cluster from #0 to #9 this loop zeroes subcluster #7\n+# and allocates subclusters #13 and #18.\n+alloc=\"13 18\"; zero=\"7\"\n+for c in $(seq 0 9); do\n+    $QEMU_IO -c \"write -q -z $((64*$c+14))k 2k\" \\\n+             -c \"write -q -P $((0xd0+$c)) $((64*$c+26))k 2k\" \\\n+             -c \"write -q -P $((0xe0+$c)) $((64*$c+36))k 2k\" \"$TEST_IMG\"\n+    _verify_l2_bitmap \"$c\"\n+done\n+\n+# Create a snapshot and set l2_offset to the new L2 table\n+$QEMU_IMG snapshot -c snap1 \"$TEST_IMG\"\n+l2_offset=1114112 # 0x110000\n+\n+# Write different patterns to each one of the clusters\n+# in order to see how copy-on-write behaves in each case.\n+$QEMU_IO -c \"write -q -P 0xf0 $((64*0+30))k 1k\" \\\n+         -c \"write -q -P 0xf1 $((64*1+20))k 1k\" \\\n+         -c \"write -q -P 0xf2 $((64*2+40))k 1k\" \\\n+         -c \"write -q -P 0xf3 $((64*3+26))k 1k\" \\\n+         -c \"write -q -P 0xf4 $((64*4+14))k 1k\" \\\n+         -c \"write -q -P 0xf5 $((64*5+1))k  1k\" \\\n+         -c \"write -q -z      $((64*6+30))k 3k\" \\\n+         -c \"write -q -z      $((64*7+26))k 2k\" \\\n+         -c \"write -q -z      $((64*8+26))k 1k\" \\\n+         -c \"write -q -z      $((64*9+12))k 1k\" \\\n+         \"$TEST_IMG\"\n+alloc=\"$(seq 13 18)\"; zero=\"7\" _verify_l2_bitmap 0\n+alloc=\"$(seq 10 18)\"; zero=\"7\" _verify_l2_bitmap 1\n+alloc=\"$(seq 13 20)\"; zero=\"7\" _verify_l2_bitmap 2\n+alloc=\"$(seq 13 18)\"; zero=\"7\" _verify_l2_bitmap 3\n+alloc=\"$(seq 7 18)\";  zero=\"\"  _verify_l2_bitmap 4\n+alloc=\"$(seq 0 18)\";  zero=\"\"  _verify_l2_bitmap 5\n+alloc=\"13 18\";  zero=\"7 15 16\" _verify_l2_bitmap 6\n+alloc=\"18\";        zero=\"7 13\" _verify_l2_bitmap 7\n+alloc=\"$(seq 13 18)\"; zero=\"7\" _verify_l2_bitmap 8\n+alloc=\"13 18\";      zero=\"6 7\" _verify_l2_bitmap 9\n+\n+# success, all done\n+echo \"*** done\"\n+rm -f $seq.full\n+status=0\ndiff --git a/tests/qemu-iotests/271.out b/tests/qemu-iotests/271.out\nnew file mode 100644\nindex 0000000000..067026623f\n--- /dev/null\n+++ b/tests/qemu-iotests/271.out\n@@ -0,0 +1,676 @@\n+QA output created by 271\n+\n+### Standard write tests (backing file: yes) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576\n+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=1048576\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+write -q -P PATTERN 0 1k\n+L2 entry #0: 0x8000000000050000 0000000000000001\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000050000 0000000000000003\n+write -q -P PATTERN 5k 1k\n+L2 entry #0: 0x8000000000050000 0000000000000007\n+write -q -P PATTERN 6k 2k\n+L2 entry #0: 0x8000000000050000 000000000000000f\n+write -q -P PATTERN 8k 6k\n+L2 entry #0: 0x8000000000050000 000000000000007f\n+write -q -P PATTERN 15k 4k\n+L2 entry #0: 0x8000000000050000 00000000000003ff\n+write -q -P PATTERN 32k 1k\n+L2 entry #0: 0x8000000000050000 00000000000103ff\n+write -q -P PATTERN 63k 4k\n+L2 entry #0: 0x8000000000050000 00000000800103ff\n+L2 entry #1: 0x8000000000060000 0000000000000003\n+write -q -z 2k 2k\n+L2 entry #0: 0x8000000000050000 00000002800103fd\n+write -q -z 0 64k\n+L2 entry #0: 0x8000000000050000 ffffffff00000000\n+write -q -P PATTERN 0 64k\n+L2 entry #0: 0x8000000000050000 00000000ffffffff\n+write -q -z -u 0 32k\n+L2 entry #0: 0x8000000000050000 0000ffffffff0000\n+write -q -z -u 0 64k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000050000 fffffffd00000002\n+write -q -P PATTERN 0 64k\n+L2 entry #0: 0x8000000000050000 00000000ffffffff\n+discard -q 0 64k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+write -q -c -P PATTERN 0 64k\n+L2 entry #0: 0x4000000000050000 0000000000000000\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000070000 00000000ffffffff\n+\n+### Standard write tests (backing file: no) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+write -q -P PATTERN 0 1k\n+L2 entry #0: 0x8000000000050000 0000000000000001\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000050000 0000000000000003\n+write -q -P PATTERN 5k 1k\n+L2 entry #0: 0x8000000000050000 0000000000000007\n+write -q -P PATTERN 6k 2k\n+L2 entry #0: 0x8000000000050000 000000000000000f\n+write -q -P PATTERN 8k 6k\n+L2 entry #0: 0x8000000000050000 000000000000007f\n+write -q -P PATTERN 15k 4k\n+L2 entry #0: 0x8000000000050000 00000000000003ff\n+write -q -P PATTERN 32k 1k\n+L2 entry #0: 0x8000000000050000 00000000000103ff\n+write -q -P PATTERN 63k 4k\n+L2 entry #0: 0x8000000000050000 00000000800103ff\n+L2 entry #1: 0x8000000000060000 0000000000000003\n+write -q -z 2k 2k\n+L2 entry #0: 0x8000000000050000 00000002800103fd\n+write -q -z 0 64k\n+L2 entry #0: 0x8000000000050000 ffffffff00000000\n+write -q -P PATTERN 0 64k\n+L2 entry #0: 0x8000000000050000 00000000ffffffff\n+write -q -z -u 0 32k\n+L2 entry #0: 0x8000000000050000 0000ffffffff0000\n+write -q -z -u 0 64k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000050000 fffffffd00000002\n+write -q -P PATTERN 0 64k\n+L2 entry #0: 0x8000000000050000 00000000ffffffff\n+discard -q 0 64k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+write -q -c -P PATTERN 0 64k\n+L2 entry #0: 0x4000000000050000 0000000000000000\n+write -q -P PATTERN 3k 512\n+L2 entry #0: 0x8000000000070000 00000000ffffffff\n+\n+### Overwriting several clusters without COW ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+write -q -P PATTERN 24k 40k\n+L2 entry #0: 0x8000000000050000 00000000fffff000\n+write -q -P PATTERN 90k 2k\n+L2 entry #1: 0x8000000000060000 0000000000002000\n+write -q -P PATTERN 156k 2k\n+L2 entry #2: 0x8000000000070000 0000000000004000\n+write -q -z 156k 2k\n+L2 entry #2: 0x8000000000070000 0000400000000000\n+write -q -P PATTERN 192k 34k\n+L2 entry #3: 0x8000000000080000 000000000001ffff\n+write -q -P PATTERN 24k 192k\n+L2 entry #0: 0x8000000000050000 00000000fffff000\n+L2 entry #1: 0x8000000000060000 00000000ffffffff\n+L2 entry #2: 0x8000000000070000 00000000ffffffff\n+L2 entry #3: 0x8000000000080000 000000000001ffff\n+\n+### Writing zeroes 1: unallocated clusters (backing file: yes) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+write -q -z 0 192k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+L2 entry #1: 0x0000000000000000 ffffffff00000000\n+L2 entry #2: 0x0000000000000000 ffffffff00000000\n+write -q -z 224k 128k\n+L2 entry #3: 0x0000000000000000 ffff000000000000\n+L2 entry #4: 0x0000000000000000 ffffffff00000000\n+L2 entry #5: 0x0000000000000000 0000ffff00000000\n+write -q -z 415k 128k\n+L2 entry #6: 0x8000000000050000 ffff000000008000\n+L2 entry #7: 0x0000000000000000 ffffffff00000000\n+L2 entry #8: 0x8000000000060000 00007fff00008000\n+\n+### Writing zeroes 2: allocated clusters (backing file: yes) ###\n+\n+write -q -P PATTERN 576k 576k\n+L2 entry #9: 0x8000000000070000 00000000ffffffff\n+L2 entry #10: 0x8000000000080000 00000000ffffffff\n+L2 entry #11: 0x8000000000090000 00000000ffffffff\n+L2 entry #12: 0x80000000000a0000 00000000ffffffff\n+L2 entry #13: 0x80000000000b0000 00000000ffffffff\n+L2 entry #14: 0x80000000000c0000 00000000ffffffff\n+L2 entry #15: 0x80000000000d0000 00000000ffffffff\n+L2 entry #16: 0x80000000000e0000 00000000ffffffff\n+L2 entry #17: 0x80000000000f0000 00000000ffffffff\n+write -q -z 576k 192k\n+L2 entry #9: 0x8000000000070000 ffffffff00000000\n+L2 entry #10: 0x8000000000080000 ffffffff00000000\n+L2 entry #11: 0x8000000000090000 ffffffff00000000\n+write -q -z 800k 128k\n+L2 entry #12: 0x80000000000a0000 ffff00000000ffff\n+L2 entry #13: 0x80000000000b0000 ffffffff00000000\n+L2 entry #14: 0x80000000000c0000 0000ffffffff0000\n+write -q -z 991k 128k\n+L2 entry #15: 0x80000000000d0000 ffff00000000ffff\n+L2 entry #16: 0x80000000000e0000 ffffffff00000000\n+L2 entry #17: 0x80000000000f0000 00007fffffff8000\n+\n+### Writing zeroes 3: compressed clusters (backing file: yes) ###\n+\n+write -q -c -P PATTERN 1152k 64k\n+L2 entry #18: 0x4000000000100000 0000000000000000\n+write -q -c -P PATTERN 1216k 64k\n+L2 entry #19: 0x4000000000110000 0000000000000000\n+write -q -c -P PATTERN 1280k 64k\n+L2 entry #20: 0x4000000000120000 0000000000000000\n+write -q -c -P PATTERN 1344k 64k\n+L2 entry #21: 0x4000000000130000 0000000000000000\n+write -q -c -P PATTERN 1408k 64k\n+L2 entry #22: 0x4000000000140000 0000000000000000\n+write -q -c -P PATTERN 1472k 64k\n+L2 entry #23: 0x4000000000150000 0000000000000000\n+write -q -c -P PATTERN 1536k 64k\n+L2 entry #24: 0x4000000000160000 0000000000000000\n+write -q -c -P PATTERN 1600k 64k\n+L2 entry #25: 0x4000000000170000 0000000000000000\n+write -q -c -P PATTERN 1664k 64k\n+L2 entry #26: 0x4000000000180000 0000000000000000\n+write -q -c -P PATTERN 1728k 64k\n+L2 entry #27: 0x4000000000190000 0000000000000000\n+write -q -c -P PATTERN 1792k 64k\n+L2 entry #28: 0x40000000001a0000 0000000000000000\n+write -q -z 1152k 192k\n+L2 entry #18: 0x0000000000000000 ffffffff00000000\n+L2 entry #19: 0x0000000000000000 ffffffff00000000\n+L2 entry #20: 0x0000000000000000 ffffffff00000000\n+write -q -z 1376k 128k\n+L2 entry #21: 0x8000000000100000 00000000ffffffff\n+L2 entry #22: 0x8000000000110000 00000000ffffffff\n+L2 entry #23: 0x8000000000120000 00000000ffffffff\n+write -q -z 1567k 129k\n+L2 entry #24: 0x8000000000130000 00000000ffffffff\n+L2 entry #25: 0x8000000000140000 00000000ffffffff\n+L2 entry #26: 0x8000000000150000 00000000ffffffff\n+write -q -z 1759k 128k\n+L2 entry #27: 0x8000000000160000 ffff00000000ffff\n+L2 entry #28: 0x0000000000000000 ffffffff00000000\n+L2 entry #29: 0x8000000000170000 00007fff00008000\n+\n+### Writing zeroes 4: other tests (backing file: yes) ###\n+\n+write -q -z 1951k 8k\n+L2 entry #30: 0x8000000000180000 0007000000088000\n+write -q -z 2048k 35k\n+L2 entry #32: 0x0000000000000000 0003ffff00000000\n+\n+### Writing zeroes 1: unallocated clusters (backing file: no) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992\n+write -q -z 0 192k\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+L2 entry #1: 0x0000000000000000 ffffffff00000000\n+L2 entry #2: 0x0000000000000000 ffffffff00000000\n+write -q -z 224k 128k\n+L2 entry #3: 0x0000000000000000 ffff000000000000\n+L2 entry #4: 0x0000000000000000 ffffffff00000000\n+L2 entry #5: 0x0000000000000000 0000ffff00000000\n+write -q -z 415k 128k\n+L2 entry #6: 0x0000000000000000 ffff800000000000\n+L2 entry #7: 0x0000000000000000 ffffffff00000000\n+L2 entry #8: 0x0000000000000000 0000ffff00000000\n+\n+### Writing zeroes 2: allocated clusters (backing file: no) ###\n+\n+write -q -P PATTERN 576k 576k\n+L2 entry #9: 0x8000000000050000 00000000ffffffff\n+L2 entry #10: 0x8000000000060000 00000000ffffffff\n+L2 entry #11: 0x8000000000070000 00000000ffffffff\n+L2 entry #12: 0x8000000000080000 00000000ffffffff\n+L2 entry #13: 0x8000000000090000 00000000ffffffff\n+L2 entry #14: 0x80000000000a0000 00000000ffffffff\n+L2 entry #15: 0x80000000000b0000 00000000ffffffff\n+L2 entry #16: 0x80000000000c0000 00000000ffffffff\n+L2 entry #17: 0x80000000000d0000 00000000ffffffff\n+write -q -z 576k 192k\n+L2 entry #9: 0x8000000000050000 ffffffff00000000\n+L2 entry #10: 0x8000000000060000 ffffffff00000000\n+L2 entry #11: 0x8000000000070000 ffffffff00000000\n+write -q -z 800k 128k\n+L2 entry #12: 0x8000000000080000 ffff00000000ffff\n+L2 entry #13: 0x8000000000090000 ffffffff00000000\n+L2 entry #14: 0x80000000000a0000 0000ffffffff0000\n+write -q -z 991k 128k\n+L2 entry #15: 0x80000000000b0000 ffff00000000ffff\n+L2 entry #16: 0x80000000000c0000 ffffffff00000000\n+L2 entry #17: 0x80000000000d0000 00007fffffff8000\n+\n+### Writing zeroes 3: compressed clusters (backing file: no) ###\n+\n+write -q -c -P PATTERN 1152k 64k\n+L2 entry #18: 0x40000000000e0000 0000000000000000\n+write -q -c -P PATTERN 1216k 64k\n+L2 entry #19: 0x40000000000f0000 0000000000000000\n+write -q -c -P PATTERN 1280k 64k\n+L2 entry #20: 0x4000000000100000 0000000000000000\n+write -q -c -P PATTERN 1344k 64k\n+L2 entry #21: 0x4000000000110000 0000000000000000\n+write -q -c -P PATTERN 1408k 64k\n+L2 entry #22: 0x4000000000120000 0000000000000000\n+write -q -c -P PATTERN 1472k 64k\n+L2 entry #23: 0x4000000000130000 0000000000000000\n+write -q -c -P PATTERN 1536k 64k\n+L2 entry #24: 0x4000000000140000 0000000000000000\n+write -q -c -P PATTERN 1600k 64k\n+L2 entry #25: 0x4000000000150000 0000000000000000\n+write -q -c -P PATTERN 1664k 64k\n+L2 entry #26: 0x4000000000160000 0000000000000000\n+write -q -c -P PATTERN 1728k 64k\n+L2 entry #27: 0x4000000000170000 0000000000000000\n+write -q -c -P PATTERN 1792k 64k\n+L2 entry #28: 0x4000000000180000 0000000000000000\n+write -q -z 1152k 192k\n+L2 entry #18: 0x0000000000000000 ffffffff00000000\n+L2 entry #19: 0x0000000000000000 ffffffff00000000\n+L2 entry #20: 0x0000000000000000 ffffffff00000000\n+write -q -z 1376k 128k\n+L2 entry #21: 0x80000000000e0000 00000000ffffffff\n+L2 entry #22: 0x80000000000f0000 00000000ffffffff\n+L2 entry #23: 0x8000000000100000 00000000ffffffff\n+write -q -z 1567k 129k\n+L2 entry #24: 0x8000000000110000 00000000ffffffff\n+L2 entry #25: 0x8000000000120000 00000000ffffffff\n+L2 entry #26: 0x8000000000130000 00000000ffffffff\n+write -q -z 1759k 128k\n+L2 entry #27: 0x8000000000140000 ffff00000000ffff\n+L2 entry #28: 0x0000000000000000 ffffffff00000000\n+L2 entry #29: 0x0000000000000000 0000ffff00000000\n+\n+### Writing zeroes 4: other tests (backing file: no) ###\n+\n+write -q -z 1951k 8k\n+L2 entry #30: 0x0000000000000000 000f800000000000\n+write -q -z 2048k 35k\n+L2 entry #32: 0x0000000000000000 0003ffff00000000\n+\n+### Zero + unmap 1: allocated clusters (backing file: yes) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+write -q -P PATTERN 576k 576k\n+L2 entry #9: 0x8000000000050000 00000000ffffffff\n+L2 entry #10: 0x8000000000060000 00000000ffffffff\n+L2 entry #11: 0x8000000000070000 00000000ffffffff\n+L2 entry #12: 0x8000000000080000 00000000ffffffff\n+L2 entry #13: 0x8000000000090000 00000000ffffffff\n+L2 entry #14: 0x80000000000a0000 00000000ffffffff\n+L2 entry #15: 0x80000000000b0000 00000000ffffffff\n+L2 entry #16: 0x80000000000c0000 00000000ffffffff\n+L2 entry #17: 0x80000000000d0000 00000000ffffffff\n+write -q -z -u 576k 192k\n+L2 entry #9: 0x0000000000000000 ffffffff00000000\n+L2 entry #10: 0x0000000000000000 ffffffff00000000\n+L2 entry #11: 0x0000000000000000 ffffffff00000000\n+write -q -z -u 800k 128k\n+L2 entry #12: 0x8000000000080000 ffff00000000ffff\n+L2 entry #13: 0x0000000000000000 ffffffff00000000\n+L2 entry #14: 0x80000000000a0000 0000ffffffff0000\n+write -q -z -u 991k 128k\n+L2 entry #15: 0x80000000000b0000 ffff00000000ffff\n+L2 entry #16: 0x0000000000000000 ffffffff00000000\n+L2 entry #17: 0x80000000000d0000 00007fffffff8000\n+\n+### Zero + unmap 2: compressed clusters (backing file: yes) ###\n+\n+write -q -c -P PATTERN 1152k 64k\n+L2 entry #18: 0x4000000000050000 0000000000000000\n+write -q -c -P PATTERN 1216k 64k\n+L2 entry #19: 0x4000000000060000 0000000000000000\n+write -q -c -P PATTERN 1280k 64k\n+L2 entry #20: 0x4000000000070000 0000000000000000\n+write -q -c -P PATTERN 1344k 64k\n+L2 entry #21: 0x4000000000090000 0000000000000000\n+write -q -c -P PATTERN 1408k 64k\n+L2 entry #22: 0x40000000000c0000 0000000000000000\n+write -q -c -P PATTERN 1472k 64k\n+L2 entry #23: 0x40000000000e0000 0000000000000000\n+write -q -c -P PATTERN 1536k 64k\n+L2 entry #24: 0x40000000000f0000 0000000000000000\n+write -q -c -P PATTERN 1600k 64k\n+L2 entry #25: 0x4000000000100000 0000000000000000\n+write -q -c -P PATTERN 1664k 64k\n+L2 entry #26: 0x4000000000110000 0000000000000000\n+write -q -c -P PATTERN 1728k 64k\n+L2 entry #27: 0x4000000000120000 0000000000000000\n+write -q -c -P PATTERN 1792k 64k\n+L2 entry #28: 0x4000000000130000 0000000000000000\n+write -q -z -u 1152k 192k\n+L2 entry #18: 0x0000000000000000 ffffffff00000000\n+L2 entry #19: 0x0000000000000000 ffffffff00000000\n+L2 entry #20: 0x0000000000000000 ffffffff00000000\n+write -q -z -u 1376k 128k\n+L2 entry #21: 0x8000000000050000 00000000ffffffff\n+L2 entry #22: 0x8000000000060000 00000000ffffffff\n+L2 entry #23: 0x8000000000070000 00000000ffffffff\n+write -q -z -u 1567k 129k\n+L2 entry #24: 0x8000000000090000 00000000ffffffff\n+L2 entry #25: 0x80000000000e0000 00000000ffffffff\n+L2 entry #26: 0x80000000000f0000 00000000ffffffff\n+write -q -z -u 1759k 128k\n+L2 entry #27: 0x80000000000c0000 ffff00000000ffff\n+L2 entry #28: 0x0000000000000000 ffffffff00000000\n+L2 entry #29: 0x8000000000100000 00007fff00008000\n+\n+### Zero + unmap 1: allocated clusters (backing file: no) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992\n+write -q -P PATTERN 576k 576k\n+L2 entry #9: 0x8000000000050000 00000000ffffffff\n+L2 entry #10: 0x8000000000060000 00000000ffffffff\n+L2 entry #11: 0x8000000000070000 00000000ffffffff\n+L2 entry #12: 0x8000000000080000 00000000ffffffff\n+L2 entry #13: 0x8000000000090000 00000000ffffffff\n+L2 entry #14: 0x80000000000a0000 00000000ffffffff\n+L2 entry #15: 0x80000000000b0000 00000000ffffffff\n+L2 entry #16: 0x80000000000c0000 00000000ffffffff\n+L2 entry #17: 0x80000000000d0000 00000000ffffffff\n+write -q -z -u 576k 192k\n+L2 entry #9: 0x0000000000000000 ffffffff00000000\n+L2 entry #10: 0x0000000000000000 ffffffff00000000\n+L2 entry #11: 0x0000000000000000 ffffffff00000000\n+write -q -z -u 800k 128k\n+L2 entry #12: 0x8000000000080000 ffff00000000ffff\n+L2 entry #13: 0x0000000000000000 ffffffff00000000\n+L2 entry #14: 0x80000000000a0000 0000ffffffff0000\n+write -q -z -u 991k 128k\n+L2 entry #15: 0x80000000000b0000 ffff00000000ffff\n+L2 entry #16: 0x0000000000000000 ffffffff00000000\n+L2 entry #17: 0x80000000000d0000 00007fffffff8000\n+\n+### Zero + unmap 2: compressed clusters (backing file: no) ###\n+\n+write -q -c -P PATTERN 1152k 64k\n+L2 entry #18: 0x4000000000050000 0000000000000000\n+write -q -c -P PATTERN 1216k 64k\n+L2 entry #19: 0x4000000000060000 0000000000000000\n+write -q -c -P PATTERN 1280k 64k\n+L2 entry #20: 0x4000000000070000 0000000000000000\n+write -q -c -P PATTERN 1344k 64k\n+L2 entry #21: 0x4000000000090000 0000000000000000\n+write -q -c -P PATTERN 1408k 64k\n+L2 entry #22: 0x40000000000c0000 0000000000000000\n+write -q -c -P PATTERN 1472k 64k\n+L2 entry #23: 0x40000000000e0000 0000000000000000\n+write -q -c -P PATTERN 1536k 64k\n+L2 entry #24: 0x40000000000f0000 0000000000000000\n+write -q -c -P PATTERN 1600k 64k\n+L2 entry #25: 0x4000000000100000 0000000000000000\n+write -q -c -P PATTERN 1664k 64k\n+L2 entry #26: 0x4000000000110000 0000000000000000\n+write -q -c -P PATTERN 1728k 64k\n+L2 entry #27: 0x4000000000120000 0000000000000000\n+write -q -c -P PATTERN 1792k 64k\n+L2 entry #28: 0x4000000000130000 0000000000000000\n+write -q -z -u 1152k 192k\n+L2 entry #18: 0x0000000000000000 ffffffff00000000\n+L2 entry #19: 0x0000000000000000 ffffffff00000000\n+L2 entry #20: 0x0000000000000000 ffffffff00000000\n+write -q -z -u 1376k 128k\n+L2 entry #21: 0x8000000000050000 00000000ffffffff\n+L2 entry #22: 0x8000000000060000 00000000ffffffff\n+L2 entry #23: 0x8000000000070000 00000000ffffffff\n+write -q -z -u 1567k 129k\n+L2 entry #24: 0x8000000000090000 00000000ffffffff\n+L2 entry #25: 0x80000000000e0000 00000000ffffffff\n+L2 entry #26: 0x80000000000f0000 00000000ffffffff\n+write -q -z -u 1759k 128k\n+L2 entry #27: 0x80000000000c0000 ffff00000000ffff\n+L2 entry #28: 0x0000000000000000 ffffffff00000000\n+L2 entry #29: 0x0000000000000000 0000ffff00000000\n+\n+### Discarding clusters with non-zero bitmaps (backing file: yes) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+L2 entry #1: 0x0000000000000000 ffffffff00000000\n+Image resized.\n+Image resized.\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+L2 entry #1: 0x0000000000000000 ffffffff00000000\n+\n+### Discarding clusters with non-zero bitmaps (backing file: no) ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x0000000000000000 ffffffff00000000\n+L2 entry #1: 0x0000000000000000 ffffffff00000000\n+Image resized.\n+Image resized.\n+L2 entry #0: 0x0000000000000000 0000ffff00000000\n+L2 entry #1: 0x0000000000000000 0000000000000000\n+\n+### Corrupted L2 entries - read test (allocated) ###\n+\n+# 'cluster is zero' bit set on the standard cluster descriptor\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x8000000000050001 0000000000000001\n+L2 entry #0: 0x8000000000050001 0000000000000001\n+\n+# Both 'subcluster is zero' and 'subcluster is allocated' bits set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #1: 0x8000000000060000 00000001ffffffff\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed\n+read failed: Input/output error\n+\n+### Corrupted L2 entries - read test (unallocated) ###\n+\n+# 'cluster is zero' bit set on the standard cluster descriptor\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x0000000000000001 0000000000000000\n+L2 entry #0: 0x0000000000000001 0000000000000000\n+\n+# 'subcluster is allocated' bit set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x0000000000000000 0000000000000001\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed\n+read failed: Input/output error\n+\n+# Both 'subcluster is zero' and 'subcluster is allocated' bits set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #1: 0x0000000000000000 0000000100000001\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed\n+read failed: Input/output error\n+\n+### Compressed cluster with subcluster bitmap != 0 - read test ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x4000000000050000 0000000180000000\n+read 65536/65536 bytes at offset 0\n+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+L2 entry #0: 0x4000000000050000 0000000180000000\n+\n+### Corrupted L2 entries - write test (allocated) ###\n+\n+# 'cluster is zero' bit set on the standard cluster descriptor\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x8000000000050001 0000000000000001\n+L2 entry #0: 0x8000000000050001 0000000000000001\n+\n+# Both 'subcluster is zero' and 'subcluster is allocated' bits set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #1: 0x8000000000060000 00000001ffffffff\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed\n+write failed: Input/output error\n+\n+### Corrupted L2 entries - write test (unallocated) ###\n+\n+# 'cluster is zero' bit set on the standard cluster descriptor\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x0000000000000001 0000000000000000\n+L2 entry #0: 0x8000000000060000 0000000000000001\n+\n+# 'subcluster is allocated' bit set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x0000000000000000 0000000000000001\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed\n+write failed: Input/output error\n+\n+# Both 'subcluster is zero' and 'subcluster is allocated' bits set\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #1: 0x0000000000000000 0000000100000001\n+qcow2: Marking image as corrupt: Invalid cluster entry found  (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed\n+write failed: Input/output error\n+\n+### Compressed cluster with subcluster bitmap != 0 - write test ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x4000000000050000 0000000180000000\n+wrote 65536/65536 bytes at offset 0\n+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+L2 entry #0: 0x8000000000060000 00000000ffffffff\n+\n+### Image creation options ###\n+\n+# cluster_size < 16k\n+qemu-img: TEST_DIR/t.IMGFMT: Extended L2 entries are only supported with cluster sizes of at least 16384 bytes\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+# backing file and preallocation=metadata\n+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=1048576\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=metadata\n+Image resized.\n+read 524288/524288 bytes at offset 0\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 524288/524288 bytes at offset 524288\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Offset          Length          Mapped to       File\n+0               0x80000        0               TEST_DIR/t.qcow2.base\n+# backing file and preallocation=falloc\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=falloc\n+Image resized.\n+read 524288/524288 bytes at offset 0\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 524288/524288 bytes at offset 524288\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Offset          Length          Mapped to       File\n+0               0x80000        0               TEST_DIR/t.qcow2.base\n+# backing file and preallocation=full\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=full\n+Image resized.\n+read 524288/524288 bytes at offset 0\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 524288/524288 bytes at offset 524288\n+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Offset          Length          Mapped to       File\n+0               0x80000        0               TEST_DIR/t.qcow2.base\n+\n+### Image resizing with preallocation and backing files ###\n+\n+# resize --preallocation=metadata\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+# resize --preallocation=falloc\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+# resize --preallocation=full\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+### Image resizing with preallocation without backing files ###\n+\n+# resize --preallocation=metadata\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072\n+wrote 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+# resize --preallocation=falloc\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072\n+wrote 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+# resize --preallocation=full\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072\n+wrote 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+Image resized.\n+read 515072/515072 bytes at offset 0\n+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+read 522240/522240 bytes at offset 515072\n+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+### qemu-img measure ###\n+\n+# 512MB, extended_l2=off\n+required size: 327680\n+fully allocated size: 537198592\n+# 512MB, extended_l2=on\n+required size: 393216\n+fully allocated size: 537264128\n+# 16K clusters, 64GB, extended_l2=off\n+required size: 42008576\n+fully allocated size: 68761485312\n+# 16K clusters, 64GB, extended_l2=on\n+required size: 75579392\n+fully allocated size: 68795056128\n+# 8k clusters\n+qemu-img: Extended L2 entries are only supported with cluster sizes of at least 16384 bytes\n+# 1024 TB\n+required size: 309285027840\n+fully allocated size: 1126209191870464\n+# 1025 TB\n+qemu-img: The image size is too large (try using a larger cluster size)\n+\n+### qemu-img amend ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+qemu-img: Toggling extended L2 entries is not supported\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+qemu-img: Toggling extended L2 entries is not supported\n+\n+### Test copy-on-write on an image with snapshots ###\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576\n+L2 entry #0: 0x8000000000050000 0000008000042000\n+L2 entry #1: 0x8000000000060000 0000008000042000\n+L2 entry #2: 0x8000000000070000 0000008000042000\n+L2 entry #3: 0x8000000000080000 0000008000042000\n+L2 entry #4: 0x8000000000090000 0000008000042000\n+L2 entry #5: 0x80000000000a0000 0000008000042000\n+L2 entry #6: 0x80000000000b0000 0000008000042000\n+L2 entry #7: 0x80000000000c0000 0000008000042000\n+L2 entry #8: 0x80000000000d0000 0000008000042000\n+L2 entry #9: 0x80000000000e0000 0000008000042000\n+L2 entry #0: 0x8000000000120000 000000800007e000\n+L2 entry #1: 0x8000000000130000 000000800007fc00\n+L2 entry #2: 0x8000000000140000 00000080001fe000\n+L2 entry #3: 0x8000000000150000 000000800007e000\n+L2 entry #4: 0x8000000000160000 000000000007ff80\n+L2 entry #5: 0x8000000000170000 000000000007ffff\n+L2 entry #6: 0x00000000000b0000 0001808000042000\n+L2 entry #7: 0x00000000000c0000 0000208000040000\n+L2 entry #8: 0x8000000000180000 000000800007e000\n+L2 entry #9: 0x00000000000e0000 000000c000042000\n+*** done\ndiff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group\nindex d886fa0cb3..68f6c2074a 100644\n--- a/tests/qemu-iotests/group\n+++ b/tests/qemu-iotests/group\n@@ -284,6 +284,7 @@\n 267 rw auto quick snapshot\n 268 rw auto quick\n 270 rw backing quick\n+271 rw auto\n 272 rw\n 273 backing quick\n 274 rw backing\n",
    "prefixes": [
        "v8",
        "34/34"
    ]
}