From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600166909; cv=none; d=zohomail.com; s=zohoarc; b=myyfS8+Z39G+ZJel1Lbc3FZwAqfFAmY5BNa6wu+xCkPd1aNn7Le4fAOE+SfwSxSm1p4AwsC3z1faqYbzO10OUZBVTi6F8qzWp9orATVFn6oOtQsd3aII4Dgyz3QiPFsALtoDnwC8VwzlNcUFlGpalRzwdcge64WLQeHMkxKBETA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600166909; h=Content-Type: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; bh=oaRxhj6MXirGImGi5k6IZssbDH2xBZ33GUTf4AD4d4Y=; b=YxRrW0TqW85cHnk20a81xobO5EVqWgqj0KrZk9D9Kita6dA6d7PtrjlmChrQ+WqRBvGafGB7jb1muIG9SdiyFdd+9IuYpp7Xt8uaXABvce9cmrj+qBOYNlyJn9xCRg9aF2H1NY0xexpSFpN3cV+/YW2jkrcXzHVVq9WM2qqPxlY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600166909437363.370202846752; Tue, 15 Sep 2020 03:48:29 -0700 (PDT) Received: from localhost ([::1]:40744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8Vf-0002Fu-OX for importer@patchew.org; Tue, 15 Sep 2020 06:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Tv-0000D2-O3 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ts-0004Vw-Om for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-I9K3KyGGN8eYk58XqRUWEw-1; Tue, 15 Sep 2020 06:46:33 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F844801FCC; Tue, 15 Sep 2020 10:46:32 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F8091002393; Tue, 15 Sep 2020 10:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oaRxhj6MXirGImGi5k6IZssbDH2xBZ33GUTf4AD4d4Y=; b=fjeToBWiOdRdpWADc9KvwZPKF1vOWIv2qnMxtwxRbQKdJ9vFCLPZBaYs4XWlsK42sQMQvt mbPv3pkB3JcnUsC62kl4GPzBvchbxJyzidVb6eDgHMBKdqePPs9yH61TmdLV8LtqKRzgJB yHio03GVykxl4mumEhKfnCh3qUlAD9Y= X-MC-Unique: I9K3KyGGN8eYk58XqRUWEw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 01/22] qemu-iotests: Fix FilePaths cleanup Date: Tue, 15 Sep 2020 12:46:06 +0200 Message-Id: <20200915104627.699552-2-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:23:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nir Soffer If os.remove() fails to remove one of the paths, for example if the file was removed by the test, the cleanup loop would exit silently, without removing the rest of the files. Fixes: de263986b5dc Signed-off-by: Nir Soffer Reviewed-by: Max Reitz Message-Id: <20200828232152.205833-2-nsoffer@redhat.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 64ccaf9061..36814daf84 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -468,11 +468,11 @@ class FilePaths: return self.paths =20 def __exit__(self, exc_type, exc_val, exc_tb): - try: - for path in self.paths: + for path in self.paths: + try: os.remove(path) - except OSError: - pass + except OSError: + pass return False =20 class FilePath(FilePaths): --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600166912; cv=none; d=zohomail.com; s=zohoarc; b=MFtRUsmWTQMJHRluRSLJ5WFYHNBx8bXx5MmOo2c7kouTjz2x3kxEBeznVIVnwoR8jDBSj/gehaiJ9wjdvPeFZfZq3ugNl1ugIqeb9dP4cNNqbL13UypFHFo4SNT0+ZyWIVUYCf+XXrBgO+8BPGstPAQQhIFpgxwTjOwWILTNiCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600166912; h=Content-Type: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; bh=VJ3fvYcZfAhMpKefh6bvQo2IkLj6yxPmWEKt+9Z9uQU=; b=ipvNN+4hJ/sBbzc8yqdSN3QJ+z0Ywrb4Yk42SHBXRbWrTezfPpinpuh1aPTN6xvCetyQaAZiJz/Fu6SYIfdDBbugT+FhzOTHTn4dcYZfXt9Qxwtg1oANriM47Oaxay2V1skg+M5OhW59IY25xwvVWjq9LDrJOvebMG8xSp8MMtE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600166912200893.3231518733705; Tue, 15 Sep 2020 03:48:32 -0700 (PDT) Received: from localhost ([::1]:41134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8Vj-0002PW-1h for importer@patchew.org; Tue, 15 Sep 2020 06:48:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Tw-0000Dp-LV for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47810 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Tu-0004W6-RC for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-thpCz1B4PxiwOLhpk9lUUg-1; Tue, 15 Sep 2020 06:46:35 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4014A1084D62; Tue, 15 Sep 2020 10:46:34 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9D5C5FC2A; Tue, 15 Sep 2020 10:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VJ3fvYcZfAhMpKefh6bvQo2IkLj6yxPmWEKt+9Z9uQU=; b=Zzoi4wrd26Mh6yLPg1tGMI4V1RSPAHaX52TF5llieX1R/zepYorpZxDhW4HAQJJyZbSn5Q VT8/gzbqTJClF5uUtjG7jNMYIA2nx9tu9mKDTcjkPgf02AnB/4+ZbJZvtyy5SwI1zhzHFp D2sV3KXA2euhdgzgy2vKFZ9HouJg/Wo= X-MC-Unique: thpCz1B4PxiwOLhpk9lUUg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 02/22] qemu-iotests: Fix FilePaths docstring Date: Tue, 15 Sep 2020 12:46:07 +0200 Message-Id: <20200915104627.699552-3-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:11:06 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nir Soffer When this class was extracted from FilePath, the docstring was not updated for generating multiple files, and the example usage was referencing unrelated file. While fixing the docstring, add example for creating sockets, which should use iotests.sock_dir instead of the default base_dir. Fixes: de263986b5dc Signed-off-by: Nir Soffer Message-Id: <20200828232152.205833-3-nsoffer@redhat.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 36814daf84..bbe63a6da0 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -450,14 +450,21 @@ def file_pattern(name): =20 class FilePaths: """ - FilePaths is an auto-generated filename that cleans itself up. + Context manager generating multiple file names. The generated files are + removed when exiting the context. =20 - Use this context manager to generate filenames and ensure that the file - gets deleted:: + Example usage: + + with FilePaths(['a.img', 'b.img']) as (img_a, img_b): + # Use img_a and img_b here... + + # a.img and b.img are automatically removed here. + + By default images are created in iotests.test_dir. To create sockets u= se + iotests.sock_dir: + + with FilePaths(['a.sock'], base_dir=3Diotests.sock_dir) as (sock,): =20 - with FilePaths(['test.img']) as img_path: - qemu_img('create', img_path, '1G') - # migration_sock_path is automatically deleted """ def __init__(self, names, base_dir=3Dtest_dir): self.paths =3D [] --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167039; cv=none; d=zohomail.com; s=zohoarc; b=Ln3DhmchgXohZAIrIy6wNkA/ZezyplpF7zYwvgGk8xkQ+5i3xaKeBA7ChoQY3dVh/4ZZpspXZOv2nO6eqRn+QDkSc4mxEFkOXC75Jptbwc88Sz9EcFOPA5GzBK8tnuKBy4B0fAUtafh12RfSRRXU9wikBzr1i6WZDu1HkWhzMQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167039; h=Content-Type: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; bh=jJPpvV6IltYiPr20vjj9EGkrUcbzVVF1bqmrz/6gk+c=; b=F+7eTGWMarUBS1ViW+LGlJZbNUYMO2x9zF0tm+Em2nJ9H9yPCytwM++V1+xFCD1mKBR7eoLkz5cBbDNnj3QHUw94qES1/GsnoRTQGVeCGOTrxjImyqfk+I7mdhJ2bM+doy4/S2lHjX2qhQPB6ggJF3Q720w7hv1+2ccUWVqGcJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167039904717.9278046625191; Tue, 15 Sep 2020 03:50:39 -0700 (PDT) Received: from localhost ([::1]:49110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8Xm-0005fW-Pl for importer@patchew.org; Tue, 15 Sep 2020 06:50:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Tz-0000Km-SD for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:24212 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Tw-0004WW-Nb for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-eY1XsI4mOOyxmnMdevQvwg-1; Tue, 15 Sep 2020 06:46:37 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64BEF801F9B; Tue, 15 Sep 2020 10:46:36 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 063F15DC08; Tue, 15 Sep 2020 10:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jJPpvV6IltYiPr20vjj9EGkrUcbzVVF1bqmrz/6gk+c=; b=WJd+r8e6vr64Hraa/m5W8OR0mS28yoGRRqGoW+V1kkDpK28eFPxU/gadOA8RObvFbF6AYg uXzjt4P7baqoQTgvDOvKHP8gkTsqwwmmUAd0EPSpXQRmfEp/6BOo8UDwbVpijndNycSw1I io3v8xOXMsfBw1fC2nkESlitDCCBbsE= X-MC-Unique: eY1XsI4mOOyxmnMdevQvwg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 03/22] qemu-iotests: Support varargs syntax in FilePaths Date: Tue, 15 Sep 2020 12:46:08 +0200 Message-Id: <20200915104627.699552-4-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nir Soffer Accept variable number of names instead of a sequence: with FilePaths("a", "b", "c") as (a, b, c): The disadvantage is that base_dir must be used as kwarg: with FilePaths("a", "b", base_dir=3Dsoc_dir) as (sock1, sock2): But this is more clear and calling optional argument as positional arguments is bad idea anyway. Signed-off-by: Nir Soffer Reviewed-by: Max Reitz Message-Id: <20200828232152.205833-4-nsoffer@redhat.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/194 | 4 ++-- tests/qemu-iotests/257 | 10 ++++------ tests/qemu-iotests/iotests.py | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index da7c4265ec..08389f474e 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -26,8 +26,8 @@ iotests.script_initialize(supported_fmts=3D['qcow2', 'qed= ', 'raw'], =20 with iotests.FilePath('source.img') as source_img_path, \ iotests.FilePath('dest.img') as dest_img_path, \ - iotests.FilePaths(['migration.sock', 'nbd.sock'], iotests.sock_dir) a= s \ - [migration_sock_path, nbd_sock_path], \ + iotests.FilePaths('migration.sock', 'nbd.sock', base_dir=3Diotests.so= ck_dir) \ + as (migration_sock_path, nbd_sock_path), \ iotests.VM('source') as source_vm, \ iotests.VM('dest') as dest_vm: =20 diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index e1e6077219..a9aa65bbe3 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -275,10 +275,9 @@ def test_bitmap_sync(bsync_mode, msync_mode=3D'bitmap'= , failure=3DNone): an incomplete backup. Testing limitations prevent testing competing writes. """ - with iotests.FilePaths(['img', 'bsync1', 'bsync2', - 'fbackup0', 'fbackup1', 'fbackup2']) as \ - (img_path, bsync1, bsync2, - fbackup0, fbackup1, fbackup2), \ + with iotests.FilePaths( + 'img', 'bsync1', 'bsync2', 'fbackup0', 'fbackup1', 'fbackup2')= as \ + (img_path, bsync1, bsync2, fbackup0, fbackup1, fbackup2), \ iotests.VM() as vm: =20 mode =3D "Mode {:s}; Bitmap Sync {:s}".format(msync_mode, bsync_mo= de) @@ -441,8 +440,7 @@ def test_backup_api(): """ Test malformed and prohibited invocations of the backup API. """ - with iotests.FilePaths(['img', 'bsync1']) as \ - (img_path, backup_path), \ + with iotests.FilePaths('img', 'bsync1') as (img_path, backup_path), \ iotests.VM() as vm: =20 log("\n=3D=3D=3D API failure tests =3D=3D=3D\n") diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index bbe63a6da0..635ec99431 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -455,7 +455,7 @@ class FilePaths: =20 Example usage: =20 - with FilePaths(['a.img', 'b.img']) as (img_a, img_b): + with FilePaths('a.img', 'b.img') as (img_a, img_b): # Use img_a and img_b here... =20 # a.img and b.img are automatically removed here. @@ -463,10 +463,10 @@ class FilePaths: By default images are created in iotests.test_dir. To create sockets u= se iotests.sock_dir: =20 - with FilePaths(['a.sock'], base_dir=3Diotests.sock_dir) as (sock,): + with FilePaths('a.sock', base_dir=3Diotests.sock_dir) as (sock,): =20 """ - def __init__(self, names, base_dir=3Dtest_dir): + def __init__(self, *names, base_dir=3Dtest_dir): self.paths =3D [] for name in names: self.paths.append(os.path.join(base_dir, file_pattern(name))) @@ -487,7 +487,7 @@ class FilePath(FilePaths): FilePath is a specialization of FilePaths that takes a single filename. """ def __init__(self, name, base_dir=3Dtest_dir): - super(FilePath, self).__init__([name], base_dir) + super(FilePath, self).__init__(name, base_dir=3Dbase_dir) =20 def __enter__(self): return self.paths[0] --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167071; cv=none; d=zohomail.com; s=zohoarc; b=CxWvenGBfR9Vk/cD777p6FidQOqDnUaK62ox8BE/m22rC+wuvmhFs8FPcn4Uim0UbV/VBpPeg/nfZT5JLzyCLMuQbjB1IH5Cwm2xSndAvqs5E8XwjUJilRH1JRR5x3vB91IrX3fYQPMkJyhbx3tLUItp3QYuFV0gYcXc3AMaB38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167071; h=Content-Type: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; bh=USfin5nSJkYWkXjVzSXutltb7DcQHN1F5Lbpdtqi6WA=; b=Na+mhUZajSYIlXQjSDn82dkYRu6VLOws7D/GCri9Aw/AXZ202yQnJhpWvtIyR92uliFMCQzMoxGYJMFPB1qDC2XSLUi3fsf/EfUCis8tphPkMfeGPnNFGtsGI/WvSy7F1HU+lWJulSNeF/2sSmWeKSzc8p/DGjPjfv+GNk8OcDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167071593814.5955652433776; Tue, 15 Sep 2020 03:51:11 -0700 (PDT) Received: from localhost ([::1]:50192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8YI-00068B-Dd for importer@patchew.org; Tue, 15 Sep 2020 06:51:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8U1-0000Nm-Hz for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:45 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:45891 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ty-0004Wq-C6 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-rA5M_AUuM22sVZYHqmKAew-1; Tue, 15 Sep 2020 06:46: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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8580C10059AC; Tue, 15 Sep 2020 10:46:38 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B4FC5DDB5; Tue, 15 Sep 2020 10:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=USfin5nSJkYWkXjVzSXutltb7DcQHN1F5Lbpdtqi6WA=; b=PxyuPH2HzZvJkwa3/ToE6hh5EKUVgdFKc6HaFOkUmvdoj0Yfst4Cmwnj6+2+XEFB0RGLSa E1Gx81IDkE6SylAkBSECRvtAWfu1sxc110s2YrMeRoe1E6zk62G8YwLzoSjCQMj23di94W CaJ4awjZxj0Yxvb4PtgR5+GXSwj6/LI= X-MC-Unique: rA5M_AUuM22sVZYHqmKAew-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 04/22] qemu-iotests: Merge FilePaths and FilePath Date: Tue, 15 Sep 2020 12:46:09 +0200 Message-Id: <20200915104627.699552-5-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nir Soffer FilePath creates now one temporary file: with FilePath("a") as a: Or more: with FilePath("a", "b", "c") as (a, b, c): This is also the behavior of the file_path() helper, used by some of the tests. Now we have only 2 helpers for creating temporary files instead of 3. Signed-off-by: Nir Soffer Reviewed-by: Max Reitz Message-Id: <20200828232152.205833-5-nsoffer@redhat.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/194 | 2 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/222 | 2 +- tests/qemu-iotests/257 | 4 ++-- tests/qemu-iotests/iotests.py | 23 ++++++++++------------- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index 08389f474e..7a4863ab18 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -26,7 +26,7 @@ iotests.script_initialize(supported_fmts=3D['qcow2', 'qed= ', 'raw'], =20 with iotests.FilePath('source.img') as source_img_path, \ iotests.FilePath('dest.img') as dest_img_path, \ - iotests.FilePaths('migration.sock', 'nbd.sock', base_dir=3Diotests.so= ck_dir) \ + iotests.FilePath('migration.sock', 'nbd.sock', base_dir=3Diotests.soc= k_dir) \ as (migration_sock_path, nbd_sock_path), \ iotests.VM('source') as source_vm, \ iotests.VM('dest') as dest_vm: diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208 index 6cb642f821..54aa4be273 100755 --- a/tests/qemu-iotests/208 +++ b/tests/qemu-iotests/208 @@ -26,7 +26,7 @@ iotests.script_initialize(supported_fmts=3D['generic']) =20 with iotests.FilePath('disk.img') as disk_img_path, \ iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \ - iotests.FilePath('nbd.sock', iotests.sock_dir) as nbd_sock_path, \ + iotests.FilePath('nbd.sock', base_dir=3Diotests.sock_dir) as nbd_sock= _path, \ iotests.VM() as vm: =20 img_size =3D '10M' diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222 index 6602f6b4ba..14d67c875b 100755 --- a/tests/qemu-iotests/222 +++ b/tests/qemu-iotests/222 @@ -49,7 +49,7 @@ remainder =3D [("0xd5", "0x108000", "32k"), # Right-end = of partial-left [1] =20 with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ - iotests.FilePath('nbd.sock', iotests.sock_dir) as nbd_sock_path, \ + iotests.FilePath('nbd.sock', base_dir=3Diotests.sock_dir) as nbd_sock= _path, \ iotests.VM() as vm: =20 log('--- Setting up images ---') diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 index a9aa65bbe3..c80e06ae28 100755 --- a/tests/qemu-iotests/257 +++ b/tests/qemu-iotests/257 @@ -275,7 +275,7 @@ def test_bitmap_sync(bsync_mode, msync_mode=3D'bitmap',= failure=3DNone): an incomplete backup. Testing limitations prevent testing competing writes. """ - with iotests.FilePaths( + with iotests.FilePath( 'img', 'bsync1', 'bsync2', 'fbackup0', 'fbackup1', 'fbackup2')= as \ (img_path, bsync1, bsync2, fbackup0, fbackup1, fbackup2), \ iotests.VM() as vm: @@ -440,7 +440,7 @@ def test_backup_api(): """ Test malformed and prohibited invocations of the backup API. """ - with iotests.FilePaths('img', 'bsync1') as (img_path, backup_path), \ + with iotests.FilePath('img', 'bsync1') as (img_path, backup_path), \ iotests.VM() as vm: =20 log("\n=3D=3D=3D API failure tests =3D=3D=3D\n") diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 635ec99431..1799338f8b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -448,14 +448,14 @@ class Timeout: def file_pattern(name): return "{0}-{1}".format(os.getpid(), name) =20 -class FilePaths: +class FilePath: """ Context manager generating multiple file names. The generated files are removed when exiting the context. =20 Example usage: =20 - with FilePaths('a.img', 'b.img') as (img_a, img_b): + with FilePath('a.img', 'b.img') as (img_a, img_b): # Use img_a and img_b here... =20 # a.img and b.img are automatically removed here. @@ -463,7 +463,10 @@ class FilePaths: By default images are created in iotests.test_dir. To create sockets u= se iotests.sock_dir: =20 - with FilePaths('a.sock', base_dir=3Diotests.sock_dir) as (sock,): + with FilePath('a.sock', base_dir=3Diotests.sock_dir) as sock: + + For convenience, calling with one argument yields a single file instea= d of + a tuple with one item. =20 """ def __init__(self, *names, base_dir=3Dtest_dir): @@ -472,7 +475,10 @@ class FilePaths: self.paths.append(os.path.join(base_dir, file_pattern(name))) =20 def __enter__(self): - return self.paths + if len(self.paths) =3D=3D 1: + return self.paths[0] + else: + return self.paths =20 def __exit__(self, exc_type, exc_val, exc_tb): for path in self.paths: @@ -482,15 +488,6 @@ class FilePaths: pass return False =20 -class FilePath(FilePaths): - """ - FilePath is a specialization of FilePaths that takes a single filename. - """ - def __init__(self, name, base_dir=3Dtest_dir): - super(FilePath, self).__init__(name, base_dir=3Dbase_dir) - - def __enter__(self): - return self.paths[0] =20 def file_path_remover(): for path in reversed(file_path_remover.paths): --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167192; cv=none; d=zohomail.com; s=zohoarc; b=Ritg35IhBBhjI70sF7tbxJy8q1W16QjTOjDEgPVnr9JLCYY6RvH5X06YK/f/VYBnimkRdqory/g6AXYQHO3BJUWJqIEwmZB5UPwFXUOswrfauCztnJrK0UuyUKQYsx+1Cj+eyyCdVXPJg/Xu8hZqD3mooCMIuTX8tM0smoo/8IA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167192; h=Content-Type: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; bh=Q4b9OkD9at6u4Tguv/aZDETuMiVpN2XcNLDqUOzPukQ=; b=n8DWUywEbd3cPAqwY0oKLoNXKdbeDUV2FAglxgcsN1mzbkEOusGRmZJHsFkB8+vqL/lp+DetfHyPdy7tjYXtecx7YNW9CFBkSc3zn7rcCXSm60Yxe4YRLBgaUTvvaFUJSmcBlmcQKGAQ0ebpXF13zbTXrZCZwR+JK8LFtUIE6ac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167192148469.53920717879066; Tue, 15 Sep 2020 03:53:12 -0700 (PDT) Received: from localhost ([::1]:58174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8aE-00013d-US for importer@patchew.org; Tue, 15 Sep 2020 06:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8U3-0000P5-6l for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:47 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:52893 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8U0-0004XG-VX for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198-WM2qKcu6MoOsclJ24WN9eg-1; Tue, 15 Sep 2020 06:46:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C528F1882FC0; Tue, 15 Sep 2020 10:46:40 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 694457B7B7; Tue, 15 Sep 2020 10:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q4b9OkD9at6u4Tguv/aZDETuMiVpN2XcNLDqUOzPukQ=; b=S7X8mCqGfaUu3aA5OpeCN+DSsP4dgjHO8igKa7oGlybmUD1ASH1Br7C50iDF+ZyLX9c/dQ Yw3t/5SGXec3gFELm5ZyshAIqDfqIWMwozFeK7tG7z0AG/aeY0oryajp9jqMmebod/5rLW AtCSFjY4GSK7jYZiUjltnbuDSvh6yFU= X-MC-Unique: WM2qKcu6MoOsclJ24WN9eg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 05/22] qemu-iotests: Simplify FilePath __init__ Date: Tue, 15 Sep 2020 12:46:10 +0200 Message-Id: <20200915104627.699552-6-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nir Soffer Use list comprehension instead of append loop. Signed-off-by: Nir Soffer Reviewed-by: Max Reitz Message-Id: <20200828232152.205833-6-nsoffer@redhat.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1799338f8b..91e4a57126 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -470,9 +470,8 @@ class FilePath: =20 """ def __init__(self, *names, base_dir=3Dtest_dir): - self.paths =3D [] - for name in names: - self.paths.append(os.path.join(base_dir, file_pattern(name))) + self.paths =3D [os.path.join(base_dir, file_pattern(name)) + for name in names] =20 def __enter__(self): if len(self.paths) =3D=3D 1: --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167340; cv=none; d=zohomail.com; s=zohoarc; b=PE8T8wiDEVxLVxzl0gr+x2Hb8K01RhvBcLx0mxLFQBwvUbbClgPe4VGkk0zvrZ524TSxntyPkylHJI8jFAe/Q7qBw35K9iljZXGW5bDoEBllrQAin1YUGkzhUjpXz72ZbxSuGWWC6SZL8wsIQY97fO5Q6NBg942Lo/Xdb8idRHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167340; h=Content-Type: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; bh=uP30DnVeODMLdNm9vUyTjR1z7jdsH9mOP9byIYWIgbY=; b=fWX50Bb/WZ1rhCiK1MKnr5jo6QrtqCmjYvKSLn6J2EZ7VP+HCpg6Tyoo+xPyRWfJa/Q6+rhbiDN/pMxf1HtUWtBmO/Ca0SRk07c8P1WwASZWYbqDJU/vx00kh82FOmdyattqniBOKef2fdupJQ+yDd1Dlf8WW2oBZZHpBtLBkeM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167340953309.13260502433025; Tue, 15 Sep 2020 03:55:40 -0700 (PDT) Received: from localhost ([::1]:39346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8cd-00052Q-Sa for importer@patchew.org; Tue, 15 Sep 2020 06:55:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UD-0000UK-FI for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20914 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8U9-0004YK-7R for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-83-NX41xAwaP7SAoHmCzt_gVw-1; Tue, 15 Sep 2020 06:46:44 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E798D64087; Tue, 15 Sep 2020 10:46:42 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A5345DC1E; Tue, 15 Sep 2020 10:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uP30DnVeODMLdNm9vUyTjR1z7jdsH9mOP9byIYWIgbY=; b=hMQD/FgyrT7yUMrdNdY0ye6/y+0UyH2J0GB3jC4uphtJcjlV++zDV+yiR2FlNVwY18Z2vA UqTMriTBmIk28QPc3IIaOG+Nlr4GeSLbgeHB6bYOW8LGQB8k4sEQWgJCgaQWbtbu7MsMQ1 2m3o1icBiO5sNDvmyVgIHiFwGtncUKY= X-MC-Unique: NX41xAwaP7SAoHmCzt_gVw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 06/22] block/quorum.c: stable children names Date: Tue, 15 Sep 2020 12:46:11 +0200 Message-Id: <20200915104627.699552-7-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:29:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Lukas Straub If we remove the child with the highest index from the quorum, decrement s->next_child_index. This way we get stable children names as long as we only remove the last child. Signed-off-by: Lukas Straub Fixes: https://bugs.launchpad.net/bugs/1881231 Reviewed-by: Zhang Chen Reviewed-by: Alberto Garcia Message-Id: <5d5f930424c1c770754041aa8ad6421dc4e2b58e.1596536719.git.lukass= traub2@web.de> Signed-off-by: Max Reitz --- block/quorum.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 6df9449fc2..e846a7e892 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -29,6 +29,8 @@ =20 #define HASH_LENGTH 32 =20 +#define INDEXSTR_LEN 32 + #define QUORUM_OPT_VOTE_THRESHOLD "vote-threshold" #define QUORUM_OPT_BLKVERIFY "blkverify" #define QUORUM_OPT_REWRITE "rewrite-corrupted" @@ -970,9 +972,9 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, opened =3D g_new0(bool, s->num_children); =20 for (i =3D 0; i < s->num_children; i++) { - char indexstr[32]; - ret =3D snprintf(indexstr, 32, "children.%d", i); - assert(ret < 32); + char indexstr[INDEXSTR_LEN]; + ret =3D snprintf(indexstr, INDEXSTR_LEN, "children.%d", i); + assert(ret < INDEXSTR_LEN); =20 s->children[i] =3D bdrv_open_child(NULL, options, indexstr, bs, &child_of_bds, BDRV_CHILD_DATA, f= alse, @@ -1024,7 +1026,7 @@ static void quorum_add_child(BlockDriverState *bs, Bl= ockDriverState *child_bs, { BDRVQuorumState *s =3D bs->opaque; BdrvChild *child; - char indexstr[32]; + char indexstr[INDEXSTR_LEN]; int ret; =20 if (s->is_blkverify) { @@ -1039,8 +1041,8 @@ static void quorum_add_child(BlockDriverState *bs, Bl= ockDriverState *child_bs, return; } =20 - ret =3D snprintf(indexstr, 32, "children.%u", s->next_child_index); - if (ret < 0 || ret >=3D 32) { + ret =3D snprintf(indexstr, INDEXSTR_LEN, "children.%u", s->next_child_= index); + if (ret < 0 || ret >=3D INDEXSTR_LEN) { error_setg(errp, "cannot generate child name"); return; } @@ -1068,6 +1070,7 @@ static void quorum_del_child(BlockDriverState *bs, Bd= rvChild *child, Error **errp) { BDRVQuorumState *s =3D bs->opaque; + char indexstr[INDEXSTR_LEN]; int i; =20 for (i =3D 0; i < s->num_children; i++) { @@ -1089,6 +1092,11 @@ static void quorum_del_child(BlockDriverState *bs, B= drvChild *child, /* We know now that num_children > threshold, so blkverify must be fal= se */ assert(!s->is_blkverify); =20 + snprintf(indexstr, INDEXSTR_LEN, "children.%u", s->next_child_index - = 1); + if (!strncmp(child->name, indexstr, INDEXSTR_LEN)) { + s->next_child_index--; + } + bdrv_drained_begin(bs); =20 /* We can safely remove this child now */ --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167046; cv=none; d=zohomail.com; s=zohoarc; b=D8pH05xJJng5QVc24P2AEmOmgBG9taLwjar46Z5tG+LRoaiYw9szvGI+ZxphQzomTk4XX/otJMqMj/CZ99t1FF/KLD14bRgbA+mDvTG8IcgYizkbbym+d90uecCmXSHb/0dvBsh16l+e8TvccEfgq+KsiBjhXU8I5olvcgKfy3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167046; h=Content-Type: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; bh=eNGMP0NumDmnPL1tkTdKMGI4YuPdVPiFI8BlpV+dcbg=; b=YSmAI1bSajE5USUAcMWvt+6XErNyYzW5dHh9aGoF6A+nD/1ZOt/6U4yS2e1b8tYjQP66f5gv7pyxYUDCjXHZRi771e9Xgfunss0TnwLwO34T2gOJlL3lPAQlQXtmZr0ObDWc5nSJyHbR87vx4mBc9j/hvMQAfB0aYyvsVTtL/pc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167046552514.1262867169579; Tue, 15 Sep 2020 03:50:46 -0700 (PDT) Received: from localhost ([::1]:49292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8Xt-0005ju-2L for importer@patchew.org; Tue, 15 Sep 2020 06:50:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UE-0000WU-GL for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8U9-0004Y6-QW for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-FCI-NTJ4MkqRaRpKSp7OCw-1; Tue, 15 Sep 2020 06:46:46 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A04F1084D64; Tue, 15 Sep 2020 10:46:45 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF45319C4F; Tue, 15 Sep 2020 10:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eNGMP0NumDmnPL1tkTdKMGI4YuPdVPiFI8BlpV+dcbg=; b=eVC7LKxmEHkJH+wPa4+o9ZPgfY5ypzwzW6NBdg2Fki9dXQGs5r4gN0wDcZut2aPgzTJ3Ir T/M7OWyCmFVrRXwayqcRNI/cAPk5J5W0qKFriodoq6DeCiChBhakUn0DIDUYf12T+ZMFkd NgaQEI5PSR5404PZtYhkM1gK0ss/sAA= X-MC-Unique: FCI-NTJ4MkqRaRpKSp7OCw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 07/22] qemu-img: avoid unaligned read requests during convert Date: Tue, 15 Sep 2020 12:46:12 +0200 Message-Id: <20200915104627.699552-8-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:10:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Lieven in case of large continous areas that share the same allocation status it happens that the value of s->sector_next_status is unaligned to the cluster size or even request alignment of the source. Avoid this by stripping down the s->sector_next_status position to cluster boundaries. Signed-off-by: Peter Lieven Message-Id: <20200901125129.6398-1-pl@kamp.de> [mreitz: Disable vhdx for 251] Signed-off-by: Max Reitz --- qemu-img.c | 22 ++++++++++++++++++++++ tests/qemu-iotests/251 | 7 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d0b1c97562..37365d06fa 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1666,6 +1666,7 @@ enum ImgConvertBlockStatus { typedef struct ImgConvertState { BlockBackend **src; int64_t *src_sectors; + int *src_alignment; int src_num; int64_t total_sectors; int64_t allocated_sectors; @@ -1732,6 +1733,7 @@ static int convert_iteration_sectors(ImgConvertState = *s, int64_t sector_num) if (s->sector_next_status <=3D sector_num) { uint64_t offset =3D (sector_num - src_cur_offset) * BDRV_SECTOR_SI= ZE; int64_t count; + int tail; BlockDriverState *src_bs =3D blk_bs(s->src[src_cur]); BlockDriverState *base; =20 @@ -1772,6 +1774,16 @@ static int convert_iteration_sectors(ImgConvertState= *s, int64_t sector_num) =20 n =3D DIV_ROUND_UP(count, BDRV_SECTOR_SIZE); =20 + /* + * Avoid that s->sector_next_status becomes unaligned to the source + * request alignment and/or cluster size to avoid unnecessary read + * cycles. + */ + tail =3D (sector_num - src_cur_offset + n) % s->src_alignment[src_= cur]; + if (n > tail) { + n -=3D tail; + } + if (ret & BDRV_BLOCK_ZERO) { s->status =3D post_backing_zero ? BLK_BACKING_FILE : BLK_ZERO; } else if (ret & BDRV_BLOCK_DATA) { @@ -2410,8 +2422,10 @@ static int img_convert(int argc, char **argv) =20 s.src =3D g_new0(BlockBackend *, s.src_num); s.src_sectors =3D g_new(int64_t, s.src_num); + s.src_alignment =3D g_new(int, s.src_num); =20 for (bs_i =3D 0; bs_i < s.src_num; bs_i++) { + BlockDriverState *src_bs; s.src[bs_i] =3D img_open(image_opts, argv[optind + bs_i], fmt, src_flags, src_writethrough, s.quiet, force_share); @@ -2426,6 +2440,13 @@ static int img_convert(int argc, char **argv) ret =3D -1; goto out; } + src_bs =3D blk_bs(s.src[bs_i]); + s.src_alignment[bs_i] =3D DIV_ROUND_UP(src_bs->bl.request_alignmen= t, + BDRV_SECTOR_SIZE); + if (!bdrv_get_info(src_bs, &bdi)) { + s.src_alignment[bs_i] =3D MAX(s.src_alignment[bs_i], + bdi.cluster_size / BDRV_SECTOR_SIZ= E); + } s.total_sectors +=3D s.src_sectors[bs_i]; } =20 @@ -2708,6 +2729,7 @@ out: g_free(s.src); } g_free(s.src_sectors); + g_free(s.src_alignment); fail_getopt: g_free(options); =20 diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 index 7918ba3559..294773bdc1 100755 --- a/tests/qemu-iotests/251 +++ b/tests/qemu-iotests/251 @@ -46,8 +46,11 @@ if [ "$IMGOPTSSYNTAX" =3D "true" ]; then # We use json:{} filenames here, so we cannot work with additional opt= ions. _unsupported_fmt $IMGFMT else - # With VDI, the output is ordered differently. Just disable it. - _unsupported_fmt vdi + # - With VDI, the output is ordered differently. Just disable it. + # - VHDX has large clusters; because qemu-img convert tries to + # align the requests to the cluster size, the output is ordered + # differently, so disable it, too. + _unsupported_fmt vdi vhdx fi =20 =20 --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167487; cv=none; d=zohomail.com; s=zohoarc; b=ieo9xu0ezwCABKTbPRMiiLfMbPLrWDbP6L+7usG55dpIMRokIVYguT4lG1gF8hnvqyCzK2JOnwVrbWxUiWhYPnNZW3iZBj5/LkoStZU1JBqqx+Ksobj9k6O1Eo5Y20aZbKG/11oXMXYsm3ETMkG2XRH/Y3avHZhKkHToCLRUvdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167487; h=Content-Type: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; bh=uRc6w0dl/Uj4FKyh7RSAnGqYP+kLY3pq8JEWMrJQ+c0=; b=jM5DqM0PTSsu3V8HBlIdjWmKs1bSyO6/RCaIL7scP3wXEGno85OcyLSBk1jKLxIcx48KMYmn00gAAHbkQzrmagNJ4Dzv3HQgS3Qc5aDLe8uOV5G/+IGdH6OjnjdckhvANsYN7x0We+rOTV99uwMwIRAVHQSIa8RpBlIuJncPLI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 16001674870594.749623919072405; Tue, 15 Sep 2020 03:58:07 -0700 (PDT) Received: from localhost ([::1]:47246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8ez-0008QG-RW for importer@patchew.org; Tue, 15 Sep 2020 06:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UE-0000Vw-6G for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44851 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8U9-0004YH-7H for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-127-QiucSzkkOAm7xKKfurwc0A-1; Tue, 15 Sep 2020 06:46:48 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A393D64086; Tue, 15 Sep 2020 10:46:47 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E24395F9C1; Tue, 15 Sep 2020 10:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uRc6w0dl/Uj4FKyh7RSAnGqYP+kLY3pq8JEWMrJQ+c0=; b=B6KVKm2Pqnr+WyYH6z1YKCiO1k6T8DoSh2lpe6p2ZAEld/yfF0dJz1FrREf9LGfqYvZmD3 bRSUdoUjCWAHpPTYRnH21WX3ITryDPRd/ZRnPRaaYUar3b+KUgjJMSFFxagioRBqn1Auqp w/vdomVtyZyWrWNMtu3DiXswhlggPVQ= X-MC-Unique: QiucSzkkOAm7xKKfurwc0A-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 08/22] qcow2: Use macros for the L1, refcount and bitmap table entry sizes Date: Tue, 15 Sep 2020 12:46:13 +0200 Message-Id: <20200915104627.699552-9-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:29:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This patch replaces instances of sizeof(uint64_t) in the qcow2 driver with macros that indicate what those sizes are actually referring to. Signed-off-by: Alberto Garcia Message-Id: <20200828110828.13833-1-berto@igalia.com> Signed-off-by: Max Reitz --- block/qcow2.h | 6 +++ block/qcow2-bitmap.c | 11 ++++-- block/qcow2-cluster.c | 24 ++++++------ block/qcow2-refcount.c | 89 ++++++++++++++++++++++-------------------- block/qcow2-snapshot.c | 20 +++++----- block/qcow2.c | 27 ++++++------- 6 files changed, 94 insertions(+), 83 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 065ec3df0b..83cfa0c391 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -99,6 +99,12 @@ #define L2E_SIZE_NORMAL (sizeof(uint64_t)) #define L2E_SIZE_EXTENDED (sizeof(uint64_t) * 2) =20 +/* Size of L1 table entries */ +#define L1E_SIZE (sizeof(uint64_t)) + +/* Size of reftable entries */ +#define REFTABLE_ENTRY_SIZE (sizeof(uint64_t)) + #define MIN_CLUSTER_BITS 9 #define MAX_CLUSTER_BITS 21 =20 diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 8c34b2aef7..d7a31a8ddc 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -42,6 +42,9 @@ #define BME_MIN_GRANULARITY_BITS 9 #define BME_MAX_NAME_SIZE 1023 =20 +/* Size of bitmap table entries */ +#define BME_TABLE_ENTRY_SIZE (sizeof(uint64_t)) + QEMU_BUILD_BUG_ON(BME_MAX_NAME_SIZE !=3D BDRV_BITMAP_MAX_NAME_SIZE); =20 #if BME_MAX_TABLE_SIZE * 8ULL > INT_MAX @@ -232,7 +235,7 @@ static int bitmap_table_load(BlockDriverState *bs, Qcow= 2BitmapTable *tb, =20 assert(tb->size <=3D BME_MAX_TABLE_SIZE); ret =3D bdrv_pread(bs->file, tb->offset, - table, tb->size * sizeof(uint64_t)); + table, tb->size * BME_TABLE_ENTRY_SIZE); if (ret < 0) { goto fail; } @@ -265,7 +268,7 @@ static int free_bitmap_clusters(BlockDriverState *bs, Q= cow2BitmapTable *tb) } =20 clear_bitmap_table(bs, bitmap_table, tb->size); - qcow2_free_clusters(bs, tb->offset, tb->size * sizeof(uint64_t), + qcow2_free_clusters(bs, tb->offset, tb->size * BME_TABLE_ENTRY_SIZE, QCOW2_DISCARD_OTHER); g_free(bitmap_table); =20 @@ -690,7 +693,7 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs,= BdrvCheckResult *res, ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, refcount_table_size, bm->table.offset, - bm->table.size * sizeof(uint64_t)); + bm->table.size * BME_TABLE_ENTRY_SI= ZE); if (ret < 0) { goto out; } @@ -1797,7 +1800,7 @@ uint64_t qcow2_get_persistent_dirty_bitmap_size(Block= DriverState *in_bs, /* Assume the entire bitmap is allocated */ bitmaps_size +=3D bmclusters * cluster_size; /* Also reserve space for the bitmap table entries */ - bitmaps_size +=3D ROUND_UP(bmclusters * sizeof(uint64_t), + bitmaps_size +=3D ROUND_UP(bmclusters * BME_TABLE_ENTRY_SIZE, cluster_size); /* And space for contribution to bitmap directory size */ bitmap_dir_size +=3D calc_dir_entry_size(strlen(name), 0); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index fcdf7af8e6..4530e5e471 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -47,8 +47,8 @@ int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t = exact_size) =20 BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE); ret =3D bdrv_pwrite_zeroes(bs->file, s->l1_table_offset + - new_l1_size * sizeof(uint64_t), - (s->l1_size - new_l1_size) * sizeof(uint64_t)= , 0); + new_l1_size * L1E_SIZE, + (s->l1_size - new_l1_size) * L1E_SIZE, 0); if (ret < 0) { goto fail; } @@ -76,7 +76,7 @@ fail: * l1_table in memory to avoid possible image corruption. */ memset(s->l1_table + new_l1_size, 0, - (s->l1_size - new_l1_size) * sizeof(uint64_t)); + (s->l1_size - new_l1_size) * L1E_SIZE); return ret; } =20 @@ -96,7 +96,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t mi= n_size, /* Do a sanity check on min_size before trying to calculate new_l1_size * (this prevents overflows during the while loop for the calculation = of * new_l1_size) */ - if (min_size > INT_MAX / sizeof(uint64_t)) { + if (min_size > INT_MAX / L1E_SIZE) { return -EFBIG; } =20 @@ -114,7 +114,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, } =20 QEMU_BUILD_BUG_ON(QCOW_MAX_L1_SIZE > INT_MAX); - if (new_l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) { + if (new_l1_size > QCOW_MAX_L1_SIZE / L1E_SIZE) { return -EFBIG; } =20 @@ -123,7 +123,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, s->l1_size, new_l1_size); #endif =20 - new_l1_size2 =3D sizeof(uint64_t) * new_l1_size; + new_l1_size2 =3D L1E_SIZE * new_l1_size; new_l1_table =3D qemu_try_blockalign(bs->file->bs, new_l1_size2); if (new_l1_table =3D=3D NULL) { return -ENOMEM; @@ -131,7 +131,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, memset(new_l1_table, 0, new_l1_size2); =20 if (s->l1_size) { - memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); + memcpy(new_l1_table, s->l1_table, s->l1_size * L1E_SIZE); } =20 /* write new table (align to cluster) */ @@ -180,7 +180,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t = min_size, s->l1_table =3D new_l1_table; old_l1_size =3D s->l1_size; s->l1_size =3D new_l1_size; - qcow2_free_clusters(bs, old_l1_table_offset, old_l1_size * sizeof(uint= 64_t), + qcow2_free_clusters(bs, old_l1_table_offset, old_l1_size * L1E_SIZE, QCOW2_DISCARD_OTHER); return 0; fail: @@ -225,9 +225,9 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_i= ndex) BDRVQcow2State *s =3D bs->opaque; int l1_start_index; int i, ret; - int bufsize =3D MAX(sizeof(uint64_t), + int bufsize =3D MAX(L1E_SIZE, MIN(bs->file->bs->bl.request_alignment, s->cluster_s= ize)); - int nentries =3D bufsize / sizeof(uint64_t); + int nentries =3D bufsize / L1E_SIZE; g_autofree uint64_t *buf =3D g_try_new0(uint64_t, nentries); =20 if (buf =3D=3D NULL) { @@ -2410,7 +2410,7 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, Error *local_err =3D NULL; =20 ret =3D qcow2_validate_table(bs, s->snapshots[i].l1_table_offset, - s->snapshots[i].l1_size, sizeof(uint64_= t), + s->snapshots[i].l1_size, L1E_SIZE, QCOW_MAX_L1_SIZE, "Snapshot L1 table", &local_err); if (ret < 0) { @@ -2418,7 +2418,7 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, goto fail; } =20 - l1_size2 =3D s->snapshots[i].l1_size * sizeof(uint64_t); + l1_size2 =3D s->snapshots[i].l1_size * L1E_SIZE; new_l1_table =3D g_try_realloc(l1_table, l1_size2); =20 if (!new_l1_table) { diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index aae52607eb..51e9778ed8 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -105,8 +105,8 @@ int qcow2_refcount_init(BlockDriverState *bs) s->get_refcount =3D get_refcount_funcs[s->refcount_order]; s->set_refcount =3D set_refcount_funcs[s->refcount_order]; =20 - assert(s->refcount_table_size <=3D INT_MAX / sizeof(uint64_t)); - refcount_table_size2 =3D s->refcount_table_size * sizeof(uint64_t); + assert(s->refcount_table_size <=3D INT_MAX / REFTABLE_ENTRY_SIZE); + refcount_table_size2 =3D s->refcount_table_size * REFTABLE_ENTRY_SIZE; s->refcount_table =3D g_try_malloc(refcount_table_size2); =20 if (s->refcount_table_size > 0) { @@ -434,8 +434,8 @@ static int alloc_refcount_block(BlockDriverState *bs, if (refcount_table_index < s->refcount_table_size) { uint64_t data64 =3D cpu_to_be64(new_block); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); - ret =3D bdrv_pwrite_sync(bs->file, - s->refcount_table_offset + refcount_table_index * sizeof(uint6= 4_t), + ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset + + refcount_table_index * REFTABLE_ENTRY_SIZE, &data64, sizeof(data64)); if (ret < 0) { goto fail; @@ -562,8 +562,8 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, DIV_ROUND_UP(total_refblock_count, 2); } /* The qcow2 file can only store the reftable size in number of cluste= rs */ - table_size =3D ROUND_UP(table_size, s->cluster_size / sizeof(uint64_t)= ); - table_clusters =3D (table_size * sizeof(uint64_t)) / s->cluster_size; + table_size =3D ROUND_UP(table_size, s->cluster_size / REFTABLE_ENTRY_S= IZE); + table_clusters =3D (table_size * REFTABLE_ENTRY_SIZE) / s->cluster_siz= e; =20 if (table_size > QCOW_MAX_REFTABLE_SIZE) { return -EFBIG; @@ -581,13 +581,13 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uin= t64_t start_offset, if (table_size > s->max_refcount_table_index) { /* We're actually growing the reftable */ memcpy(new_table, s->refcount_table, - (s->max_refcount_table_index + 1) * sizeof(uint64_t)); + (s->max_refcount_table_index + 1) * REFTABLE_ENTRY_SIZE); } else { /* Improbable case: We're shrinking the reftable. However, the cal= ler * has assured us that there is only empty space beyond @start_off= set, * so we can simply drop all of the refblocks that won't fit into = the * new reftable. */ - memcpy(new_table, s->refcount_table, table_size * sizeof(uint64_t)= ); + memcpy(new_table, s->refcount_table, table_size * REFTABLE_ENTRY_S= IZE); } =20 if (new_refblock_offset) { @@ -682,7 +682,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, =20 BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); ret =3D bdrv_pwrite_sync(bs->file, table_offset, new_table, - table_size * sizeof(uint64_t)); + table_size * REFTABLE_ENTRY_SIZE); if (ret < 0) { goto fail; } @@ -717,7 +717,8 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, update_max_refcount_table_index(s); =20 /* Free old table. */ - qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint= 64_t), + qcow2_free_clusters(bs, old_table_offset, + old_table_size * REFTABLE_ENTRY_SIZE, QCOW2_DISCARD_OTHER); =20 return end_offset; @@ -1253,7 +1254,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, =20 l2_slice =3D NULL; l1_table =3D NULL; - l1_size2 =3D l1_size * sizeof(uint64_t); + l1_size2 =3D l1_size * L1E_SIZE; slice_size2 =3D s->l2_slice_size * l2_entry_size(s); n_slices =3D s->cluster_size / slice_size2; =20 @@ -1784,7 +1785,7 @@ static int check_refcounts_l1(BlockDriverState *bs, uint64_t *l1_table =3D NULL, l2_offset, l1_size2; int i, ret; =20 - l1_size2 =3D l1_size * sizeof(uint64_t); + l1_size2 =3D l1_size * L1E_SIZE; =20 /* Mark L1 table as used */ ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, refcount_tab= le_size, @@ -2146,7 +2147,7 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, res->corruptions++; continue; } - if (sn->l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) { + if (sn->l1_size > QCOW_MAX_L1_SIZE / L1E_SIZE) { fprintf(stderr, "ERROR snapshot %s (%s) l1_size=3D%#" PRIx32 "= : " "L1 table is too large; snapshot table entry corrupted= \n", sn->id_str, sn->name, sn->l1_size); @@ -2169,7 +2170,8 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, /* refcount data */ ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, nb_clusters, s->refcount_table_offset, - s->refcount_table_size * sizeof(uint64_= t)); + s->refcount_table_size * + REFTABLE_ENTRY_SIZE); if (ret < 0) { return ret; } @@ -2390,11 +2392,11 @@ write_refblocks: uint32_t old_reftable_size =3D reftable_size; uint64_t *new_on_disk_reftable; =20 - reftable_size =3D ROUND_UP((refblock_index + 1) * sizeof(uint6= 4_t), - s->cluster_size) / sizeof(uint64_t); + reftable_size =3D ROUND_UP((refblock_index + 1) * REFTABLE_ENT= RY_SIZE, + s->cluster_size) / REFTABLE_ENTRY_SIZ= E; new_on_disk_reftable =3D g_try_realloc(on_disk_reftable, reftable_size * - sizeof(uint64_t)); + REFTABLE_ENTRY_SIZE); if (!new_on_disk_reftable) { res->check_errors++; ret =3D -ENOMEM; @@ -2403,7 +2405,7 @@ write_refblocks: on_disk_reftable =3D new_on_disk_reftable; =20 memset(on_disk_reftable + old_reftable_size, 0, - (reftable_size - old_reftable_size) * sizeof(uint64_t)); + (reftable_size - old_reftable_size) * REFTABLE_ENTRY_SI= ZE); =20 /* The offset we have for the reftable is now no longer valid; * this will leak that range, but we can easily fix that by ru= nning @@ -2420,7 +2422,7 @@ write_refblocks: reftable_offset < 0) { uint64_t reftable_clusters =3D size_to_clusters(s, reftable_si= ze * - sizeof(uint64_t)= ); + REFTABLE_ENTRY_S= IZE); reftable_offset =3D alloc_clusters_imrt(bs, reftable_clusters, refcount_table, nb_clust= ers, &first_free_cluster); @@ -2460,8 +2462,8 @@ write_refblocks: uint64_t post_refblock_start, reftable_clusters; =20 post_refblock_start =3D ROUND_UP(*nb_clusters, s->refcount_block_s= ize); - reftable_clusters =3D size_to_clusters(s, - reftable_size * sizeof(uint64= _t)); + reftable_clusters =3D + size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZE); /* Not pretty but simple */ if (first_free_cluster < post_refblock_start) { first_free_cluster =3D post_refblock_start; @@ -2485,16 +2487,16 @@ write_refblocks: } =20 ret =3D qcow2_pre_write_overlap_check(bs, 0, reftable_offset, - reftable_size * sizeof(uint64_t), + reftable_size * REFTABLE_ENTRY_SIZ= E, false); if (ret < 0) { fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret)); goto fail; } =20 - assert(reftable_size < INT_MAX / sizeof(uint64_t)); + assert(reftable_size < INT_MAX / REFTABLE_ENTRY_SIZE); ret =3D bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable, - reftable_size * sizeof(uint64_t)); + reftable_size * REFTABLE_ENTRY_SIZE); if (ret < 0) { fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret)); goto fail; @@ -2503,7 +2505,7 @@ write_refblocks: /* Enter new reftable into the image header */ reftable_offset_and_clusters.reftable_offset =3D cpu_to_be64(reftable_= offset); reftable_offset_and_clusters.reftable_clusters =3D - cpu_to_be32(size_to_clusters(s, reftable_size * sizeof(uint64_t))); + cpu_to_be32(size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZ= E)); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), &reftable_offset_and_clusters, @@ -2693,14 +2695,14 @@ int qcow2_check_metadata_overlap(BlockDriverState *= bs, int ign, int64_t offset, offset =3D start_of_cluster(s, offset); =20 if ((chk & QCOW2_OL_ACTIVE_L1) && s->l1_size) { - if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t= ))) { + if (overlaps_with(s->l1_table_offset, s->l1_size * L1E_SIZE)) { return QCOW2_OL_ACTIVE_L1; } } =20 if ((chk & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) { if (overlaps_with(s->refcount_table_offset, - s->refcount_table_size * sizeof(uint64_t))) { + s->refcount_table_size * REFTABLE_ENTRY_SIZE)) { return QCOW2_OL_REFCOUNT_TABLE; } } @@ -2715,7 +2717,7 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs= , int ign, int64_t offset, for (i =3D 0; i < s->nb_snapshots; i++) { if (s->snapshots[i].l1_size && overlaps_with(s->snapshots[i].l1_table_offset, - s->snapshots[i].l1_size * sizeof(uint64_t))) { + s->snapshots[i].l1_size * L1E_SIZE)) { return QCOW2_OL_INACTIVE_L1; } } @@ -2749,11 +2751,11 @@ int qcow2_check_metadata_overlap(BlockDriverState *= bs, int ign, int64_t offset, for (i =3D 0; i < s->nb_snapshots; i++) { uint64_t l1_ofs =3D s->snapshots[i].l1_table_offset; uint32_t l1_sz =3D s->snapshots[i].l1_size; - uint64_t l1_sz2 =3D l1_sz * sizeof(uint64_t); + uint64_t l1_sz2 =3D l1_sz * L1E_SIZE; uint64_t *l1; int ret; =20 - ret =3D qcow2_validate_table(bs, l1_ofs, l1_sz, sizeof(uint64_= t), + ret =3D qcow2_validate_table(bs, l1_ofs, l1_sz, L1E_SIZE, QCOW_MAX_L1_SIZE, "", NULL); if (ret < 0) { return ret; @@ -2877,8 +2879,8 @@ static int alloc_refblock(BlockDriverState *bs, uint6= 4_t **reftable, uint64_t new_reftable_size; =20 new_reftable_size =3D ROUND_UP(reftable_index + 1, - s->cluster_size / sizeof(uint64_t)); - if (new_reftable_size > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t))= { + s->cluster_size / REFTABLE_ENTRY_SIZE= ); + if (new_reftable_size > QCOW_MAX_REFTABLE_SIZE / REFTABLE_ENTRY_SI= ZE) { error_setg(errp, "This operation would make the refcount table grow " "beyond the maximum size supported by QEMU, abortin= g"); @@ -2886,14 +2888,14 @@ static int alloc_refblock(BlockDriverState *bs, uin= t64_t **reftable, } =20 new_reftable =3D g_try_realloc(*reftable, new_reftable_size * - sizeof(uint64_t)); + REFTABLE_ENTRY_SIZE); if (!new_reftable) { error_setg(errp, "Failed to increase reftable buffer size"); return -ENOMEM; } =20 memset(new_reftable + *reftable_size, 0, - (new_reftable_size - *reftable_size) * sizeof(uint64_t)); + (new_reftable_size - *reftable_size) * REFTABLE_ENTRY_SIZE); =20 *reftable =3D new_reftable; *reftable_size =3D new_reftable_size; @@ -3164,13 +3166,14 @@ int qcow2_change_refcount_order(BlockDriverState *b= s, int refcount_order, =20 if (new_allocation) { if (new_reftable_offset) { - qcow2_free_clusters(bs, new_reftable_offset, - allocated_reftable_size * sizeof(uint6= 4_t), - QCOW2_DISCARD_NEVER); + qcow2_free_clusters( + bs, new_reftable_offset, + allocated_reftable_size * REFTABLE_ENTRY_SIZE, + QCOW2_DISCARD_NEVER); } =20 new_reftable_offset =3D qcow2_alloc_clusters(bs, new_reftable_= size * - sizeof(uint64_t= )); + REFTABLE_ENTRY_= SIZE); if (new_reftable_offset < 0) { error_setg_errno(errp, -new_reftable_offset, "Failed to allocate the new reftable"); @@ -3196,7 +3199,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs,= int refcount_order, =20 /* Write the new reftable */ ret =3D qcow2_pre_write_overlap_check(bs, 0, new_reftable_offset, - new_reftable_size * sizeof(uint64_= t), + new_reftable_size * REFTABLE_ENTRY= _SIZE, false); if (ret < 0) { error_setg_errno(errp, -ret, "Overlap check failed"); @@ -3208,7 +3211,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs,= int refcount_order, } =20 ret =3D bdrv_pwrite(bs->file, new_reftable_offset, new_reftable, - new_reftable_size * sizeof(uint64_t)); + new_reftable_size * REFTABLE_ENTRY_SIZE); =20 for (i =3D 0; i < new_reftable_size; i++) { be64_to_cpus(&new_reftable[i]); @@ -3285,7 +3288,7 @@ done: =20 if (new_reftable_offset > 0) { qcow2_free_clusters(bs, new_reftable_offset, - new_reftable_size * sizeof(uint64_t), + new_reftable_size * REFTABLE_ENTRY_SIZE, QCOW2_DISCARD_OTHER); } } @@ -3374,7 +3377,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; uint64_t *reftable_tmp =3D - g_malloc(s->refcount_table_size * sizeof(uint64_t)); + g_malloc(s->refcount_table_size * REFTABLE_ENTRY_SIZE); int i, ret; =20 for (i =3D 0; i < s->refcount_table_size; i++) { @@ -3412,7 +3415,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) } =20 ret =3D bdrv_pwrite_sync(bs->file, s->refcount_table_offset, reftable_= tmp, - s->refcount_table_size * sizeof(uint64_t)); + s->refcount_table_size * REFTABLE_ENTRY_SIZE); /* * If the write in the reftable failed the image may contain a partial= ly * overwritten reftable. In this case it would be better to clear the diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 2756b37d24..9b68690f56 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -659,7 +659,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSna= pshotInfo *sn_info) sn->extra_data_size =3D sizeof(QCowSnapshotExtraData); =20 /* Allocate the L1 table of the snapshot and copy the current one ther= e. */ - l1_table_offset =3D qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint6= 4_t)); + l1_table_offset =3D qcow2_alloc_clusters(bs, s->l1_size * L1E_SIZE); if (l1_table_offset < 0) { ret =3D l1_table_offset; goto fail; @@ -679,13 +679,13 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUS= napshotInfo *sn_info) } =20 ret =3D qcow2_pre_write_overlap_check(bs, 0, sn->l1_table_offset, - s->l1_size * sizeof(uint64_t), fal= se); + s->l1_size * L1E_SIZE, false); if (ret < 0) { goto fail; } =20 ret =3D bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, - s->l1_size * sizeof(uint64_t)); + s->l1_size * L1E_SIZE); if (ret < 0) { goto fail; } @@ -768,7 +768,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) sn =3D &s->snapshots[snapshot_index]; =20 ret =3D qcow2_validate_table(bs, sn->l1_table_offset, sn->l1_size, - sizeof(uint64_t), QCOW_MAX_L1_SIZE, + L1E_SIZE, QCOW_MAX_L1_SIZE, "Snapshot L1 table", &local_err); if (ret < 0) { error_report_err(local_err); @@ -803,8 +803,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const cha= r *snapshot_id) goto fail; } =20 - cur_l1_bytes =3D s->l1_size * sizeof(uint64_t); - sn_l1_bytes =3D sn->l1_size * sizeof(uint64_t); + cur_l1_bytes =3D s->l1_size * L1E_SIZE; + sn_l1_bytes =3D sn->l1_size * L1E_SIZE; =20 /* * Copy the snapshot L1 table to the current L1 table. @@ -917,7 +917,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, sn =3D s->snapshots[snapshot_index]; =20 ret =3D qcow2_validate_table(bs, sn.l1_table_offset, sn.l1_size, - sizeof(uint64_t), QCOW_MAX_L1_SIZE, + L1E_SIZE, QCOW_MAX_L1_SIZE, "Snapshot L1 table", errp); if (ret < 0) { return ret; @@ -953,7 +953,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, error_setg_errno(errp, -ret, "Failed to free the cluster and L1 ta= ble"); return ret; } - qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * sizeof(uint64= _t), + qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * L1E_SIZE, QCOW2_DISCARD_SNAPSHOT); =20 /* must update the copied flag on the current cluster offsets */ @@ -1030,12 +1030,12 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, =20 /* Allocate and read in the snapshot's L1 table */ ret =3D qcow2_validate_table(bs, sn->l1_table_offset, sn->l1_size, - sizeof(uint64_t), QCOW_MAX_L1_SIZE, + L1E_SIZE, QCOW_MAX_L1_SIZE, "Snapshot L1 table", errp); if (ret < 0) { return ret; } - new_l1_bytes =3D sn->l1_size * sizeof(uint64_t); + new_l1_bytes =3D sn->l1_size * L1E_SIZE; new_l1_table =3D qemu_try_blockalign(bs->file->bs, new_l1_bytes); if (new_l1_table =3D=3D NULL) { return -ENOMEM; diff --git a/block/qcow2.c b/block/qcow2.c index da56b1a4df..ef9a45e82f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1543,7 +1543,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, =20 /* read the level 1 table */ ret =3D qcow2_validate_table(bs, header.l1_table_offset, - header.l1_size, sizeof(uint64_t), + header.l1_size, L1E_SIZE, QCOW_MAX_L1_SIZE, "Active L1 table", errp); if (ret < 0) { goto fail; @@ -1568,15 +1568,14 @@ static int coroutine_fn qcow2_do_open(BlockDriverSt= ate *bs, QDict *options, } =20 if (s->l1_size > 0) { - s->l1_table =3D qemu_try_blockalign(bs->file->bs, - s->l1_size * sizeof(uint64_t)); + s->l1_table =3D qemu_try_blockalign(bs->file->bs, s->l1_size * L1E= _SIZE); if (s->l1_table =3D=3D NULL) { error_setg(errp, "Could not allocate L1 table"); ret =3D -ENOMEM; goto fail; } ret =3D bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, - s->l1_size * sizeof(uint64_t)); + s->l1_size * L1E_SIZE); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read L1 table"); goto fail; @@ -3213,7 +3212,7 @@ int64_t qcow2_refcount_metadata_size(int64_t clusters= , size_t cluster_size, * where no further refcount blocks or table clusters are required to * reference count every cluster. */ - int64_t blocks_per_table_cluster =3D cluster_size / sizeof(uint64_t); + int64_t blocks_per_table_cluster =3D cluster_size / REFTABLE_ENTRY_SIZ= E; int64_t refcounts_per_block =3D cluster_size * 8 / (1 << refcount_orde= r); int64_t table =3D 0; /* number of refcount table clusters */ int64_t blocks =3D 0; /* number of refcount block clusters */ @@ -3270,8 +3269,8 @@ static int64_t qcow2_calc_prealloc_size(int64_t total= _size, =20 /* total size of L1 tables */ nl1e =3D nl2e * l2e_size / cluster_size; - nl1e =3D ROUND_UP(nl1e, cluster_size / sizeof(uint64_t)); - meta_size +=3D nl1e * sizeof(uint64_t); + nl1e =3D ROUND_UP(nl1e, cluster_size / L1E_SIZE); + meta_size +=3D nl1e * L1E_SIZE; =20 /* total size of refcount table and blocks */ meta_size +=3D qcow2_refcount_metadata_size( @@ -4460,7 +4459,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, /* write updated header.size */ offset =3D cpu_to_be64(offset); ret =3D bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), - &offset, sizeof(uint64_t)); + &offset, sizeof(offset)); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to update the image size"); goto fail; @@ -4700,8 +4699,8 @@ static int make_completely_empty(BlockDriverState *bs) =20 BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); =20 - l1_clusters =3D DIV_ROUND_UP(s->l1_size, s->cluster_size / sizeof(uint= 64_t)); - l1_size2 =3D (uint64_t)s->l1_size * sizeof(uint64_t); + l1_clusters =3D DIV_ROUND_UP(s->l1_size, s->cluster_size / L1E_SIZE); + l1_size2 =3D (uint64_t)s->l1_size * L1E_SIZE; =20 /* After this call, neither the in-memory nor the on-disk refcount * information accurately describe the actual references */ @@ -4747,14 +4746,14 @@ static int make_completely_empty(BlockDriverState *= bs) =20 s->l1_table_offset =3D 3 * s->cluster_size; =20 - new_reftable =3D g_try_new0(uint64_t, s->cluster_size / sizeof(uint64_= t)); + new_reftable =3D g_try_new0(uint64_t, s->cluster_size / REFTABLE_ENTRY= _SIZE); if (!new_reftable) { ret =3D -ENOMEM; goto fail_broken_refcounts; } =20 s->refcount_table_offset =3D s->cluster_size; - s->refcount_table_size =3D s->cluster_size / sizeof(uint64_t); + s->refcount_table_size =3D s->cluster_size / REFTABLE_ENTRY_SIZE; s->max_refcount_table_index =3D 0; =20 g_free(s->refcount_table); @@ -4826,7 +4825,7 @@ static int qcow2_make_empty(BlockDriverState *bs) int step =3D QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size); int l1_clusters, ret =3D 0; =20 - l1_clusters =3D DIV_ROUND_UP(s->l1_size, s->cluster_size / sizeof(uint= 64_t)); + l1_clusters =3D DIV_ROUND_UP(s->l1_size, s->cluster_size / L1E_SIZE); =20 if (s->qcow_version >=3D 3 && !s->snapshots && !s->nb_bitmaps && 3 + l1_clusters <=3D s->refcount_block_size && @@ -4957,7 +4956,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts= , BlockDriverState *in_bs, l2e_size =3D extended_l2 ? L2E_SIZE_EXTENDED : L2E_SIZE_NORMAL; l2_tables =3D DIV_ROUND_UP(virtual_size / cluster_size, cluster_size / l2e_size); - if (l2_tables * sizeof(uint64_t) > QCOW_MAX_L1_SIZE) { + if (l2_tables * L1E_SIZE > QCOW_MAX_L1_SIZE) { error_setg(&local_err, "The image size is too large " "(try using a larger cluster size)"); goto err; --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167226; cv=none; d=zohomail.com; s=zohoarc; b=Nnvat/SHTcsi81MDIb2ilw7dq3D8ja8dVKqoyNmK2I7FrCiJZirSGA+E0iDSbdBCHdF3cykBCzc41Al6oFKKuoCYwFMs68e8rCcePBMHpGWbLkqmrVbbJsLe0PpNd0o++vsCHuBfkoESliyOtDVB7eSPtNXwZZbQQ+bRpXBsr0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167226; h=Content-Type: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; bh=W4TlSJjMROfvhgotRhNIJHzLDa6dGxPD7XOQl1qmuGs=; b=PGF0Y9Z/hcr+UNymfdCozh5xCnbDsG0SJJGqm27P2n/1qI995nyjEafqieneGVhoZX6AWACWIO84tV3ve3j1ZUcz/8vbUkjZD+UQjt3ZrNmX4ghDYZzaKihnS4aDxabPN0WuteWmca2sKxsyoTEXCzLUzRL4sde2iyVcvwTWYo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167226029250.45632647550485; Tue, 15 Sep 2020 03:53:46 -0700 (PDT) Received: from localhost ([::1]:60672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8am-00023z-Jw for importer@patchew.org; Tue, 15 Sep 2020 06:53:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UG-0000Yp-6k for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UC-0004Yh-2j for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-KbDM-RJfPYSLehqqwpTzbw-1; Tue, 15 Sep 2020 06:46:51 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00BF81084D62; Tue, 15 Sep 2020 10:46:50 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AD0E2C31E; Tue, 15 Sep 2020 10:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W4TlSJjMROfvhgotRhNIJHzLDa6dGxPD7XOQl1qmuGs=; b=h1R1tiW2rffjnBtOnLv1EGX/VatBEZvghnJl3nJhz802eHUxMk/biV1Kot5QPRAt6FiRRG fyq9c4V7/QuaPO8492hqe0BIL++37re0k+6n0NMNoV07Qii1hi+JlVIpjiRpUiSBkYMMtg Ethd+9B5VG1Po+CioNgvVwRbAWxVg5I= X-MC-Unique: KbDM-RJfPYSLehqqwpTzbw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 09/22] qcow2: Fix removal of list members from BDRVQcow2State.cluster_allocs Date: Tue, 15 Sep 2020 12:46:14 +0200 Message-Id: <20200915104627.699552-10-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:23:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia When a write request needs to allocate new clusters (or change the L2 bitmap of existing ones) a QCowL2Meta structure is created so the L2 metadata can be later updated and any copy-on-write can be performed if necessary. A write request can span a region consisting of an arbitrary combination of previously unallocated and allocated clusters, and if the unallocated ones can be put contiguous to the existing ones then QEMU will do so in order to minimize the number of write operations. In practice this means that a write request has not just one but a number of QCowL2Meta structures. All of them are added to the cluster_allocs list that is stored in BDRVQcow2State and is used to detect overlapping requests. After the write request finishes all its associated QCowL2Meta are removed from that list. calculate_l2_meta() takes care of creating and putting those structures in the list, and qcow2_handle_l2meta() takes care of removing them. The problem is that the error path in handle_alloc() also tries to remove an item in that list, a remnant from the time when this was handled there (that code would not even be correct anymore because it only removes one struct and not all the ones from the same write request). This can trigger a double removal of the same item from the list, causing a crash. This is not easy to reproduce in practice because it requires that do_alloc_cluster_offset() fails after a successful previous allocation during the same write request, but it can be reproduced with the included test case. Signed-off-by: Alberto Garcia Message-Id: <3440a1c4d53c4fe48312b478c96accb338cbef7c.1599150873.git.berto@= igalia.com> Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 3 -- tests/qemu-iotests/305 | 74 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/305.out | 16 +++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100755 tests/qemu-iotests/305 create mode 100644 tests/qemu-iotests/305.out diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 4530e5e471..f65ccc5840 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1710,9 +1710,6 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, =20 out: qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); - if (ret < 0 && *m && (*m)->nb_clusters > 0) { - QLIST_REMOVE(*m, next_in_flight); - } return ret; } =20 diff --git a/tests/qemu-iotests/305 b/tests/qemu-iotests/305 new file mode 100755 index 0000000000..768818af4a --- /dev/null +++ b/tests/qemu-iotests/305 @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# +# Test the handling of errors in write requests with multiple allocations +# +# Copyright (C) 2020 Igalia, S.L. +# Author: Alberto Garcia +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dberto@igalia.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux +_unsupported_imgopts cluster_size refcount_bits extended_l2 compat=3D0.10 = data_file + +echo '### Create the image' +_make_test_img -o refcount_bits=3D64,cluster_size=3D1k 1M + +# The reference counts of the clusters for the first 123k of this +# write request are stored in the first refcount block. The last +# cluster (guest offset 123k) is referenced in the second refcount +# block. +echo '### Fill the first refcount block and one data cluster from the seco= nd' +$QEMU_IO -c 'write 0 124k' "$TEST_IMG" | _filter_qemu_io + +echo '### Discard two of the last data clusters, leave one in the middle' +$QEMU_IO -c 'discard 121k 1k' "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c 'discard 123k 1k' "$TEST_IMG" | _filter_qemu_io + +echo '### Corrupt the offset of the second refcount block' +refcount_table_offset=3D$(peek_file_be "$TEST_IMG" 48 8) +poke_file "$TEST_IMG" $(($refcount_table_offset+14)) "\x06" + +# This tries to allocate the two clusters discarded earlier (guest +# offsets 121k and 123k). Their reference counts are in the first and +# second refcount blocks respectively, but only the first one can be +# allocated correctly because the second entry of the refcount table +# is corrupted. +echo '### Try to allocate the discarded clusters again' +$QEMU_IO -c 'write 121k 3k' "$TEST_IMG" | _filter_qemu_io + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/305.out b/tests/qemu-iotests/305.out new file mode 100644 index 0000000000..538019e726 --- /dev/null +++ b/tests/qemu-iotests/305.out @@ -0,0 +1,16 @@ +QA output created by 305 +### Create the image +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 +### Fill the first refcount block and one data cluster from the second +wrote 126976/126976 bytes at offset 0 +124 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +### Discard two of the last data clusters, leave one in the middle +discard 1024/1024 bytes at offset 123904 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +discard 1024/1024 bytes at offset 125952 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +### Corrupt the offset of the second refcount block +### Try to allocate the discarded clusters again +qcow2: Marking image as corrupt: Refblock offset 0x20600 unaligned (reftab= le index: 0x1); further corruption events will be suppressed +write failed: Input/output error +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 5cad015231..ff59cfd2d4 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -313,3 +313,4 @@ 302 quick 303 rw quick 304 rw quick +305 rw quick --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167592; cv=none; d=zohomail.com; s=zohoarc; b=Lrshd6DGSmaryyMisYR0k0yAgDtLo1VprriUJMQBbfCOWUiZnyprCnUG+g3eVpLfwIIIWdX8oOh/FodHA+BVygEmviEk+yZ2I6GMcM3j6M4ozgeJoVUmc6a/x2VbqkGqupGn0yfz1/+fxZ+IgVUPtx3OFrWWwm7sc0WIKAfHafM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167592; h=Content-Type: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; bh=v7xfZqXP8N2Iw5FMG+YtAL5uE/6BoA1G9Am5lWixxdU=; b=Oobgzg34+PUA0RQgMMeAxunzat0LHW9ViRcaUJ/VexEp6mNI0DelUv1KoFO1v/YoUi3XnhvS+GxDTpQkOqi3wy9/PnL2xVqW/kjIHbeBVwYrvtSfzxR9YxdbIeX6qnZ/eG9zABVFvIzwNeEJ9wfwRucd2PyUDuWMMf3qpBSGTno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 160016759242421.133259156322197; Tue, 15 Sep 2020 03:59:52 -0700 (PDT) Received: from localhost ([::1]:55246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8gh-0003FC-DJ for importer@patchew.org; Tue, 15 Sep 2020 06:59:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UF-0000XN-K5 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UE-0004Zy-54 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:46:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-JDNvuE19MSmxr-JV4LNxRA-1; Tue, 15 Sep 2020 06:46:53 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BE0A801ADF; Tue, 15 Sep 2020 10:46:52 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D032B19C4F; Tue, 15 Sep 2020 10:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v7xfZqXP8N2Iw5FMG+YtAL5uE/6BoA1G9Am5lWixxdU=; b=NAcJ78Sp2tYqgNCyvufZKssEyGbJNXpzjUHJGzcHv9gtAFhR8tNJHspkHVTjVu2ll+ioM9 EUh6/spzWJj/ZIE3CzcyM83ss8jNfTglDhsXMIITmJDdd3TtnjBrYiOEwSy2j61QUQckgR Yqv4UYwv3i1UmMRAGyMM216tZp2q5KI= X-MC-Unique: JDNvuE19MSmxr-JV4LNxRA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 10/22] qcow2: Don't check nb_clusters when removing l2meta from the list Date: Tue, 15 Sep 2020 12:46:15 +0200 Message-Id: <20200915104627.699552-11-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:10:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia In the past, when a new cluster was allocated the l2meta structure was a variable in the stack so it was necessary to have a way to tell whether it had been initialized and contained valid data or not. The nb_clusters field was used for this purpose. Since commit f50f88b9fe this is no longer the case, l2meta (nowadays a pointer to a list) is only allocated when needed and nb_clusters is guaranteed to be > 0 so this check is unnecessary. Signed-off-by: Alberto Garcia Message-Id: Signed-off-by: Max Reitz --- block/qcow2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ef9a45e82f..3e8114dcf8 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2111,9 +2111,7 @@ static coroutine_fn int qcow2_handle_l2meta(BlockDriv= erState *bs, } =20 /* Take the request off the list of running requests */ - if (l2meta->nb_clusters !=3D 0) { - QLIST_REMOVE(l2meta, next_in_flight); - } + QLIST_REMOVE(l2meta, next_in_flight); =20 qemu_co_queue_restart_all(&l2meta->dependent_requests); =20 --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167366; cv=none; d=zohomail.com; s=zohoarc; b=YdozhnFitbxLFZ33NafjbAtkDz1Fw/p/u//C2CvCIkGmszE6zD3Q0The3LZxpRZD2dO97WZ2mwO6UaXrcIIpofCiwN3WVCReO6RoKSOpiZj164RDd+kYiEelW4c20Sb2Rn2+8kOT85MqOi3dWXo/qcevWrK67T8bQHugZiPfP4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167366; h=Content-Type: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; bh=qzOm2DmuuR/9Ie19niGExs/IYglc8i+tCED3cG83MII=; b=gflAS6PoJ/Ve0MlZ//yxHijzLPalBIjQlH5MvpiId0ZyHMMGyQVzvwdxDje9QXNccn3mgSDBmiFKcYWMs/PZPyigQkI0ot8dHvt5GgUazeCWNsBvY3LsB/HFRP6Q9WjCLGLeB4G2PK4XSYSf4LrHdjnyTh321gey3pwXxoqgv/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167366104632.172966063881; Tue, 15 Sep 2020 03:56:06 -0700 (PDT) Received: from localhost ([::1]:40436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8d2-0005YH-Ml for importer@patchew.org; Tue, 15 Sep 2020 06:56:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UG-0000Z6-E3 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UE-0004a6-BI for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-cWEZkKQUM2Cx1fclbO2U5Q-1; Tue, 15 Sep 2020 06:46:55 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E9521084D64; Tue, 15 Sep 2020 10:46:54 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0215619C4F; Tue, 15 Sep 2020 10:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qzOm2DmuuR/9Ie19niGExs/IYglc8i+tCED3cG83MII=; b=g1XM8lMAXqSjCK863l1wKEjOWacqFvKZ2uy/rtHFpVJRbdtYZGATaYbDPGYaIDY5btjLFZ moIpleYjQ3IZ6+tmHISpF77OQj/sHtjqsiMp0YXf5VpWJofKx4GwReufIODY6HVaYgAbtd suUHx12mlmgEW5IUgeNjRPRVqu4QAW4= X-MC-Unique: cWEZkKQUM2Cx1fclbO2U5Q-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 11/22] qcow2: Rewrite the documentation of qcow2_alloc_cluster_offset() Date: Tue, 15 Sep 2020 12:46:16 +0200 Message-Id: <20200915104627.699552-12-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:23:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The current text corresponds to an earlier, simpler version of this function and it does not explain how it works now. Signed-off-by: Alberto Garcia Message-Id: Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f65ccc5840..ce1260e746 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1714,18 +1714,22 @@ out: } =20 /* - * alloc_cluster_offset + * For a given area on the virtual disk defined by @offset and @bytes, + * find the corresponding area on the qcow2 image, allocating new + * clusters (or subclusters) if necessary. The result can span a + * combination of allocated and previously unallocated clusters. * - * For a given offset on the virtual disk, find the cluster offset in qcow2 - * file. If the offset is not found, allocate a new cluster. + * On return, @host_offset is set to the beginning of the requested + * area. This area is guaranteed to be contiguous on the qcow2 file + * but it can be smaller than initially requested. In this case @bytes + * is updated with the actual size. * - * If the cluster was already allocated, m->nb_clusters is set to 0 and - * other fields in m are meaningless. - * - * If the cluster is newly allocated, m->nb_clusters is set to the number = of - * contiguous clusters that have been allocated. In this case, the other - * fields of m are valid and contain information about the first allocated - * cluster. + * If any clusters or subclusters were allocated then @m contains a + * list with the information of all the affected regions. Note that + * this can happen regardless of whether this function succeeds or + * not. The caller is responsible for updating the L2 metadata of the + * allocated clusters (on success) or freeing them (on failure), and + * for clearing the contents of @m afterwards in both cases. * * If the request conflicts with another write request in flight, the coro= utine * is queued and will be reentered when the dependency has completed. --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167788; cv=none; d=zohomail.com; s=zohoarc; b=OrBWe5GgWvAocmLTp0d97/eiDpzSCWK2GPiYM6KkqjJ9ETyvptqHRRYTuyQ42rTRW1fO/ROB4wg/lutY5D8RUjzxLH3VOBtUm1BXh83j+ZSDwroSA63B8B5gq+OAp9TCllZXmC9wUNFo1m4u8Zk7iuDOchDehDSMIYmcrPjwjFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167788; h=Content-Type: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; bh=oI+aOJWW59NHhphSZwR0nlNLS5F1Pya2WLuaZoiZpG8=; b=flLThA2lkdaLVt7TCAh+21XZuLoq2b4vX2KSjJ5wUkPV0KTkKI/oTcd/+weyzzc4JT79FpyUF9KNprtcoU57H0v1KZk81ogK86RrKbD3NMJY+k4dxD6YPnQ/lIjcX4s4mq6K5IHDTlbJwkLFJSHAaPbS7h6GN0ZfyHcsDydtQ/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167788350337.75065093300725; Tue, 15 Sep 2020 04:03:08 -0700 (PDT) Received: from localhost ([::1]:60528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8jr-0005dV-KD for importer@patchew.org; Tue, 15 Sep 2020 07:03:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UI-0000dk-ES for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UG-0004bN-Jy for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89--2lLytUaM3mWrM5-YV_R4Q-1; Tue, 15 Sep 2020 06:46:57 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87B40802B70; Tue, 15 Sep 2020 10:46:56 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C1945DC08; Tue, 15 Sep 2020 10:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oI+aOJWW59NHhphSZwR0nlNLS5F1Pya2WLuaZoiZpG8=; b=gpwFI4mnubq412Xo2K3wjWkTc9Eb0v5lxZfQFyN3dY6bxm5vmLnIfsUsmoHKn1FRt+TVwX QWgeZB7KSDMjQCdvGjh4FciAeGEKrTfGKKXWH/cf5Dw2lrqVRW2rx4kOGsUKg+lECwPWZm KZzBZ9ltHsx9mHUuwAbYoxOXedLYq6w= X-MC-Unique: -2lLytUaM3mWrM5-YV_R4Q-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 12/22] qemu-img: Explicit number replaced by a constant Date: Tue, 15 Sep 2020 12:46:17 +0200 Message-Id: <20200915104627.699552-13-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:10:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yi Li Signed-off-by: Yi Li Message-Id: <20200819013607.32280-1-yili@winhong.com> Reviewed-by: Alberto Garcia Reviewed-by: Stefano Garzarella Signed-off-by: Max Reitz --- qemu-img.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 37365d06fa..1d8c5cd778 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1201,10 +1201,10 @@ static int is_allocated_sectors(const uint8_t *buf,= int n, int *pnum, *pnum =3D 0; return 0; } - is_zero =3D buffer_is_zero(buf, 512); + is_zero =3D buffer_is_zero(buf, BDRV_SECTOR_SIZE); for(i =3D 1; i < n; i++) { - buf +=3D 512; - if (is_zero !=3D buffer_is_zero(buf, 512)) { + buf +=3D BDRV_SECTOR_SIZE; + if (is_zero !=3D buffer_is_zero(buf, BDRV_SECTOR_SIZE)) { break; } } @@ -2513,8 +2513,8 @@ static int img_convert(int argc, char **argv) } } =20 - qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s.total_sectors * 512, - &error_abort); + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, + s.total_sectors * BDRV_SECTOR_SIZE, &error_abo= rt); ret =3D add_old_style_options(out_fmt, opts, out_baseimg, NULL); if (ret < 0) { goto out; --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167509; cv=none; d=zohomail.com; s=zohoarc; b=RemmCqZ9AyVGRvXIa10xlOP5mcRbouAjgWyoBlKlh+hBr/PPkBBZtO8hF1KhUECTvgmfTG6KzpCMDOk+rDTho5+j5+q+UTYnuYKkL3r3sXREGegcwTTSYAIQmhKWLtSOSV/VnRxc/53hsakQkwYlauY1vABf3YH2opCUo3Aaw0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167509; h=Content-Type: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; bh=MBds4CXxGE46H6Itn3fmDY2ijfb8SIWiB0usBs4CUhE=; b=n74hOQGdMmKeG1ZzZd8r6Y9WTJxrNCCJtOqFaGrghwemEB4H1Ty5nvfuBG7NGtD5VfdWJj4oQU0erOH4XxXp2e+0oqk+KjfJmOdKPIKB7UmPg1jdHvcuC2lPOFdTSk7I7gFBqyFiXCMwAmpX3+bd6FDGDs04n7Z2usbSltebDjI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167509854104.0527154724681; Tue, 15 Sep 2020 03:58:29 -0700 (PDT) Received: from localhost ([::1]:49100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8fM-0000l5-Nt for importer@patchew.org; Tue, 15 Sep 2020 06:58:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UL-0000nS-My for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UI-0004cH-Ke for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-NbXYX8woNGmUD7-8WhxZkw-1; Tue, 15 Sep 2020 06:46:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1AF264089; Tue, 15 Sep 2020 10:46:58 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5136A7B7B7; Tue, 15 Sep 2020 10:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MBds4CXxGE46H6Itn3fmDY2ijfb8SIWiB0usBs4CUhE=; b=Aai7d3FtzmUSN4MWMZjFRJnQcUZO8BJaGIKo9FjwcfSsyvSa9fm0wq966cWReps32xjP/2 QY50A0uFnjc3FRILI2KSipBeHLDGbfRIgkaSlJ0PG7RjX20CNIN3W05E/60f3sTR/BY2DM uB1JE00jjwhDSfaPWA+BTteTik7dUYE= X-MC-Unique: NbXYX8woNGmUD7-8WhxZkw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 13/22] iotests: Skip test_stream_parallel in test 030 when doing "make check" Date: Tue, 15 Sep 2020 12:46:18 +0200 Message-Id: <20200915104627.699552-14-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:23:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Thomas Huth The test_stream_parallel test still occasionally fails in the CI. Thus let's disable it during "make check" for now so that it does not cause trouble during merge tests. We can enable it again once the problem has been resolved. Signed-off-by: Thomas Huth Message-Id: <20200907113824.134788-1-thuth@redhat.com> Signed-off-by: Max Reitz --- tests/check-block.sh | 3 +++ tests/qemu-iotests/030 | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/check-block.sh b/tests/check-block.sh index 8e29c868e5..a5a69060e1 100755 --- a/tests/check-block.sh +++ b/tests/check-block.sh @@ -55,6 +55,9 @@ fi =20 cd tests/qemu-iotests =20 +# QEMU_CHECK_BLOCK_AUTO is used to disable some unstable sub-tests +export QEMU_CHECK_BLOCK_AUTO=3D1 + ret=3D0 for fmt in $format_list ; do ./check -makecheck -$fmt $group || ret=3D1 diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 31c028306b..dcb4b5d6a6 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -21,6 +21,7 @@ import time import os import iotests +import unittest from iotests import qemu_img, qemu_io =20 backing_img =3D os.path.join(iotests.test_dir, 'backing.img') @@ -228,6 +229,7 @@ class TestParallelOps(iotests.QMPTestCase): =20 # Test that it's possible to run several block-stream operations # in parallel in the same snapshot chain + @unittest.skipIf(os.environ.get('QEMU_CHECK_BLOCK_AUTO'), 'disabled in= CI') def test_stream_parallel(self): self.assert_no_active_block_jobs() =20 --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167188; cv=none; d=zohomail.com; s=zohoarc; b=bi08RO/Kzv9WbgzsRResK/jYv01mPmDvjByo4ma5H3gWDnn+shZ6KJS7hoEn86LAz4JF6KQYqowI9TAeWHlzfXc7FjFhnK8omipH9WrQ0Cd+ETKCupyYDCGM7RnephmXL4SVX0fHZiUIZETzgNEwcCU3MU04FHwCheY2PdqJuW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167188; h=Content-Type: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; bh=HQvHNhVhnCk7Lx3ZLs/jlIsfMx16dmhaV5cJAS4ylNw=; b=XXGf9ZE+sNyVK4fCxZ9vyuuRjGSIl52zg2hXd1PC5LDHD+R7U2Oe1xbOdbpf4VSkvW7HPZKiBgB7f5MiHRb/CiX9ACsOH3p+x3QJ0dk0i1rNaMg1yp1siYOah8udE1kGgfoLJ6AtlZqLvD37vFYOiosndxuXpBiRkirbI5KMl1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167188061120.65580442233761; Tue, 15 Sep 2020 03:53:08 -0700 (PDT) Received: from localhost ([::1]:57704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8aA-0000qp-Py for importer@patchew.org; Tue, 15 Sep 2020 06:53:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UN-0000rO-94 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:07 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:54755 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UL-0004ck-0u for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-DFUVZkRpNmGP84x8iMZy9A-1; Tue, 15 Sep 2020 06:47:02 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA0381084D62; Tue, 15 Sep 2020 10:47:00 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CD2160BE2; Tue, 15 Sep 2020 10:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQvHNhVhnCk7Lx3ZLs/jlIsfMx16dmhaV5cJAS4ylNw=; b=MNYND29QqbM17ybdki8CkkYs/i/RIQY5t5pQ9I0QAnI6XRsYG1RlBaU6FOR/C22+stBxkF vJL5Hv3ARZVBsdL6EZrJTbdyjDEVGwfble0iZnWghsHRXiwZgem6UY6wMHwTH807NYs4fW 2IJ4vXl/j8DzYlskBvJn3SJBRvP63VM= X-MC-Unique: DFUVZkRpNmGP84x8iMZy9A-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 14/22] block/vhdx: Support vhdx image only with 512 bytes logical sector size Date: Tue, 15 Sep 2020 12:46:19 +0200 Message-Id: <20200915104627.699552-15-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 05:35:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Swapnil Ingle block/vhdx uses qemu block layer where sector size is always 512 bytes. This may have issues with 4K logical sector sized vhdx image. For e.g qemu-img convert on such images fails with following assert: $qemu-img convert -f vhdx -O raw 4KTest1.vhdx test.raw qemu-img: util/iov.c:388: qiov_slice: Assertion `offset + len <=3D qiov->size' failed. Aborted This patch adds an check to return ENOTSUP for vhdx images which have logical sector size other than 512 bytes. Signed-off-by: Swapnil Ingle Message-Id: <1596794594-44531-1-git-send-email-swapnil.ingle@nutanix.com> Signed-off-by: Max Reitz --- block/vhdx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index 791eb90263..356ec4c455 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -816,9 +816,9 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD= RVVHDXState *s) goto exit; } =20 - /* only 2 supported sector sizes */ - if (s->logical_sector_size !=3D 512 && s->logical_sector_size !=3D 409= 6) { - ret =3D -EINVAL; + /* Currently we only support 512 */ + if (s->logical_sector_size !=3D 512) { + ret =3D -ENOTSUP; goto exit; } =20 --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167929; cv=none; d=zohomail.com; s=zohoarc; b=O+q1SDmPwp1u+l+pFbRX1oowoYW1aOqXi/Epc22uPwpDiT6xTOz6naOgyw/xaH3Br8j+GQ3gjJ8Mqrb6rbuayCzasK/mUh8uCA6lWlVaFrlZf1IlY9jQnjjVFETxu/R7U+vw6UtOVgPAuu7wogYsFH2Q5A7FiFgYSUaGSBfvt4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167929; h=Content-Type: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; bh=rSgvq6swWaOeoMm7noo48t3BlK9H+HlOXThylQ/P9wg=; b=L61/O5+S6GghGmkuwFZoCoyR9Q5CTB3Pg8nlWptY+dQdaiNGWDgKPbBv4WQSFkwhIPufqumCyJzKv/oGMa64+4KIXij1IpBDte/CRZ3dt4rfvlPUALEvXKVcyzqAGPVmEkmZV+pKZGQTr7pwXEzvUgIWFg7MVUhHqV9VpzJPMCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167929384727.9540209513789; Tue, 15 Sep 2020 04:05:29 -0700 (PDT) Received: from localhost ([::1]:38174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8m8-00089X-MD for importer@patchew.org; Tue, 15 Sep 2020 07:05:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UO-0000tA-O0 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:08 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23919 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UM-0004dB-VL for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-k3N2VNm1NEyosckPjGS5BA-1; Tue, 15 Sep 2020 06:47:04 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F0AB801AC2; Tue, 15 Sep 2020 10:47:03 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADF0610021AA; Tue, 15 Sep 2020 10:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rSgvq6swWaOeoMm7noo48t3BlK9H+HlOXThylQ/P9wg=; b=SS637634MTSgrxtT/07G2mNuM6vjZTMKmQZEW7aEJXtncdq8vl3YxmeoLzz0cKpm8beViL BpVtkDzNkEVkDMnEoc+Tct3pe+gza3Lz7IN6XNIitZ13FRcNEiIOV1PrfqOrK8TBXpbu/C 9OBP1NaLI5ZB+TZ8msm6YTSQCxEraBI= X-MC-Unique: k3N2VNm1NEyosckPjGS5BA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 15/22] qcow2: Handle QCowL2Meta on error in preallocate_co() Date: Tue, 15 Sep 2020 12:46:20 +0200 Message-Id: <20200915104627.699552-16-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia If qcow2_alloc_cluster_offset() or qcow2_alloc_cluster_link_l2() fail then this function simply returns the error code, potentially leaking the QCowL2Meta structure and leaving stale items in s->cluster_allocs. A second problem is that this function calls qcow2_free_any_clusters() on failure but passing a host cluster offset instead of an L2 entry. Luckily for normal uncompressed clusters a raw offset also works like a valid L2 entry so it works just the same, but we should be using qcow2_free_clusters() instead. This patch fixes both problems by using qcow2_handle_l2meta(). Signed-off-by: Alberto Garcia Message-Id: Reviewed-by: Kevin Wolf Signed-off-by: Max Reitz --- block/qcow2.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 3e8114dcf8..d241fb734c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2101,7 +2101,6 @@ static coroutine_fn int qcow2_handle_l2meta(BlockDriv= erState *bs, QCowL2Meta *next; =20 if (link_l2) { - assert(!l2meta->prealloc); ret =3D qcow2_alloc_cluster_link_l2(bs, l2meta); if (ret) { goto out; @@ -3123,7 +3122,7 @@ static int coroutine_fn preallocate_co(BlockDriverSta= te *bs, uint64_t offset, int64_t file_length; unsigned int cur_bytes; int ret; - QCowL2Meta *meta; + QCowL2Meta *meta =3D NULL, *m; =20 assert(offset <=3D new_length); bytes =3D new_length - offset; @@ -3134,27 +3133,17 @@ static int coroutine_fn preallocate_co(BlockDriverS= tate *bs, uint64_t offset, &host_offset, &meta); if (ret < 0) { error_setg_errno(errp, -ret, "Allocating clusters failed"); - return ret; + goto out; } =20 - while (meta) { - QCowL2Meta *next =3D meta->next; - meta->prealloc =3D true; - - ret =3D qcow2_alloc_cluster_link_l2(bs, meta); - if (ret < 0) { - error_setg_errno(errp, -ret, "Mapping clusters failed"); - qcow2_free_any_clusters(bs, meta->alloc_offset, - meta->nb_clusters, QCOW2_DISCARD_N= EVER); - return ret; - } - - /* There are no dependent requests, but we need to remove our - * request from the list of in-flight requests */ - QLIST_REMOVE(meta, next_in_flight); + for (m =3D meta; m !=3D NULL; m =3D m->next) { + m->prealloc =3D true; + } =20 - g_free(meta); - meta =3D next; + ret =3D qcow2_handle_l2meta(bs, &meta, true); + if (ret < 0) { + error_setg_errno(errp, -ret, "Mapping clusters failed"); + goto out; } =20 /* TODO Preallocate data if requested */ @@ -3171,7 +3160,8 @@ static int coroutine_fn preallocate_co(BlockDriverSta= te *bs, uint64_t offset, file_length =3D bdrv_getlength(s->data_file->bs); if (file_length < 0) { error_setg_errno(errp, -file_length, "Could not get file size"); - return file_length; + ret =3D file_length; + goto out; } =20 if (host_offset + cur_bytes > file_length) { @@ -3181,11 +3171,15 @@ static int coroutine_fn preallocate_co(BlockDriverS= tate *bs, uint64_t offset, ret =3D bdrv_co_truncate(s->data_file, host_offset + cur_bytes, fa= lse, mode, 0, errp); if (ret < 0) { - return ret; + goto out; } } =20 - return 0; + ret =3D 0; + +out: + qcow2_handle_l2meta(bs, &meta, false); + return ret; } =20 /* qcow2_refcount_metadata_size: --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600166939; cv=none; d=zohomail.com; s=zohoarc; b=fNbrNbyTdNJchfc4FWoPgxDMqp6HWwFP6QSy8DhLqeFkggUZAqbfRU0Bnp1NWgY5z7fbmTsl+LQScM+X2tFp+7x7x1httbwdX+5seTPi4qGrqO0g8bvCyJobw9XlyUrq+gRYJq8os1k0OWhy1U2wcibuIK/xWqlqRyM9JhGIvcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600166939; h=Content-Type: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; bh=r7bomLHOqMKUeU1AC9hPJC8dPd2D9Dctugd/c7FolZg=; b=TcvXMeRsgi3qI3BN4ty6SsKeltYhXjc9hW4FF/BkeEcV9FGJ2M+XcOPosQ6pn0SzB/BpnS8y24iUcXxQiCX6FmwSaAXTiNgmwrb3W7PeiE3Dh2s6i4LORQOgwADw0B6aeLqHNgUsvX6+9LARbQK3lC8u2rZjnrFv3JzYOtlIdug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600166939839890.4552319996261; Tue, 15 Sep 2020 03:48:59 -0700 (PDT) Received: from localhost ([::1]:43204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8WA-0003Eb-Ny for importer@patchew.org; Tue, 15 Sep 2020 06:48:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UR-0000vr-9P for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28278 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UP-0004da-GW for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-1bSZL-GsPBK2xlnuVADHRw-1; Tue, 15 Sep 2020 06:47:06 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 682B01005E65; Tue, 15 Sep 2020 10:47:05 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E24D275143; Tue, 15 Sep 2020 10:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r7bomLHOqMKUeU1AC9hPJC8dPd2D9Dctugd/c7FolZg=; b=MioPubEKTGE8WyWUgN3XqF6rd9qdVr2ET7YheDtykgFjlzG8AB2nOjtRnl62PnN3xRpdK6 3G3vRMWK8boje7sjsM4N8cs2TmUY3CXWbvFxW9MElFnyJBxma3wkbo24IbNwYd119FmyE3 /9Db8TxtoVXJv5ufh/2iQHvzj9WGwU4= X-MC-Unique: 1bSZL-GsPBK2xlnuVADHRw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 16/22] qcow2: Make qcow2_free_any_clusters() free only one cluster Date: Tue, 15 Sep 2020 12:46:21 +0200 Message-Id: <20200915104627.699552-17-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:29:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function takes an L2 entry and a number of clusters to free. Although in principle it can free any type of cluster (using the L2 entry to determine its type) in practice the API is broken because compressed clusters have a variable size and there is no way to free more than one without having the L2 entry of each one of them. The good news all callers are passing nb_clusters=3D1 so we can simply get rid of that parameter. Signed-off-by: Alberto Garcia Message-Id: <77cea0f4616f921d37e971b3c5b18a2faa24b173.1599573989.git.berto@= igalia.com> Reviewed-by: Kevin Wolf Signed-off-by: Max Reitz --- block/qcow2.h | 4 ++-- block/qcow2-cluster.c | 6 +++--- block/qcow2-refcount.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 83cfa0c391..b73a4cf1f8 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -861,8 +861,8 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int siz= e); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, enum qcow2_discard_type type); -void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, - int nb_clusters, enum qcow2_discard_type type= ); +void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry, + enum qcow2_discard_type type); =20 int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ce1260e746..1a67b2d928 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1096,7 +1096,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) */ if (!m->keep_old_clusters && j !=3D 0) { for (i =3D 0; i < j; i++) { - qcow2_free_any_clusters(bs, old_cluster[i], 1, QCOW2_DISCARD_N= EVER); + qcow2_free_any_cluster(bs, old_cluster[i], QCOW2_DISCARD_NEVER= ); } } =20 @@ -1913,7 +1913,7 @@ static int discard_in_l2_slice(BlockDriverState *bs, = uint64_t offset, set_l2_bitmap(s, l2_slice, l2_index + i, new_l2_bitmap); } /* Then decrease the refcount */ - qcow2_free_any_clusters(bs, old_l2_entry, 1, type); + qcow2_free_any_cluster(bs, old_l2_entry, type); } =20 qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); @@ -2005,7 +2005,7 @@ static int zero_in_l2_slice(BlockDriverState *bs, uin= t64_t offset, =20 qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (unmap) { - qcow2_free_any_clusters(bs, old_l2_entry, 1, QCOW2_DISCARD_REQ= UEST); + qcow2_free_any_cluster(bs, old_l2_entry, QCOW2_DISCARD_REQUEST= ); } set_l2_entry(s, l2_slice, l2_index + i, new_l2_entry); if (has_subclusters(s)) { diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 51e9778ed8..8e649b008e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1157,8 +1157,8 @@ void qcow2_free_clusters(BlockDriverState *bs, * Free a cluster using its L2 entry (handles clusters of all types, e.g. * normal cluster, compressed cluster, etc.) */ -void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, - int nb_clusters, enum qcow2_discard_type type) +void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry, + enum qcow2_discard_type type) { BDRVQcow2State *s =3D bs->opaque; QCow2ClusterType ctype =3D qcow2_get_cluster_type(bs, l2_entry); @@ -1169,7 +1169,7 @@ void qcow2_free_any_clusters(BlockDriverState *bs, ui= nt64_t l2_entry, ctype =3D=3D QCOW2_CLUSTER_ZERO_ALLOC)) { bdrv_pdiscard(s->data_file, l2_entry & L2E_OFFSET_MASK, - nb_clusters << s->cluster_bits); + s->cluster_size); } return; } @@ -1192,7 +1192,7 @@ void qcow2_free_any_clusters(BlockDriverState *bs, ui= nt64_t l2_entry, l2_entry & L2E_OFFSET_MASK); } else { qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, - nb_clusters << s->cluster_bits, type); + s->cluster_size, type); } break; case QCOW2_CLUSTER_ZERO_PLAIN: --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167098; cv=none; d=zohomail.com; s=zohoarc; b=YY4cxaTg9ONQt5mxSx2aSmHft8hFNNqoMU1SrQxmckxIpUojfP6nIGcuk1uh6nZlGI2x5AI89Bfk/8mvtsuru/sxNXbnmHJ9BXSZ+30laWp9ezUVh3b2BB6YhsdH5h1/JuIQtCBHYxA02Y9eDOwOfFO/UnSQZ0Z8iYI7jDJTSuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167098; h=Content-Type: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; bh=vAFzHXXrT8JF/Dks55b4/EORu1meOABDFzPrNBEoQpA=; b=MyCwu5fx2+NbLdhmdFM/aM+2MBZjlJWnaG5xVmBRo13C2oPF9/j7+pq5OyOoapbRTpSrH8DZpYRewhoLuxC3U+eb+P7QWmA76oYyqdJId/HfkaYqxG74Vcbg18CWZGVAme0CGCXNZOpxf5blWwsuDXrzDKk7UTswv369gIe6Xvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167098223337.28536444694646; Tue, 15 Sep 2020 03:51:38 -0700 (PDT) Received: from localhost ([::1]:51514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8Yj-0006kj-2o for importer@patchew.org; Tue, 15 Sep 2020 06:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UV-0000xU-EH for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44204 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UR-0004ds-TX for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-7NIwaUBmOmWBbhADiQWO4Q-1; Tue, 15 Sep 2020 06:47:08 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9898F802B72; Tue, 15 Sep 2020 10:47:07 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B18D5DC08; Tue, 15 Sep 2020 10:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vAFzHXXrT8JF/Dks55b4/EORu1meOABDFzPrNBEoQpA=; b=T5loG0xT9zRNkheYTfU5gFwTm1Zr6x7xQidU5dfuBj5jFaYdkot76ljU2uCsMl6iP+ng2i m6/cWduNSATw64C1x2Vmr2MCtR3o94RfMchLL8/dAbfVNjosQ7sX9kMMhNSAyTnGaS1OVt BT5ZCS7rQQtvNEfVfBj3keLpCMLFWhA= X-MC-Unique: 7NIwaUBmOmWBbhADiQWO4Q-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 17/22] qcow2: Return the original error code in qcow2_co_pwrite_zeroes() Date: Tue, 15 Sep 2020 12:46:22 +0200 Message-Id: <20200915104627.699552-18-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:11:06 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alberto Garcia This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk. If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes. If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller. Signed-off-by: Alberto Garcia Message-Id: <20200909123739.719-1-berto@igalia.com> Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Signed-off-by: Max Reitz --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index d241fb734c..77c43ce178 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3907,7 +3907,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, type !=3D QCOW2_SUBCLUSTER_ZERO_PLAIN && type !=3D QCOW2_SUBCLUSTER_ZERO_ALLOC)) { qemu_co_mutex_unlock(&s->lock); - return -ENOTSUP; + return ret < 0 ? ret : -ENOTSUP; } } else { qemu_co_mutex_lock(&s->lock); --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167670; cv=none; d=zohomail.com; s=zohoarc; b=dzaRWMcwIVxhz6kAk7UE0BIY3pb5B5K6ySeqTAgvs6nGsUKV0+ixAxfZhPhdwcmqTvKY9HtL021Du3x4ZDNIQJP0FNfMgR4vBmPVi32EKErg4e1ErKysB7eSuHaww8WqySd40YGePTSKa1dVuoFwTujR8GLNqJ4k8ES8DvMrP+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167670; h=Content-Type: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; bh=O+wlTowVCJpAvfNu8KtauowcUK2/YnTK25EvbZZlnOk=; b=ETUSCGWAaFmPxApnA6zaTHzSf7pwQBIQUKq4g7BfJi8GHDqwrWL+0TcofxUjNWrlrL6Saroeu11UOOkRdynuYN2jxsr8CRqZpEZPFW9SYIJHAZolf+mA2r6odoZzk6ctaqk5kW5chc13RLRMV4iml5PyTgrrRPGVw/YW4VQt8jU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167670708610.3732681342835; Tue, 15 Sep 2020 04:01:10 -0700 (PDT) Received: from localhost ([::1]:56956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8hw-0003vK-26 for importer@patchew.org; Tue, 15 Sep 2020 07:01:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8UX-0000xc-5u for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:17 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51563 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8UU-0004e5-JK for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-Ij26yJLrORm4umYw58rhHg-1; Tue, 15 Sep 2020 06:47:10 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C79FD1005E67; Tue, 15 Sep 2020 10:47:09 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68F8B7EB7C; Tue, 15 Sep 2020 10:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O+wlTowVCJpAvfNu8KtauowcUK2/YnTK25EvbZZlnOk=; b=AXsbUDNzquW/HI9xr2VYhwPquUlWv+hZhDH9t4lDNZu//exxxurLP34rKSW+lnc5zlwjYI 8VG1aSZbWSe3wQixSoOuHWQ87OQY0PPDMwnTmkB2k760Itq7cblM54mGgLVdafdQR2PPoc NEwgoNbbplxWonYMp593DwT4ecj4SNQ= X-MC-Unique: Ij26yJLrORm4umYw58rhHg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 18/22] block/rbd: remove runtime_opts Date: Tue, 15 Sep 2020 12:46:23 +0200 Message-Id: <20200915104627.699552-19-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: John Snow This saw its last use in 4bfb274165ba. Signed-off-by: John Snow Message-Id: <20200806211345.2925343-2-jsnow@redhat.com> Signed-off-by: Max Reitz --- block/rbd.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 688074c64b..171c67e3a0 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -341,48 +341,6 @@ static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs) } } =20 -static QemuOptsList runtime_opts =3D { - .name =3D "rbd", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), - .desc =3D { - { - .name =3D "pool", - .type =3D QEMU_OPT_STRING, - .help =3D "Rados pool name", - }, - { - .name =3D "namespace", - .type =3D QEMU_OPT_STRING, - .help =3D "Rados namespace name in the pool", - }, - { - .name =3D "image", - .type =3D QEMU_OPT_STRING, - .help =3D "Image name in the pool", - }, - { - .name =3D "conf", - .type =3D QEMU_OPT_STRING, - .help =3D "Rados config file location", - }, - { - .name =3D "snapshot", - .type =3D QEMU_OPT_STRING, - .help =3D "Ceph snapshot name", - }, - { - /* maps to 'id' in rados_create() */ - .name =3D "user", - .type =3D QEMU_OPT_STRING, - .help =3D "Rados id name", - }, - /* - * server.* extracted manually, see qemu_rbd_mon_host() - */ - { /* end of list */ } - }, -}; - /* FIXME Deprecate and remove keypairs or make it available in QMP. */ static int qemu_rbd_do_create(BlockdevCreateOptions *options, const char *keypairs, const char *password_s= ecret, --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167231; cv=none; d=zohomail.com; s=zohoarc; b=aDdcaIfOXo8WMCY9o3c2lf1EEONTublZCDUUBDS13rZRxUtDRWfXKUHJh1514nkBDnYq9Sa9XHYOhx3xcRTcZPllt0j4/DfU0kSM571Kuu7hUuvXqjmYFsExDaylbVz0pFOToib+a45/hzLAbVoWX/0W9685LX+7x6MJN/Ll0ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167231; h=Content-Type: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; bh=Q1d7aSDUJFfCbXjMlR1mUnXgVGpiraArPRPgnZfoQOs=; b=FUzDnvtMfbZInubahclVPYi4oNdUO5/NjF915vVYbm6l4rVy3U9iRwn4Y509Z96/sh5XERZ0HehpW2iprtO332b5NLk1ekDbftlPeRTXHZne3gRaLQY8X78Ii0mC1TIQrw1MhLoHqqH6yfg9VHgodyz3aqw8ZNMQmw4Z/cii+Yo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600167231662540.7728051399176; Tue, 15 Sep 2020 03:53:51 -0700 (PDT) Received: from localhost ([::1]:33044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8as-0002JO-9w for importer@patchew.org; Tue, 15 Sep 2020 06:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Uc-00012J-2q for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:22 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:34612 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ua-0004f0-Cf for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-Oa0EyMkQMDOyn8s19hz2tg-1; Tue, 15 Sep 2020 06:47:13 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F042F801AC2; Tue, 15 Sep 2020 10:47:11 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 923D02C31E; Tue, 15 Sep 2020 10:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q1d7aSDUJFfCbXjMlR1mUnXgVGpiraArPRPgnZfoQOs=; b=M/hudjAvTO+kIr5xpCI1U2VJzC+ECF9v8M3tCYnjjVQVGEGQYIDCWne06K4ls+3b0NOn1H xOuawIdJazhvGbwSkj9moW3uitconyTYlW6x39VDzAiBNkiFW9OiEaqVrXGHTJoIQP7WT3 7MYAu24868QSYAqSEF0hfiG48F1L0Oc= X-MC-Unique: Oa0EyMkQMDOyn8s19hz2tg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 19/22] block/qcow: remove runtime opts Date: Tue, 15 Sep 2020 12:46:24 +0200 Message-Id: <20200915104627.699552-20-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: John Snow Introduced by d85f4222b468, These were seemingly never used at all. Signed-off-by: John Snow Message-Id: <20200806211345.2925343-3-jsnow@redhat.com> Signed-off-by: Max Reitz --- block/qcow.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/block/qcow.c b/block/qcow.c index e514a86fe5..f8919a44d1 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -105,15 +105,6 @@ static int qcow_probe(const uint8_t *buf, int buf_size= , const char *filename) return 0; } =20 -static QemuOptsList qcow_runtime_opts =3D { - .name =3D "qcow", - .head =3D QTAILQ_HEAD_INITIALIZER(qcow_runtime_opts.head), - .desc =3D { - BLOCK_CRYPTO_OPT_DEF_QCOW_KEY_SECRET("encrypt."), - { /* end of list */ } - }, -}; - static int qcow_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600168050; cv=none; d=zohomail.com; s=zohoarc; b=oCW09k/L5CJc1POSpNZam3s5gtCneft6BUBeh5/s9csFqfYaQZXta+UnwtqyiG7mcaWRME7MUBnHVyDHVuOvNHq0Eu1XY82dBg/nKwerm1QRsvpX91Uu0+DQcnEpm/frtZ4soAjDIQZlkj65lKdDEJVdILw5ByJUTAPJgfC0Mis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600168050; h=Content-Type: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; bh=vZ/4iXDyh/GClurwSqIb6dMh22LSvdlpa0SHBWTovlY=; b=QSVcj6cl2jpx2Bqdvt70z4WR6bAuA9rzQPkdZm4mgC5OiaMBTn9pXeWLtBfn/WgfSLJ6mFUSJTWV1emA5hjt5U5IUhWaPjIkJFLcmTvbLNLQZGOGS8Vn1t40tq6N1VYF7KSj5Wlc+WZNUJtVVtIFp/aIWCYnUjSOnRYS1OM4vPI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600168050516774.2946667850633; Tue, 15 Sep 2020 04:07:30 -0700 (PDT) Received: from localhost ([::1]:43188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8o4-0001wB-Py for importer@patchew.org; Tue, 15 Sep 2020 07:07:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ud-00013i-At for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54473 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ua-0004ey-Cg for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-srlLcSfRNpyb_PyYXah7-A-1; Tue, 15 Sep 2020 06:47:15 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A8601084D69; Tue, 15 Sep 2020 10:47:14 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC9B35DC1E; Tue, 15 Sep 2020 10:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZ/4iXDyh/GClurwSqIb6dMh22LSvdlpa0SHBWTovlY=; b=JV+29TZf2oMuWpXDyyXLTNhQ2e01ZVFlbD/7WVhxoRNc37JJdRK72x31OXKZ3thnHxnFuW o10kSSjrjmTUPisjhXwjZHcMYbCJabjFItt3m4W2GLXH09kxf9PIJJ5Tg1S/aycBRMaUUo 3pZpziF2eiiXWdQ5CnuMRWqQ4uc9Iw8= X-MC-Unique: srlLcSfRNpyb_PyYXah7-A-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 20/22] qcow2: Make preallocate_co() resize the image to the correct size Date: Tue, 15 Sep 2020 12:46:25 +0200 Message-Id: <20200915104627.699552-21-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 02:11:06 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function preallocates metadata structures and then extends the image to its new size, but that new size calculation is wrong because it doesn't take into account that the host_offset variable is always cluster-aligned. This problem can be reproduced with preallocation=3Dmetadata when the original size is not cluster-aligned but the new size is. In this case the final image size will be shorter than expected. qemu-img create -f qcow2 img.qcow2 31k qemu-img resize --preallocation=3Dmetadata img.qcow2 128k Signed-off-by: Alberto Garcia Message-Id: Reviewed-by: Max Reitz [mreitz: Mark compat=3D0.10 unsupported for iotest 125] Signed-off-by: Max Reitz --- block/qcow2.c | 1 + tests/qemu-iotests/125 | 44 ++++++++++++++++++++++---------------- tests/qemu-iotests/125.out | 28 ++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 77c43ce178..1cb5daf39a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3135,6 +3135,7 @@ static int coroutine_fn preallocate_co(BlockDriverSta= te *bs, uint64_t offset, error_setg_errno(errp, -ret, "Allocating clusters failed"); goto out; } + host_offset +=3D offset_into_cluster(s, offset); =20 for (m =3D meta; m !=3D NULL; m =3D m->next) { m->prealloc =3D true; diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125 index 7cb1c19730..5720e86dce 100755 --- a/tests/qemu-iotests/125 +++ b/tests/qemu-iotests/125 @@ -43,6 +43,10 @@ get_image_size_on_host() =20 _supported_fmt qcow2 _supported_proto file +# Growing a file with a backing file (without preallocation=3Dfull or +# =3Dfalloc) requires zeroing the newly added area, which is impossible +# to do quickly for v2 images, and hence is unsupported. +_unsupported_imgopts 'compat=3D0.10' =20 if [ -z "$TEST_IMG_FILE" ]; then TEST_IMG_FILE=3D$TEST_IMG @@ -168,24 +172,28 @@ done $QEMU_IMG create -f raw "$TEST_IMG.base" 128k | _filter_img_create $QEMU_IO -c 'write -q -P 1 0 128k' -f raw "$TEST_IMG.base" for orig_size in 31k 33k; do - echo "--- Resizing image from $orig_size to 96k ---" - _make_test_img -F raw -b "$TEST_IMG.base" -o cluster_size=3D64k "$orig= _size" - $QEMU_IMG resize -f "$IMGFMT" --preallocation=3Dfull "$TEST_IMG" 96k - # The first part of the image should contain data from the backing file - $QEMU_IO -c "read -q -P 1 0 ${orig_size}" "$TEST_IMG" - # The resized part of the image should contain zeroes - $QEMU_IO -c "read -q -P 0 ${orig_size} 63k" "$TEST_IMG" - # If the image does not have an external data file we can also verify = its - # actual size. The resized image should have 7 clusters: - # header, L1 table, L2 table, refcount table, refcount block, 2 data c= lusters - if ! _get_data_file "$TEST_IMG" > /dev/null; then - expected_file_length=3D$((65536 * 7)) - file_length=3D$(stat -c '%s' "$TEST_IMG_FILE") - if [ "$file_length" !=3D "$expected_file_length" ]; then - echo "ERROR: file length $file_length (expected $expected_file= _length)" - fi - fi - echo + for dst_size in 96k 128k; do + for prealloc in metadata full; do + echo "--- Resizing image from $orig_size to $dst_size (preallo= cation=3D$prealloc) ---" + _make_test_img -F raw -b "$TEST_IMG.base" -o cluster_size=3D64= k "$orig_size" + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D"$prealloc" "$= TEST_IMG" "$dst_size" + # The first part of the image should contain data from the bac= king file + $QEMU_IO -c "read -q -P 1 0 ${orig_size}" "$TEST_IMG" + # The resized part of the image should contain zeroes + $QEMU_IO -c "read -q -P 0 ${orig_size} 63k" "$TEST_IMG" + # If the image does not have an external data file we can also= verify its + # actual size. The resized image should have 7 clusters: + # header, L1 table, L2 table, refcount table, refcount block, = 2 data clusters + if ! _get_data_file "$TEST_IMG" > /dev/null; then + expected_file_length=3D$((65536 * 7)) + file_length=3D$(stat -c '%s' "$TEST_IMG_FILE") + if [ "$file_length" !=3D "$expected_file_length" ]; then + echo "ERROR: file length $file_length (expected $expec= ted_file_length)" + fi + fi + echo + done + done done =20 # success, all done diff --git a/tests/qemu-iotests/125.out b/tests/qemu-iotests/125.out index 7f76f7af20..63a6e9e8a9 100644 --- a/tests/qemu-iotests/125.out +++ b/tests/qemu-iotests/125.out @@ -768,11 +768,35 @@ wrote 81920/81920 bytes at offset 2048000 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3Draw size=3D131072 ---- Resizing image from 31k to 96k --- +--- Resizing image from 31k to 96k (preallocation=3Dmetadata) --- Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D31744 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw Image resized. =20 ---- Resizing image from 33k to 96k --- +--- Resizing image from 31k to 96k (preallocation=3Dfull) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D31744 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 31k to 128k (preallocation=3Dmetadata) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D31744 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 31k to 128k (preallocation=3Dfull) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D31744 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 33k to 96k (preallocation=3Dmetadata) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33792 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 33k to 96k (preallocation=3Dfull) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33792 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 33k to 128k (preallocation=3Dmetadata) --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33792 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw +Image resized. + +--- Resizing image from 33k to 128k (preallocation=3Dfull) --- Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33792 backing_file=3DT= EST_DIR/t.IMGFMT.base backing_fmt=3Draw Image resized. =20 --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600167832; cv=none; d=zohomail.com; s=zohoarc; b=cxU25lRiuuJwsB1UNWcV7W81cHCg6VdXHJYUAXtH5kovrMR6JEg9dlxEIbkA+Ar+iwwMIfiFxzPjUBHRNi4QNhLVUkOqSqW33SAwW1C2Qtg7AnaBQcFEggbYwQPA8QGmuO+g/mNU0dyndJ+Tu3i0jm6WyhkyxEqbj7eaQJfNmY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600167832; h=Content-Type: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; bh=AdKmknnugHxI0CH7khxlUbe/K2/sscGCveI8C0uvRGw=; b=CWX9ZtU/4R8pIRgW6W7Zfi4lDpFcC6qAM9Suhb26/DMOwQbrA8+x0OlnUkGPiLxclsIezqiPFJoSbb+NGk3/eUnzKIDikXHpr/97Vxb0UpIp8JifekkMjTPAIRAFLrcOkU8PcGL+ZNT2J9g3lFRw8dEuMrdfXXwqrNGcrbW6gwM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 16001678324671018.3258067876385; Tue, 15 Sep 2020 04:03:52 -0700 (PDT) Received: from localhost ([::1]:33748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8kZ-0006Fc-M4 for importer@patchew.org; Tue, 15 Sep 2020 07:03:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Uc-00012s-L2 for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:22 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42863 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ua-0004f7-Ep for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-pHoh_n4HMeqca-yE0Ym4MQ-1; Tue, 15 Sep 2020 06:47:17 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87599802B72; Tue, 15 Sep 2020 10:47:16 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 051FC60BE2; Tue, 15 Sep 2020 10:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AdKmknnugHxI0CH7khxlUbe/K2/sscGCveI8C0uvRGw=; b=BZXS8NrhKq16zRN80dLNBhuZeLM2VjntT0Z8+57DDrPkLhaqpn9El1ADY7Fq2JyViL0vcH ukaUBTT1qowV4rtJvrvo+miUzal5cHVaRx73H4zQahA1eUaDD1J56e4sv+RB5hHzMoKIm6 QVH8xtJ3QvYNcg1zDcgHyG2VOSq/mYk= X-MC-Unique: pHoh_n4HMeqca-yE0Ym4MQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 21/22] qcow2: Convert qcow2_alloc_cluster_offset() into qcow2_alloc_host_offset() Date: Tue, 15 Sep 2020 12:46:26 +0200 Message-Id: <20200915104627.699552-22-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia qcow2_alloc_cluster_offset() takes an (unaligned) guest offset and returns the (aligned) offset of the corresponding cluster in the qcow2 image. In practice none of the callers need to know where the cluster starts so this patch makes the function calculate and return the final host offset directly. The function is also renamed accordingly. See 388e581615 for a similar change to qcow2_get_cluster_offset(). Signed-off-by: Alberto Garcia Message-Id: <9bfef50ec9200d752413be4fc2aeb22a28378817.1599833007.git.berto@= igalia.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2.h | 6 +++--- block/qcow2-cluster.c | 14 ++++++++++---- block/qcow2.c | 36 +++++++++++++----------------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index b73a4cf1f8..b71e444fca 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -901,9 +901,9 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t se= ctor_num, int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, QCow2SubclusterType *subcluster_type); -int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, - unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m); +int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, + unsigned int *bytes, uint64_t *host_offset, + QCowL2Meta **m); int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size, diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 1a67b2d928..9acc6ce4ae 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1719,6 +1719,10 @@ out: * clusters (or subclusters) if necessary. The result can span a * combination of allocated and previously unallocated clusters. * + * Note that offset may not be cluster aligned. In this case, the returned + * *host_offset points to exact byte referenced by offset and therefore + * isn't cluster aligned as well. + * * On return, @host_offset is set to the beginning of the requested * area. This area is guaranteed to be contiguous on the qcow2 file * but it can be smaller than initially requested. In this case @bytes @@ -1736,9 +1740,9 @@ out: * * Return 0 on success and -errno in error cases */ -int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, - unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m) +int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, + unsigned int *bytes, uint64_t *host_offset, + QCowL2Meta **m) { BDRVQcow2State *s =3D bs->opaque; uint64_t start, remaining; @@ -1759,7 +1763,7 @@ again: while (true) { =20 if (*host_offset =3D=3D INV_OFFSET && cluster_offset !=3D INV_OFFS= ET) { - *host_offset =3D start_of_cluster(s, cluster_offset); + *host_offset =3D cluster_offset; } =20 assert(remaining >=3D cur_bytes); @@ -1842,6 +1846,8 @@ again: *bytes -=3D remaining; assert(*bytes > 0); assert(*host_offset !=3D INV_OFFSET); + assert(offset_into_cluster(s, *host_offset) =3D=3D + offset_into_cluster(s, offset)); =20 return 0; } diff --git a/block/qcow2.c b/block/qcow2.c index 1cb5daf39a..b05512718c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2559,7 +2559,7 @@ static coroutine_fn int qcow2_co_pwritev_part( int offset_in_cluster; int ret; unsigned int cur_bytes; /* number of sectors in current iteration */ - uint64_t cluster_offset; + uint64_t host_offset; QCowL2Meta *l2meta =3D NULL; AioTaskPool *aio =3D NULL; =20 @@ -2580,16 +2580,13 @@ static coroutine_fn int qcow2_co_pwritev_part( =20 qemu_co_mutex_lock(&s->lock); =20 - ret =3D qcow2_alloc_cluster_offset(bs, offset, &cur_bytes, - &cluster_offset, &l2meta); + ret =3D qcow2_alloc_host_offset(bs, offset, &cur_bytes, + &host_offset, &l2meta); if (ret < 0) { goto out_locked; } =20 - assert(offset_into_cluster(s, cluster_offset) =3D=3D 0); - - ret =3D qcow2_pre_write_overlap_check(bs, 0, - cluster_offset + offset_in_clu= ster, + ret =3D qcow2_pre_write_overlap_check(bs, 0, host_offset, cur_bytes, true); if (ret < 0) { goto out_locked; @@ -2601,7 +2598,7 @@ static coroutine_fn int qcow2_co_pwritev_part( aio =3D aio_task_pool_new(QCOW2_MAX_WORKERS); } ret =3D qcow2_add_task(bs, aio, qcow2_co_pwritev_task_entry, 0, - cluster_offset + offset_in_cluster, offset, + host_offset, offset, cur_bytes, qiov, qiov_offset, l2meta); l2meta =3D NULL; /* l2meta is consumed by qcow2_co_pwritev_task() = */ if (ret < 0) { @@ -3129,13 +3126,12 @@ static int coroutine_fn preallocate_co(BlockDriverS= tate *bs, uint64_t offset, =20 while (bytes) { cur_bytes =3D MIN(bytes, QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size)= ); - ret =3D qcow2_alloc_cluster_offset(bs, offset, &cur_bytes, - &host_offset, &meta); + ret =3D qcow2_alloc_host_offset(bs, offset, &cur_bytes, + &host_offset, &meta); if (ret < 0) { error_setg_errno(errp, -ret, "Allocating clusters failed"); goto out; } - host_offset +=3D offset_into_cluster(s, offset); =20 for (m =3D meta; m !=3D NULL; m =3D m->next) { m->prealloc =3D true; @@ -4043,10 +4039,9 @@ qcow2_co_copy_range_to(BlockDriverState *bs, BdrvRequestFlags write_flags) { BDRVQcow2State *s =3D bs->opaque; - int offset_in_cluster; int ret; unsigned int cur_bytes; /* number of sectors in current iteration */ - uint64_t cluster_offset; + uint64_t host_offset; QCowL2Meta *l2meta =3D NULL; =20 assert(!bs->encrypted); @@ -4057,31 +4052,26 @@ qcow2_co_copy_range_to(BlockDriverState *bs, =20 l2meta =3D NULL; =20 - offset_in_cluster =3D offset_into_cluster(s, dst_offset); cur_bytes =3D MIN(bytes, INT_MAX); =20 /* TODO: * If src->bs =3D=3D dst->bs, we could simply copy by incrementing * the refcnt, without copying user data. * Or if src->bs =3D=3D dst->bs->backing->bs, we could copy by dis= carding. */ - ret =3D qcow2_alloc_cluster_offset(bs, dst_offset, &cur_bytes, - &cluster_offset, &l2meta); + ret =3D qcow2_alloc_host_offset(bs, dst_offset, &cur_bytes, + &host_offset, &l2meta); if (ret < 0) { goto fail; } =20 - assert(offset_into_cluster(s, cluster_offset) =3D=3D 0); - - ret =3D qcow2_pre_write_overlap_check(bs, 0, - cluster_offset + offset_in_cluster, cur_bytes, true); + ret =3D qcow2_pre_write_overlap_check(bs, 0, host_offset, cur_byte= s, + true); if (ret < 0) { goto fail; } =20 qemu_co_mutex_unlock(&s->lock); - ret =3D bdrv_co_copy_range_to(src, src_offset, - s->data_file, - cluster_offset + offset_in_cluster, + ret =3D bdrv_co_copy_range_to(src, src_offset, s->data_file, host_= offset, cur_bytes, read_flags, write_flags); qemu_co_mutex_lock(&s->lock); if (ret < 0) { --=20 2.26.2 From nobody Fri May 3 18:51:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1600168130; cv=none; d=zohomail.com; s=zohoarc; b=KY5zu+7fdV06wy7r+/JB5MtyZKFoLMNxxsLa0EUug4yqIVBRR4ob/fFiP9QIIc3xX6B4jgXeewvirfbeYbKG2PKV3Hakox6/qFYoiVJpfyk3PVTrfY89Y2dPQ+ByQMynCDXGsbpRQWM+QT86acbznQws/2sFkiSEpzTj5RBJHDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600168130; h=Content-Type: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; bh=xZoa4RowV/fB16RrOuni5OhsgOZy07E6WT0/T3ii30M=; b=gdP6mKAW2YRpCeA3zMcVG3he4BZSBRCEYykc1T/V2Zvkw8S97M9CtRlYXL+WGbj4LHCRMepzNavaV8gEvXi8R8CtGgIxlEh1zUEOGmUE0/NbPITb68OouvC2akloWRWEboDg85lZAXDJBl5/OTWNPvxn8fmPpZOWGRe++62A3SY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1600168130561280.25866372841267; Tue, 15 Sep 2020 04:08:50 -0700 (PDT) Received: from localhost ([::1]:47172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI8pN-0003ak-MG for importer@patchew.org; Tue, 15 Sep 2020 07:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ug-00019j-DX for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:26 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40625 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kI8Ue-0004fz-MZ for qemu-devel@nongnu.org; Tue, 15 Sep 2020 06:47:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-EfyzLUtGOaOAn2cZSieiUA-1; Tue, 15 Sep 2020 06:47:19 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AFF0A1005E64; Tue, 15 Sep 2020 10:47:18 +0000 (UTC) Received: from localhost (ovpn-113-7.ams2.redhat.com [10.36.113.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 514D05FC2A; Tue, 15 Sep 2020 10:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600166843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xZoa4RowV/fB16RrOuni5OhsgOZy07E6WT0/T3ii30M=; b=MFlVlUc1gD7+6qQeweQ+jkSaifce0tpxf226ATswznRkUFD+5f0uf9Fg0B42A87pj/zGgX Bfh13Kusw0HcHVyAoabgB/pol4tbRAoxqvQ1fFoALjrcgEUUNO5tAOJlwOOEOxfG32oB+K 0BzJoNIL+sOw7Y8IRbV4gkYufojyiF4= X-MC-Unique: EfyzLUtGOaOAn2cZSieiUA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 22/22] block/rbd: add 'namespace' to qemu_rbd_strong_runtime_opts[] Date: Tue, 15 Sep 2020 12:46:27 +0200 Message-Id: <20200915104627.699552-23-mreitz@redhat.com> In-Reply-To: <20200915104627.699552-1-mreitz@redhat.com> References: <20200915104627.699552-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 03:21:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Commit 19ae9ae014 ("block/rbd: Add support for ceph namespaces") introduced namespace support for RBD, but we forgot to add the new 'namespace' options to qemu_rbd_strong_runtime_opts[]. The 'namespace' is used to identify the image, so it is a strong option since it can changes the data of a BDS. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1821528 Fixes: 19ae9ae014 ("block/rbd: Add support for ceph namespaces") Cc: Florian Florensa Signed-off-by: Stefano Garzarella Message-Id: <20200914190553.74871-1-sgarzare@redhat.com> Reviewed-by: Jason Dillaman Signed-off-by: Max Reitz --- block/rbd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/rbd.c b/block/rbd.c index 171c67e3a0..9bd2bce716 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1247,6 +1247,7 @@ static QemuOptsList qemu_rbd_create_opts =3D { =20 static const char *const qemu_rbd_strong_runtime_opts[] =3D { "pool", + "namespace", "image", "conf", "snapshot", --=20 2.26.2