From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582214947; cv=none; d=zohomail.com; s=zohoarc; b=UJgsue6FIwQ6IAD4hjx7PwoegeQYQuXNsAhalue0sMrsfi3JiI14QA6xXWYin2aziyO7pXFE+oEuuOJDzGLJ/QtLL+mAwwaP5P/JcDk3zMkY0Y3+e5a5agDyHrBIG2seLyVEFD5Uc13QSpIi3ISPRuvtM9ZanS23IYD7tGYihUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582214947; 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=ZmI4DNaB7Lj41ajhnkOeFKygDdymhC+3mP9r+G8Ea/g=; b=EjBQ0uM559BzFD/EWjVqmx2tzVOyYTIUu5MajdZ08v+LP+PPSCL/IHzZ60LZanFZ+bQANPvc2aRS/8fKXnyWYJ5MWDWekDBhvz5XVYMkyy5Ogtj5OeZFE8P5oCoTRqiruUeooqudgM+OObJ/XA0oZZcHp4Ft3AjJz54naEHoO/w= 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 1582214947216325.4664112560554; Thu, 20 Feb 2020 08:09:07 -0800 (PST) Received: from localhost ([::1]:45016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oNu-0003E5-8J for importer@patchew.org; Thu, 20 Feb 2020 11:09:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54504) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oMm-0001z6-9Q for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:07:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oMk-0004E8-U4 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:07:56 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24080 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oMk-0004C2-Op for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:07:54 -0500 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-169-P2TEEgwfNpKBwQYun54vqg-1; Thu, 20 Feb 2020 11:07:49 -0500 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 97BCF8017CC; Thu, 20 Feb 2020 16:07:48 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76DCA5DA7C; Thu, 20 Feb 2020 16:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214874; 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=ZmI4DNaB7Lj41ajhnkOeFKygDdymhC+3mP9r+G8Ea/g=; b=dGEXniXvKdX1t36BUWlrvsGcaup4vOuIXkjj/x4qiZv8hq9/fhNsq/gA+b5O38AhETZO2L AmDKNWuU3IOwk4v2x5RFLgxqN/w8kfBux6q0usoPfqHUSa4Npp2EWTSKvliwFgugj6mKU9 oXSZeR6FTiDS0992kV0P9AXMPGUmHzg= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 01/18] docs: improve qcow2 spec about extending image header Date: Thu, 20 Feb 2020 17:06:53 +0100 Message-Id: <20200220160710.533297-2-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: P2TEEgwfNpKBwQYun54vqg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Kevin Wolf , 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: Vladimir Sementsov-Ogievskiy Make it more obvious how to add new fields to the version 3 header and how to interpret them. The specification is adjusted so that for new defined optional fields: 1. Software may support some of these optional fields and ignore the others, which means that features may be backported to downstream Qemu independently. 2. If we want to add incompatible field (or a field, for which some of its values would be incompatible), it must be accompanied by incompatible feature bit. Also the concept of "default is zero" is clarified, as it's strange to say that the value of the field is assumed to be zero for the software version which don't know about the field at all and don't know how to treat it be it zero or not. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Message-Id: <20200131142219.3264-2-vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia [mreitz: s/some its/some of its/] Signed-off-by: Max Reitz --- docs/interop/qcow2.txt | 45 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index af5711e533..823cc266e0 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -79,9 +79,9 @@ The first cluster of a qcow2 image contains the file head= er: Offset into the image file at which the snapshot table starts. Must be aligned to a cluster boundary. =20 -If the version is 3 or higher, the header has the following additional fie= lds. -For version 2, the values are assumed to be zero, unless specified otherwi= se -in the description of a field. +For version 2, the header is exactly 72 bytes in length, and finishes here. +For version 3 or higher, the header length is at least 104 bytes, including +the next fields through header_length. =20 72 - 79: incompatible_features Bitmask of incompatible features. An implementation mu= st @@ -164,6 +164,45 @@ in the description of a field. 100 - 103: header_length Length of the header structure in bytes. For version 2 images, the length is always assumed to be 72 bytes. + For version 3 it's at least 104 bytes and must be a mu= ltiple + of 8. + + +=3D=3D=3D Additional fields (version 3 and higher) =3D=3D=3D + +In general, these fields are optional and may be safely ignored by the sof= tware, +as well as filled by zeros (which is equal to field absence), if software = needs +to set field B, but does not care about field A which precedes B. More +formally, additional fields have the following compatibility rules: + +1. If the value of the additional field must not be ignored for correct +handling of the file, it will be accompanied by a corresponding incompatib= le +feature bit. + +2. If there are no unrecognized incompatible feature bits set, an unknown +additional field may be safely ignored other than preserving its value when +rewriting the image header. + +3. An explicit value of 0 will have the same behavior as when the field is= not +present*, if not altered by a specific incompatible bit. + +*. A field is considered not present when header_length is less than or eq= ual +to the field's offset. Also, all additional fields are not present for +version 2. + + < ... No additional fields in the header currently ... > + + +=3D=3D=3D Header padding =3D=3D=3D + +@header_length must be a multiple of 8, which means that if the end of the= last +additional field is not aligned, some padding is needed. This padding must= be +zeroed, so that if some existing (or future) additional field will fall in= to +the padding, it will be interpreted accordingly to point [3.] of the previ= ous +paragraph, i.e. in the same manner as when this field is not present. + + +=3D=3D=3D Header extensions =3D=3D=3D =20 Directly after the image header, optional sections called header extension= s can be stored. Each extension has a structure like the following: --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582214988; cv=none; d=zohomail.com; s=zohoarc; b=UrHeuKCQpvQPK/w/KpQWeDrR7m/9rbwZ82vV60ZN8vRU2JqrnUpJcHWBhRyBlPHKkTXHgneIEz0auqYA15c0i2M+ZXmS0ycLnZjCAVnXKahQnlp2lch+L35/ikknZ4KaQ2Vp0B6mrdlhGQ/yISELvSQH4+69NAcyDJQtqyw7A/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582214988; 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=OhMxv/IG+GIdXRB2FTwhfQ52TVogWpuaqU23iG/opWM=; b=kSuV2xS5Kll+d7Y8D8trOY5drcg+nUBo1xHvP6szif/UD10tzYzqK2+iF/1imnDbFV6MYDDT5EuLqxvlEn8IS3LHcEuJ46HI26R4dSVLi21Hygbpvmfr5ff8HNKTMx4xR6yJXz6pSCO9/r3kqHO2JaG2XKLA90hzFpctoA+O82E= 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 158221498893160.410782808429985; Thu, 20 Feb 2020 08:09:48 -0800 (PST) Received: from localhost ([::1]:45036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oOZ-0004CS-59 for importer@patchew.org; Thu, 20 Feb 2020 11:09:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54612) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oN9-0002Xa-Lo for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oN8-0004nM-41 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:19 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:43167 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oN8-0004mt-0Y for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:18 -0500 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-237-Bhe8QZU4OeeGseZZwQ1TCQ-1; Thu, 20 Feb 2020 11:08:08 -0500 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 8AFC9800D53; Thu, 20 Feb 2020 16:08:07 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD6DF5C1B0; Thu, 20 Feb 2020 16:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214897; 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=OhMxv/IG+GIdXRB2FTwhfQ52TVogWpuaqU23iG/opWM=; b=TkWFfmfCKtl0H1PbSG6hj/kJVmXZtGEIHDMq8B8gb9nJHrCgTT4pDdG6LRsTrfBZTxwXq1 pedTIBL9wVzymxn6BsSRmGe92XLXM96MO1L1eCfLQ5hGs7iUMS2zAFRtNA1zjr5we6Anoo BZsd5IGbvYY4R7kejUyL05JYJxceotc= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 02/18] docs: qcow2: introduce compression type feature Date: Thu, 20 Feb 2020 17:06:54 +0100 Message-Id: <20200220160710.533297-3-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: Bhe8QZU4OeeGseZZwQ1TCQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Kevin Wolf , 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: Vladimir Sementsov-Ogievskiy The patch adds a new additional field to the qcow2 header: compression_type, which specifies compression type. If field is absent or zero, default compression type is set: ZLIB, which corresponds to current behavior. New compression type (ZSTD) is to be added in further commit. Suggested-by: Denis Plotnikov Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200131142219.3264-3-vsementsov@virtuozzo.com> [mreitz: s/Bits 3-63: Reserved/Bits 4-63: Reserved/] Signed-off-by: Max Reitz --- docs/interop/qcow2.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index 823cc266e0..5597e24474 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -109,7 +109,12 @@ the next fields through header_length. An External Data File Name header extensio= n may be present if this bit is set. =20 - Bits 3-63: Reserved (set to 0) + Bit 3: Compression type bit. If this bit is set, + a non-default compression is used for comp= ressed + clusters. The compression_type field must = be + present and not zero. + + Bits 4-63: Reserved (set to 0) =20 80 - 87: compatible_features Bitmask of compatible features. An implementation can @@ -190,7 +195,19 @@ present*, if not altered by a specific incompatible bi= t. to the field's offset. Also, all additional fields are not present for version 2. =20 - < ... No additional fields in the header currently ... > + 104: compression_type + + Defines the compression method used for compressed clu= sters. + All compressed clusters in an image use the same compr= ession + type. + + If the incompatible bit "Compression type" is set: the= field + must be present and non-zero (which means non-zlib + compression type). Otherwise, this field must not be p= resent + or must be zero (which means zlib). + + Available compression type values: + 0: zlib =20 =20 =3D=3D=3D Header padding =3D=3D=3D --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215028; cv=none; d=zohomail.com; s=zohoarc; b=m7FuhEwSuSc+HJ67ozfGdv7bKLgfLcYRUcTKl8VuxWXBp3N0UrmqgXahhHXYcbYCHHTIsigORxDswGoPS/K2JYWSdPBAfyglokKMUpCeS5th4LBHchJoQzpvV1Shrgq7GtJ+56MxoLnom3IoWNulhWXouZRr6tck50yui72Wj3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215028; 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=imNKplwU1VPK3E7/RFcXyoj2wsOgHzALDXKw2ZlZRZI=; b=EZVaeNj6bpdl680nIhYUVrMYCl8TIt/a9ef5bKwUV9RqH12W0voiqKKwqtkgeyKMW12idtGDshUgXlw/+78gFg4UqIYg0xi06wJ6RS9jQORAhzEyq4MEK/MlHEU5CFIpzjrB7NPF1waBlOLIZn4GKvSudiG/Icn3qQTGocqcw5U= 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 1582215028004605.2033001902544; Thu, 20 Feb 2020 08:10:28 -0800 (PST) Received: from localhost ([::1]:45080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oPD-00060S-0d for importer@patchew.org; Thu, 20 Feb 2020 11:10:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54584) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oN8-0002Vk-DL for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oN7-0004mo-CD for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20210 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oN7-0004md-7u for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:17 -0500 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-464-BCgvJZ6nPMKU8r6TehKAOA-1; Thu, 20 Feb 2020 11:08:13 -0500 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 C757A18B632E; Thu, 20 Feb 2020 16:08:12 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 336625C1B0; Thu, 20 Feb 2020 16:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214896; 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=imNKplwU1VPK3E7/RFcXyoj2wsOgHzALDXKw2ZlZRZI=; b=grM3mPgZGvZZWaiAyBYxYffSTZoHrQXbgaHFXVNtKeC5jn2/eF3AVJ2zQvmPOTVh8T/XjQ xsXBnBl8Lg5280RssFQbyQAj3PxEafZwUZYWlGRW1vsTwLVxc4Y3hug68BmuqbBjYODBVP nMC921hQX8WILbwytw9HUSLepO3TBtU= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 03/18] iotests: Remove the superfluous 2nd check for the availability of quorum Date: Thu, 20 Feb 2020 17:06:55 +0100 Message-Id: <20200220160710.533297-4-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: BCgvJZ6nPMKU8r6TehKAOA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Kevin Wolf , 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 Commit d9df28e7b07 ("iotests: check whitelisted formats") added the modern @iotests.skip_if_unsupported() to the functions in this test, so we don't need the old explicit test here anymore. Signed-off-by: Thomas Huth Message-Id: <20200129141751.32652-1-thuth@redhat.com> Reviewed-by: Alberto Garcia Reviewed-by: Andrey Shinkevich Tested-by: Andrey Shinkevich Signed-off-by: Max Reitz --- tests/qemu-iotests/139 | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139 index 6b1a444364..7120d3142b 100755 --- a/tests/qemu-iotests/139 +++ b/tests/qemu-iotests/139 @@ -344,9 +344,6 @@ class TestBlockdevDel(iotests.QMPTestCase): =20 @iotests.skip_if_unsupported(['quorum']) def testQuorum(self): - if not iotests.supports_quorum(): - return - self.addQuorum('quorum0', 'node0', 'node1') # We cannot remove the children of a Quorum device self.delBlockDriverState('node0', expect_error =3D True) --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215081; cv=none; d=zohomail.com; s=zohoarc; b=NBY3M4yomMHlZKeL76m+ggqJQXYaZbXH3t6n2SoLRhbIEhKgg9WxDZlThpAw8n5/b6q2Rp4Uf+D2tWjrfiRf5FhyeJb2AJYT/WpbgZ3Tm2ntAUAg4Uycp1nlu8i/LyRW3IONmS1nCm1NGainh0kpxBMK++5udpv+NDqzdXiarXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215081; 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=yTx9JZmtFTD/Ejx3Xq+NYb931mqXMVJweEJBkYozBEA=; b=GjUlFBSM7Vfe3AB+e8RWAKP0Z/IBinfTj8dO/vSIci8sgwpQznPweI/myuNF2fXcHRDWbbLF3sA8USI4BGbwSMolItoGxVb9T9zLodovvuvrz02XWXJcJ21xUx35MCNeylg9Jz4vaxR43E+vm7+b54ibGEzizr1/IF7Pbrchl2I= 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 1582215081429222.27018779814193; Thu, 20 Feb 2020 08:11:21 -0800 (PST) Received: from localhost ([::1]:45118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQ4-0007ip-Ex for importer@patchew.org; Thu, 20 Feb 2020 11:11:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54664) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oNN-0002rk-86 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oNM-000592-8m for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:33 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:24974 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oNM-000532-4c for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:32 -0500 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-356-bcYY6jG8MI6dkOevnCACng-1; Thu, 20 Feb 2020 11:08:23 -0500 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 9D6788017DF; Thu, 20 Feb 2020 16:08:20 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FF168AC5B; Thu, 20 Feb 2020 16:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214908; 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=yTx9JZmtFTD/Ejx3Xq+NYb931mqXMVJweEJBkYozBEA=; b=LsWToRc33VkPBDr+39v10gdkKN1cDsIkaf0BSO17W/UzK4FEjR7mqnbLsGyA76KxkCP5uP 0rmuHgWrojxAA1//qbQ3Dz6lmqXEvVs+YXtHi5eZbKqF4OovLk9yGhRdcIC+uL0/tLqtjh 3uoZKelduwsYth8d0JPDRX7NwlFTDLU= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 04/18] iotests/147: Fix drive parameters Date: Thu, 20 Feb 2020 17:06:56 +0100 Message-Id: <20200220160710.533297-5-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: bcYY6jG8MI6dkOevnCACng-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , 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" 8dff69b94 added an aio parameter to the drive parameter but forgot to add a comma before, thus breaking the test. Fix it again. Fixes: 8dff69b9415b4287e900358744b732195e1ab2e2 Signed-off-by: Max Reitz Message-Id: <20200206130812.612960-1-mreitz@redhat.com> Reviewed-by: Eric Blake Tested-by: Eric Blake Signed-off-by: Max Reitz --- tests/qemu-iotests/147 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147 index f4b0a11dba..d7a9f31089 100755 --- a/tests/qemu-iotests/147 +++ b/tests/qemu-iotests/147 @@ -134,7 +134,7 @@ class BuiltinNBD(NBDBlockdevAddBase): self.server.add_drive_raw('if=3Dnone,id=3Dnbd-export,' + 'file=3D%s,' % test_img + 'format=3D%s,' % imgfmt + - 'cache=3D%s' % cachemode + + 'cache=3D%s,' % cachemode + 'aio=3D%s' % aiomode) self.server.launch() =20 --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215252; cv=none; d=zohomail.com; s=zohoarc; b=ftCRXZBPtQ87Qezuva4rRqqykTThW+365lPxhcHGOGb75VnFjI5742SDQondtPiwIrZlUzgDlJLLKTPzpJmXIFDuYFD/Jr7K5fBuaE5HK1pZT8W+HrHhxBXl+nTxaBRpFSd3hbcc5GtLCCjloQ+R+wd5ol9y9NkHFk2nt8J0P/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215252; 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=SV6cCgR5vGPvx+m/2n/rccL9WOTCAUOs32GzciPYSDM=; b=e22IMywIpQpqE6ilpnf+KH+pOGyctv27/JtChgLCWmKjxu6kqBZUQcT3apStGgqXtcuEwThJHsXf0KTL5l1Q+uS4zRuqisVCJMvAxm4mx+8+igoI8M2wjSU+5xDUnkXYypOxGt+/YnXfSVKSoZdBVJ8TWN3qWQp5sZBF+n7rVBc= 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 1582215252844155.2927815695391; Thu, 20 Feb 2020 08:14:12 -0800 (PST) Received: from localhost ([::1]:45216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oSq-0004ck-0f for importer@patchew.org; Thu, 20 Feb 2020 11:14:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54723) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oNS-00034z-NK for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oNR-0005EF-5q for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:38 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:46230 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oNR-0005E1-12 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:37 -0500 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-316-fXQVIqFrP-m6EiHueBAk1Q-1; Thu, 20 Feb 2020 11:08:33 -0500 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 A317E18B9FCB; Thu, 20 Feb 2020 16:08:30 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE4775DA82; Thu, 20 Feb 2020 16:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214916; 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=SV6cCgR5vGPvx+m/2n/rccL9WOTCAUOs32GzciPYSDM=; b=JNyQZic6q3xR1l0pNgNwf3k/Si6DGYYWuL3xVt+F5G25m6hd/7mT9G/LDcl5jD7220A3QL bdqWZ/VpS4fHvdL9y3uc6Vlru/DAxwA0KZnXbEG1RahAwapU8Au9EpbRSfS40w/BZfumdg wO6YiP23deLf7s/clvtU5z8HZwvePQQ= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 05/18] qapi: Allow getting flat output from 'query-named-block-nodes' Date: Thu, 20 Feb 2020 17:06:57 +0100 Message-Id: <20200220160710.533297-6-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: fXQVIqFrP-m6EiHueBAk1Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , 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 Krempa When a management application manages node names there's no reason to recurse into backing images in the output of query-named-block-nodes. Add a parameter to the command which will return just the top level structs. Signed-off-by: Peter Krempa Message-Id: <4470f8c779abc404dcf65e375db195cd91a80651.1579509782.git.pkremp= a@redhat.com> Reviewed-by: Eric Blake [mreitz: Fixed coding style] Signed-off-by: Max Reitz --- block.c | 5 +++-- block/qapi.c | 11 +++++++++-- blockdev.c | 8 ++++++-- include/block/block.h | 2 +- include/block/qapi.h | 4 +++- monitor/hmp-cmds.c | 2 +- qapi/block-core.json | 7 ++++++- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 946e3c896e..08372ced26 100644 --- a/block.c +++ b/block.c @@ -4807,14 +4807,15 @@ BlockDriverState *bdrv_find_node(const char *node_n= ame) } =20 /* Put this QMP function here so it can access the static graph_bdrv_state= s. */ -BlockDeviceInfoList *bdrv_named_nodes_list(Error **errp) +BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, + Error **errp) { BlockDeviceInfoList *list, *entry; BlockDriverState *bs; =20 list =3D NULL; QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - BlockDeviceInfo *info =3D bdrv_block_device_info(NULL, bs, errp); + BlockDeviceInfo *info =3D bdrv_block_device_info(NULL, bs, flat, e= rrp); if (!info) { qapi_free_BlockDeviceInfoList(list); return NULL; diff --git a/block/qapi.c b/block/qapi.c index 9a5d0c9b27..3f09477cc5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -42,7 +42,9 @@ #include "qemu/cutils.h" =20 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, Error **errp) + BlockDriverState *bs, + bool flat, + Error **errp) { ImageInfo **p_image_info; BlockDriverState *bs0; @@ -156,6 +158,11 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *= blk, return NULL; } =20 + /* stop gathering data for flat output */ + if (flat) { + break; + } + if (bs0->drv && bs0->backing) { info->backing_file_depth++; bs0 =3D bs0->backing->bs; @@ -389,7 +396,7 @@ static void bdrv_query_info(BlockBackend *blk, BlockInf= o **p_info, =20 if (bs && bs->drv) { info->has_inserted =3D true; - info->inserted =3D bdrv_block_device_info(blk, bs, errp); + info->inserted =3D bdrv_block_device_info(blk, bs, false, errp); if (info->inserted =3D=3D NULL) { goto err; } diff --git a/blockdev.c b/blockdev.c index 45de0ba37e..011dcfec27 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3734,9 +3734,13 @@ void qmp_drive_backup(DriveBackup *backup, Error **e= rrp) blockdev_do_action(&action, errp); } =20 -BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp) +BlockDeviceInfoList *qmp_query_named_block_nodes(bool has_flat, + bool flat, + Error **errp) { - return bdrv_named_nodes_list(errp); + bool return_flat =3D has_flat && flat; + + return bdrv_named_nodes_list(return_flat, errp); } =20 XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp) diff --git a/include/block/block.h b/include/block/block.h index 314ce63ed9..cd6b5b95aa 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -454,7 +454,7 @@ void bdrv_lock_medium(BlockDriverState *bs, bool locked= ); void bdrv_eject(BlockDriverState *bs, bool eject_flag); const char *bdrv_get_format_name(BlockDriverState *bs); BlockDriverState *bdrv_find_node(const char *node_name); -BlockDeviceInfoList *bdrv_named_nodes_list(Error **errp); +BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp); XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp); BlockDriverState *bdrv_lookup_bs(const char *device, const char *node_name, diff --git a/include/block/qapi.h b/include/block/qapi.h index cd9410dee3..22c7807c89 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -29,7 +29,9 @@ #include "block/snapshot.h" =20 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, Error **errp= ); + BlockDriverState *bs, + bool flat, + Error **errp); int bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, Error **errp); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index b237613e0d..53bc3f76c4 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -620,7 +620,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) } =20 /* Print node information */ - blockdev_list =3D qmp_query_named_block_nodes(NULL); + blockdev_list =3D qmp_query_named_block_nodes(false, false, NULL); for (blockdev =3D blockdev_list; blockdev; blockdev =3D blockdev->next= ) { assert(blockdev->value->has_node_name); if (device && strcmp(device, blockdev->value->node_name)) { diff --git a/qapi/block-core.json b/qapi/block-core.json index 37d7ea7295..85e27bb61f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1758,6 +1758,9 @@ # # Get the named block driver list # +# @flat: Omit the nested data about backing image ("backing-image" key) if= true. +# Default is false (Since 5.0) +# # Returns: the list of BlockDeviceInfo # # Since: 2.0 @@ -1811,7 +1814,9 @@ # } } ] } # ## -{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] } +{ 'command': 'query-named-block-nodes', + 'returns': [ 'BlockDeviceInfo' ], + 'data': { '*flat': 'bool' } } =20 ## # @XDbgBlockGraphNodeType: --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215011; cv=none; d=zohomail.com; s=zohoarc; b=DIKlL/NpVKuNX5pG5tUrX5IvJ4WxAMOWGlhtKj9UNPZPPlForuL/iFYHBKyLx64nlfzB0PUKhFKJtsitoE5gnFAce7xxGbOmdvlwxaMGmwJJvJFrZYP5/mMl/fEegzhzjZ3Uoqpd5m6UD4GAsSkYGGrqB2BYc4GNPGTgcdyjDUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215011; 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=+8/PRIwPN+WNDBo8H+1U+retri+fRshGQEUM+hCun2E=; b=U9wk5JeaS2wz1sJldkjuULiyaHh+rE2vYt3c1VqtiqwYGh52JmqQYxDsfPdbf4XdvXvb8HQUx22GE/Yrc+2Ror9rp77nd/l+mpK9XXMl7CbeLy7ovQHjTaehDsgJPWysdhqskVz4xHmy23IHHMpE6n3zd2iVN5hPggKZW9CSEmY= 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 1582215011727960.13248910406; Thu, 20 Feb 2020 08:10:11 -0800 (PST) Received: from localhost ([::1]:45068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oOw-0005Q0-I4 for importer@patchew.org; Thu, 20 Feb 2020 11:10:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54774) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oNc-0003Gb-F3 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oNb-0005Ro-0F for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59527 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oNa-0005Ou-S6 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:08:46 -0500 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-230-_JHDCFVHP-OTx3PzqJs9lg-1; Thu, 20 Feb 2020 11:08:42 -0500 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 0F8AC8010F5; Thu, 20 Feb 2020 16:08:41 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6765177935; Thu, 20 Feb 2020 16:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214926; 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=+8/PRIwPN+WNDBo8H+1U+retri+fRshGQEUM+hCun2E=; b=N2UPYpS9W56Bj1fNcwXUHC2lFUEZVE/YuVnb1MYMt8v0d44W5wteAKxDX1Tb0/0F4gczNB 3P8sCmLbCaUXuVeuYHCRgF+ZVYO1Re3Ywmt0oMdhGuvosFI2z78owtWNY8YgJyYRCpUXXO 1S9POF1E9xpexr8Wj7R9ugXjNSg/iEM= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 06/18] qemu-img: Add --target-is-zero to convert Date: Thu, 20 Feb 2020 17:06:58 +0100 Message-Id: <20200220160710.533297-7-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: _JHDCFVHP-OTx3PzqJs9lg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Kevin Wolf , 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: David Edmondson In many cases the target of a convert operation is a newly provisioned target that the user knows is blank (reads as zero). In this situation there is no requirement for qemu-img to wastefully zero out the entire device. Add a new option, --target-is-zero, allowing the user to indicate that an existing target device will return zeros for all reads. Signed-off-by: David Edmondson Message-Id: <20200205110248.2009589-2-david.edmondson@oracle.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- docs/interop/qemu-img.rst | 9 ++++++++- qemu-img-cmds.hx | 4 ++-- qemu-img.c | 26 +++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/docs/interop/qemu-img.rst b/docs/interop/qemu-img.rst index 42e4451db4..5f40137c10 100644 --- a/docs/interop/qemu-img.rst +++ b/docs/interop/qemu-img.rst @@ -214,6 +214,13 @@ Parameters to convert subcommand: will still be printed. Areas that cannot be read from the source will be treated as containing only zeroes. =20 +.. option:: --target-is-zero + + Assume that reading the destination image will always return + zeros. This parameter is mutually exclusive with a destination image + that has a backing file. It is required to also use the ``-n`` + parameter to skip image creation. + Parameters to dd subcommand: =20 .. program:: qemu-img-dd @@ -366,7 +373,7 @@ Command description: 4 Error on reading data =20 -.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OU= TPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZ= E] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME +.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [--target-is-zero] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-= T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PA= RAM] [-S SPARSE_SIZE] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] O= UTPUT_FILENAME =20 Convert the disk image *FILENAME* or a snapshot *SNAPSHOT_PARAM* to disk image *OUTPUT_FILENAME* using format *OUTPUT_FMT*. It can diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index d7fbc6b1f4..c9c54de1df 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -39,9 +39,9 @@ SRST ERST =20 DEF("convert", img_convert, - "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U= ] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fm= t] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m = num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename= ") + "convert [--object objectdef] [--image-opts] [--target-image-opts] [--= target-is-zero] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_c= ache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-= S sparse_size] [-m num_coroutines] [-W] [--salvage] filename [filename2 [..= .]] output_filename") SRST -.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OU= TPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZ= E] [-m NUM_COROUTINES] [-W] [--salvage] FILENAME [FILENAME2 [...]] OUTPUT_F= ILENAME +.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [--target-is-zero] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-= T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PA= RAM] [-S SPARSE_SIZE] [-m NUM_COROUTINES] [-W] [--salvage] FILENAME [FILENA= ME2 [...]] OUTPUT_FILENAME ERST =20 DEF("create", img_create, diff --git a/qemu-img.c b/qemu-img.c index 2b4562b9d9..0faf2cd2f5 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -70,6 +70,7 @@ enum { OPTION_PREALLOCATION =3D 265, OPTION_SHRINK =3D 266, OPTION_SALVAGE =3D 267, + OPTION_TARGET_IS_ZERO =3D 268, }; =20 typedef enum OutputFormat { @@ -1984,10 +1985,9 @@ static int convert_do_copy(ImgConvertState *s) int64_t sector_num =3D 0; =20 /* Check whether we have zero initialisation or can get it efficiently= */ - if (s->target_is_new && s->min_sparse && !s->target_has_backing) { + if (!s->has_zero_init && s->target_is_new && s->min_sparse && + !s->target_has_backing) { s->has_zero_init =3D bdrv_has_zero_init(blk_bs(s->target)); - } else { - s->has_zero_init =3D false; } =20 if (!s->has_zero_init && !s->target_has_backing && @@ -2086,6 +2086,7 @@ static int img_convert(int argc, char **argv) {"force-share", no_argument, 0, 'U'}, {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS= }, {"salvage", no_argument, 0, OPTION_SALVAGE}, + {"target-is-zero", no_argument, 0, OPTION_TARGET_IS_ZERO}, {0, 0, 0, 0} }; c =3D getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WU", @@ -2209,6 +2210,14 @@ static int img_convert(int argc, char **argv) case OPTION_TARGET_IMAGE_OPTS: tgt_image_opts =3D true; break; + case OPTION_TARGET_IS_ZERO: + /* + * The user asserting that the target is blank has the + * same effect as the target driver supporting zero + * initialisation. + */ + s.has_zero_init =3D true; + break; } } =20 @@ -2247,6 +2256,11 @@ static int img_convert(int argc, char **argv) warn_report("This will become an error in future QEMU versions."); } =20 + if (s.has_zero_init && !skip_create) { + error_report("--target-is-zero requires use of -n flag"); + goto fail_getopt; + } + s.src_num =3D argc - optind - 1; out_filename =3D s.src_num >=3D 1 ? argv[argc - 1] : NULL; =20 @@ -2380,6 +2394,12 @@ static int img_convert(int argc, char **argv) } s.target_has_backing =3D (bool) out_baseimg; =20 + if (s.has_zero_init && s.target_has_backing) { + error_report("Cannot use --target-is-zero when the destination " + "image has a backing file"); + goto out; + } + if (s.src_num > 1 && out_baseimg) { error_report("Having a backing file for the target makes no sense = when " "concatenating multiple input images"); --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215134; cv=none; d=zohomail.com; s=zohoarc; b=Cwv4kwo/4KigtJwqlRCygFdXhoii87GsnEJCWIvUDS36X1PDpRwzqvMLnExs3tzQSZI/hvj0sWsMNNUR74AUIm41O5NIljb5tA+aFhghggoU0IfT3XSp+y8AGg/DTH6cSebF5Wix8GBvlT0DgZetBhjqwTCybVw+MNjk+viGKFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215134; 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=ALUSqLGIv9MuVl6i2ukq12jWRzMvUQ5tuco6BqnE/NQ=; b=JfgKrwJS14YnUarjIoniK6Pib71ODfmOiqkpIXTFzj9UkvadzAng+8OYHjo6Beke1i8ZPX1H/ZspXA6op4CNfpUzPhJAtJwmbEIQz7MQ/qYURGX6BHrO7ODCcHiu5oA8H+sVOC4UuaEEA/zq5tmVdRpoRAdDs6FSnhRQCnhFpfY= 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 1582215134771172.66909464081766; Thu, 20 Feb 2020 08:12:14 -0800 (PST) Received: from localhost ([::1]:45134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQv-0000Yt-Qx for importer@patchew.org; Thu, 20 Feb 2020 11:12:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54865) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oOK-0004li-3d for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oOH-0005g6-VA for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:32 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49829 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oOF-0005dz-LR for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:29 -0500 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-239-gEUFvm-GO-6lu8KRLvQufg-1; Thu, 20 Feb 2020 11:09:21 -0500 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 D1D51101FC61; Thu, 20 Feb 2020 16:09:19 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DE5C5D9E2; Thu, 20 Feb 2020 16:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214967; 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=ALUSqLGIv9MuVl6i2ukq12jWRzMvUQ5tuco6BqnE/NQ=; b=gdSsQpPhYvLKyAh1Fzhw+3NvSfGj0XmKeK2+OlR3HNjBBdrui70KPje78vD+B4/5lU7sym 96/7MiepBdB57QsIN6p8r4cTAQFoRfvygmfVOSDVSp93ZlNSSSDIofquF1ZyfEYwKgMH+g A54NFHN4OHuUssvf5GkvH0PAmmerhUE= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 07/18] block: always fill entire LUKS header space with zeros Date: Thu, 20 Feb 2020 17:06:59 +0100 Message-Id: <20200220160710.533297-8-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: gEUFvm-GO-6lu8KRLvQufg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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: Daniel P. Berrang=C3=A9 When initializing the LUKS header the size with default encryption parameters will currently be 2068480 bytes. This is rounded up to a multiple of the cluster size, 2081792, with 64k sectors. If the end of the header is not the same as the end of the cluster we fill the extra space with zeros. This was forgetting that not even the space allocated for the header will be fully initialized, as we only write key material for the first key slot. The space left for the other 7 slots is never written to. An optimization to the ref count checking code: commit a5fff8d4b4d928311a5005efa12d0991fe3b66f9 (refs/bisect/bad) Author: Vladimir Sementsov-Ogievskiy Date: Wed Feb 27 16:14:30 2019 +0300 qcow2-refcount: avoid eating RAM made the assumption that every cluster which was allocated would have at least some data written to it. This was violated by way the LUKS header is only partially written, with much space simply reserved for future use. Depending on the cluster size this problem was masked by the logic which wrote zeros between the end of the LUKS header and the end of the cluster. $ qemu-img create --object secret,id=3Dcluster_encrypt0,data=3D123456 \ -f qcow2 -o cluster_size=3D2k,encrypt.iter-time=3D1,\ encrypt.format=3Dluks,encrypt.key-secret=3Dcluster_encrypt0 \ cluster_size_check.qcow2 100M Formatting 'cluster_size_check.qcow2', fmt=3Dqcow2 size=3D104857600 encrypt.format=3Dluks encrypt.key-secret=3Dcluster_encrypt0 encrypt.iter-time=3D1 cluster_size=3D2048 lazy_refcounts=3Doff refcount= _bits=3D16 $ qemu-img check --object secret,id=3Dcluster_encrypt0,data=3Dredhat \ 'json:{"driver": "qcow2", "encrypt.format": "luks", \ "encrypt.key-secret": "cluster_encrypt0", \ "file.driver": "file", "file.filename": "cluster_size_check.qcow= 2"}' ERROR: counting reference for region exceeding the end of the file by one c= luster or more: offset 0x2000 size 0x1f9000 Leaked cluster 4 refcount=3D1 reference=3D0 ...snip... Leaked cluster 130 refcount=3D1 reference=3D0 1 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. 127 leaked clusters were found on the image. This means waste of disk space, but no harm to data. Image end offset: 268288 The problem only exists when the disk image is entirely empty. Writing data to the disk image payload will solve the problem by causing the end of the file to be extended further. The change fixes it by ensuring that the entire allocated LUKS header region is fully initialized with zeros. The qemu-img check will still fail for any pre-existing disk images created prior to this change, unless at least 1 byte of the payload is written to. Fully writing zeros to the entire LUKS header is a good idea regardless as it ensures that space has been allocated on the host filesystem (or whatever block storage backend is used). Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20200207135520.2669430-1-berrange@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qcow2.c | 11 +++-- tests/qemu-iotests/284 | 97 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/284.out | 62 ++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 167 insertions(+), 4 deletions(-) create mode 100755 tests/qemu-iotests/284 create mode 100644 tests/qemu-iotests/284.out diff --git a/block/qcow2.c b/block/qcow2.c index 8dcee5efec..3c754f616b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -135,13 +135,16 @@ static ssize_t qcow2_crypto_hdr_init_func(QCryptoBloc= k *block, size_t headerlen, s->crypto_header.length =3D headerlen; s->crypto_header.offset =3D ret; =20 - /* Zero fill remaining space in cluster so it has predictable - * content in case of future spec changes */ + /* + * Zero fill all space in cluster so it has predictable + * content, as we may not initialize some regions of the + * header (eg only 1 out of 8 key slots will be initialized) + */ clusterlen =3D size_to_clusters(s, headerlen) * s->cluster_size; assert(qcow2_pre_write_overlap_check(bs, 0, ret, clusterlen, false) = =3D=3D 0); ret =3D bdrv_pwrite_zeroes(bs->file, - ret + headerlen, - clusterlen - headerlen, 0); + ret, + clusterlen, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not zero fill encryption heade= r"); return -1; diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284 new file mode 100755 index 0000000000..071e89b33e --- /dev/null +++ b/tests/qemu-iotests/284 @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +# +# Test ref count checks on encrypted images +# +# Copyright (C) 2019 Red Hat, Inc. +# +# 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=3Dberrange@redhat.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 generic +_supported_os Linux + + +size=3D1M + +SECRET=3D"secret,id=3Dsec0,data=3Dastrochicken" + +IMGSPEC=3D"driver=3D$IMGFMT,file.filename=3D$TEST_IMG,encrypt.key-secret= =3Dsec0" +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT + +_run_test() +{ + IMGOPTSSYNTAX=3Dtrue + OLD_TEST_IMG=3D"$TEST_IMG" + TEST_IMG=3D"driver=3D$IMGFMT,file.filename=3D$TEST_IMG,encrypt.key= -secret=3Dsec0" + QEMU_IMG_EXTRA_ARGS=3D"--image-opts --object $SECRET" + + echo + echo "=3D=3D cluster size $csize" + echo "=3D=3D checking image refcounts =3D=3D" + _check_test_img + + echo + echo "=3D=3D writing some data =3D=3D" + $QEMU_IO -c "write -P 0x9 0 1" $QEMU_IMG_EXTRA_ARGS $TEST_IMG | _= filter_qemu_io | _filter_testdir + echo + echo "=3D=3D rechecking image refcounts =3D=3D" + _check_test_img + + echo + echo "=3D=3D writing some more data =3D=3D" + $QEMU_IO -c "write -P 0x9 $csize 1" $QEMU_IMG_EXTRA_ARGS $TEST_IMG= | _filter_qemu_io | _filter_testdir + echo + echo "=3D=3D rechecking image refcounts =3D=3D" + _check_test_img + + TEST_IMG=3D"$OLD_TEST_IMG" + QEMU_IMG_EXTRA_ARGS=3D + IMGOPTSSYNTAX=3D +} + + +echo +echo "testing LUKS qcow2 encryption" +echo + +for csize in 512 2048 32768 +do + _make_test_img --object $SECRET -o "encrypt.format=3Dluks,encrypt.key-se= cret=3Dsec0,encrypt.iter-time=3D10,cluster_size=3D$csize" $size + _run_test + _cleanup_test_img +done + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/284.out b/tests/qemu-iotests/284.out new file mode 100644 index 0000000000..48216f5742 --- /dev/null +++ b/tests/qemu-iotests/284.out @@ -0,0 +1,62 @@ +QA output created by 284 + +testing LUKS qcow2 encryption + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 + +=3D=3D cluster size 512 +=3D=3D checking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some data =3D=3D +wrote 1/1 bytes at offset 0 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some more data =3D=3D +wrote 1/1 bytes at offset 512 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 + +=3D=3D cluster size 2048 +=3D=3D checking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some data =3D=3D +wrote 1/1 bytes at offset 0 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some more data =3D=3D +wrote 1/1 bytes at offset 2048 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 + +=3D=3D cluster size 32768 +=3D=3D checking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some data =3D=3D +wrote 1/1 bytes at offset 0 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. + +=3D=3D writing some more data =3D=3D +wrote 1/1 bytes at offset 32768 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D rechecking image refcounts =3D=3D +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1904223020..818380a8f0 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -290,3 +290,4 @@ 280 rw migration quick 281 rw quick 283 auto quick +284 rw --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215133; cv=none; d=zohomail.com; s=zohoarc; b=iRJjbxj46dkrgBLuunm8QEzihxr9WP2qQDtV5VXMuOMJ1KI0ik/16OxVjJoMapFO+mjW6h3Oa3YYdu9lwN8vUztmGzwk2O/Iam1mLWtAlryS0G58+9mkks2qh/GcvbEoZauWyfyrlNlxyyzSW12cZ2Ey0Mr2Rorot2ilqKKhOl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215133; 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=MttArOFtWxbQbyc/L7DWpav82OCvI7dSnQyTC0YOVBQ=; b=IU0Hw/YvjMijnToYXtKFFYn0exOfF8y0LYKXVi7hFSW2mn55Aoif4r8OcToFFrk8v8fN/Q8/wj8+1nu3wMBRK+jFRMcA92b+hMYH763r8y8TPzNYtP57p/t+QhRF34G++OkQAH5Cj7ZDChF+EdQDMDHymrGlCoqMmSa3uKsK9Fs= 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 1582215133042200.3616038111927; Thu, 20 Feb 2020 08:12:13 -0800 (PST) Received: from localhost ([::1]:45132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQu-0000WX-7X for importer@patchew.org; Thu, 20 Feb 2020 11:12:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54939) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oOZ-0005Hc-TA for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oOY-00068J-GG for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:47 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:36726 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oOY-000682-Av for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:46 -0500 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-304-yxSDvBd5NqqcQDFqwopwXQ-1; Thu, 20 Feb 2020 11:09:41 -0500 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 01067477; Thu, 20 Feb 2020 16:09:40 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35CF9101D489; Thu, 20 Feb 2020 16:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214985; 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=MttArOFtWxbQbyc/L7DWpav82OCvI7dSnQyTC0YOVBQ=; b=NjXb+xSFRRjtm309iFF0D/9w67rl+8wlJ4+XtK0HFRDFrCgqWOz4J62SczaSx9ON8oNGY3 IArupLcamw/l3bLmosny+OZ1zowQYay1UfWgjwDQGVzgV58k+Xw9vMAf3UxeLyu2BxN9nZ YJcNVzXqzSMeIYrE/vJfMlLAZbKelX8= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 08/18] block/backup-top: fix flags handling Date: Thu, 20 Feb 2020 17:07:00 +0100 Message-Id: <20200220160710.533297-9-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: yxSDvBd5NqqcQDFqwopwXQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , 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: Vladimir Sementsov-Ogievskiy backup-top "supports" write-unchanged, by skipping CBW operation in backup_top_co_pwritev. But it forgets to do the same in backup_top_co_pwrite_zeroes, as well as declare support for BDRV_REQ_WRITE_UNCHANGED. Fix this, and, while being here, declare also support for flags supported by source child. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200207161231.32707-1-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- block/backup-top.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/block/backup-top.c b/block/backup-top.c index fa78f3256d..1bfb360bd3 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -48,11 +48,17 @@ static coroutine_fn int backup_top_co_preadv( } =20 static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offs= et, - uint64_t bytes) + uint64_t bytes, BdrvRequestFlags fl= ags) { BDRVBackupTopState *s =3D bs->opaque; - uint64_t end =3D QEMU_ALIGN_UP(offset + bytes, s->bcs->cluster_size); - uint64_t off =3D QEMU_ALIGN_DOWN(offset, s->bcs->cluster_size); + uint64_t off, end; + + if (flags & BDRV_REQ_WRITE_UNCHANGED) { + return 0; + } + + off =3D QEMU_ALIGN_DOWN(offset, s->bcs->cluster_size); + end =3D QEMU_ALIGN_UP(offset + bytes, s->bcs->cluster_size); =20 return block_copy(s->bcs, off, end - off, NULL); } @@ -60,7 +66,7 @@ static coroutine_fn int backup_top_cbw(BlockDriverState *= bs, uint64_t offset, static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { - int ret =3D backup_top_cbw(bs, offset, bytes); + int ret =3D backup_top_cbw(bs, offset, bytes, 0); if (ret < 0) { return ret; } @@ -71,7 +77,7 @@ static int coroutine_fn backup_top_co_pdiscard(BlockDrive= rState *bs, static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { - int ret =3D backup_top_cbw(bs, offset, bytes); + int ret =3D backup_top_cbw(bs, offset, bytes, flags); if (ret < 0) { return ret; } @@ -84,11 +90,9 @@ static coroutine_fn int backup_top_co_pwritev(BlockDrive= rState *bs, uint64_t bytes, QEMUIOVector *qiov, int flag= s) { - if (!(flags & BDRV_REQ_WRITE_UNCHANGED)) { - int ret =3D backup_top_cbw(bs, offset, bytes); - if (ret < 0) { - return ret; - } + int ret =3D backup_top_cbw(bs, offset, bytes, flags); + if (ret < 0) { + return ret; } =20 return bdrv_co_pwritev(bs->backing, offset, bytes, qiov, flags); @@ -196,8 +200,13 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverSt= ate *source, return NULL; } =20 - top->total_sectors =3D source->total_sectors; state =3D top->opaque; + top->total_sectors =3D source->total_sectors; + top->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & source->supported_write_flags); + top->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & + source->supported_zero_flags); =20 bdrv_ref(target); state->target =3D bdrv_attach_child(top, target, "target", &child_file= , errp); --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215466; cv=none; d=zohomail.com; s=zohoarc; b=QpXZWaV0Ef0VWzAi9kMqLrvVuGCY8TgHQU9QXEvB/fppkiOTekDO5teSWiD7ciNppmwFcZzil9u+WJ4FPqLG2+N7fTzDrq1fWh1AK64o6iCCjEcOWZWUtmDBuTgMIJbCNxkTvtVDT/9HjLh8U+0ESUDMZrXqDOSzDdjqGuPqxgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215466; 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=cxlR7vKbANcUPIfyDMHCSg6ZxhMzW1WqgzZTqXEeqG4=; b=TzM5sfroWQpUCxDfCAwpyG9iay9O7jqinU8hSkm2H+POn6UsIWh6Bvh6NHhiVc5+xEoMbTsxfPNDgRN3A6nIy8ErnaxoR89OpqVgxC4YN0TZCjBwBSuKy0+5GU2PqfJr4SYaqP3qYsRFGILt5SMT27KIu70vKtPV/jcZRumNuHs= 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 1582215466201333.4391095908029; Thu, 20 Feb 2020 08:17:46 -0800 (PST) Received: from localhost ([::1]:45290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oWG-0001f4-Vk for importer@patchew.org; Thu, 20 Feb 2020 11:17:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54976) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oOj-0005im-E0 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oOi-0006Bb-Bm for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:57 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48921 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oOi-0006BQ-87 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:09:56 -0500 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-372-h7Nv1wEEPNeyXLPm67D9cw-1; Thu, 20 Feb 2020 11:09:51 -0500 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 A52A71005512; Thu, 20 Feb 2020 16:09:50 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C71A291820; Thu, 20 Feb 2020 16:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214995; 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=cxlR7vKbANcUPIfyDMHCSg6ZxhMzW1WqgzZTqXEeqG4=; b=LMgw5oHbQH5Ifnoo3S+Z+bH17L8tK8XpWG69aI7AN3rfWLcmJgwK7v2QOSz0jK+RC21J9e sTUyb8+uugu5w37Rx1bOpAk5xFU7BwChpYfBIPnQF2JMdH/A+ezlBRF7uYvsPkLQd8cxWW 9TSpP4pjaeY4WvjuIl+jia6RB0HYMCU= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 09/18] iotests/279: Fix for non-qcow2 formats Date: Thu, 20 Feb 2020 17:07:01 +0100 Message-Id: <20200220160710.533297-10-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: h7Nv1wEEPNeyXLPm67D9cw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , 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" First, driver=3Dqcow2 will not work so well with non-qcow2 formats (and this test claims to support qcow, qed, and vmdk). Second, vmdk will always report the backing file format to be vmdk. Filter that out so the output looks like for all other formats. Third, the flat vmdk subformats do not support backing files, so they will not work with this test. Signed-off-by: Max Reitz Message-Id: <20191219144243.1763246-1-mreitz@redhat.com> Tested-by: Thomas Huth Signed-off-by: Max Reitz --- tests/qemu-iotests/279 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/279 b/tests/qemu-iotests/279 index 6682376808..30d29b1cb2 100755 --- a/tests/qemu-iotests/279 +++ b/tests/qemu-iotests/279 @@ -38,6 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow qcow2 vmdk qed _supported_proto file _supported_os Linux +_unsupported_imgopts "subformat=3DmonolithicFlat" \ + "subformat=3DtwoGbMaxExtentFlat" \ =20 TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M TEST_IMG=3D"$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base" @@ -45,11 +47,12 @@ _make_test_img -b "$TEST_IMG.mid" =20 echo echo '=3D=3D qemu-img info --backing-chain =3D=3D' -_img_info --backing-chain | _filter_img_info +_img_info --backing-chain | _filter_img_info | grep -v 'backing file forma= t' =20 echo echo '=3D=3D qemu-img info --backing-chain --image-opts =3D=3D' -TEST_IMG=3D"driver=3Dqcow2,file.driver=3Dfile,file.filename=3D$TEST_IMG" _= img_info --backing-chain --image-opts | _filter_img_info +TEST_IMG=3D"driver=3D$IMGFMT,file.driver=3Dfile,file.filename=3D$TEST_IMG"= _img_info --backing-chain --image-opts \ + | _filter_img_info | grep -v 'backing file format' =20 # success, all done echo "*** done" --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215347; cv=none; d=zohomail.com; s=zohoarc; b=K9XpA3ciCysqFaJnFgLCz4GZlWoib1R+WnSEep/du0QVY1ycBLVyN0MjvBaLk9YPGE6F3PBI/Nh7ZjvJM3S3muMJkxh0V0k3PUh6Up7K+olhAejqt24v03LizKhqXqAg+glGyid8IDn3pWEhxPJXYl/vQ1ziR8k/Ml8mhTzYpJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215347; 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=ME+RuJBRymVkZGFzUvmwu7dYrlI6PfVNp7T9hjqwwG0=; b=dnwIb/bhrjWG5p2XHWNo/EkDr9m1fA5kuiYUX7VeM4vkbsZ7DuzX6bdPuzXRIf8IpJ5lzeZL0UUoqx4B4yY8AIjEjMbdvpTJLIp+K7l9Rm0/xH+UviFISmNx8CeBJU8VS7u9fLyJXUL9dU1NU4xoApKThZL1CSqWqgL5Zwlng3o= 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 1582215347273783.8166363506533; Thu, 20 Feb 2020 08:15:47 -0800 (PST) Received: from localhost ([::1]:45254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oUL-0006u6-LC for importer@patchew.org; Thu, 20 Feb 2020 11:15:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55085) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oPC-0006n7-NI for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:10:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oPB-0006KR-Jl for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:10:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44183 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oPB-0006KE-FJ for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:10:25 -0500 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-436-qRftOIdaPm2-HCikafR8MA-1; Thu, 20 Feb 2020 11:10:20 -0500 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 A031019251B7; Thu, 20 Feb 2020 16:10:19 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 965F05C1B0; Thu, 20 Feb 2020 16:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215024; 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=ME+RuJBRymVkZGFzUvmwu7dYrlI6PfVNp7T9hjqwwG0=; b=URtCBIGhygFVpH5FGh62Wqvtx4LfOT7SdkyDO6E/WXHMDKULwHY2b9DlwKohd1Tim5W0VM Cu3N/3EzvgO53fH3wwDJXdKRNes8UuBTpWDgv6pw3ZvG1pUmhZN4pdJ9vXcx/zv7yN46h7 RtGofeQUzBBLJF3NySk1QoB/tm62U98= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 10/18] block/nbd: Fix hang in .bdrv_close() Date: Thu, 20 Feb 2020 17:07:02 +0100 Message-Id: <20200220160710.533297-11-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: qRftOIdaPm2-HCikafR8MA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Kevin Wolf , 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" When nbd_close() is called from a coroutine, the connection_co never gets to run, and thus nbd_teardown_connection() hangs. This is because aio_co_enter() only puts the connection_co into the main coroutine's wake-up queue, so this main coroutine needs to yield and wait for connection_co to terminate. Suggested-by: Kevin Wolf Signed-off-by: Max Reitz Message-Id: <20200122164532.178040-2-mreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Maxim Levitsky Signed-off-by: Max Reitz --- block/nbd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block/nbd.c b/block/nbd.c index d085554f21..6d3b22f844 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -70,6 +70,7 @@ typedef struct BDRVNBDState { CoMutex send_mutex; CoQueue free_sema; Coroutine *connection_co; + Coroutine *teardown_co; QemuCoSleepState *connection_co_sleep_ns_state; bool drained; bool wait_drained_end; @@ -203,7 +204,15 @@ static void nbd_teardown_connection(BlockDriverState *= bs) qemu_co_sleep_wake(s->connection_co_sleep_ns_state); } } - BDRV_POLL_WHILE(bs, s->connection_co); + if (qemu_in_coroutine()) { + s->teardown_co =3D qemu_coroutine_self(); + /* connection_co resumes us when it terminates */ + qemu_coroutine_yield(); + s->teardown_co =3D NULL; + } else { + BDRV_POLL_WHILE(bs, s->connection_co); + } + assert(!s->connection_co); } =20 static bool nbd_client_connecting(BDRVNBDState *s) @@ -395,6 +404,9 @@ static coroutine_fn void nbd_connection_entry(void *opa= que) s->ioc =3D NULL; } =20 + if (s->teardown_co) { + aio_co_wake(s->teardown_co); + } aio_wait_kick(); } =20 --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215468; cv=none; d=zohomail.com; s=zohoarc; b=HPAZ2IgjlYh+JnKfrz/WfPX4P+ILR5/HVsZtggT2wSvglUfyIzUoAq0euPi4qfHDrt788QxfaSchtG1LAuqV04L1ZD6smCyyLMVJTNxiAu01ztK3h1HqNqZuxwkDjODwoZbm0wty8GXuKvluJ0z59C9IUOI47MX1gaNYjA0k6Cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215468; 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=Y1j2F+uA43I/ghbVuJetmMh/0pWyi7QRriUjNOiBmpQ=; b=EjZjbzOtGRDzmfCf1jiaSQURdagaSBMBhW/QLDHYbHjIcfMSbtFgpYR8rKT0o3zOdzmBD8IZZcmpWDkccFUxXgmtNH8nVropG0/0HICFtyMifwwBgoLamoYTYkFRls4wDBm9u0YSBFxUvh7jplBAjS885EnBvavDj/ejgha8jyQ= 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 1582215468668221.80837798614994; Thu, 20 Feb 2020 08:17:48 -0800 (PST) Received: from localhost ([::1]:45292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oWJ-0001nH-OY for importer@patchew.org; Thu, 20 Feb 2020 11:17:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55162) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQ4-0008Ra-SX for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oQ3-00076o-G7 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47793 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oQ3-00075O-CA for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:19 -0500 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-211-i2eJYoZyPcqU61b1XfbvJw-1; Thu, 20 Feb 2020 11:11:13 -0500 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 9E17E1085444; Thu, 20 Feb 2020 16:11:12 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E0155D9E2; Thu, 20 Feb 2020 16:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215077; 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=Y1j2F+uA43I/ghbVuJetmMh/0pWyi7QRriUjNOiBmpQ=; b=B9o5mqZ2Ynw64S0HyPzeBZvOu1qW0PTFz6SiSD4o4cx6kFiNloKYYqHCphfgP/St028BWi C4Ib0g+60IF+xz/0zhc9UpL+LvXVFj6A6sKRCrS87wXHvb9yM0IGTnTgxehJ14PP9e9xwX rk6uGlWUAJ1fPzR4zxEp4z22FFtJLRw= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 11/18] block: Generic file creation fallback Date: Thu, 20 Feb 2020 17:07:03 +0100 Message-Id: <20200220160710.533297-12-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: i2eJYoZyPcqU61b1XfbvJw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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" If a protocol driver does not support image creation, we can see whether maybe the file exists already. If so, just truncating it will be sufficient. Signed-off-by: Max Reitz Message-Id: <20200122164532.178040-3-mreitz@redhat.com> Signed-off-by: Max Reitz --- block.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 147 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 08372ced26..308a91c96b 100644 --- a/block.c +++ b/block.c @@ -532,20 +532,139 @@ out: return ret; } =20 -int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp) +/** + * Helper function for bdrv_create_file_fallback(): Resize @blk to at + * least the given @minimum_size. + * + * On success, return @blk's actual length. + * Otherwise, return -errno. + */ +static int64_t create_file_fallback_truncate(BlockBackend *blk, + int64_t minimum_size, Error *= *errp) { - BlockDriver *drv; + Error *local_err =3D NULL; + int64_t size; + int ret; + + ret =3D blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, &loc= al_err); + if (ret < 0 && ret !=3D -ENOTSUP) { + error_propagate(errp, local_err); + return ret; + } + + size =3D blk_getlength(blk); + if (size < 0) { + error_free(local_err); + error_setg_errno(errp, -size, + "Failed to inquire the new image file's length"); + return size; + } + + if (size < minimum_size) { + /* Need to grow the image, but we failed to do that */ + error_propagate(errp, local_err); + return -ENOTSUP; + } + + error_free(local_err); + local_err =3D NULL; + + return size; +} + +/** + * Helper function for bdrv_create_file_fallback(): Zero the first + * sector to remove any potentially pre-existing image header. + */ +static int create_file_fallback_zero_first_sector(BlockBackend *blk, + int64_t current_size, + Error **errp) +{ + int64_t bytes_to_clear; + int ret; + + bytes_to_clear =3D MIN(current_size, BDRV_SECTOR_SIZE); + if (bytes_to_clear) { + ret =3D blk_pwrite_zeroes(blk, 0, bytes_to_clear, BDRV_REQ_MAY_UNM= AP); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to clear the new image's first sector= "); + return ret; + } + } + + return 0; +} + +static int bdrv_create_file_fallback(const char *filename, BlockDriver *dr= v, + QemuOpts *opts, Error **errp) +{ + BlockBackend *blk; + QDict *options =3D qdict_new(); + int64_t size =3D 0; + char *buf =3D NULL; + PreallocMode prealloc; Error *local_err =3D NULL; int ret; =20 + size =3D qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0); + buf =3D qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); + prealloc =3D qapi_enum_parse(&PreallocMode_lookup, buf, + PREALLOC_MODE_OFF, &local_err); + g_free(buf); + if (local_err) { + error_propagate(errp, local_err); + return -EINVAL; + } + + if (prealloc !=3D PREALLOC_MODE_OFF) { + error_setg(errp, "Unsupported preallocation mode '%s'", + PreallocMode_str(prealloc)); + return -ENOTSUP; + } + + qdict_put_str(options, "driver", drv->format_name); + + blk =3D blk_new_open(filename, NULL, options, + BDRV_O_RDWR | BDRV_O_RESIZE, errp); + if (!blk) { + error_prepend(errp, "Protocol driver '%s' does not support image " + "creation, and opening the image failed: ", + drv->format_name); + return -EINVAL; + } + + size =3D create_file_fallback_truncate(blk, size, errp); + if (size < 0) { + ret =3D size; + goto out; + } + + ret =3D create_file_fallback_zero_first_sector(blk, size, errp); + if (ret < 0) { + goto out; + } + + ret =3D 0; +out: + blk_unref(blk); + return ret; +} + +int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp) +{ + BlockDriver *drv; + drv =3D bdrv_find_protocol(filename, true, errp); if (drv =3D=3D NULL) { return -ENOENT; } =20 - ret =3D bdrv_create(drv, filename, opts, &local_err); - error_propagate(errp, local_err); - return ret; + if (drv->bdrv_co_create_opts) { + return bdrv_create(drv, filename, opts, errp); + } else { + return bdrv_create_file_fallback(filename, drv, opts, errp); + } } =20 /** @@ -1444,6 +1563,24 @@ QemuOptsList bdrv_runtime_opts =3D { }, }; =20 +static QemuOptsList fallback_create_opts =3D { + .name =3D "fallback-create-opts", + .head =3D QTAILQ_HEAD_INITIALIZER(fallback_create_opts.head), + .desc =3D { + { + .name =3D BLOCK_OPT_SIZE, + .type =3D QEMU_OPT_SIZE, + .help =3D "Virtual disk size" + }, + { + .name =3D BLOCK_OPT_PREALLOC, + .type =3D QEMU_OPT_STRING, + .help =3D "Preallocation mode (allowed values: off)" + }, + { /* end of list */ } + } +}; + /* * Common part for opening disk images and files * @@ -5772,15 +5909,13 @@ void bdrv_img_create(const char *filename, const ch= ar *fmt, return; } =20 - if (!proto_drv->create_opts) { - error_setg(errp, "Protocol driver '%s' does not support image crea= tion", - proto_drv->format_name); - return; - } - /* Create parameter list */ create_opts =3D qemu_opts_append(create_opts, drv->create_opts); - create_opts =3D qemu_opts_append(create_opts, proto_drv->create_opts); + if (proto_drv->create_opts) { + create_opts =3D qemu_opts_append(create_opts, proto_drv->create_op= ts); + } else { + create_opts =3D qemu_opts_append(create_opts, &fallback_create_opt= s); + } =20 opts =3D qemu_opts_create(create_opts, NULL, 0, &error_abort); =20 --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215209; cv=none; d=zohomail.com; s=zohoarc; b=eegVwlx63cmstEEWQUzLC9vWmxRpmSIl76gomD8m9Z8ktA572wk1BnOTP1HlWfxN8wDXOGEs3+zFSSqOLZFtMwmIOXI0h6lHRMRFzH9F3clN8FydhfT0VejyFJkS8EySLj06sk13b6hQWyGMsssBOB0vCpfp1F2LkKGk7hKRBB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215209; 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=Zqzb1tFd/mwGWRwOtwMePqgul2Q2QiYxo3u298Fw+l0=; b=TTXUR6RRTrhDK97mmO3tRNOU/yuPD/UQA7Od6pO7DS0zIvR87mhZ7o5q/TVkFkDDXRpG6B+ltZKsOOfTDMuZuyNKYlAmyW5YYNBYcjrFVl/bG+O2YSHqozj2Pq/+haQMX2Ar6g2Wud8ytmsD6s6enPA9AxnBUV9KECPKww030QY= 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 1582215209249325.41133488566993; Thu, 20 Feb 2020 08:13:29 -0800 (PST) Received: from localhost ([::1]:45184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oS7-0003Ec-Vj for importer@patchew.org; Thu, 20 Feb 2020 11:13:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55186) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQH-0000Za-Dt for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oQG-0007CV-74 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42397 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oQG-0007CK-2I for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:32 -0500 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-294-smsJNc8cOXyiy4Cp9k9moQ-1; Thu, 20 Feb 2020 11:11:21 -0500 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 3F325100550E; Thu, 20 Feb 2020 16:11:20 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1E8460BE1; Thu, 20 Feb 2020 16:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215091; 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=Zqzb1tFd/mwGWRwOtwMePqgul2Q2QiYxo3u298Fw+l0=; b=VrQ4eTWngsIv9sHI5v1Fo8RJJ3VutdzM8A6sLWjSU82I2FtzCuCb/HG0+JUr4gq7MjBG+g Fgt7os8UCjLuDl/WrNldYjRww/moTtmvU0qM+6w8YznQIQPwi/gqlNXXo7XSw1ZSC49AI8 P8WsHM9QGysVeQZekxaa2Z74pnLEs98= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 12/18] file-posix: Drop hdev_co_create_opts() Date: Thu, 20 Feb 2020 17:07:04 +0100 Message-Id: <20200220160710.533297-13-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: smsJNc8cOXyiy4Cp9k9moQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Kevin Wolf , 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" The generic fallback implementation effectively does the same. Reviewed-by: Maxim Levitsky Signed-off-by: Max Reitz Message-Id: <20200122164532.178040-4-mreitz@redhat.com> Signed-off-by: Max Reitz --- block/file-posix.c | 67 ---------------------------------------------- 1 file changed, 67 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index ab82ee1a67..6345477112 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -3477,67 +3477,6 @@ static coroutine_fn int hdev_co_pwrite_zeroes(BlockD= riverState *bs, return raw_do_pwrite_zeroes(bs, offset, bytes, flags, true); } =20 -static int coroutine_fn hdev_co_create_opts(const char *filename, QemuOpts= *opts, - Error **errp) -{ - int fd; - int ret =3D 0; - struct stat stat_buf; - int64_t total_size =3D 0; - bool has_prefix; - - /* This function is used by both protocol block drivers and therefore = either - * of these prefixes may be given. - * The return value has to be stored somewhere, otherwise this is an e= rror - * due to -Werror=3Dunused-value. */ - has_prefix =3D - strstart(filename, "host_device:", &filename) || - strstart(filename, "host_cdrom:" , &filename); - - (void)has_prefix; - - ret =3D raw_normalize_devicepath(&filename, errp); - if (ret < 0) { - return ret; - } - - /* Read out options */ - total_size =3D ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), - BDRV_SECTOR_SIZE); - - fd =3D qemu_open(filename, O_WRONLY | O_BINARY); - if (fd < 0) { - ret =3D -errno; - error_setg_errno(errp, -ret, "Could not open device"); - return ret; - } - - if (fstat(fd, &stat_buf) < 0) { - ret =3D -errno; - error_setg_errno(errp, -ret, "Could not stat device"); - } else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode)) { - error_setg(errp, - "The given file is neither a block nor a character devi= ce"); - ret =3D -ENODEV; - } else if (lseek(fd, 0, SEEK_END) < total_size) { - error_setg(errp, "Device is too small"); - ret =3D -ENOSPC; - } - - if (!ret && total_size) { - uint8_t buf[BDRV_SECTOR_SIZE] =3D { 0 }; - int64_t zero_size =3D MIN(BDRV_SECTOR_SIZE, total_size); - if (lseek(fd, 0, SEEK_SET) =3D=3D -1) { - ret =3D -errno; - } else { - ret =3D qemu_write_full(fd, buf, zero_size); - ret =3D ret =3D=3D zero_size ? 0 : -errno; - } - } - qemu_close(fd); - return ret; -} - static BlockDriver bdrv_host_device =3D { .format_name =3D "host_device", .protocol_name =3D "host_device", @@ -3550,8 +3489,6 @@ static BlockDriver bdrv_host_device =3D { .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, - .bdrv_co_create_opts =3D hdev_co_create_opts, - .create_opts =3D &raw_create_opts, .mutable_opts =3D mutable_opts, .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, .bdrv_co_pwrite_zeroes =3D hdev_co_pwrite_zeroes, @@ -3678,8 +3615,6 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, - .bdrv_co_create_opts =3D hdev_co_create_opts, - .create_opts =3D &raw_create_opts, .mutable_opts =3D mutable_opts, .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, =20 @@ -3812,8 +3747,6 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, - .bdrv_co_create_opts =3D hdev_co_create_opts, - .create_opts =3D &raw_create_opts, .mutable_opts =3D mutable_opts, =20 .bdrv_co_preadv =3D raw_co_preadv, --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215595; cv=none; d=zohomail.com; s=zohoarc; b=eQRIQjNdxDr36woIDi1p6VTt5jxUR4o3IRklEOy2pi0Y36gWizd3Q19rR9BQJ2ot/yF7tfOkLkWR20os9Xmnx9NWi/ynvdZlKsUvy9oH9IIg5o4+rrbZhFMec3X3AJrNH7+kROX1LUnpHXxj/SPd8a8iUqqifxw7G4gdzjgue+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215595; 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=qUx1jkzn2LXx673KdYZrWkQgEj1mTKxfCWKAh53agL8=; b=UqYeVt9hLrWrBNNVk8blzhBeXZVk4p86KQSY1JdpUqlE8Z6PczFYKK3yRmV23oBblKXJ+lVVmDe2yoUaXp7wPFg16ngSBb2ftd8Y8KW1wJHiphnDouASKEVftt9yKOVJP4TABfjohkkQwCqVVNyCaaJPi3Y3d1JgR9HGsJpnUkY= 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 1582215595876733.6353023600392; Thu, 20 Feb 2020 08:19:55 -0800 (PST) Received: from localhost ([::1]:45326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oYM-0005ds-KL for importer@patchew.org; Thu, 20 Feb 2020 11:19:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oQW-0000ez-42 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oQU-0007Ep-7K for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:48 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:32110 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oQU-0007DF-2x for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:11:46 -0500 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-362-TKwBCt8NOOuT1vOKRkTYkg-1; Thu, 20 Feb 2020 11:11:32 -0500 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 E3BD7802700; Thu, 20 Feb 2020 16:11:30 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C03F5DA7B; Thu, 20 Feb 2020 16:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215096; 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=qUx1jkzn2LXx673KdYZrWkQgEj1mTKxfCWKAh53agL8=; b=iiJ3OhKs/O7XE9oWSfzq+F1sdhAPA+DMv/+Z4jBulBAFjO/KyU6KiyCwD24+F0CA6jFVtT rmU4/GOlKAmg227cKrG62TIH/GNqneUYtL0d2X03y3/rvUjqRGptE+UbJFuRiPPZjy9R17 IbrHkQBI8EstY+hWI66bmFBgttpbfu4= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 13/18] iscsi: Drop iscsi_co_create_opts() Date: Thu, 20 Feb 2020 17:07:05 +0100 Message-Id: <20200220160710.533297-14-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: TKwBCt8NOOuT1vOKRkTYkg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , 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" The generic fallback implementation effectively does the same. Reviewed-by: Maxim Levitsky Signed-off-by: Max Reitz Message-Id: <20200122164532.178040-5-mreitz@redhat.com> Signed-off-by: Max Reitz --- block/iscsi.c | 56 --------------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index c8feaa2f0e..682abd8e09 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2164,58 +2164,6 @@ static int coroutine_fn iscsi_co_truncate(BlockDrive= rState *bs, int64_t offset, return 0; } =20 -static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpt= s *opts, - Error **errp) -{ - int ret =3D 0; - int64_t total_size =3D 0; - BlockDriverState *bs; - IscsiLun *iscsilun =3D NULL; - QDict *bs_options; - Error *local_err =3D NULL; - - bs =3D bdrv_new(); - - /* Read out options */ - total_size =3D DIV_ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE= , 0), - BDRV_SECTOR_SIZE); - bs->opaque =3D g_new0(struct IscsiLun, 1); - iscsilun =3D bs->opaque; - - bs_options =3D qdict_new(); - iscsi_parse_filename(filename, bs_options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret =3D -EINVAL; - } else { - ret =3D iscsi_open(bs, bs_options, 0, NULL); - } - qobject_unref(bs_options); - - if (ret !=3D 0) { - goto out; - } - iscsi_detach_aio_context(bs); - if (iscsilun->type !=3D TYPE_DISK) { - ret =3D -ENODEV; - goto out; - } - if (bs->total_sectors < total_size) { - ret =3D -ENOSPC; - goto out; - } - - ret =3D 0; -out: - if (iscsilun->iscsi !=3D NULL) { - iscsi_destroy_context(iscsilun->iscsi); - } - g_free(bs->opaque); - bs->opaque =3D NULL; - bdrv_unref(bs); - return ret; -} - static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { IscsiLun *iscsilun =3D bs->opaque; @@ -2486,8 +2434,6 @@ static BlockDriver bdrv_iscsi =3D { .bdrv_parse_filename =3D iscsi_parse_filename, .bdrv_file_open =3D iscsi_open, .bdrv_close =3D iscsi_close, - .bdrv_co_create_opts =3D iscsi_co_create_opts, - .create_opts =3D &iscsi_create_opts, .bdrv_reopen_prepare =3D iscsi_reopen_prepare, .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, @@ -2525,8 +2471,6 @@ static BlockDriver bdrv_iser =3D { .bdrv_parse_filename =3D iscsi_parse_filename, .bdrv_file_open =3D iscsi_open, .bdrv_close =3D iscsi_close, - .bdrv_co_create_opts =3D iscsi_co_create_opts, - .create_opts =3D &iscsi_create_opts, .bdrv_reopen_prepare =3D iscsi_reopen_prepare, .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215480; cv=none; d=zohomail.com; s=zohoarc; b=H44Stpp81l2SrIGSiRhhfo1JonQatazOBcnMnXfZyECKK3EKbSjbLwiWRG/Ja4x11Yjc+aYvuloiZi8nyljKvbJDaZrbEpHEVxbcw4JUOKDXDUOuIFRTMXVc4C3KzArioS6N/76VSE6i9Z+IxnyWkJBjtTlcBIejwo5i3XHUGrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215480; 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=+P3c9IeuuFwlbAjzYnXXV2dOknHwBFRWXj5QywQJiVY=; b=DzGEMQAiqsskMa8YQgx6GcQ9x3InscrL/4S9FEVbHprVqRtaxX8Lfncj2IQ4iAo6R6XBuhEETSC+g5FG7HJ8dLqf+u0bQOM6+6XgAvYIWjCqQ7MjehBzLXk2RCGQipgvYCEHhYlcMJrfD1OY7Z1+cGtFc/flwK8hCBtXhmOA2Vc= 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 1582215480114571.5710355579403; Thu, 20 Feb 2020 08:18:00 -0800 (PST) Received: from localhost ([::1]:45296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oWV-0002FS-6f for importer@patchew.org; Thu, 20 Feb 2020 11:17:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55472) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oRz-0003YR-6m for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oRx-0007ag-PK for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:19 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45119 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oRx-0007aO-Lc for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:17 -0500 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-405-bybKC1oHNrKMtRHhzmRFSQ-1; Thu, 20 Feb 2020 11:13:12 -0500 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 F12B5800D48; Thu, 20 Feb 2020 16:13:10 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 598AD19481; Thu, 20 Feb 2020 16:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215197; 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=+P3c9IeuuFwlbAjzYnXXV2dOknHwBFRWXj5QywQJiVY=; b=RVK4cPx38G5bOKprqvX2LD/xp1woJOPK8qQLYlPpaFECHm34dEfIyfI2INlzi1b0G586o1 FyJEKmEo9o15t5wbGm9AhmOq7dqDbZAhIDwALU2run8tcmKr4/DlrdYXubGIAcerjymw02 1yNUp3duKJmX7KSL7HWCEn3dPlpuHbg= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 14/18] iotests: Add test for image creation fallback Date: Thu, 20 Feb 2020 17:07:06 +0100 Message-Id: <20200220160710.533297-15-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: bybKC1oHNrKMtRHhzmRFSQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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" Signed-off-by: Max Reitz Message-Id: <20200122164532.178040-6-mreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Maxim Levitsky [mreitz: Added a note that NBD does not support resizing, which is why the second case is expected to fail] Signed-off-by: Max Reitz --- tests/qemu-iotests/259 | 62 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/259.out | 14 +++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/qemu-iotests/259 create mode 100644 tests/qemu-iotests/259.out diff --git a/tests/qemu-iotests/259 b/tests/qemu-iotests/259 new file mode 100755 index 0000000000..62e29af05f --- /dev/null +++ b/tests/qemu-iotests/259 @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# +# Test generic image creation fallback (by using NBD) +# +# Copyright (C) 2019 Red Hat, Inc. +# +# 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=3Dmreitz@redhat.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 raw +_supported_proto nbd +_supported_os Linux + + +_make_test_img 64M + +echo +echo '--- Testing creation ---' + +$QEMU_IMG create -f qcow2 "$TEST_IMG" 64M | _filter_img_create +$QEMU_IMG info "$TEST_IMG" | _filter_img_info + +echo +echo '--- Testing creation for which the node would need to grow ---' + +# NBD does not support resizing, so this will fail +$QEMU_IMG create -f qcow2 -o preallocation=3Dmetadata "$TEST_IMG" 64M 2>&1= \ + | _filter_img_create + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/259.out b/tests/qemu-iotests/259.out new file mode 100644 index 0000000000..ffed19c2a0 --- /dev/null +++ b/tests/qemu-iotests/259.out @@ -0,0 +1,14 @@ +QA output created by 259 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 + +--- Testing creation --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3Dqcow2 size=3D67108864 +image: TEST_DIR/t.IMGFMT +file format: qcow2 +virtual size: 64 MiB (67108864 bytes) +disk size: unavailable + +--- Testing creation for which the node would need to grow --- +qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver d= oes not support resize +Formatting 'TEST_DIR/t.IMGFMT', fmt=3Dqcow2 size=3D67108864 preallocation= =3Dmetadata +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 818380a8f0..b17711d17d 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -273,6 +273,7 @@ 256 rw auto quick 257 rw 258 rw quick +259 rw auto quick 260 rw quick 261 rw 262 rw quick migration --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215693; cv=none; d=zohomail.com; s=zohoarc; b=eyT9+QfHMTKfvwjiodTPoCp/DKnVlYUkDmoT+oVNOKDGzsICIMWcQ7vzasH7r5MUFLxDyQMGMh+5vWNws3WYM8WRvhqisvqHKo3wailL48DLJ11KzvM9y8laMcrkAKKGXBb704w/uC20DeYbx/AQLRInUwZnF8nemr4tIA7PzVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215693; 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=GZxh2QIKv+rwCE1aHIlFEa2Fw2OaGQEvH1Pxdw3tUPM=; b=VYecanjsT6HJcBHWirI1wxcbiSPY4thwrJ91V+xiIodO/PMUMVyU2Urf9mN4WjZr4V2O8IZ30T6WpRLhVBOChVcNpUVYfaIxzZrxz7bWmg6kvoByEMGLPXtI93gBmyUjMYl2UXFQI0wSgfALgBp4uV5EcWL7AgqYaId2jhkak+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 158221569387149.53663432789358; Thu, 20 Feb 2020 08:21:33 -0800 (PST) Received: from localhost ([::1]:45418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oZw-0007yx-RD for importer@patchew.org; Thu, 20 Feb 2020 11:21:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55493) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oS9-0003yh-5i for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oS8-0007dN-3W for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:29 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42998 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oS7-0007c0-Up for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:28 -0500 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-4zZhL8nNNhm0a3zR39MXbg-1; Thu, 20 Feb 2020 11:13:22 -0500 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 6B7A4DB60; Thu, 20 Feb 2020 16:13:21 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B9C919756; Thu, 20 Feb 2020 16:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215207; 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=GZxh2QIKv+rwCE1aHIlFEa2Fw2OaGQEvH1Pxdw3tUPM=; b=EeNFbwraEP4zTMRzMa3g6/0cfP29rSFNpcLcSj+aI8U7eLDPX3hAO7ZXlvCk7hrImsYVNp 01yeGX0vrygVD/z3OUeVkCAe5oi1U+Q4H+ZJSKm46+eHaaq4YNYi3zPuOMmQmRuNouDGGR WnelVKot1wSSwMJTkRztT+gNxGvQ6PE= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 15/18] qemu-img: Fix convert -n -B for backing-less targets Date: Thu, 20 Feb 2020 17:07:07 +0100 Message-Id: <20200220160710.533297-16-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 4zZhL8nNNhm0a3zR39MXbg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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" s.target_has_backing does not reflect whether the target BDS has a backing file; it only tells whether we should use a backing file during conversion (specified by -B). As such, if you use convert -n, the target does not necessarily actually have a backing file, and then dereferencing out_bs->backing fails here. When converting to an existing file, we should set target_backing_sectors to a negative value, because first, as the comment explains, this value is only used for optimization, so it is always fine to do that. Second, we use this value to determine where the target must be initialized to zeroes (overlays are initialized to zero after the end of their backing file). When converting to an existing file, we cannot assume that to be true. Cc: qemu-stable@nongnu.org Fixes: 351c8efff9ad809c822d55620df54d575d536f68 ("qemu-img: Special post-backing convert handling") Signed-off-by: Max Reitz Message-Id: <20200121155915.98232-2-mreitz@redhat.com> Reviewed-by: John Snow Signed-off-by: Max Reitz --- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 0faf2cd2f5..804630a368 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2523,7 +2523,7 @@ static int img_convert(int argc, char **argv) } } =20 - if (s.target_has_backing) { + if (s.target_has_backing && s.target_is_new) { /* Errors are treated as "backing length unknown" (which means * s.target_backing_sectors has to be negative, which it will * be automatically). The backing file length is used only --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215352; cv=none; d=zohomail.com; s=zohoarc; b=mJrYyTDB/DvdmxGw8yzxosAH+HcNHZ79hJ5C3GiwVoyMes4V4g6/BBm+0uP+I4AOKq7jHeQWIDD/zApbW9lPxbA2Syyfm435CZ+KZV3JvCEg/escOiGbKPyjEcsm0qY2FvAvg20az9NOhWOasYoVx43tAZpgVFUZ217iAYGsXKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215352; 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=D/RFWb//vwRXnJ50nvQetO6VIazhkUzCowSW8Gse64g=; b=F8NYKMMDqK/ALAx3oKPNUDSs12/+uOqfXassWdRzaSW2tHhmqDDpM7AvsN/x7hET1+4KeKlvebXfZsZXr4jPBgoiTz8Ej7xv3dERZwn2P7smiHppIy0eHm5fAnLJABUHw3GqQ13sWTGZDZIP/f6711RwUqJYYLlguS9aR/E8IYI= 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 1582215352096821.3496129716647; Thu, 20 Feb 2020 08:15:52 -0800 (PST) Received: from localhost ([::1]:45256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oUP-00071C-M0 for importer@patchew.org; Thu, 20 Feb 2020 11:15:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55556) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oSH-00045A-Cj for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oSG-0007ic-C7 for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:37 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48304 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oSG-0007iQ-2C for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:36 -0500 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-395-IRn26HcEMyyuG-rXbjH7Vg-1; Thu, 20 Feb 2020 11:13:28 -0500 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 88F38800D4E; Thu, 20 Feb 2020 16:13:27 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A76CF87B0A; Thu, 20 Feb 2020 16:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215215; 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=D/RFWb//vwRXnJ50nvQetO6VIazhkUzCowSW8Gse64g=; b=a3+u+fR1U9u7SOTizhpD6XsvgAYLE0BvGt+iKO3GV89LFaqrpZjhz4Z9W5di5+gBaVbtf0 64JmvbvtpTgldxDBMSlsKW452xMvmFrJcbtfkl5ws0dWL/U6dE9ojD5/dXqnpapk5b+Avn FKwXFNDQY1IOBrlLTpGC9QFxCSHH2y8= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 16/18] iotests: Test convert -n -B to backing-less target Date: Thu, 20 Feb 2020 17:07:08 +0100 Message-Id: <20200220160710.533297-17-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: IRn26HcEMyyuG-rXbjH7Vg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Kevin Wolf , 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" This must not crash. Signed-off-by: Max Reitz Message-Id: <20200121155915.98232-3-mreitz@redhat.com> Reviewed-by: John Snow Signed-off-by: Max Reitz --- tests/qemu-iotests/122 | 14 ++++++++++++++ tests/qemu-iotests/122.out | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122 index dfa350936f..f7a3ae684a 100755 --- a/tests/qemu-iotests/122 +++ b/tests/qemu-iotests/122 @@ -276,6 +276,20 @@ $QEMU_IMG convert -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG= ".orig =20 $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG".orig =20 +echo +echo '=3D=3D=3D -n -B to an image without a backing file =3D=3D=3D' +echo + +# Base for the output +TEST_IMG=3D"$TEST_IMG".base _make_test_img 64M + +# Output that does have $TEST_IMG.base set as its (implicit) backing file +TEST_IMG=3D"$TEST_IMG".orig _make_test_img 64M + +# Convert with -n, which should not confuse -B with "target BDS has a +# backing file" +$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -n "$TEST_IMG" "$TEST_IMG= ".orig + # success, all done echo '*** done' rm -f $seq.full diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 849b6cc2ef..1a35951a80 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -228,4 +228,9 @@ Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=3DIMGFMT size= =3D67108864 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Images are identical. + +=3D=3D=3D -n -B to an image without a backing file =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=3DIMGFMT size=3D67108864 *** done --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215470; cv=none; d=zohomail.com; s=zohoarc; b=KXBUo2yp/FMRF/eXb78pnXvDDzNwOJMIe4di7wCpQ/tgYNYlK1IC+4mvMnTPSJL/Vx07fGmVXjaMsyw926AJ03VEzz2nVspaz3xDLiSvuHLLLcGDfPI15x4LfQzW7X5vc4zFiUhlKTTZmp6cxLtwvb0q/p0+ogmvY6h9hV21fks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215470; 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=JgzQoCkToAaLJGU81K+sbb7vCdZYQlGr8ipRHTLnR4o=; b=hBoKr+HbtCLsDcFk9F7UQRszkAktzj1/Ml0c6m3Q+d0ljkIwP/cnAkpnTOe+2hTFOwcRZsp1XDz5bnpdU9yh9EF+BwPKz/RHAuHE8dwlfTB2FHUA0w6Muvh1SGoyAAhHf6YfVkHErpzH8SNbdFWRSoJTCe4AuJmPCAwzHk2FlOk= 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 1582215470798351.0235294419863; Thu, 20 Feb 2020 08:17:50 -0800 (PST) Received: from localhost ([::1]:45294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oWL-0001sh-PO for importer@patchew.org; Thu, 20 Feb 2020 11:17:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55569) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oSS-0004Ry-Jt for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oSR-0007jc-EF for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32046 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oSR-0007jY-AS for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:47 -0500 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-13-97MWK5_zPqGW3VSV-RO6Aw-1; Thu, 20 Feb 2020 11:13:41 -0500 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 15741DB62; Thu, 20 Feb 2020 16:13:40 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 517DA60C87; Thu, 20 Feb 2020 16:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215226; 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=JgzQoCkToAaLJGU81K+sbb7vCdZYQlGr8ipRHTLnR4o=; b=N94aifm8xxXoWLnOdkx84MKIx3sqVBMcqbGlSu8Ch9zsJRJ4yVqcv7vS4a30bqmWKbhlPG AiNVhyGRAFrVcFwljLwkEVHGHYztYY1bUMwt08O4/RCzrfYbYKCMQAvHM4BZPoev8NJFoo GqD4f27eZPCB9EsRQhy6tGHr3X718v8= X-MC-Unique: 97MWK5_zPqGW3VSV-RO6Aw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 17/18] block: Fix VM size field width in snapshot dump Date: Thu, 20 Feb 2020 17:07:09 +0100 Message-Id: <20200220160710.533297-18-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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" When printing the snapshot list (e.g. with qemu-img snapshot -l), the VM size field is only seven characters wide. As of de38b5005e9, this is not necessarily sufficient: We generally print three digits, and this may require a decimal point. Also, the unit field grew from something as plain as "M" to " MiB". This means that number and unit may take up eight characters in total; but we also want spaces in front. Considering previously the maximum width was four characters and the field width was chosen to be three characters wider, let us adjust the field width to be eleven now. Fixes: de38b5005e946aa3714963ea4c501e279e7d3666 Buglink: https://bugs.launchpad.net/qemu/+bug/1859989 Signed-off-by: Max Reitz Message-Id: <20200117105859.241818-2-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 3f09477cc5..afd9f3b4a7 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -664,7 +664,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) char *sizing =3D NULL; =20 if (!sn) { - qemu_printf("%-10s%-20s%7s%20s%15s", + qemu_printf("%-10s%-20s%11s%20s%15s", "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); } else { ti =3D sn->date_sec; @@ -679,7 +679,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) (int)(secs % 60), (int)((sn->vm_clock_nsec / 1000000) % 1000)); sizing =3D size_to_str(sn->vm_state_size); - qemu_printf("%-10s%-20s%7s%20s%15s", + qemu_printf("%-10s%-20s%11s%20s%15s", sn->id_str, sn->name, sizing, date_buf, --=20 2.24.1 From nobody Thu May 2 09:36:12 2024 Delivered-To: importer@patchew.org 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; 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=1582215592; cv=none; d=zohomail.com; s=zohoarc; b=mEfwl7Fht4Y+NxxAMANP7xoEhFKke8gY4FRlEsGcyIGrcYlQw8nW/6PrFhIHe99SYppl7OPytg0xGM4LpzVLzQtN0ZWBr/oTDtcK9OjopsQvGzQhNTBq+LKxexoWS6IwX2ElmFplDpQZrW5r4Di8EcaRqG6a28qB7KaA0L1Knd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582215592; 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=3uo7IzQcHLLPvInEIDQM2gitcHRMOb4KBi9jO0ZWKgM=; b=CGZGjPxJCyZjDVQ4MxUWT+lgSV9txauebVbING0lmTnoxEaaDd5sUZCAhBgfqpa8mOi0BQEOA1Xo+HwAZCCU13TgYkDo/AZ8RfYFxp1vqicd1Z+nt0DLmFeTR+1evt5V1VozL2W+ARW8zz/wu165Oms5nVy8hXbE4IBZeof6rfA= 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 1582215592395949.4137012493917; Thu, 20 Feb 2020 08:19:52 -0800 (PST) Received: from localhost ([::1]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oYJ-0005TM-7F for importer@patchew.org; Thu, 20 Feb 2020 11:19:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55610) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4oSX-0004f0-St for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4oSW-0007kw-JL for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33724 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4oSW-0007kc-GA for qemu-devel@nongnu.org; Thu, 20 Feb 2020 11:13:52 -0500 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-491-mT73dgz0PO-s3A6N2w84DA-1; Thu, 20 Feb 2020 11:13:49 -0500 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 6EBA61005512; Thu, 20 Feb 2020 16:13:48 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18CCC5C1B0; Thu, 20 Feb 2020 16:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582215232; 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=3uo7IzQcHLLPvInEIDQM2gitcHRMOb4KBi9jO0ZWKgM=; b=SjUUBiyS9GZUeL5R/pqPtU6gVJT8OSUAExMNvcedUrwkJhjM86Ic8p9Bmu77LQ3uoEn/kg wygWKEzhmjeXiJ6Pt+NyaXIMBpOZiEuZBqJp69vM0tUlbpWeSLqIB9e3WNTEIIrndWbUhf Upxs2QLamKorelJqv7+5WMQQFn/jyrk= From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 18/18] iotests: Test snapshot -l field separation Date: Thu, 20 Feb 2020 17:07:10 +0100 Message-Id: <20200220160710.533297-19-mreitz@redhat.com> In-Reply-To: <20200220160710.533297-1-mreitz@redhat.com> References: <20200220160710.533297-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: mT73dgz0PO-s3A6N2w84DA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Kevin Wolf , 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" Add a test that all fields in "qemu-img snapshot -l"s output are separated by spaces. Signed-off-by: Max Reitz Message-Id: <20200117105859.241818-3-mreitz@redhat.com> Reviewed-by: Eric Blake [mreitz: Renamed test from 284 to 286] Signed-off-by: Max Reitz --- tests/qemu-iotests/286 | 76 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/286.out | 8 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 85 insertions(+) create mode 100755 tests/qemu-iotests/286 create mode 100644 tests/qemu-iotests/286.out diff --git a/tests/qemu-iotests/286 b/tests/qemu-iotests/286 new file mode 100755 index 0000000000..f14445ba4a --- /dev/null +++ b/tests/qemu-iotests/286 @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# +# Test qemu-img snapshot -l +# +# Copyright (C) 2019 Red Hat, Inc. +# +# 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 . +# + +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 +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +# Internal snapshots are (currently) impossible with refcount_bits=3D1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=3D1[^0-9]' data_file + +_make_test_img 64M + +# Should be so long as to take up the whole field width +sn_name=3Dabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz + +# More memory will give us a larger VM state, i.e. one above 1 MB. +# This way, we get a number with a decimal point. +qemu_comm_method=3Dmonitor _launch_qemu -m 512 "$TEST_IMG" + +_send_qemu_cmd $QEMU_HANDLE "savevm $sn_name" '(qemu)' +_send_qemu_cmd $QEMU_HANDLE 'quit' '(qemu)' +wait=3Dyes _cleanup_qemu + +# Check that all fields are separated by spaces. +# We first collapse all space sequences into one space each; +# then we turn every space-separated field into a '.'; +# and finally, we name the '.'s so the output is not just a confusing +# sequence of dots. + +echo 'Output structure:' +$QEMU_IMG snapshot -l "$TEST_IMG" | tail -n 1 | tr -s ' ' \ + | sed -e 's/\S\+/./g' \ + | sed -e 's/\./(snapshot ID)/' \ + -e 's/\./(snapshot name)/' \ + -e 's/\./(VM state size value)/' \ + -e 's/\./(VM state size unit)/' \ + -e 's/\./(snapshot date)/' \ + -e 's/\./(snapshot time)/' \ + -e 's/\./(VM clock)/' + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/286.out b/tests/qemu-iotests/286.out new file mode 100644 index 0000000000..39ff07e12c --- /dev/null +++ b/tests/qemu-iotests/286.out @@ -0,0 +1,8 @@ +QA output created by 286 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) savevm abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz +(qemu) quit +Output structure: +(snapshot ID) (snapshot name) (VM state size value) (VM state size unit) (= snapshot date) (snapshot time) (VM clock) +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index b17711d17d..0317667695 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -292,3 +292,4 @@ 281 rw quick 283 auto quick 284 rw +286 rw quick --=20 2.24.1