From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242588; cv=none; d=zoho.com; s=zohoarc; b=nAvaLRyRPRwcJwRxWl0eYTcMAePuIkTT9XW1k4FrtIH9mEELc5BBtc6H1NG6OCYtyvs4PKNud/7lIPDFaHUgeTo5TYC6Z9dyhiCts+pLcNqlj8/x745A9z4maEZTSRzewmh3BhQSG7fQkmQ4CGuYUm1yIXlSQRge0o6cMeylsRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UcvsN2X/zqfiE2Z4km6T2PUUWXLtsNJMfZe0+OmD/Z4=; b=W+qaBLJebjuzUyl77qndjB/Ult0l7QA96yNojTFE5NMljd7HfbWrZdVw2kSfDObtlQXjJMssvAJfDkoVdRPe/gUYFaQAIYtPICjZUj2PbjqVwxjY+ISK/m9JGu0gdRFkBV1AhVGjQ9jSKjFgiqPkji9eZ2XK1ObhW/Gkkk7ueRA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242588605719.7305529005366; Tue, 7 May 2019 08:23:08 -0700 (PDT) Received: from localhost ([127.0.0.1]:48514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1vs-0002no-JF for importer@patchew.org; Tue, 07 May 2019 11:23:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rW-0007pv-Dq for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rU-0003se-Fj for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rO-0003lE-Lw; Tue, 07 May 2019 11:18:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F370308793B; Tue, 7 May 2019 15:18:24 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 075F860C5F; Tue, 7 May 2019 15:18:23 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:09 +0200 Message-Id: <20190507151819.17401-2-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 07 May 2019 15:18:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/11] qcow2-refcount: fix check_oflag_copied X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Increase corruptions_fixed only after successful fix. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-id: 20190227131433.197063-2-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e0fe322500..ed3d8ebd57 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1846,7 +1846,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, for (i =3D 0; i < s->l1_size; i++) { uint64_t l1_entry =3D s->l1_table[i]; uint64_t l2_offset =3D l1_entry & L1E_OFFSET_MASK; - bool l2_dirty =3D false; + int l2_dirty =3D 0; =20 if (!l2_offset) { continue; @@ -1912,8 +1912,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, l2_table[j] =3D cpu_to_be64(refcount =3D=3D 1 ? l2_entry | QCOW_OFLAG_COPIED : l2_entry & ~QCOW_OFLAG_COPIED); - l2_dirty =3D true; - res->corruptions_fixed++; + l2_dirty++; } else { res->corruptions++; } @@ -1921,7 +1920,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } } =20 - if (l2_dirty) { + if (l2_dirty > 0) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size, false); @@ -1940,6 +1939,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, res->check_errors++; goto fail; } + res->corruptions_fixed +=3D l2_dirty; } } =20 --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242460; cv=none; d=zoho.com; s=zohoarc; b=VJv7E0bMsTD1v5Pmhm1+Z5rtbB4z3+RfL9pSCQ+lZxEeljDi0I5A8Cxt59XKjk4T/CBKDPWnzegvj7ERop39IqwNGJgUGj0t5ytDjObFF7P3IEkKIq6C3xeb+vI5arA1zbOg3GMw3fN2DfoXT4LNzbUaWy4XgJm8O2Tbin1wUgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242460; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OgEhsAhPGch+NlaeYQpmJfZqtVqXy66OXWyC+Unbl/M=; b=dUGEKKx0LeGtoLB8ir8d57YGrqNjvsoKnCVUQv3812QlwiHgjPuO8pLEsKV4AbKrYSCDtPpBLbu9d8rxiqp/pszkXVPd9QeSmk3j/xpeEAmbFpG7lAzQ2ZzB95VkgxWtwxiykGnhGe2IFpJv5WMoTnVDPZDeADenPjq8LSuAryk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242460022887.7182562630652; Tue, 7 May 2019 08:21:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:48481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1tY-0000Zu-RS for importer@patchew.org; Tue, 07 May 2019 11:20:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rX-0007s1-MT for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rW-0003u1-E1 for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rQ-0003oX-KH; Tue, 07 May 2019 11:18:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBBC9C04FFF1; Tue, 7 May 2019 15:18:26 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6356F5D9CC; Tue, 7 May 2019 15:18:26 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:10 +0200 Message-Id: <20190507151819.17401-3-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 07 May 2019 15:18:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/11] qcow2-refcount: avoid eating RAM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy qcow2_inc_refcounts_imrt() (through realloc_refcount_array()) can eat an unpredictable amount of memory on corrupted table entries, which are referencing regions far beyond the end of file. Prevent this, by skipping such regions from further processing. Interesting that iotest 138 checks exactly the behavior which we fix here. So, change the test appropriately. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-id: 20190227131433.197063-3-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 19 +++++++++++++++++++ tests/qemu-iotests/138 | 12 +++++------- tests/qemu-iotests/138.out | 5 ++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index ed3d8ebd57..21e50dacf4 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1520,12 +1520,31 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, = BdrvCheckResult *res, { BDRVQcow2State *s =3D bs->opaque; uint64_t start, last, cluster_offset, k, refcount; + int64_t file_len; int ret; =20 if (size <=3D 0) { return 0; } =20 + file_len =3D bdrv_getlength(bs->file->bs); + if (file_len < 0) { + return file_len; + } + + /* + * Last cluster of qcow2 image may be semi-allocated, so it may be OK = to + * reference some space after file end but it should be less than one + * cluster. + */ + if (offset + size - file_len >=3D s->cluster_size) { + fprintf(stderr, "ERROR: counting reference for region exceeding th= e " + "end of the file by one cluster or more: offset 0x%" PRIx64 + " size 0x%" PRIx64 "\n", offset, size); + res->corruptions++; + return 0; + } + start =3D start_of_cluster(s, offset); last =3D start_of_cluster(s, offset + size - 1); for(cluster_offset =3D start; cluster_offset <=3D last; diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 index f353ac8219..6a731370db 100755 --- a/tests/qemu-iotests/138 +++ b/tests/qemu-iotests/138 @@ -54,15 +54,13 @@ $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io # Put the data cluster at a multiple of 2 TB, resulting in the image appar= ently # having a multiple of 2^32 clusters # (To be more specific: It is at 32 PB) -poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" +poke_file "$TEST_IMG" $((2048 + 8)) "\x00\x80\x00\x00\x00\x00\x00\x00" =20 # An offset of 32 PB results in qemu-img check having to allocate an in-me= mory -# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). -# This should be generally too much for any system and thus fail. -# What this test is checking is that the qcow2 driver actually tries to al= locate -# such a large amount of memory (and is consequently aborting) instead of = having -# truncated the cluster count somewhere (which would result in much less m= emory -# being allocated and then a segfault occurring). +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters), if qemu-= img +# don't check that referenced data cluster is far beyond the end of file. +# But starting from 4.0, qemu-img does this check, and instead of "Cannot +# allocate memory", we have an error showing that l2 entry is invalid. _check_test_img =20 # success, all done diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out index 3fe911f85a..aca7d47a80 100644 --- a/tests/qemu-iotests/138.out +++ b/tests/qemu-iotests/138.out @@ -5,5 +5,8 @@ QA output created by 138 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D512 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Check failed: Cannot allocate memory +ERROR: counting reference for region exceeding the end of the file by one = cluster or more: offset 0x80000000000000 size 0x200 + +1 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. *** done --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242780; cv=none; d=zoho.com; s=zohoarc; b=Ana+UrLOinf0J8JNcYa+b+UV7S840cf8t1VTBhAKsMfSqBUOfsBryNl7SyrI1J2AmQ39AaAgCrG8beJSug8zC/8yidzRmGj9hHax9V1nMz9J8mfBCLpnVvBYs8+M/Hz/B+JIGOUqqzU8vjvskmtrHxxt2+hE012rCaIimXbpcG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242780; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9YiWUrD9DGVSlJSWxeXsPQxpwMsJHKpDazwgOHU3cP4=; b=h65z/d4SNX8TnmHamE1MByV6DznL7VCa5iU2OQ1ncgSszmsgCKoiMjfZrvf2v5y+R5ztzeuhO32KT1QNFBGe0+D8j6QeoPqgPY5B/eyUzDuxHZmwfg3dU10x6yfadS2cujPiqVuri9mp5kVfH4rRCXljbGE3JUbl09UEEgeeVGI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242780692742.6897439340786; Tue, 7 May 2019 08:26:20 -0700 (PDT) Received: from localhost ([127.0.0.1]:48574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1yt-00060W-Fk for importer@patchew.org; Tue, 07 May 2019 11:26:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rZ-0007vX-WF for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rY-0003xq-SH for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rU-0003qM-DZ; Tue, 07 May 2019 11:18:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3063981E0A; Tue, 7 May 2019 15:18:29 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE6EA64026; Tue, 7 May 2019 15:18:28 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:11 +0200 Message-Id: <20190507151819.17401-4-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 May 2019 15:18:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/11] qcow2-refcount: check_refcounts_l2: reduce ignored overlaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Reduce number of structures ignored in overlap check: when checking active table ignore active tables, when checking inactive table ignore inactive ones. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-id: 20190227131433.197063-4-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 21e50dacf4..1ac2b0490d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1591,7 +1591,7 @@ enum { static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size, int64_t l2_off= set, - int flags, BdrvCheckMode fix) + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l2_table, l2_entry; @@ -1682,11 +1682,12 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, if (fix & BDRV_FIX_ERRORS) { uint64_t l2e_offset =3D l2_offset + (uint64_t)i * sizeof(uint64_t); + int ign =3D active ? QCOW2_OL_ACTIVE_L2 : + QCOW2_OL_INACTIVE_L2; =20 l2_entry =3D QCOW_OFLAG_ZERO; l2_table[i] =3D cpu_to_be64(l2_entry); - ret =3D qcow2_pre_write_overlap_check(bs, - QCOW2_OL_ACTIVE_L2 | QCOW2_OL_INACTIVE_L2, + ret =3D qcow2_pre_write_overlap_check(bs, ign, l2e_offset, sizeof(uint64_t), false); if (ret < 0) { fprintf(stderr, "ERROR: Overlap check failed\n= "); @@ -1762,7 +1763,7 @@ static int check_refcounts_l1(BlockDriverState *bs, void **refcount_table, int64_t *refcount_table_size, int64_t l1_table_offset, int l1_size, - int flags, BdrvCheckMode fix) + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l1_table =3D NULL, l2_offset, l1_size2; @@ -1818,7 +1819,7 @@ static int check_refcounts_l1(BlockDriverState *bs, /* Process and check L2 entries */ ret =3D check_refcounts_l2(bs, res, refcount_table, refcount_table_size, l2_offset, flags, - fix); + fix, active); if (ret < 0) { goto fail; } @@ -2109,7 +2110,7 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, /* current L1 table */ ret =3D check_refcounts_l1(bs, res, refcount_table, nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_IN= FO, - fix); + fix, true); if (ret < 0) { return ret; } @@ -2138,7 +2139,8 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, continue; } ret =3D check_refcounts_l1(bs, res, refcount_table, nb_clusters, - sn->l1_table_offset, sn->l1_size, 0, fix); + sn->l1_table_offset, sn->l1_size, 0, fix, + false); if (ret < 0) { return ret; } --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242446; cv=none; d=zoho.com; s=zohoarc; b=mm89okiEjQVckeLjIOffprfGBXU9btuFWyxEq/YKdvFZlJ3Nd7SIlirUS1ypa9da/4Y1+DZsiN9AMalpRXFy0dkJfI8JqDI/StRyi785sY1uutQAUFVUbexsE2ciCU4J1jwgfdmbnR9HPEFSaS616IJZbVxpCV3zkO1vFfvIbdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242446; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4QJm8x2h7GutGW7RS3eefGfefmXMs/TGuQYA5Ia4gMI=; b=aJ2HaaA4Z0I9FrZWfVsPT2PvJHUqRzn5rP8PaWAoB5lKzBp1E7l/RkZPMgbB2RKDn7OJbTsjR1f5Aa3EL3ZbEc+NxOJo9m0hMq8bKaVC9sh+AKg+D0CQ0gCGFmR7AYptvgPn8E9HqhC5LzRFHiYfWJDCai7UyuCmSrtY14AAvf8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242446314284.9996094852668; Tue, 7 May 2019 08:20:46 -0700 (PDT) Received: from localhost ([127.0.0.1]:48475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1tX-0000YO-78 for importer@patchew.org; Tue, 07 May 2019 11:20:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rZ-0007vC-M4 for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rY-0003xg-Ov for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rU-0003rz-TT; Tue, 07 May 2019 11:18:34 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A9943091761; Tue, 7 May 2019 15:18:31 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20E4C10027BD; Tue, 7 May 2019 15:18:30 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:12 +0200 Message-Id: <20190507151819.17401-5-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 07 May 2019 15:18:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/11] qcow2-refcount: check_refcounts_l2: don't count fixed cluster as allocated X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Do not count a cluster which is fixed to be ZERO as allocated. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-id: 20190227131433.197063-5-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 1ac2b0490d..6851807ffc 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1660,15 +1660,6 @@ static int check_refcounts_l2(BlockDriverState *bs, = BdrvCheckResult *res, { uint64_t offset =3D l2_entry & L2E_OFFSET_MASK; =20 - if (flags & CHECK_FRAG_INFO) { - res->bfi.allocated_clusters++; - if (next_contiguous_offset && - offset !=3D next_contiguous_offset) { - res->bfi.fragmented_clusters++; - } - next_contiguous_offset =3D offset + s->cluster_size; - } - /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { if (qcow2_get_cluster_type(bs, l2_entry) =3D=3D @@ -1721,6 +1712,15 @@ static int check_refcounts_l2(BlockDriverState *bs, = BdrvCheckResult *res, } } =20 + if (flags & CHECK_FRAG_INFO) { + res->bfi.allocated_clusters++; + if (next_contiguous_offset && + offset !=3D next_contiguous_offset) { + res->bfi.fragmented_clusters++; + } + next_contiguous_offset =3D offset + s->cluster_size; + } + /* Mark cluster as used */ if (!has_data_file(bs)) { ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242596; cv=none; d=zoho.com; s=zohoarc; b=B070Sc9SQZSrkJQ6agGq4XHj8gAZBfdXBi5vcR3aGww2MlFTI2ISmDmLp6u7T3M30vya4E0ZI9d2UWl+AcvjrF88ZXlvxyywMjLethp0XXUgcc38wjACc7w2BTk/Wv7MwTJIoqVzfCUKxBTi7QJBYMGV11uxIPyeNF3aYDqFr2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242596; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NN0df8LtNz7pOF5R1RvOohWe+m0K+aTZcSTAjo27Muo=; b=bgt3EM4oLTktnaD+C5lUygoj2TSjaZ4x9GNCxCHY2wNjbqEGU1fno2zpoYqWgjfCKRWM5ZFpgqJd4TEsg+e4wDMU7lBPNoKe7zgIKRqQQL4nLWY/LBbutt+WZ0qAwNOMYCyspYfEwOvdsXhyq42z1mzwSUDMkow8UbF3lvxb2fE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242596149811.0069696012179; Tue, 7 May 2019 08:23:16 -0700 (PDT) Received: from localhost ([127.0.0.1]:48516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1vx-0002wT-3J for importer@patchew.org; Tue, 07 May 2019 11:23:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1ra-0007vu-FC for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rZ-0003yF-CL for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rW-0003tf-Kd; Tue, 07 May 2019 11:18:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA96A89C35; Tue, 7 May 2019 15:18:33 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8149357DE5; Tue, 7 May 2019 15:18:33 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:13 +0200 Message-Id: <20190507151819.17401-6-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 07 May 2019 15:18:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/11] qcow2-refcount: don't mask corruptions under internal errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy No reasons for not reporting found corruptions as corruptions in case of some internal errors, especially in case of just failed to fix l2 entry (and in this case, missed corruptions may influence comparing logic, when we calculate difference between corruptions fields of two results) Signed-off-by: Vladimir Sementsov-Ogievskiy Message-id: 20190227131433.197063-6-vsementsov@virtuozzo.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 6851807ffc..fa7ac1f7cb 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1662,6 +1662,8 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, =20 /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { + res->corruptions++; + if (qcow2_get_cluster_type(bs, l2_entry) =3D=3D QCOW2_CLUSTER_ZERO_ALLOC) { @@ -1697,18 +1699,16 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, /* Do not abort, continue checking the rest of= this * L2 table's entries */ } else { + res->corruptions--; res->corruptions_fixed++; /* Skip marking the cluster as used * (it is unused now) */ continue; } - } else { - res->corruptions++; } } else { fprintf(stderr, "ERROR offset=3D%" PRIx64 ": Data clus= ter is " "not properly aligned; L2 entry corrupted.\n", off= set); - res->corruptions++; } } =20 @@ -1879,6 +1879,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, continue; } if ((refcount =3D=3D 1) !=3D ((l1_entry & QCOW_OFLAG_COPIED) !=3D = 0)) { + res->corruptions++; fprintf(stderr, "%s OFLAG_COPIED L2 cluster: l1_index=3D%d " "l1_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "\n", repair ? "Repairing" : "ERROR", i, l1_entry, refcount); @@ -1891,9 +1892,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, res->check_errors++; goto fail; } + res->corruptions--; res->corruptions_fixed++; - } else { - res->corruptions++; } } =20 @@ -1925,6 +1925,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } } if ((refcount =3D=3D 1) !=3D ((l2_entry & QCOW_OFLAG_COPIE= D) !=3D 0)) { + res->corruptions++; fprintf(stderr, "%s OFLAG_COPIED data cluster: " "l2_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "= \n", repair ? "Repairing" : "ERROR", l2_entry, refc= ount); @@ -1933,8 +1934,6 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, ? l2_entry | QCOW_OFLAG_COPIED : l2_entry & ~QCOW_OFLAG_COPIED); l2_dirty++; - } else { - res->corruptions++; } } } @@ -1959,6 +1958,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, res->check_errors++; goto fail; } + res->corruptions -=3D l2_dirty; res->corruptions_fixed +=3D l2_dirty; } } @@ -1997,6 +1997,7 @@ static int check_refblocks(BlockDriverState *bs, Bdrv= CheckResult *res, } =20 if (cluster >=3D *nb_clusters) { + res->corruptions++; fprintf(stderr, "%s refcount block %" PRId64 " is outside imag= e\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); =20 @@ -2036,6 +2037,7 @@ static int check_refblocks(BlockDriverState *bs, Bdrv= CheckResult *res, goto resize_fail; } =20 + res->corruptions--; res->corruptions_fixed++; ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, nb_clusters, @@ -2049,12 +2051,9 @@ static int check_refblocks(BlockDriverState *bs, Bdr= vCheckResult *res, continue; =20 resize_fail: - res->corruptions++; *rebuild =3D true; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-ret)); - } else { - res->corruptions++; } continue; } --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242823; cv=none; d=zoho.com; s=zohoarc; b=UTKrg30yhECfq6I4vHWjYl6cV70XXVK5AIzBUOx8ua0Vop6n1oCAPH8er/1dZbXOxLBMeh3EnnJ3ZMdyzS++iYd6D1qeQaUpgDghgvB/c2LNjyhqn5i6sMqcPWJdrqjal6Dnf+kDzIY2gDQJ0Ezi3Jjs61xgA82NKX1wIPmeA5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242823; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VcHB4btVW3nFfNCeNTbdlR03P0zeWmzABPUX9Atcsz0=; b=OiBlFE9W4lUzTvKgH6m7/7DjaXvfyEcnaNyXYK4Vi0xS+b/2AgGH26KtlanWHqjcqcBI1YgT3YTc0WVftpXv7522PbGNE16X8OsUwRqGvYCvrCy+HsAPZ3WjvixwJEUUiIXSDMnjHIkPxDxYEMFdZNjcI6SVvBN1W17GZcwOnB4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242823097799.2583816783188; Tue, 7 May 2019 08:27:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:48582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1zc-0006uJ-3C for importer@patchew.org; Tue, 07 May 2019 11:26:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rb-0007xj-VQ for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rb-0003zX-4o for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rY-0003xT-Vc; Tue, 07 May 2019 11:18:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50C30C057F32; Tue, 7 May 2019 15:18:36 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC32761B85; Tue, 7 May 2019 15:18:35 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:14 +0200 Message-Id: <20190507151819.17401-7-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 May 2019 15:18:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/11] qcow2: discard bitmap when removed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Andrey Shinkevich Bitmap data may take a lot of disk space, so it's better to discard it always. Signed-off-by: Andrey Shinkevich Message-id: 1551346019-293202-1-git-send-email-andrey.shinkevich@virtuozzo.= com Reviewed-by: Vladimir Sementsov-Ogievskiy [mreitz: Use the commit message proposed by Vladimir] Signed-off-by: Max Reitz --- block/qcow2-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index e53a1609d7..8a75366c92 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -202,7 +202,7 @@ static void clear_bitmap_table(BlockDriverState *bs, ui= nt64_t *bitmap_table, continue; } =20 - qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER= ); + qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAY= S); bitmap_table[i] =3D 0; } } --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242614; cv=none; d=zoho.com; s=zohoarc; b=h46Rpdryi+5QKKoRMLqMe1I8sx1yTrlgeWHT6T3N0HlfSECOzka5VG/l+MOK9LEesMzUsB2kcYXD2vbTbm+TEQeOToyTt3lO5pmpNAbgP0SsJoJjkMNgnPbXbvdT4euP08+3zV+EI9Ck5JBhcy+tOK/wak3mbRvl4qrpnKFQmrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242614; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jFXO82JlQR2eHNawDi6nZGKonnWZyVt7gGMhmYDU+sk=; b=HSUvjRW+GZIN3mmt2d++T3NUqNKxkafdghdM1nPO5A4pgLbYfnzVjxUsI4FjiwWDkZ32v0IpJ8Jwce4/Z7FfC2kyDIaRTw6cSctk4f1DswXGRiWzJeAVVikEu1K4gHX0Ffgjjw6baxJFUjUuMDyduG3RLSNGW7H6VhxVDcUppvI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155724261401682.37528399861219; Tue, 7 May 2019 08:23:34 -0700 (PDT) Received: from localhost ([127.0.0.1]:48519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1wH-0003Gp-TW for importer@patchew.org; Tue, 07 May 2019 11:23:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rg-00082l-Jq for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rf-00041t-0r for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rb-0003zS-HZ; Tue, 07 May 2019 11:18:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D86CB307D863; Tue, 7 May 2019 15:18:38 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F6955D9D1; Tue, 7 May 2019 15:18:38 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:15 +0200 Message-Id: <20190507151819.17401-8-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 07 May 2019 15:18:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/11] block/ssh: Implement .bdrv_refresh_filename() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This requires some changes to keep iotests 104 and 207 working. qemu-img info in 104 will now return a filename including the user name and the port, which need to be filtered by adjusting REMOTE_TEST_DIR in common.rc. This additional information has to be marked optional, however (which is simple as REMOTE_TEST_DIR is a regex), because otherwise 197 and 215 would fail: They use it (indirectly) to filter qemu-img create output which contains a backing filename they have passed to it -- which probably does not contain a user name or port number. The problem in 207 is a nice one to have: qemu-img info used to return json:{} filenames, but with this patch it returns nice plain ones. We now need to adjust the filtering to hide the user name (and port number while we are at it). The simplest way to do this is to include both in iotests.remote_filename() so that bdrv_refresh_filename() will not change it, and then iotests.img_info_log() will filter it correctly automatically. Signed-off-by: Max Reitz Tested-by: Richard W.M. Jones Message-id: 20190225190828.17726-2-mreitz@redhat.com Signed-off-by: Max Reitz --- block/ssh.c | 52 +++++++++++++++++++++++++++++++---- tests/qemu-iotests/207 | 10 +++---- tests/qemu-iotests/207.out | 10 +++---- tests/qemu-iotests/common.rc | 2 +- tests/qemu-iotests/iotests.py | 2 +- 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 859249113d..2eaeab84d5 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -75,6 +75,14 @@ typedef struct BDRVSSHState { =20 /* Used to warn if 'flush' is not supported. */ bool unsafe_flush_warning; + + /* + * Store the user name for ssh_refresh_filename() because the + * default depends on the system you are on -- therefore, when we + * generate a filename, it should always contain the user name we + * are actually using. + */ + char *user; } BDRVSSHState; =20 static void ssh_state_init(BDRVSSHState *s) @@ -87,6 +95,8 @@ static void ssh_state_init(BDRVSSHState *s) =20 static void ssh_state_free(BDRVSSHState *s) { + g_free(s->user); + if (s->sftp_handle) { libssh2_sftp_close(s->sftp_handle); } @@ -628,14 +638,13 @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOp= tionsSsh *opts, int ssh_flags, int creat_mode, Error **errp) { int r, ret; - const char *user; long port =3D 0; =20 if (opts->has_user) { - user =3D opts->user; + s->user =3D g_strdup(opts->user); } else { - user =3D g_get_user_name(); - if (!user) { + s->user =3D g_strdup(g_get_user_name()); + if (!s->user) { error_setg_errno(errp, errno, "Can't get user name"); ret =3D -errno; goto err; @@ -685,7 +694,7 @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOpti= onsSsh *opts, } =20 /* Authenticate. */ - ret =3D authenticate(s, user, errp); + ret =3D authenticate(s, s->user, errp); if (ret < 0) { goto err; } @@ -1242,6 +1251,38 @@ static int coroutine_fn ssh_co_truncate(BlockDriverS= tate *bs, int64_t offset, return ssh_grow_file(s, offset, errp); } =20 +static void ssh_refresh_filename(BlockDriverState *bs) +{ + BDRVSSHState *s =3D bs->opaque; + const char *path, *host_key_check; + int ret; + + /* + * None of these options can be represented in a plain "host:port" + * format, so if any was given, we have to abort. + */ + if (s->inet->has_ipv4 || s->inet->has_ipv6 || s->inet->has_to || + s->inet->has_numeric) + { + return; + } + + path =3D qdict_get_try_str(bs->full_open_options, "path"); + assert(path); /* mandatory option */ + + host_key_check =3D qdict_get_try_str(bs->full_open_options, "host_key_= check"); + + ret =3D snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "ssh://%s@%s:%s%s%s%s", + s->user, s->inet->host, s->inet->port, path, + host_key_check ? "?host_key_check=3D" : "", + host_key_check ?: ""); + if (ret >=3D sizeof(bs->exact_filename)) { + /* An overflow makes the filename unusable, so do not report any */ + bs->exact_filename[0] =3D '\0'; + } +} + static const char *const ssh_strong_runtime_opts[] =3D { "host", "port", @@ -1268,6 +1309,7 @@ static BlockDriver bdrv_ssh =3D { .bdrv_getlength =3D ssh_getlength, .bdrv_co_truncate =3D ssh_co_truncate, .bdrv_co_flush_to_disk =3D ssh_co_flush, + .bdrv_refresh_filename =3D ssh_refresh_filename, .create_opts =3D &ssh_create_opts, .strong_runtime_opts =3D ssh_strong_runtime_opts, }; diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 index dfd3c51bd1..b3816136f7 100755 --- a/tests/qemu-iotests/207 +++ b/tests/qemu-iotests/207 @@ -66,7 +66,7 @@ with iotests.FilePath('t.img') as disk_path, \ 'size': 4194304 }) vm.shutdown() =20 - iotests.img_info_log(remote_path, filter_path=3Ddisk_path) + iotests.img_info_log(remote_path) iotests.log("") iotests.img_info_log(disk_path) =20 @@ -91,7 +91,7 @@ with iotests.FilePath('t.img') as disk_path, \ 'size': 8388608 }) vm.shutdown() =20 - iotests.img_info_log(remote_path, filter_path=3Ddisk_path) + iotests.img_info_log(remote_path) =20 vm.launch() blockdev_create(vm, { 'driver': 'ssh', @@ -108,7 +108,7 @@ with iotests.FilePath('t.img') as disk_path, \ 'size': 4194304 }) vm.shutdown() =20 - iotests.img_info_log(remote_path, filter_path=3Ddisk_path) + iotests.img_info_log(remote_path) =20 md5_key =3D subprocess.check_output( 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + @@ -146,7 +146,7 @@ with iotests.FilePath('t.img') as disk_path, \ 'size': 8388608 }) vm.shutdown() =20 - iotests.img_info_log(remote_path, filter_path=3Ddisk_path) + iotests.img_info_log(remote_path) =20 sha1_key =3D subprocess.check_output( 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + @@ -184,7 +184,7 @@ with iotests.FilePath('t.img') as disk_path, \ 'size': 4194304 }) vm.shutdown() =20 - iotests.img_info_log(remote_path, filter_path=3Ddisk_path) + iotests.img_info_log(remote_path) =20 # # Invalid path and user diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out index 979d5cf745..ec9823793a 100644 --- a/tests/qemu-iotests/207.out +++ b/tests/qemu-iotests/207.out @@ -5,7 +5,7 @@ {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "ser= ver.port": "22", "driver": "ssh", "path": "TEST_IMG"}} +image: TEST_IMG file format: IMGFMT virtual size: 4 MiB (4194304 bytes) =20 @@ -21,7 +21,7 @@ virtual size: 4 MiB (4194304 bytes) {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "ser= ver.port": "22", "driver": "ssh", "path": "TEST_IMG"}} +image: TEST_IMG file format: IMGFMT virtual size: 8 MiB (8388608 bytes) =20 @@ -30,7 +30,7 @@ virtual size: 8 MiB (8388608 bytes) {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "ser= ver.port": "22", "driver": "ssh", "path": "TEST_IMG"}} +image: TEST_IMG file format: IMGFMT virtual size: 4 MiB (4194304 bytes) =20 @@ -45,7 +45,7 @@ Job failed: remote host key does not match host_key_check= 'wrong' {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "ser= ver.port": "22", "driver": "ssh", "path": "TEST_IMG"}} +image: TEST_IMG file format: IMGFMT virtual size: 8 MiB (8388608 bytes) =20 @@ -60,7 +60,7 @@ Job failed: remote host key does not match host_key_check= 'wrong' {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: json:{"driver": "IMGFMT", "file": {"server.host": "127.0.0.1", "ser= ver.port": "22", "driver": "ssh", "path": "TEST_IMG"}} +image: TEST_IMG file format: IMGFMT virtual size: 4 MiB (4194304 bytes) =20 diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index a543e546c2..93f87389b6 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -158,7 +158,7 @@ else TEST_IMG=3D"nbd:127.0.0.1:10810" elif [ "$IMGPROTO" =3D "ssh" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT - REMOTE_TEST_DIR=3D"ssh://127.0.0.1$TEST_DIR" + REMOTE_TEST_DIR=3D"ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\= ?$TEST_DIR" TEST_IMG=3D"ssh://127.0.0.1$TEST_IMG_FILE" elif [ "$IMGPROTO" =3D "nfs" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 997dc910cb..f811f69135 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -411,7 +411,7 @@ def remote_filename(path): if imgproto =3D=3D 'file': return path elif imgproto =3D=3D 'ssh': - return "ssh://127.0.0.1%s" % (path) + return "ssh://%s@127.0.0.1:22%s" % (os.environ.get('USER'), path) else: raise Exception("Protocol %s not supported" % (imgproto)) =20 --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242934; cv=none; d=zoho.com; s=zohoarc; b=cWI+nyQFwltm2efR+caiuJJ4Zr9B0/Ih/lyrPEBPxhCHZmWI2sEQVGhjAniJ2V7V6+0vfCjJf0o0J/REWIT1+QgbwnSMfxP5MAdA1BWgNmygbqkwVxvCzs0nm8rxdnyZ29VgTS7mK8lExZmMU8QzfjwbGJVWil+vGcpJRGZBQz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242934; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zNUHxGYHFsEEiSe0tNHA79axXnADp7yI0hlFSAi2w6k=; b=GLQjXXcG0nQmEuFHoFvDpxgo2X03Z+WphlZuKGuejzuhLA1NyPhtOaUbOkvYwS7XYYVwsh/nHKWgezj0YRErclJ0GWwLGgmTjv6yGYP+zFRgwNov8ThNoB5q7Jxfeg9osleRwGZPK/fMu6ieism4FLtqLQYpj1iwRCFEHdecEVM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242934131444.30480841903545; Tue, 7 May 2019 08:28:54 -0700 (PDT) Received: from localhost ([127.0.0.1]:48608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO21S-0000Sb-4p for importer@patchew.org; Tue, 07 May 2019 11:28:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rg-000830-QJ for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rf-00042I-U8 for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rd-000419-Tk; Tue, 07 May 2019 11:18:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E62581F11; Tue, 7 May 2019 15:18:41 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C38E75D9D1; Tue, 7 May 2019 15:18:40 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:16 +0200 Message-Id: <20190507151819.17401-9-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 07 May 2019 15:18:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/11] block/ssh: Implement .bdrv_dirname() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" ssh_bdrv_dirname() is basically the generic bdrv_dirname(), except it takes care not to silently chop off any query string (i.e., host_key_check). Signed-off-by: Max Reitz Tested-by: Richard W.M. Jones Message-id: 20190225190828.17726-3-mreitz@redhat.com Signed-off-by: Max Reitz --- block/ssh.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/block/ssh.c b/block/ssh.c index 2eaeab84d5..12fd4f39e8 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1283,6 +1283,26 @@ static void ssh_refresh_filename(BlockDriverState *b= s) } } =20 +static char *ssh_bdrv_dirname(BlockDriverState *bs, Error **errp) +{ + if (qdict_haskey(bs->full_open_options, "host_key_check")) { + /* + * We cannot generate a simple prefix if we would have to + * append a query string. + */ + error_setg(errp, + "Cannot generate a base directory with host_key_check s= et"); + return NULL; + } + + if (bs->exact_filename[0] =3D=3D '\0') { + error_setg(errp, "Cannot generate a base directory for this ssh no= de"); + return NULL; + } + + return path_combine(bs->exact_filename, ""); +} + static const char *const ssh_strong_runtime_opts[] =3D { "host", "port", @@ -1310,6 +1330,7 @@ static BlockDriver bdrv_ssh =3D { .bdrv_co_truncate =3D ssh_co_truncate, .bdrv_co_flush_to_disk =3D ssh_co_flush, .bdrv_refresh_filename =3D ssh_refresh_filename, + .bdrv_dirname =3D ssh_bdrv_dirname, .create_opts =3D &ssh_create_opts, .strong_runtime_opts =3D ssh_strong_runtime_opts, }; --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242787; cv=none; d=zoho.com; s=zohoarc; b=orRUChyY2D4z27hfVFqjMwSseB7pCZsve4r77G16rptOGLs8G/Ky3cPaVQW+zr87UX1Whh64vGtVC/1ZqMT/kiikR+Wvi34VOC1vgEsrdOnRjHl58+1L1FI2oBTZcdZClzl1d3AhJqe6GXgzMoxR4weH2fYseIj3WUCQYdAQwug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242787; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MjjpQ7el3gN1VULtrZUrThQgelzbs3gGZmsnx+u4AGU=; b=Dz7ZXZOtQThCSefMDHrUtU9pqPEIzfkeWjPbOHA/rvYJsrXHqCPGzMm6TLAOwXrcz0bTESE4kpivqWWFL2N9xCnUbpqJFJxTWhIQh2hI04xf2tshEG+KXItPmNzEnD5rxQIL5P7ECk2un7gAVb1BZEacd3fWV3zxul0XhG3WED0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242787536509.92081401170935; Tue, 7 May 2019 08:26:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:48576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1z2-00068B-4y for importer@patchew.org; Tue, 07 May 2019 11:26:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rj-000857-Am for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1ri-000440-E1 for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50236) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rg-00042E-8P; Tue, 07 May 2019 11:18:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C086C05D3FD; Tue, 7 May 2019 15:18:43 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24E5D3DA5; Tue, 7 May 2019 15:18:42 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:17 +0200 Message-Id: <20190507151819.17401-10-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 May 2019 15:18:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/11] block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Alberto Garcia There is no need to check for this because all block drivers that have children implement bdrv_child_perm and all callers already ensure that bs->drv is set. Furthermore, if this check would fail then the callers would end up with uninitialized values for nperm and nshared. This patch replaces the check with an assertion. Signed-off-by: Alberto Garcia Message-id: 20190404112953.4058-1-berto@igalia.com Signed-off-by: Max Reitz --- block.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 9ae5c0ed2f..7dc8fe289a 100644 --- a/block.c +++ b/block.c @@ -1743,11 +1743,10 @@ static void bdrv_child_perm(BlockDriverState *bs, B= lockDriverState *child_bs, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared) { - if (bs->drv && bs->drv->bdrv_child_perm) { - bs->drv->bdrv_child_perm(bs, c, role, reopen_queue, - parent_perm, parent_shared, - nperm, nshared); - } + assert(bs->drv && bs->drv->bdrv_child_perm); + bs->drv->bdrv_child_perm(bs, c, role, reopen_queue, + parent_perm, parent_shared, + nperm, nshared); /* TODO Take force_share from reopen_queue */ if (child_bs && child_bs->force_share) { *nshared =3D BLK_PERM_ALL; --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242976; cv=none; d=zoho.com; s=zohoarc; b=OFFbpX3Dw4kLAyy5/lLVF0y4WGGiOSAkSS1rh+xSOMU3vLVvjnSq+bXIXC/o2WA3iVVbq9BAYlM4N/e9x6EF+hsLjq6jNAupy9NDEzJP5mp9jvlpYuQFvoBzaSL7oZvbonUPLGbjJv+5dHLFD9X2C/kG3R49Y3OSrl2s07qftAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242976; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bs90NIuGADH0/nfZy06WnqpYOqEM4YB2adVDpCk/mMc=; b=iyzlgYtS44lP2rVX6Yk4p3svH386WP9rUXSDwdqogwgI4RKOPgVKNc/9vLgJSwLtnQ36KAU4a9PZdtCSFN6lkfcktF9LCnXxUFjjtyiBO2V2Cuwdjhu/hvFP/4ZKaiK9tiiCtDInk4crP3sYfV0qZWw94vn7P0fNHCbIfz8uXKM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155724297675490.84622766400469; Tue, 7 May 2019 08:29:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:48614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO228-00015j-Nc for importer@patchew.org; Tue, 07 May 2019 11:29:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rm-00086D-4M for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1rl-00045b-7W for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35092) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1ri-00043c-JF; Tue, 07 May 2019 11:18:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2A53308793B; Tue, 7 May 2019 15:18:45 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A4D2173D9; Tue, 7 May 2019 15:18:45 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:18 +0200 Message-Id: <20190507151819.17401-11-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 07 May 2019 15:18:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/11] commit: Use bdrv_append() in commit_start() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function combines bdrv_set_backing_hd() and bdrv_replace_node() so we can use it to simplify the code a bit in commit_start(). Signed-off-by: Alberto Garcia Message-id: 20190403143748.9790-1-berto@igalia.com Signed-off-by: Max Reitz --- block/commit.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/block/commit.c b/block/commit.c index 27537d995b..14e5bb394c 100644 --- a/block/commit.c +++ b/block/commit.c @@ -303,23 +303,14 @@ void commit_start(const char *job_id, BlockDriverStat= e *bs, commit_top_bs->total_sectors =3D top->total_sectors; bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top)); =20 - bdrv_set_backing_hd(commit_top_bs, top, &local_err); + bdrv_append(commit_top_bs, top, &local_err); if (local_err) { - bdrv_unref(commit_top_bs); - commit_top_bs =3D NULL; - error_propagate(errp, local_err); - goto fail; - } - bdrv_replace_node(top, commit_top_bs, &local_err); - if (local_err) { - bdrv_unref(commit_top_bs); commit_top_bs =3D NULL; error_propagate(errp, local_err); goto fail; } =20 s->commit_top_bs =3D commit_top_bs; - bdrv_unref(commit_top_bs); =20 /* Block all nodes between top and base, because they will * disappear from the chain after this operation. */ --=20 2.20.1 From nobody Sun May 19 09:23:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557243065; cv=none; d=zoho.com; s=zohoarc; b=fTqQYIzRgtO5ohyedM7PFHlO10NtSkZCvLiA2G3y0ySTR53ICo8v7wFc+WDVYt8Gc9K/0x+3jlSE4vjgHouTleHHPQeOaosk5tbnNNGLNauPmcb+ihP2VB+8LlMSRVBKrP+1acR9SqYxAgDIJXGakZqEkqkKzKgFSEjnH1pcUIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557243065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1gBFZ56UMl/smpDmOC1E8XyUWB1tKpzeCA8TXnQmAuY=; b=JXp0LtykdzJrZaurZMwPi1t5z4TEsIG1De+8vaHEdluJ6liQ/T03JspPmIqwqsonNicFj7/GNtgDAx7GneVsZy0t0DTI96qkpdQ4yhanV3Go76Cqgiha43Go6LidKJav2O8efE9jjvnz5qpjla/59/kWtfx+NnrhGig490kH1Z4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557243065838890.7457937151026; Tue, 7 May 2019 08:31:05 -0700 (PDT) Received: from localhost ([127.0.0.1]:48671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO23Z-0002JA-Oa for importer@patchew.org; Tue, 07 May 2019 11:31:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rp-000883-JR for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1ro-00048a-IT for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rl-00045E-0z; Tue, 07 May 2019 11:18:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FEFE8553D; Tue, 7 May 2019 15:18:48 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6E535D9CC; Tue, 7 May 2019 15:18:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:19 +0200 Message-Id: <20190507151819.17401-12-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 07 May 2019 15:18:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/11] iotests: Fix iotests 110 and 126 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A recent patch results in qemu-img reporting the backing file format of vmdk images as vmdk. This broke iotests 110 and 126. Fixes: 7502be838e2fb62cc00f9e55f632e0b88ead5e6e Signed-off-by: Max Reitz Message-id: 20190415154129.31021-1-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/110 | 10 +++++++--- tests/qemu-iotests/126 | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 index fad672c1ae..33b169ffd4 100755 --- a/tests/qemu-iotests/110 +++ b/tests/qemu-iotests/110 @@ -53,8 +53,12 @@ TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M _make_test_img -b "$TEST_IMG_REL.base" 64M # qemu should be able to reconstruct the filename, so relative backing nam= es # should work +# (We have to filter the backing file format because vmdk always +# reports it (as vmdk), whereas other image formats would do so only +# with the backing_fmt creation option, which neither vmdk nor qcow +# support) TEST_IMG=3D"json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$= TEST_IMG'}}" \ - _img_info | _filter_img_info + _img_info | _filter_img_info | grep -v 'backing file format' =20 echo echo '=3D=3D=3D Non-reconstructable filename =3D=3D=3D' @@ -78,7 +82,7 @@ TEST_IMG=3D"json:{ } ] } -}" _img_info | _filter_img_info +}" _img_info | _filter_img_info | grep -v 'backing file format' =20 echo echo '=3D=3D=3D Backing name is always relative to the backed image =3D=3D= =3D' @@ -110,7 +114,7 @@ TEST_IMG=3D"json:{ } ] } -}" _img_info | _filter_img_info +}" _img_info | _filter_img_info | grep -v 'backing file format' =20 =20 # success, all done diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126 index 96dc048d59..e3ee65c606 100755 --- a/tests/qemu-iotests/126 +++ b/tests/qemu-iotests/126 @@ -62,8 +62,12 @@ TOP_IMG=3D"$TEST_DIR/image:top.$IMGFMT" TEST_IMG=3D$BASE_IMG _make_test_img 64M TEST_IMG=3D$TOP_IMG _make_test_img -b ./image:base.$IMGFMT =20 -# The default cluster size depends on the image format -TEST_IMG=3D$TOP_IMG _img_info | grep -v 'cluster_size' +# (1) The default cluster size depends on the image format +# (2) vmdk only supports vmdk backing files, so it always reports the +# format of its backing file as such (but neither it nor qcow +# support the backing_fmt creation option, so we cannot use that to +# harmonize the output across all image formats this test supports) +TEST_IMG=3D$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file f= ormat' =20 _rm_test_img "$BASE_IMG" _rm_test_img "$TOP_IMG" @@ -79,7 +83,7 @@ TOP_IMG=3D"file:image:top.$IMGFMT" TEST_IMG=3D$BASE_IMG _make_test_img 64M TEST_IMG=3D$TOP_IMG _make_test_img -b "$BASE_IMG" =20 -TEST_IMG=3D$TOP_IMG _img_info | grep -v 'cluster_size' +TEST_IMG=3D$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file f= ormat' =20 _rm_test_img "$BASE_IMG" _rm_test_img "image:top.$IMGFMT" --=20 2.20.1