{"id":1307011,"url":"http://patchwork.ozlabs.org/api/patches/1307011/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/19afb93b267b9698edf5e0253458c5db69ef91a2.1591801197.git.berto@igalia.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":"<19afb93b267b9698edf5e0253458c5db69ef91a2.1591801197.git.berto@igalia.com>","list_archive_url":null,"date":"2020-06-10T15:03:11","name":"[v8,33/34] qcow2: Assert that expand_zero_clusters_in_l1() does not support subclusters","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"33a9a5695e54955dd3de6efd22fb2bff0b6d9d07","submitter":{"id":65704,"url":"http://patchwork.ozlabs.org/api/people/65704/?format=json","name":"Alberto Garcia","email":"berto@igalia.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/19afb93b267b9698edf5e0253458c5db69ef91a2.1591801197.git.berto@igalia.com/mbox/","series":[{"id":182563,"url":"http://patchwork.ozlabs.org/api/series/182563/?format=json","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/1307011/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1307011/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=OxAYhRR5;\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 49hr6G5N7pz9sQx\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 11 Jun 2020 01:11:02 +1000 (AEST)","from localhost ([::1]:40618 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 1jj2NW-0002zI-Kj\n\tfor incoming@patchwork.ozlabs.org; Wed, 10 Jun 2020 11:10:58 -0400","from eggs.gnu.org ([2001:470:142:3::10]:36144)\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 1jj2Gv-0002hJ-Uk; Wed, 10 Jun 2020 11:04:10 -0400","from fanzine.igalia.com ([178.60.130.6]:58259)\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-0006wi-6i; Wed, 10 Jun 2020 11:04:09 -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-0007hM-SW; 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-0007Nx-LD; 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=FNEfjpoQrBQwt7pMv2/+wQIBqEVUgJ9upnhqgM5UNv0=;\n b=OxAYhRR5FB2uT+XcSB3+EH46eh0ct4ezQpCGwSR5wlY676cP8JIysWd7u5ttn91oAITfzMsLj5CW7kv3dJWaQ/bsKSnbClGin53vIllLsovwg11PfNidaNpZKKJ9TJnA/nYM/4jAUBkmWcKSeGyLPLSn/tRP16hoiEGa/hzTNU45cz8SdVQreEKXttJcBS0jepj9+UJh/wpQ2A3wMMuRgWG0k+HCimJs7c/xXXjv9L2635UrFmLhHNylsnJJVgDcd1no6/7Xa82esKSKvMAjbcRTXVEKMrf6+A2o0EUH0Vk3BGu//v6PvFMm63csrGn0L6cFze4JtrRpqebzA4u68w==;","From":"Alberto Garcia <berto@igalia.com>","To":"qemu-devel@nongnu.org","Subject":"[PATCH v8 33/34] qcow2: Assert that expand_zero_clusters_in_l1() does\n not support subclusters","Date":"Wed, 10 Jun 2020 17:03:11 +0200","Message-Id":"\n <19afb93b267b9698edf5e0253458c5db69ef91a2.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":"This function is only used by qcow2_expand_zero_clusters() to\ndowngrade a qcow2 image to a previous version. It is however not\npossible to downgrade an image with extended L2 entries because older\nversions of qcow2 do not have this feature.\n\nSigned-off-by: Alberto Garcia <berto@igalia.com>\nReviewed-by: Eric Blake <eblake@redhat.com>\n---\n block/qcow2-cluster.c      | 8 +++++++-\n tests/qemu-iotests/061     | 6 ++++++\n tests/qemu-iotests/061.out | 5 +++++\n 3 files changed, 18 insertions(+), 1 deletion(-)","diff":"diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c\nindex c8217081f2..e8bb1f32f3 100644\n--- a/block/qcow2-cluster.c\n+++ b/block/qcow2-cluster.c\n@@ -2157,6 +2157,9 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,\n     int ret;\n     int i, j;\n \n+    /* qcow2_downgrade() is not allowed in images with subclusters */\n+    assert(!has_subclusters(s));\n+\n     slice_size2 = s->l2_slice_size * l2_entry_size(s);\n     n_slices = s->cluster_size / slice_size2;\n \n@@ -2225,7 +2228,8 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,\n                 if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {\n                     if (!bs->backing) {\n                         /* not backed; therefore we can simply deallocate the\n-                         * cluster */\n+                         * cluster. No need to call set_l2_bitmap(), this\n+                         * function doesn't support images with subclusters. */\n                         set_l2_entry(s, l2_slice, j, 0);\n                         l2_dirty = true;\n                         continue;\n@@ -2296,6 +2300,8 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,\n                 } else {\n                     set_l2_entry(s, l2_slice, j, offset);\n                 }\n+                /* No need to call set_l2_bitmap() after set_l2_entry() because\n+                 * this function doesn't support images with subclusters. */\n                 l2_dirty = true;\n             }\n \ndiff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061\nindex 10eb243164..23add2dfe3 100755\n--- a/tests/qemu-iotests/061\n+++ b/tests/qemu-iotests/061\n@@ -303,6 +303,12 @@ $QEMU_IMG amend -o \"compat=0.10\" \"$TEST_IMG\"\n _img_info --format-specific\n _check_test_img\n \n+echo\n+echo \"=== Testing version downgrade with extended L2 entries ===\"\n+echo\n+_make_test_img -o \"compat=1.1,extended_l2=on\" 64M\n+$QEMU_IMG amend -o \"compat=0.10\" \"$TEST_IMG\"\n+\n echo\n echo \"=== Try changing the external data file ===\"\n echo\ndiff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out\nindex 39812d8cf8..c1acdbd751 100644\n--- a/tests/qemu-iotests/061.out\n+++ b/tests/qemu-iotests/061.out\n@@ -528,6 +528,11 @@ Format specific information:\n     extended l2: false\n No errors were found on the image.\n \n+=== Testing version downgrade with extended L2 entries ===\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864\n+qemu-img: Cannot downgrade an image with incompatible features 0x10 set\n+\n === Try changing the external data file ===\n \n Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864\n","prefixes":["v8","33/34"]}