From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961138; cv=none; d=zohomail.com; s=zohoarc; b=k+8xd0N1dTkVO+5VvPKFHsi5Jd2FAt/bCxb3gj2IlLwPqcd19qfKKh4YA9tJDMDuK/yvrWPreqslTq4e2Sb+reKdEDY23TTm3woVbFj0Zb+wSw8vSvYR6dRd/QG4L7Hegx8KzNN8iP54wKn7UIKA9UNACZiE9ngf+XBsDh/Njwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961138; 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=Qfzq08Le1zJf7CAaoM1AwB/IXH0chskOmrefaRv4knQ=; b=oEVmmT9P9hDlnRtpxKjRxikPrG2pBNZy/W2l2hmzOsKq9phphMBx+jgcb85ENvHqVrp7MEt2RnqTj38vBW7Q/fEYLO8Log6U7W5z9f2WFvMfnV3Gjg9BlEEyWh1mjqXu8zwA+X4+J0isi2303YX4ZaiNVj+ITHF69mjKXVSIiT8= 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 1588961138285562.1959084745398; Fri, 8 May 2020 11:05:38 -0700 (PDT) Received: from localhost ([::1]:57940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7NQ-0001zj-DY for importer@patchew.org; Fri, 08 May 2020 14:05:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ln-0000DC-Lv for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:55 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:52342 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lk-0007J3-GN for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-6CVAJRdzPKe3uvRWxLOOSw-1; Fri, 08 May 2020 14:03:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 858897BB2; Fri, 8 May 2020 18:03:43 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EFEB61989; Fri, 8 May 2020 18:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961029; 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=Qfzq08Le1zJf7CAaoM1AwB/IXH0chskOmrefaRv4knQ=; b=WQllda6DnjRXt7u6UnuITjqMggl9dAG1mqsBtB6Y/psnuz/nmoKAujTFYEDmptcVAvhHx0 uw2MDfBGHM7z7jJ5qmKF32+UzOy7SUiiuPdRRurxnlf0OaGfPtCOUN5ekyiAumdk+pMaCb yT9lduuItK2ErB5psbP5vBzqpaz0y6E= X-MC-Unique: 6CVAJRdzPKe3uvRWxLOOSw-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 1/9] docs: Sort sections on qemu-img subcommand parameters Date: Fri, 8 May 2020 13:03:32 -0500 Message-Id: <20200508180340.675712-2-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 08:00:48 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com 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" We already list the subcommand summaries alphabetically, we should do the same for the documentation related to subcommand-specific parameters. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- docs/tools/qemu-img.rst | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst index 0080f83a76c9..7d08c48d308f 100644 --- a/docs/tools/qemu-img.rst +++ b/docs/tools/qemu-img.rst @@ -142,30 +142,6 @@ by the used format or see the format descriptions belo= w for details. the documentation of the emulator's ``-drive cache=3D...`` option for al= lowed values. -Parameters to snapshot subcommand: - -.. program:: qemu-img-snapshot - -.. option:: snapshot - - Is the name of the snapshot to create, apply or delete - -.. option:: -a - - Applies a snapshot (revert disk to saved state) - -.. option:: -c - - Creates a snapshot - -.. option:: -d - - Deletes a snapshot - -.. option:: -l - - Lists all snapshots in the given image - Parameters to compare subcommand: .. program:: qemu-img-compare @@ -245,6 +221,30 @@ Parameters to dd subcommand: Sets the number of input blocks to skip +Parameters to snapshot subcommand: + +.. program:: qemu-img-snapshot + +.. option:: snapshot + + Is the name of the snapshot to create, apply or delete + +.. option:: -a + + Applies a snapshot (revert disk to saved state) + +.. option:: -c + + Creates a snapshot + +.. option:: -d + + Deletes a snapshot + +.. option:: -l + + Lists all snapshots in the given image + Command description: .. program:: qemu-img-commands --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961141; cv=none; d=zohomail.com; s=zohoarc; b=dz+hgA0hTUEDfsYeUiJdScmIiO6ZDn0Am56UUr3A7Mk95Hvrtlz9HuUvtLJeSwAAIkwYFGkNgvzOIIvy0SOTew3NAvnnSyesZGmEJPGEO/OOdu8DA/pYezcgIGVmh5+a0VNxWAuHtB3QoDalISMayhBu0QRTOf4RP4EeSyJV/3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961141; 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=PQLMYYEI8PL6c8h28Vx0MCV7nQXRtHfkaEXos5JlrgI=; b=jcNp1xDYVaO0qW3Q0ifj3RIAJQ9jse1mWag1kHxFJPp9evIDrmUWWgc/hD10MzlAkg8dKXJ9UkP79xz9NuhenXeAzg34IQoBaT/OWOWC2TBPGeB+f+Mu4H9S4V+6FAZG/+ZTA1Iw+OU82FjOafqusHhmF7GyKD77KlVP9bl2KPo= 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 1588961141007864.8139269344848; Fri, 8 May 2020 11:05:41 -0700 (PDT) Received: from localhost ([::1]:58214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7NT-00026T-QI for importer@patchew.org; Fri, 08 May 2020 14:05:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ln-0000Cl-0I for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31355 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lk-0007JL-Hb for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-u4jzXmS1NVCIJCZ5celltQ-1; Fri, 08 May 2020 14:03:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87E6D835B40; Fri, 8 May 2020 18:03:46 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB3DC6109E; Fri, 8 May 2020 18:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961030; 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=PQLMYYEI8PL6c8h28Vx0MCV7nQXRtHfkaEXos5JlrgI=; b=ZtCxYG3VzvT8MJVh41S/eFpQ7empSJM8YaR2VjDN/XnbnUkn2BIKy6FzVPhrHz2tSU3xF4 2x5MNM8g5hiMM/LeMe+gxLzmGLufczsPQ64ldcSl73uoI4U4s+1RNP3z9vLGuM0Md/wzZg BlUT1Usr69FrzokORmhdntNd81SifP4= X-MC-Unique: u4jzXmS1NVCIJCZ5celltQ-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 2/9] qemu-img: Fix stale comments on doc location Date: Fri, 8 May 2020 13:03:33 -0500 Message-Id: <20200508180340.675712-3-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=eblake@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 02:25:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com 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" Missed in commit e13c59fa. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- qemu-img.c | 2 +- qemu-img-cmds.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 6a4327aaba56..b6e8af9202a5 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -108,7 +108,7 @@ static void QEMU_NORETURN unrecognized_option(const cha= r *option) error_exit("unrecognized option '%s'", option); } -/* Please keep in synch with qemu-img.texi */ +/* Please keep in synch with docs/tools/qemu-img.rst */ static void QEMU_NORETURN help(void) { const char *help_msg =3D diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index c9c54de1df40..e0886437b1f2 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -7,7 +7,7 @@ HXCOMM command structures and help message. HXCOMM HXCOMM can be used for comments, discarded from both rST and C HXCOMM When amending the rST sections, please remember to copy the usage -HXCOMM over to the per-command sections in qemu-img.texi. +HXCOMM over to the per-command sections in docs/tools/qemu-img.rst. DEF("amend", img_amend, "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cach= e] -o options filename") --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961241; cv=none; d=zohomail.com; s=zohoarc; b=nOoNuswLnHwSWROoLcIfRR4G5JUl45/5oZbAoshcFjFpyrn4KQoIEvOeaYTSd4Fs1mNwgiH+K2xCBcs/y7V90/ECooa/RzrFMCuh//JNYTvOi3b8jVxpB9NSk+HlP3feML8EpHF1ftUprubiMr3B883Vv7C7h7PNJ1BSIvH+KwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961241; 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=QFsU1fnG+OxiO3NOXekzCY6P7K+iTcnWsAzh/BfR9i0=; b=JXVUrneZIyc9yzgCvNY3iZEodJP7+Mv/69puBzKbkEjeSAqZBn7Sh7OtGMGRFIo2zJGe8Vz8zgSw7RZnPSUlH3PWrc//GpPjsbaEr6X4jmRfKM3xw7oKl3ZNfoSazj20OCGrp1F28c9uyd6WGfEthf89im1PLh21vhTna9kiHxc= 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 1588961241026692.4612381290829; Fri, 8 May 2020 11:07:21 -0700 (PDT) Received: from localhost ([::1]:38758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7P5-0006XU-If for importer@patchew.org; Fri, 08 May 2020 14:07:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lo-0000Db-DF for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:56 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:50430 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ln-0007RI-Fq for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-yTev0zgyNjaHPdQTrAMd5g-1; Fri, 08 May 2020 14:03:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C551107ACCA; Fri, 8 May 2020 18:03:47 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC38F6199C; Fri, 8 May 2020 18:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961034; 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=QFsU1fnG+OxiO3NOXekzCY6P7K+iTcnWsAzh/BfR9i0=; b=cjnS6dim8Yvppq3LQMTHUtTR1b1ZAZf7pFoxgOsskk3ZtQrrhZro02uPe7ql5B7B6mna7M 50M76n7qZatAE23zmhsvWCZaWe/H1jotrj6yBZA6vZQV6rMqIi12eCj/24xzW9A9Ixe+c5 P8vpEuUWGuYgKSd/YRlDY4ANaxW3p+8= X-MC-Unique: yTev0zgyNjaHPdQTrAMd5g-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 3/9] block: Make it easier to learn which BDS support bitmaps Date: Fri, 8 May 2020 13:03:34 -0500 Message-Id: <20200508180340.675712-4-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 08:00:48 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy , John Snow , qemu-block@nongnu.org, mreitz@redhat.com 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" Upcoming patches will enhance bitmap support in qemu-img, but in doing so, it turns out to be nice to suppress output when bitmaps make no sense (such as on a qcow2 v2 image). Add a hook to make this easier to query. In the future, when we improve the ability to look up bitmaps through a filter, we will probably also want to teach the block layer to automatically let filters pass this request on through. Signed-off-by: Eric Blake --- block/qcow2.h | 1 + include/block/block_int.h | 1 + include/block/dirty-bitmap.h | 1 + block/dirty-bitmap.c | 9 +++++++++ block/qcow2-bitmap.c | 7 +++++++ block/qcow2.c | 1 + 6 files changed, 20 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index f4de0a27d5c3..fb2b2b5a7b4d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -764,6 +764,7 @@ bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverSta= te *bs, int qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, Error **errp); +bool qcow2_dirty_bitmap_supported(BlockDriverState *bs); ssize_t coroutine_fn qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size, diff --git a/include/block/block_int.h b/include/block/block_int.h index df6d0273d679..cb1082da4c43 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -560,6 +560,7 @@ struct BlockDriver { uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); + bool (*bdrv_dirty_bitmap_supported)(BlockDriverState *bs); bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs, const char *name, uint32_t granularity, diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 8a1002941892..6d2e1707639f 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -16,6 +16,7 @@ typedef enum BitmapCheckFlags { #define BDRV_BITMAP_MAX_NAME_SIZE 1023 +bool bdrv_dirty_bitmap_supported(BlockDriverState *bs); BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, uint32_t granularity, const char *name, diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 063793e31606..89869c483c44 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -478,6 +478,15 @@ int bdrv_remove_persistent_dirty_bitmap(BlockDriverSta= te *bs, const char *name, } } +bool +bdrv_dirty_bitmap_supported(BlockDriverState *bs) +{ + if (bs->drv && bs->drv->bdrv_dirty_bitmap_supported) { + return bs->drv->bdrv_dirty_bitmap_supported(bs); + } + return false; +} + static bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, uint32_t granularity, Error **errp) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index cb06954b4a5a..b9889c2144cd 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1748,3 +1748,10 @@ fail: name, bdrv_get_device_or_node_name(bs)); return false; } + +bool qcow2_dirty_bitmap_supported(BlockDriverState *bs) +{ + BDRVQcow2State *s =3D bs->opaque; + + return s->qcow_version >=3D 3; +} diff --git a/block/qcow2.c b/block/qcow2.c index 1ad95ff04851..838d810ca5ec 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5663,6 +5663,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_detach_aio_context =3D qcow2_detach_aio_context, .bdrv_attach_aio_context =3D qcow2_attach_aio_context, + .bdrv_dirty_bitmap_supported =3D qcow2_dirty_bitmap_supported, .bdrv_co_can_store_new_dirty_bitmap =3D qcow2_co_can_store_new_dirty_b= itmap, .bdrv_co_remove_persistent_dirty_bitmap =3D qcow2_co_remove_persistent_dirty_bitmap, --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961145; cv=none; d=zohomail.com; s=zohoarc; b=MiJy8K/Ckrsz6hYYwlZW4CMmJ1zszRkPJrg85ZRDQhJl56Si+2Jla1zgt1QI5rzg9Hkux9RrpAKtQJS6DJi1pmDYvYME8bXAwQT06MhgwKQYYLVWp6BMaFjmUPIBHLtyyBpDeBqBGU9rK2cFft3ZxR7IACNlJYdW8JMRUQmLX0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961145; 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=BKk0pHHr70KlF7kNveCWamzavwpNj3fNnyHFZAjXaH8=; b=hqCN9KH2eo6rpim6E7z8zEb7JEHmBhPJEnvR9csEk2PAiWrlq9BigOnAyLCcMy5rCI5nP4kT4mBpyD5OQjJM23PXAwJ1Wn6vlM2LCwifjos40Qpt/rUtjAepcopvnE5g/lDDyL3G2QEBg4sm8yzu/cecN2A5sDnQ3vTQINlUqp4= 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 1588961145133458.9540807384848; Fri, 8 May 2020 11:05:45 -0700 (PDT) Received: from localhost ([::1]:58630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7NX-0002Iq-Rn for importer@patchew.org; Fri, 08 May 2020 14:05:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ln-0000DA-Kb for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41341 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lk-0007JV-Oc for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-94-vpPYkgMwP0SX8hS58N8o8A-1; Fri, 08 May 2020 14:03:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22FC51895A28; Fri, 8 May 2020 18:03:48 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4BBE6198A; Fri, 8 May 2020 18:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961032; 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=BKk0pHHr70KlF7kNveCWamzavwpNj3fNnyHFZAjXaH8=; b=AgMLfDN8zPTcDEE39xiZ2nH4VMicBnDnb3zdfXSr7Y1JJTw2AORj7UW9luilHuQdplJnyU N2SK7AxImhOF+KTcnDLyfy4kT1MffBr80ljTAC+/BUnGqNgOAezqgrZsTg6mm0mOlpcfis /SSEDLPJKHBSkp0BpeYPAdwfDNkZfrg= X-MC-Unique: vpPYkgMwP0SX8hS58N8o8A-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 4/9] blockdev: Promote several bitmap functions to non-static Date: Fri, 8 May 2020 13:03:35 -0500 Message-Id: <20200508180340.675712-5-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=eblake@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 02:25:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Markus Armbruster , qemu-block@nongnu.org, mreitz@redhat.com 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 next patch will split blockdev.c, which will require accessing some previously-static functions from more than one .c file. But part of promoting a function to public is picking a naming scheme that does not reek of exposing too many internals (two of the three functions were named starting with 'do_'). To make future code motion easier, perform the function rename and non-static promotion into its own patch. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- include/block/block_int.h | 12 +++++++++++ blockdev.c | 45 ++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index cb1082da4c43..e71505951d48 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1344,4 +1344,16 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDri= ver *drv, Error **errp); extern QemuOptsList bdrv_create_opts_simple; +BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, + const char *name, + BlockDriverState **pbs, + Error **errp); +BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *ta= rget, + BlockDirtyBitmapMergeSourceList = *bms, + HBitmap **backup, Error **errp); +BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *n= ame, + bool release, + BlockDriverState **bitmap_bs, + Error **errp); + #endif /* BLOCK_INT_H */ diff --git a/blockdev.c b/blockdev.c index b3c840ec0312..fbeb38437869 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1197,10 +1197,10 @@ out_aio_context: * * @return: A bitmap object on success, or NULL on failure. */ -static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, - const char *name, - BlockDriverState **pbs, - Error **errp) +BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, + const char *name, + BlockDriverState **pbs, + Error **errp) { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; @@ -2171,11 +2171,6 @@ static void block_dirty_bitmap_disable_abort(BlkActi= onState *common) } } -static BdrvDirtyBitmap *do_block_dirty_bitmap_merge( - const char *node, const char *target, - BlockDirtyBitmapMergeSourceList *bitmaps, - HBitmap **backup, Error **errp); - static void block_dirty_bitmap_merge_prepare(BlkActionState *common, Error **errp) { @@ -2189,15 +2184,11 @@ static void block_dirty_bitmap_merge_prepare(BlkAct= ionState *common, action =3D common->action->u.block_dirty_bitmap_merge.data; - state->bitmap =3D do_block_dirty_bitmap_merge(action->node, action->ta= rget, - action->bitmaps, &state->b= ackup, - errp); + state->bitmap =3D block_dirty_bitmap_merge(action->node, action->targe= t, + action->bitmaps, &state->back= up, + errp); } -static BdrvDirtyBitmap *do_block_dirty_bitmap_remove( - const char *node, const char *name, bool release, - BlockDriverState **bitmap_bs, Error **errp); - static void block_dirty_bitmap_remove_prepare(BlkActionState *common, Error **errp) { @@ -2211,8 +2202,8 @@ static void block_dirty_bitmap_remove_prepare(BlkActi= onState *common, action =3D common->action->u.block_dirty_bitmap_remove.data; - state->bitmap =3D do_block_dirty_bitmap_remove(action->node, action->n= ame, - false, &state->bs, errp); + state->bitmap =3D block_dirty_bitmap_remove(action->node, action->name, + false, &state->bs, errp); if (state->bitmap) { bdrv_dirty_bitmap_skip_store(state->bitmap, true); bdrv_dirty_bitmap_set_busy(state->bitmap, true); @@ -2504,9 +2495,10 @@ out: aio_context_release(aio_context); } -static BdrvDirtyBitmap *do_block_dirty_bitmap_remove( - const char *node, const char *name, bool release, - BlockDriverState **bitmap_bs, Error **errp) +BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *n= ame, + bool release, + BlockDriverState **bitmap_bs, + Error **errp) { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; @@ -2548,7 +2540,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_remove( void qmp_block_dirty_bitmap_remove(const char *node, const char *name, Error **errp) { - do_block_dirty_bitmap_remove(node, name, true, NULL, errp); + block_dirty_bitmap_remove(node, name, true, NULL, errp); } /** @@ -2609,10 +2601,9 @@ void qmp_block_dirty_bitmap_disable(const char *node= , const char *name, bdrv_disable_dirty_bitmap(bitmap); } -static BdrvDirtyBitmap *do_block_dirty_bitmap_merge( - const char *node, const char *target, - BlockDirtyBitmapMergeSourceList *bitmaps, - HBitmap **backup, Error **errp) +BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *ta= rget, + BlockDirtyBitmapMergeSourceList = *bitmaps, + HBitmap **backup, Error **errp) { BlockDriverState *bs; BdrvDirtyBitmap *dst, *src, *anon; @@ -2675,7 +2666,7 @@ void qmp_block_dirty_bitmap_merge(const char *node, c= onst char *target, BlockDirtyBitmapMergeSourceList *bitmaps, Error **errp) { - do_block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); + block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); } BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *= node, --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961424; cv=none; d=zohomail.com; s=zohoarc; b=Amu4uhJDtPJoITDqXu/aWu1csjnET4gE2aCAgVaZ5170P6N2BqcJCvRKcJsmt38yTYUNqhDRAREHpm3jrOykz5zIRosmeJ6DkkRtwTLYzVmf9cO5qP8rZ9gS0iXUrCDoHoA8WKHrtM31EYxwSqDVpN10GPi5VY2qhxcBWkM8wBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961424; 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=aTDlaSPoKqHFd41v+HmThZFauF5Ja/aKrcRTOWNtIAI=; b=GOOkk6wDidoG50hbtkzeslZy8k4pEvp/oDtvXeNwjyzcNJnxiPVbSx/0AgS3wIcdyqUDzHrdSbwtCt0GDEXdcvzb1uAkO7+i3gvpTeOsX4xoB1/pNu2IgmwlnkqdLsh9wUVAquBFdwgTgjHs6REUUeC/pYEoa1UYmwgLmOLAkl4= 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 1588961424784801.972623633235; Fri, 8 May 2020 11:10:24 -0700 (PDT) Received: from localhost ([::1]:48940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7S3-0002W2-8Q for importer@patchew.org; Fri, 08 May 2020 14:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7M5-0000lA-Nc for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38008 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7M3-0007r4-QP for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-nH_DdKi7NNWtxsLJwfigfg-1; Fri, 08 May 2020 14:03:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 075938014C1; Fri, 8 May 2020 18:03:49 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5821D6198A; Fri, 8 May 2020 18:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961049; 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=aTDlaSPoKqHFd41v+HmThZFauF5Ja/aKrcRTOWNtIAI=; b=J4pXHctq+5JCq0wq8k2H0xJI/d5GB+rN6J0A2zMWIsEJIyb8fmXBMQK1xyRzti6Ycz2Wly GyS7gmG6KYzHTrAEtExGOga11koBTxDL7TntGUilr0TEgPHpPGNUUOZZKDCJlNkXVM8da2 zHPH8HmRWJ3p4gv4xzKNnhucIkL1TJ8= X-MC-Unique: nH_DdKi7NNWtxsLJwfigfg-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 5/9] blockdev: Split off basic bitmap operations for qemu-img Date: Fri, 8 May 2020 13:03:36 -0500 Message-Id: <20200508180340.675712-6-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=eblake@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 02:25:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Markus Armbruster , mreitz@redhat.com, John Snow 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" Upcoming patches want to add some basic bitmap manipulation abilities to qemu-img. But blockdev.o is too heavyweight to link into qemu-img (among other things, it would drag in block jobs and transaction support - qemu-img does offline manipulation, where atomicity is less important because there are no concurrent modifications to compete with), so it's time to split off the bare bones of what we will need into a new file block/monitor/bitmap-qmp-cmds.o. This is sufficient to expose 6 QMP commands for use by qemu-img (add, remove, clear, enable, disable, merge), as well as move the three helper functions touched in the previous patch. Regarding MAINTAINERS, the new file is automatically part of block core, but also makes sense as related to other dirty bitmap files. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- Makefile.objs | 3 +- block/monitor/bitmap-qmp-cmds.c | 323 ++++++++++++++++++++++++++++++++ blockdev.c | 284 ---------------------------- MAINTAINERS | 1 + block/monitor/Makefile.objs | 1 + 5 files changed, 326 insertions(+), 286 deletions(-) create mode 100644 block/monitor/bitmap-qmp-cmds.c diff --git a/Makefile.objs b/Makefile.objs index a7c967633acf..99774cfd2545 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -13,9 +13,8 @@ chardev-obj-y =3D chardev/ authz-obj-y =3D authz/ -block-obj-y =3D nbd/ +block-obj-y =3D block/ block/monitor/ nbd/ scsi/ block-obj-y +=3D block.o blockjob.o job.o -block-obj-y +=3D block/ scsi/ block-obj-y +=3D qemu-io-cmds.o block-obj-$(CONFIG_REPLICATION) +=3D replication.o diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmd= s.c new file mode 100644 index 000000000000..748e1e682483 --- /dev/null +++ b/block/monitor/bitmap-qmp-cmds.c @@ -0,0 +1,323 @@ +/* + * QEMU host block device bitmaps + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" + +#include "sysemu/blockdev.h" +#include "block/block.h" +#include "block/block_int.h" +#include "qapi/qapi-commands-block.h" +#include "qapi/error.h" + +/** + * block_dirty_bitmap_lookup: + * Return a dirty bitmap (if present), after validating + * the node reference and bitmap names. + * + * @node: The name of the BDS node to search for bitmaps + * @name: The name of the bitmap to search for + * @pbs: Output pointer for BDS lookup, if desired. Can be NULL. + * @errp: Output pointer for error information. Can be NULL. + * + * @return: A bitmap object on success, or NULL on failure. + */ +BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, + const char *name, + BlockDriverState **pbs, + Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; + + if (!node) { + error_setg(errp, "Node cannot be NULL"); + return NULL; + } + if (!name) { + error_setg(errp, "Bitmap name cannot be NULL"); + return NULL; + } + bs =3D bdrv_lookup_bs(node, node, NULL); + if (!bs) { + error_setg(errp, "Node '%s' not found", node); + return NULL; + } + + bitmap =3D bdrv_find_dirty_bitmap(bs, name); + if (!bitmap) { + error_setg(errp, "Dirty bitmap '%s' not found", name); + return NULL; + } + + if (pbs) { + *pbs =3D bs; + } + + return bitmap; +} + +void qmp_block_dirty_bitmap_add(const char *node, const char *name, + bool has_granularity, uint32_t granularity, + bool has_persistent, bool persistent, + bool has_disabled, bool disabled, + Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; + AioContext *aio_context; + + if (!name || name[0] =3D=3D '\0') { + error_setg(errp, "Bitmap name cannot be empty"); + return; + } + + bs =3D bdrv_lookup_bs(node, node, errp); + if (!bs) { + return; + } + + aio_context =3D bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + + if (has_granularity) { + if (granularity < 512 || !is_power_of_2(granularity)) { + error_setg(errp, "Granularity must be power of 2 " + "and at least 512"); + goto out; + } + } else { + /* Default to cluster size, if available: */ + granularity =3D bdrv_get_default_bitmap_granularity(bs); + } + + if (!has_persistent) { + persistent =3D false; + } + + if (!has_disabled) { + disabled =3D false; + } + + if (persistent && + !bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp)) + { + goto out; + } + + bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, errp); + if (bitmap =3D=3D NULL) { + goto out; + } + + if (disabled) { + bdrv_disable_dirty_bitmap(bitmap); + } + + bdrv_dirty_bitmap_set_persistence(bitmap, persistent); + +out: + aio_context_release(aio_context); +} + +BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *n= ame, + bool release, + BlockDriverState **bitmap_bs, + Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; + AioContext *aio_context; + + bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); + if (!bitmap || !bs) { + return NULL; + } + + aio_context =3D bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_BUSY | BDRV_BITMAP_RO, + errp)) { + aio_context_release(aio_context); + return NULL; + } + + if (bdrv_dirty_bitmap_get_persistence(bitmap) && + bdrv_remove_persistent_dirty_bitmap(bs, name, errp) < 0) + { + aio_context_release(aio_context); + return NULL; + } + + if (release) { + bdrv_release_dirty_bitmap(bitmap); + } + + if (bitmap_bs) { + *bitmap_bs =3D bs; + } + + aio_context_release(aio_context); + return release ? NULL : bitmap; +} + +void qmp_block_dirty_bitmap_remove(const char *node, const char *name, + Error **errp) +{ + block_dirty_bitmap_remove(node, name, true, NULL, errp); +} + +/** + * Completely clear a bitmap, for the purposes of synchronizing a bitmap + * immediately after a full backup operation. + */ +void qmp_block_dirty_bitmap_clear(const char *node, const char *name, + Error **errp) +{ + BdrvDirtyBitmap *bitmap; + BlockDriverState *bs; + + bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); + if (!bitmap || !bs) { + return; + } + + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { + return; + } + + bdrv_clear_dirty_bitmap(bitmap, NULL); +} + +void qmp_block_dirty_bitmap_enable(const char *node, const char *name, + Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; + + bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); + if (!bitmap) { + return; + } + + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) { + return; + } + + bdrv_enable_dirty_bitmap(bitmap); +} + +void qmp_block_dirty_bitmap_disable(const char *node, const char *name, + Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; + + bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); + if (!bitmap) { + return; + } + + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) { + return; + } + + bdrv_disable_dirty_bitmap(bitmap); +} + +BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *ta= rget, + BlockDirtyBitmapMergeSourceList = *bitmaps, + HBitmap **backup, Error **errp) +{ + BlockDriverState *bs; + BdrvDirtyBitmap *dst, *src, *anon; + BlockDirtyBitmapMergeSourceList *lst; + Error *local_err =3D NULL; + + dst =3D block_dirty_bitmap_lookup(node, target, &bs, errp); + if (!dst) { + return NULL; + } + + anon =3D bdrv_create_dirty_bitmap(bs, bdrv_dirty_bitmap_granularity(ds= t), + NULL, errp); + if (!anon) { + return NULL; + } + + for (lst =3D bitmaps; lst; lst =3D lst->next) { + switch (lst->value->type) { + const char *name, *node; + case QTYPE_QSTRING: + name =3D lst->value->u.local; + src =3D bdrv_find_dirty_bitmap(bs, name); + if (!src) { + error_setg(errp, "Dirty bitmap '%s' not found", name); + dst =3D NULL; + goto out; + } + break; + case QTYPE_QDICT: + node =3D lst->value->u.external.node; + name =3D lst->value->u.external.name; + src =3D block_dirty_bitmap_lookup(node, name, NULL, errp); + if (!src) { + dst =3D NULL; + goto out; + } + break; + default: + abort(); + } + + bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); + if (local_err) { + error_propagate(errp, local_err); + dst =3D NULL; + goto out; + } + } + + /* Merge into dst; dst is unchanged on failure. */ + bdrv_merge_dirty_bitmap(dst, anon, backup, errp); + + out: + bdrv_release_dirty_bitmap(anon); + return dst; +} + +void qmp_block_dirty_bitmap_merge(const char *node, const char *target, + BlockDirtyBitmapMergeSourceList *bitmaps, + Error **errp) +{ + block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); +} diff --git a/blockdev.c b/blockdev.c index fbeb38437869..72df193ca73b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1185,53 +1185,6 @@ out_aio_context: return NULL; } -/** - * block_dirty_bitmap_lookup: - * Return a dirty bitmap (if present), after validating - * the node reference and bitmap names. - * - * @node: The name of the BDS node to search for bitmaps - * @name: The name of the bitmap to search for - * @pbs: Output pointer for BDS lookup, if desired. Can be NULL. - * @errp: Output pointer for error information. Can be NULL. - * - * @return: A bitmap object on success, or NULL on failure. - */ -BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, - const char *name, - BlockDriverState **pbs, - Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *bitmap; - - if (!node) { - error_setg(errp, "Node cannot be NULL"); - return NULL; - } - if (!name) { - error_setg(errp, "Bitmap name cannot be NULL"); - return NULL; - } - bs =3D bdrv_lookup_bs(node, node, NULL); - if (!bs) { - error_setg(errp, "Node '%s' not found", node); - return NULL; - } - - bitmap =3D bdrv_find_dirty_bitmap(bs, name); - if (!bitmap) { - error_setg(errp, "Dirty bitmap '%s' not found", name); - return NULL; - } - - if (pbs) { - *pbs =3D bs; - } - - return bitmap; -} - /* New and old BlockDriverState structs for atomic group operations */ typedef struct BlkActionState BlkActionState; @@ -2432,243 +2385,6 @@ void qmp_block_passwd(bool has_device, const char *= device, "Setting block passwords directly is no longer supported"); } -void qmp_block_dirty_bitmap_add(const char *node, const char *name, - bool has_granularity, uint32_t granularity, - bool has_persistent, bool persistent, - bool has_disabled, bool disabled, - Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *bitmap; - AioContext *aio_context; - - if (!name || name[0] =3D=3D '\0') { - error_setg(errp, "Bitmap name cannot be empty"); - return; - } - - bs =3D bdrv_lookup_bs(node, node, errp); - if (!bs) { - return; - } - - aio_context =3D bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - - if (has_granularity) { - if (granularity < 512 || !is_power_of_2(granularity)) { - error_setg(errp, "Granularity must be power of 2 " - "and at least 512"); - goto out; - } - } else { - /* Default to cluster size, if available: */ - granularity =3D bdrv_get_default_bitmap_granularity(bs); - } - - if (!has_persistent) { - persistent =3D false; - } - - if (!has_disabled) { - disabled =3D false; - } - - if (persistent && - !bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp)) - { - goto out; - } - - bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, errp); - if (bitmap =3D=3D NULL) { - goto out; - } - - if (disabled) { - bdrv_disable_dirty_bitmap(bitmap); - } - - bdrv_dirty_bitmap_set_persistence(bitmap, persistent); - -out: - aio_context_release(aio_context); -} - -BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *n= ame, - bool release, - BlockDriverState **bitmap_bs, - Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *bitmap; - AioContext *aio_context; - - bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); - if (!bitmap || !bs) { - return NULL; - } - - aio_context =3D bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_BUSY | BDRV_BITMAP_RO, - errp)) { - aio_context_release(aio_context); - return NULL; - } - - if (bdrv_dirty_bitmap_get_persistence(bitmap) && - bdrv_remove_persistent_dirty_bitmap(bs, name, errp) < 0) - { - aio_context_release(aio_context); - return NULL; - } - - if (release) { - bdrv_release_dirty_bitmap(bitmap); - } - - if (bitmap_bs) { - *bitmap_bs =3D bs; - } - - aio_context_release(aio_context); - return release ? NULL : bitmap; -} - -void qmp_block_dirty_bitmap_remove(const char *node, const char *name, - Error **errp) -{ - block_dirty_bitmap_remove(node, name, true, NULL, errp); -} - -/** - * Completely clear a bitmap, for the purposes of synchronizing a bitmap - * immediately after a full backup operation. - */ -void qmp_block_dirty_bitmap_clear(const char *node, const char *name, - Error **errp) -{ - BdrvDirtyBitmap *bitmap; - BlockDriverState *bs; - - bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); - if (!bitmap || !bs) { - return; - } - - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { - return; - } - - bdrv_clear_dirty_bitmap(bitmap, NULL); -} - -void qmp_block_dirty_bitmap_enable(const char *node, const char *name, - Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *bitmap; - - bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); - if (!bitmap) { - return; - } - - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) { - return; - } - - bdrv_enable_dirty_bitmap(bitmap); -} - -void qmp_block_dirty_bitmap_disable(const char *node, const char *name, - Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *bitmap; - - bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); - if (!bitmap) { - return; - } - - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) { - return; - } - - bdrv_disable_dirty_bitmap(bitmap); -} - -BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *ta= rget, - BlockDirtyBitmapMergeSourceList = *bitmaps, - HBitmap **backup, Error **errp) -{ - BlockDriverState *bs; - BdrvDirtyBitmap *dst, *src, *anon; - BlockDirtyBitmapMergeSourceList *lst; - Error *local_err =3D NULL; - - dst =3D block_dirty_bitmap_lookup(node, target, &bs, errp); - if (!dst) { - return NULL; - } - - anon =3D bdrv_create_dirty_bitmap(bs, bdrv_dirty_bitmap_granularity(ds= t), - NULL, errp); - if (!anon) { - return NULL; - } - - for (lst =3D bitmaps; lst; lst =3D lst->next) { - switch (lst->value->type) { - const char *name, *node; - case QTYPE_QSTRING: - name =3D lst->value->u.local; - src =3D bdrv_find_dirty_bitmap(bs, name); - if (!src) { - error_setg(errp, "Dirty bitmap '%s' not found", name); - dst =3D NULL; - goto out; - } - break; - case QTYPE_QDICT: - node =3D lst->value->u.external.node; - name =3D lst->value->u.external.name; - src =3D block_dirty_bitmap_lookup(node, name, NULL, errp); - if (!src) { - dst =3D NULL; - goto out; - } - break; - default: - abort(); - } - - bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); - if (local_err) { - error_propagate(errp, local_err); - dst =3D NULL; - goto out; - } - } - - /* Merge into dst; dst is unchanged on failure. */ - bdrv_merge_dirty_bitmap(dst, anon, backup, errp); - - out: - bdrv_release_dirty_bitmap(anon); - return dst; -} - -void qmp_block_dirty_bitmap_merge(const char *node, const char *target, - BlockDirtyBitmapMergeSourceList *bitmaps, - Error **errp) -{ - block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); -} - BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *= node, const char *= name, Error **errp) diff --git a/MAINTAINERS b/MAINTAINERS index 1f84e3ae2c6a..6a8dc1e69d42 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2007,6 +2007,7 @@ L: qemu-block@nongnu.org S: Supported F: include/qemu/hbitmap.h F: include/block/dirty-bitmap.h +F: block/monitor/bitmap-qmp-cmds.c F: block/dirty-bitmap.c F: block/qcow2-bitmap.c F: migration/block-dirty-bitmap.c diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs index 0a74f9a8b5b7..39acf8502224 100644 --- a/block/monitor/Makefile.objs +++ b/block/monitor/Makefile.objs @@ -1 +1,2 @@ common-obj-y +=3D block-hmp-cmds.o +block-obj-y +=3D bitmap-qmp-cmds.o --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961250; cv=none; d=zohomail.com; s=zohoarc; b=artNR+uszbCTOaa4CxjTJjs3pUUMav683YYTW5rf5FU87e9poRP1iv95sf+3DlGUXnXYn47WNQjFCJstSgu7WyEYWdgp1pLyGHdFZAQlnhIQiIIfw6iOI5jp1J8haw7mfcr69UpFTdfCY6EiSnZVMb21q2X0gghYV+cREgP+wVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961250; 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=TSQejQ3hQjUBVwzP/uc1lCFqc+4punHX1/rpaGEY2m0=; b=nm/vB6qVJpVDPdoYHi4r2Nwl1Ao3RJYOApmYmHhqWU+LXMAR4Mr8aV8CgAVe3kzDcl3c3RaDp7+E3L1oFVVqfxKqD/tEtQcUF+cN0M5Kp9oSwR7yDaC0b5laduco/SVoqDgmFiPVt9YiDgZ64SVFUEHRKLbR11BHCOsZHy4daGs= 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 1588961250962352.5755262890632; Fri, 8 May 2020 11:07:30 -0700 (PDT) Received: from localhost ([::1]:39394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7PF-0006ny-KH for importer@patchew.org; Fri, 08 May 2020 14:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ls-0000Lj-GX for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:00 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:47637 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lo-0007SO-E2 for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-229-OWwOcdsUP76d-gp0TgugiQ-1; Fri, 08 May 2020 14:03:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95BC5107ACCA; Fri, 8 May 2020 18:03:49 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32FBB61988; Fri, 8 May 2020 18:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961035; 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=TSQejQ3hQjUBVwzP/uc1lCFqc+4punHX1/rpaGEY2m0=; b=BV/KrheCo8iLezBHIK7HOLjCDn8vBFLnYBYjWEO08wIxQsoSagttJ40JR/wjbuGDetZsXF H+OYPU744nvpB2woKXJEkQL+RQLw5ctaZPK2r6/cFyqEKB/W5okLu4MZAgQVco4lX+Z87a YmvjBp7cRmudDMO1Nn1mqqXQvVh6u1c= X-MC-Unique: OWwOcdsUP76d-gp0TgugiQ-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 6/9] qemu-img: Add bitmap sub-command Date: Fri, 8 May 2020 13:03:37 -0500 Message-Id: <20200508180340.675712-7-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 01:34:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com 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" Include actions for --add, --remove, --clear, --enable, --disable, and --merge (note that --clear is a bit of fluff, because the same can be accomplished by removing a bitmap and then adding a new one in its place, but it matches what QMP commands exist). Listing is omitted, because it does not require a bitmap name and because it was already possible with 'qemu-img info'. A single command line can play one or more bitmap commands in sequence on the same bitmap name (although all added bitmaps share the same granularity, and and all merged bitmaps come from the same source file). Merge defaults to other bitmaps in the primary image, but can also be told to merge bitmaps from a distinct image. While this supports --image-opts for the file being modified, I did not think it worth the extra complexity to support that for the source file in a cross-file merges. Likewise, I chose to have --merge only take a single source rather than following the QMP support for multiple merges in one go (although you can still use more than one --merge in the command line); in part because qemu-img is offline and therefore atomicity is not an issue. Upcoming patches will add iotest coverage of these commands while also testing other features. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- docs/tools/qemu-img.rst | 23 ++++ qemu-img.c | 254 ++++++++++++++++++++++++++++++++++++++++ qemu-img-cmds.hx | 7 ++ 3 files changed, 284 insertions(+) diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst index 7d08c48d308f..68393c357386 100644 --- a/docs/tools/qemu-img.rst +++ b/docs/tools/qemu-img.rst @@ -281,6 +281,29 @@ Command description: For write tests, by default a buffer filled with zeros is written. This = can be overridden with a pattern byte specified by *PATTERN*. +.. option:: bitmap (--merge SOURCE | --add | --remove | --clear | --enable= | --disable)... [-b SOURCE_FILE [-F SOURCE_FMT]] [-g GRANULARITY] [--objec= t OBJECTDEF] [--image-opts | -f FMT] FILENAME BITMAP + + Perform one or more modifications of the persistent bitmap *BITMAP* + in the disk image *FILENAME*. The various modifications are: + + ``--add`` to create *BITMAP*, enabled to record future edits. + + ``--remove`` to remove *BITMAP*. + + ``--clear`` to clear *BITMAP*. + + ``--enable`` to change *BITMAP* to start recording future edits. + + ``--disable`` to change *BITMAP* to stop recording future edits. + + ``--merge`` to merge the contents of *SOURCE_BITMAP* into *BITMAP*. + + Additional options ``-g`` set a non-default *GRANULARITY* for + ``--add``, and ``-b`` and ``-F`` select an alternative source file + for all *SOURCE* bitmaps used by ``--merge``. + + To see what bitmaps are present in an image, use ``qemu-img info``. + .. option:: check [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [--out= put=3DOFMT] [-r [leaks | all]] [-T SRC_CACHE] [-U] FILENAME Perform a consistency check on the disk image *FILENAME*. The command can diff --git a/qemu-img.c b/qemu-img.c index b6e8af9202a5..7ad86f7b8072 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -28,6 +28,7 @@ #include "qemu-common.h" #include "qemu-version.h" #include "qapi/error.h" +#include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-visit-block-core.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qjson.h" @@ -71,6 +72,12 @@ enum { OPTION_SHRINK =3D 266, OPTION_SALVAGE =3D 267, OPTION_TARGET_IS_ZERO =3D 268, + OPTION_ADD =3D 269, + OPTION_REMOVE =3D 270, + OPTION_CLEAR =3D 271, + OPTION_ENABLE =3D 272, + OPTION_DISABLE =3D 273, + OPTION_MERGE =3D 274, }; typedef enum OutputFormat { @@ -169,6 +176,14 @@ static void QEMU_NORETURN help(void) " '-n' skips the target volume creation (useful if the volume = is created\n" " prior to running qemu-img)\n" "\n" + "Parameters to bitmap subcommand:\n" + " 'bitmap' is the name of the bitmap to manipulate, through on= e or more\n" + " actions from '--add', '--remove', '--clear', '--enable'= , '--diable',\n" + " or '--merge source'\n" + " '-g granularity' sets the granularity for '--add' actions\n" + " '-b source' and '-F src_fmt' tell '--merge' actions to find = the source\n" + " bitmaps from an alternative file\n" + "\n" "Parameters to check subcommand:\n" " '-r' tries to repair any inconsistencies that are found duri= ng the check.\n" " '-r leaks' repairs only cluster leaks, whereas '-r all'= fixes all\n" @@ -4461,6 +4476,245 @@ out: return 0; } +enum ImgBitmapAct { + BITMAP_ADD, + BITMAP_REMOVE, + BITMAP_CLEAR, + BITMAP_ENABLE, + BITMAP_DISABLE, + BITMAP_MERGE, +}; +typedef struct ImgBitmapAction { + enum ImgBitmapAct act; + const char *src; /* only used for merge */ + QSIMPLEQ_ENTRY(ImgBitmapAction) next; +} ImgBitmapAction; + +static int img_bitmap(int argc, char **argv) +{ + Error *err =3D NULL; + int c, ret =3D -1; + QemuOpts *opts =3D NULL; + const char *fmt =3D NULL, *src_fmt =3D NULL, *src_filename =3D NULL; + const char *filename, *bitmap; + BlockBackend *blk =3D NULL, *src =3D NULL; + BlockDriverState *bs =3D NULL, *src_bs =3D NULL; + bool image_opts =3D false; + int64_t granularity =3D 0; + bool add =3D false, merge =3D false; + QSIMPLEQ_HEAD(, ImgBitmapAction) actions; + ImgBitmapAction *act, *act_next; + const char *op; + + QSIMPLEQ_INIT(&actions); + + for (;;) { + static const struct option long_options[] =3D { + {"help", no_argument, 0, 'h'}, + {"object", required_argument, 0, OPTION_OBJECT}, + {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"add", no_argument, 0, OPTION_ADD}, + {"remove", no_argument, 0, OPTION_REMOVE}, + {"clear", no_argument, 0, OPTION_CLEAR}, + {"enable", no_argument, 0, OPTION_ENABLE}, + {"disable", no_argument, 0, OPTION_DISABLE}, + {"merge", required_argument, 0, OPTION_MERGE}, + {"granularity", required_argument, 0, 'g'}, + {"source-file", required_argument, 0, 'b'}, + {"source-format", required_argument, 0, 'F'}, + {0, 0, 0, 0} + }; + c =3D getopt_long(argc, argv, ":b:f:F:g:h", long_options, NULL); + if (c =3D=3D -1) { + break; + } + + switch (c) { + case ':': + missing_argument(argv[optind - 1]); + break; + case '?': + unrecognized_option(argv[optind - 1]); + break; + case 'h': + help(); + break; + case 'b': + src_filename =3D optarg; + break; + case 'f': + fmt =3D optarg; + break; + case 'F': + src_fmt =3D optarg; + break; + case 'g': + granularity =3D cvtnum(optarg); + if (granularity < 0) { + error_report("Invalid granularity specified"); + return 1; + } + break; + case OPTION_ADD: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_ADD; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + add =3D true; + break; + case OPTION_REMOVE: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_REMOVE; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + break; + case OPTION_CLEAR: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_CLEAR; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + break; + case OPTION_ENABLE: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_ENABLE; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + break; + case OPTION_DISABLE: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_DISABLE; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + break; + case OPTION_MERGE: + act =3D g_new0(ImgBitmapAction, 1); + act->act =3D BITMAP_MERGE; + act->src =3D optarg; + QSIMPLEQ_INSERT_TAIL(&actions, act, next); + merge =3D true; + break; + case OPTION_OBJECT: + opts =3D qemu_opts_parse_noisily(&qemu_object_opts, optarg, tr= ue); + if (!opts) { + goto out; + } + break; + case OPTION_IMAGE_OPTS: + image_opts =3D true; + break; + } + } + + if (qemu_opts_foreach(&qemu_object_opts, + user_creatable_add_opts_foreach, + qemu_img_object_print_help, &error_fatal)) { + goto out; + } + + if (QSIMPLEQ_EMPTY(&actions)) { + error_report("Need at least one of --add, --remove, --clear, " + "--enable, --disable, or --merge"); + goto out; + } + + if (granularity && !add) { + error_report("granularity only supported with --add"); + goto out; + } + if (src_fmt && !src_filename) { + error_report("-F only supported with -b"); + goto out; + } + if (src_filename && !merge) { + error_report("Merge bitmap source file only supported with " + "--merge"); + goto out; + } + + if (optind !=3D argc - 2) { + error_report("Expecting filename and bitmap name"); + goto out; + } + + filename =3D argv[optind]; + bitmap =3D argv[optind + 1]; + + blk =3D img_open(image_opts, filename, fmt, BDRV_O_RDWR, false, false, + false); + if (!blk) { + goto out; + } + bs =3D blk_bs(blk); + if (src_filename) { + src =3D img_open(NULL, src_filename, src_fmt, 0, false, false, + false); + if (!src) { + goto out; + } + src_bs =3D blk_bs(src); + } else { + src_bs =3D bs; + } + + QSIMPLEQ_FOREACH_SAFE(act, &actions, next, act_next) { + switch (act->act) { + case BITMAP_ADD: + qmp_block_dirty_bitmap_add(bs->node_name, bitmap, + !!granularity, granularity, true, t= rue, + false, false, &err); + op =3D "add"; + break; + case BITMAP_REMOVE: + qmp_block_dirty_bitmap_remove(bs->node_name, bitmap, &err); + op =3D "remove"; + break; + case BITMAP_CLEAR: + qmp_block_dirty_bitmap_clear(bs->node_name, bitmap, &err); + op =3D "clear"; + break; + case BITMAP_ENABLE: + qmp_block_dirty_bitmap_enable(bs->node_name, bitmap, &err); + op =3D "enable"; + break; + case BITMAP_DISABLE: + qmp_block_dirty_bitmap_disable(bs->node_name, bitmap, &err); + op =3D "disable"; + break; + case BITMAP_MERGE: { + BlockDirtyBitmapMergeSource *merge_src; + BlockDirtyBitmapMergeSourceList *list; + + merge_src =3D g_new0(BlockDirtyBitmapMergeSource, 1); + merge_src->type =3D QTYPE_QDICT; + merge_src->u.external.node =3D g_strdup(src_bs->node_name); + merge_src->u.external.name =3D g_strdup(act->src); + list =3D g_new0(BlockDirtyBitmapMergeSourceList, 1); + list->value =3D merge_src; + qmp_block_dirty_bitmap_merge(bs->node_name, bitmap, list, &err= ); + qapi_free_BlockDirtyBitmapMergeSourceList(list); + op =3D "merge"; + break; + } + default: + g_assert_not_reached(); + } + + if (err) { + error_reportf_err(err, "Operation %s on bitmap %s failed", + op, bitmap); + ret =3D -1; + goto out; + } + g_free(act); + } + + ret =3D 0; + + out: + blk_unref(src); + blk_unref(blk); + qemu_opts_del(opts); + if (ret) { + return 1; + } + return 0; +} + #define C_BS 01 #define C_COUNT 02 #define C_IF 04 diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index e0886437b1f2..011688245668 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -20,6 +20,13 @@ DEF("bench", img_bench, SRST .. option:: bench [-c COUNT] [-d DEPTH] [-f FMT] [--flush-interval=3DFLUSH= _INTERVAL] [-i AIO] [-n] [--no-drain] [-o OFFSET] [--pattern=3DPATTERN] [-q= ] [-s BUFFER_SIZE] [-S STEP_SIZE] [-t CACHE] [-w] [-U] FILENAME ERST + +DEF("bitmap", img_bitmap, + "bitmap (--merge SOURCE | --add | --remove | --clear | --enable | --di= sable)... [-b source_file [-F source_fmt]] [-g granularity] [--object objec= tdef] [--image-opts | -f fmt] filename bitmap") +SRST +.. option:: bitmap (--merge SOURCE | --add | --remove | --clear | --enable= | --disable)... [-b SOURCE_FILE [-F SOURCE_FMT]] [-g GRANULARITY] [--objec= t OBJECTDEF] [--image-opts | -f FMT] FILENAME BITMAP +ERST + DEF("check", img_check, "check [--object objectdef] [--image-opts] [-q] [-f fmt] [--output=3Do= fmt] [-r [leaks | all]] [-T src_cache] [-U] filename") SRST --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961371; cv=none; d=zohomail.com; s=zohoarc; b=AyKhUnpGkQnYeygv1k000xVhWSsr58ywRoJJMMRokEIEoUck2BehhDvtP4S1I6l7VxgRQVlFD9QumcvX5A4e9YJWcXl1zIC2u+B5GJhU9dKMiqOOHcVGcuvdIu1n7CywFVZo3Sn7IPqrE3E37A+eFW9mw78mf+9/q+EA2mHExSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961371; 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=Dx9qEWC661Ly8+zLBn9gRB4mebS5W7U6GluC841n62c=; b=XEvI1NMnFNc/RQGFxzPL4xDZ9r0R98cXAdYtN+/Cp4VACmyhvnRIi2pag2fRkI9TKQviidIEdGWh9bdynvxR96M3wju4PLpuD/bLHf/LSDXCmgsF16BtXE7I6NhgcHkQ1V/UMQ71zfuUwfl8DYVUFMhwgNp8y1kEgV7oKGKZyKw= 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 1588961371425449.61060220418244; Fri, 8 May 2020 11:09:31 -0700 (PDT) Received: from localhost ([::1]:46436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7RC-0001Hl-4v for importer@patchew.org; Fri, 08 May 2020 14:09:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lp-0000Ex-Oj for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23264 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lo-0007Se-5n for qemu-devel@nongnu.org; Fri, 08 May 2020 14:03:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-ICnD_VyVMva5bEUy4uL3ng-1; Fri, 08 May 2020 14:03:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBFB37BAD; Fri, 8 May 2020 18:03:52 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id D05C26198A; Fri, 8 May 2020 18:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961035; 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=Dx9qEWC661Ly8+zLBn9gRB4mebS5W7U6GluC841n62c=; b=Hni3rKWz+W+57SN6mDY8Zc34CbnTpyMOSi9xCyVwnmyWwfwY43+J69ejz67tfz6r6iB88j GhFzSq6bsOLTHjmRiLcva0iK/cKAKdqOEJFyiX4hN/CO8/DQFQXh5l61SKfuE/gXz5urBd 59diP4siFdIyP1mLEZ/q/ZdLKIa8y8w= X-MC-Unique: ICnD_VyVMva5bEUy4uL3ng-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 7/9] qcow2: Expose bitmaps' size during measure Date: Fri, 8 May 2020 13:03:38 -0500 Message-Id: <20200508180340.675712-8-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=eblake@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 02:25:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Nir Soffer , Markus Armbruster , qemu-block@nongnu.org, mreitz@redhat.com 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" It's useful to know how much space can be occupied by qcow2 persistent bitmaps, even though such metadata is unrelated to the guest-visible data. Report this value as an additional field, present when measuring an existing image and the output format supports bitmaps. Update iotest 178 and 190 to updated output, as well as new coverage in 190 demonstrating non-zero values made possible with the recently-added qemu-img bitmap command. The addition of a new field demonstrates why we should always zero-initialize qapi C structs; while the qcow2 driver still fully populates all fields, the raw and crypto drivers had to be tweaked to avoid uninitialized data. See also: https://bugzilla.redhat.com/1779904 Reported-by: Nir Soffer Signed-off-by: Eric Blake --- qapi/block-core.json | 15 +++++++---- block/crypto.c | 2 +- block/qcow2.c | 37 ++++++++++++++++++++++++--- block/raw-format.c | 2 +- qemu-img.c | 3 +++ tests/qemu-iotests/178.out.qcow2 | 16 ++++++++++++ tests/qemu-iotests/190 | 43 ++++++++++++++++++++++++++++++-- tests/qemu-iotests/190.out | 23 ++++++++++++++++- 8 files changed, 128 insertions(+), 13 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 943df1926a91..9a7a388c7ad3 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -633,18 +633,23 @@ # efficiently so file size may be smaller than virtual disk size. # # The values are upper bounds that are guaranteed to fit the new image fil= e. -# Subsequent modification, such as internal snapshot or bitmap creation, m= ay -# require additional space and is not covered here. +# Subsequent modification, such as internal snapshot or further bitmap +# creation, may require additional space and is not covered here. # -# @required: Size required for a new image file, in bytes. +# @required: Size required for a new image file, in bytes, when copying ju= st +# guest-visible contents. # # @fully-allocated: Image file size, in bytes, once data has been written -# to all sectors. +# to all sectors, when copying just guest-visible conten= ts. +# +# @bitmaps: Additional size required for bitmap metadata in a source image, +# if that bitmap metadata can be copied in addition to guest +# contents. (since 5.1) # # Since: 2.10 ## { 'struct': 'BlockMeasureInfo', - 'data': {'required': 'int', 'fully-allocated': 'int'} } + 'data': {'required': 'int', 'fully-allocated': 'int', '*bitmaps': 'int'}= } ## # @query-block: diff --git a/block/crypto.c b/block/crypto.c index 6b21d6bf6c01..eadbcb248563 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -552,7 +552,7 @@ static BlockMeasureInfo *block_crypto_measure(QemuOpts = *opts, * Unallocated blocks are still encrypted so allocation status makes no * difference to the file size. */ - info =3D g_new(BlockMeasureInfo, 1); + info =3D g_new0(BlockMeasureInfo, 1); info->fully_allocated =3D luks_payload_size + size; info->required =3D luks_payload_size + size; return info; diff --git a/block/qcow2.c b/block/qcow2.c index 838d810ca5ec..f836a6047879 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4721,6 +4721,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts= , BlockDriverState *in_bs, PreallocMode prealloc; bool has_backing_file; bool has_luks; + uint64_t bitmaps_size =3D 0; /* size occupied by bitmaps in in_bs */ /* Parse image creation options */ cluster_size =3D qcow2_opt_get_cluster_size_del(opts, &local_err); @@ -4796,13 +4797,38 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *op= ts, BlockDriverState *in_bs, /* Account for input image */ if (in_bs) { + BdrvDirtyBitmap *bm; + size_t bitmap_dir_size =3D 0; int64_t ssize =3D bdrv_getlength(in_bs); + if (ssize < 0) { error_setg_errno(&local_err, -ssize, "Unable to get image virtual_size"); goto err; } + FOR_EACH_DIRTY_BITMAP(in_bs, bm) { + if (bdrv_dirty_bitmap_get_persistence(bm)) { + const char *name =3D bdrv_dirty_bitmap_name(bm); + uint32_t granularity =3D bdrv_dirty_bitmap_granularity(bm); + uint64_t bmbits =3D DIV_ROUND_UP(bdrv_dirty_bitmap_size(bm= ), + granularity); + uint64_t bmclusters =3D DIV_ROUND_UP(DIV_ROUND_UP(bmbits, + CHAR_BIT), + cluster_size); + + /* Assume the entire bitmap is allocated */ + bitmaps_size +=3D bmclusters * cluster_size; + /* Also reserve space for the bitmap table entries */ + bitmaps_size +=3D ROUND_UP(bmclusters * sizeof(uint64_t), + cluster_size); + /* And space for contribution to bitmap directory size */ + bitmap_dir_size +=3D ROUND_UP(strlen(name) + 24, + sizeof(uint64_t)); + } + } + bitmaps_size +=3D ROUND_UP(bitmap_dir_size, cluster_size); + virtual_size =3D ROUND_UP(ssize, cluster_size); if (has_backing_file) { @@ -4849,16 +4875,21 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *op= ts, BlockDriverState *in_bs, required =3D virtual_size; } - info =3D g_new(BlockMeasureInfo, 1); + info =3D g_new0(BlockMeasureInfo, 1); info->fully_allocated =3D qcow2_calc_prealloc_size(virtual_size, cluster_size, ctz32(refcount_bits)) + luks_payload_size; - /* Remove data clusters that are not required. This overestimates the + /* + * Remove data clusters that are not required. This overestimates the * required size because metadata needed for the fully allocated file = is - * still counted. + * still counted. Show bitmaps only if both source and destination + * would support them. */ info->required =3D info->fully_allocated - virtual_size + required; + info->has_bitmaps =3D version >=3D 3 && in_bs && + bdrv_dirty_bitmap_supported(in_bs); + info->bitmaps =3D bitmaps_size; return info; err: diff --git a/block/raw-format.c b/block/raw-format.c index 9108e4369628..a134b1954ca2 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -346,7 +346,7 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, Bl= ockDriverState *in_bs, BDRV_SECTOR_SIZE); } - info =3D g_new(BlockMeasureInfo, 1); + info =3D g_new0(BlockMeasureInfo, 1); info->required =3D required; /* Unallocated sectors count towards the file size in raw images */ diff --git a/qemu-img.c b/qemu-img.c index 7ad86f7b8072..0e747247e0c5 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5278,6 +5278,9 @@ static int img_measure(int argc, char **argv) if (output_format =3D=3D OFORMAT_HUMAN) { printf("required size: %" PRIu64 "\n", info->required); printf("fully allocated size: %" PRIu64 "\n", info->fully_allocate= d); + if (info->has_bitmaps) { + printf("bitmaps size: %" PRIu64 "\n", info->bitmaps); + } } else { dump_json_block_measure_info(info); } diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.= qcow2 index f59bf4b2fbc4..0c6ca5e05713 100644 --- a/tests/qemu-iotests/178.out.qcow2 +++ b/tests/qemu-iotests/178.out.qcow2 @@ -37,6 +37,7 @@ qemu-img: The image size is too large (try using a larger= cluster size) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D0 required size: 196608 fully allocated size: 196608 +bitmaps size: 0 converted image file size in bytes: 196608 @@ -45,6 +46,7 @@ converted image file size in bytes: 196608 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 required size: 393216 fully allocated size: 1074135040 +bitmaps size: 0 wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 65536 @@ -53,6 +55,7 @@ wrote 64512/64512 bytes at offset 134217728 63 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) required size: 589824 fully allocated size: 1074135040 +bitmaps size: 0 converted image file size in bytes: 524288 @@ -60,6 +63,7 @@ converted image file size in bytes: 524288 required size: 524288 fully allocated size: 1074135040 +bitmaps size: 0 converted image file size in bytes: 458752 @@ -67,16 +71,19 @@ converted image file size in bytes: 458752 required size: 1074135040 fully allocated size: 1074135040 +bitmaps size: 0 =3D=3D qcow2 input image and LUKS encryption =3D=3D required size: 2686976 fully allocated size: 1076232192 +bitmaps size: 0 =3D=3D qcow2 input image and preallocation (human) =3D=3D required size: 1074135040 fully allocated size: 1074135040 +bitmaps size: 0 converted image file size in bytes: 1074135040 @@ -87,6 +94,7 @@ wrote 8388608/8388608 bytes at offset 0 8 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) required size: 8716288 fully allocated size: 8716288 +bitmaps size: 0 converted image file size in bytes: 8716288 @@ -173,6 +181,7 @@ qemu-img: The image size is too large (try using a larg= er cluster size) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D0 { + "bitmaps": 0, "required": 196608, "fully-allocated": 196608 } @@ -183,6 +192,7 @@ converted image file size in bytes: 196608 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 { + "bitmaps": 0, "required": 393216, "fully-allocated": 1074135040 } @@ -193,6 +203,7 @@ wrote 65536/65536 bytes at offset 65536 wrote 64512/64512 bytes at offset 134217728 63 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { + "bitmaps": 0, "required": 589824, "fully-allocated": 1074135040 } @@ -202,6 +213,7 @@ converted image file size in bytes: 524288 =3D=3D qcow2 input image with internal snapshot (json) =3D=3D { + "bitmaps": 0, "required": 524288, "fully-allocated": 1074135040 } @@ -211,6 +223,7 @@ converted image file size in bytes: 458752 =3D=3D qcow2 input image and a backing file (json) =3D=3D { + "bitmaps": 0, "required": 1074135040, "fully-allocated": 1074135040 } @@ -218,6 +231,7 @@ converted image file size in bytes: 458752 =3D=3D qcow2 input image and LUKS encryption =3D=3D { + "bitmaps": 0, "required": 2686976, "fully-allocated": 1076232192 } @@ -225,6 +239,7 @@ converted image file size in bytes: 458752 =3D=3D qcow2 input image and preallocation (json) =3D=3D { + "bitmaps": 0, "required": 1074135040, "fully-allocated": 1074135040 } @@ -237,6 +252,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D838= 8608 wrote 8388608/8388608 bytes at offset 0 8 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { + "bitmaps": 0, "required": 8716288, "fully-allocated": 8716288 } diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190 index 6d41650438e1..1b5fff45bfcd 100755 --- a/tests/qemu-iotests/190 +++ b/tests/qemu-iotests/190 @@ -2,7 +2,7 @@ # # qemu-img measure sub-command tests on huge qcow2 files # -# Copyright (C) 2017 Red Hat, Inc. +# Copyright (C) 2017-2020 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 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file -echo "=3D=3D Huge file =3D=3D" +echo "=3D=3D Huge file without bitmaps =3D=3D" echo _make_test_img -o 'cluster_size=3D2M' 2T @@ -51,6 +51,45 @@ $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" $QEMU_IMG measure -O qcow2 -o cluster_size=3D64k -f qcow2 "$TEST_IMG" $QEMU_IMG measure -O qcow2 -o cluster_size=3D2M -f qcow2 "$TEST_IMG" +echo +echo "=3D=3D Huge file with bitmaps =3D=3D" +echo + +$QEMU_IMG bitmap --add --granularity 512 -f qcow2 "$TEST_IMG" b1 +$QEMU_IMG bitmap --add -g 2M -f qcow2 "$TEST_IMG" b2 + +# No bitmap output, since raw does not support it +$QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" +# No bitmap output, since no bitmaps on raw source +$QEMU_IMG measure -O qcow2 -f raw "$TEST_IMG" +# No bitmap output, since v2 does not support it +$QEMU_IMG measure -O qcow2 -o compat=3D0.10 -f qcow2 "$TEST_IMG" + +# Compute expected output: +echo +val2T=3D$((2*1024*1024*1024*1024)) +cluster=3D$((64*1024)) +b1clusters=3D$(( (val2T/512/8 + cluster - 1) / cluster )) +b2clusters=3D$(( (val2T/2/1024/1024/8 + cluster - 1) / cluster )) +echo expected bitmap $((b1clusters * cluster + + (b1clusters * 8 + cluster - 1) / cluster * cluster + + b2clusters * cluster + + (b2clusters * 8 + cluster - 1) / cluster * cluster + + cluster)) +$QEMU_IMG measure -O qcow2 -o cluster_size=3D64k -f qcow2 "$TEST_IMG" + +# Compute expected output: +echo +cluster=3D$((2*1024*1024)) +b1clusters=3D$(( (val2T/512/8 + cluster - 1) / cluster )) +b2clusters=3D$(( (val2T/2/1024/1024/8 + cluster - 1) / cluster )) +echo expected bitmap $((b1clusters * cluster + + (b1clusters * 8 + cluster - 1) / cluster * cluster + + b2clusters * cluster + + (b2clusters * 8 + cluster - 1) / cluster * cluster + + cluster)) +$QEMU_IMG measure -O qcow2 -o cluster_size=3D2M -f qcow2 "$TEST_IMG" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/190.out b/tests/qemu-iotests/190.out index d001942002db..6d5a25e9de2f 100644 --- a/tests/qemu-iotests/190.out +++ b/tests/qemu-iotests/190.out @@ -1,11 +1,32 @@ QA output created by 190 -=3D=3D Huge file =3D=3D +=3D=3D Huge file without bitmaps =3D=3D Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2199023255552 required size: 2199023255552 fully allocated size: 2199023255552 required size: 335806464 fully allocated size: 2199359062016 +bitmaps size: 0 required size: 18874368 fully allocated size: 2199042129920 +bitmaps size: 0 + +=3D=3D Huge file with bitmaps =3D=3D + +required size: 2199023255552 +fully allocated size: 2199023255552 +required size: 7012352 +fully allocated size: 17170432 +required size: 335806464 +fully allocated size: 2199359062016 + +expected bitmap 537198592 +required size: 335806464 +fully allocated size: 2199359062016 +bitmaps size: 537198592 + +expected bitmap 545259520 +required size: 18874368 +fully allocated size: 2199042129920 +bitmaps size: 545259520 *** done --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961277; cv=none; d=zohomail.com; s=zohoarc; b=brmE8jNTjn3hzV/tIZoSWwnXL0BZ9Voxdu191m8LOMBEW+hebgqYQ9x+E4+C6kanNBIqTdEjIT9C8zzHGw6qqDRSGpIopsI2csadsC5N1YM8uHE2I3xWZTkw8okAXbJkK2qL4EMC6vat6f5PpiSYczzNr3vdaqRp8LuxotSWVbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961277; 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=YBrGFnRDQhTJRIchHheuPEW7L6+PUKuwmbbmKLv1N78=; b=UCIwEVNiHVHw50Lum84kGG7lzUogBFy25rLzjPLY9vQziMtlT6ju8msf2FVXIZgZxnHM1kqReMFmoV15RkCjB+0GHtlSn6Mb2tiYPTCu8ccheBsCrcLgGQJsGiSlvTg/GnQKSxIqLQi7w+RaAJEbNVCnEtkhxLv9w1BNU2PRgIc= 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 1588961277399430.937321147372; Fri, 8 May 2020 11:07:57 -0700 (PDT) Received: from localhost ([::1]:42132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7Pg-0007wD-3A for importer@patchew.org; Fri, 08 May 2020 14:07:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lu-0000R3-7B for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:02 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:22673 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Ls-0007eW-Q8 for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-kdT5Kp00P4iwlZXn4uOyGg-1; Fri, 08 May 2020 14:03:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AAAB1895A37; Fri, 8 May 2020 18:03:53 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8EEA61988; Fri, 8 May 2020 18:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961040; 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=YBrGFnRDQhTJRIchHheuPEW7L6+PUKuwmbbmKLv1N78=; b=Kkrwqj4avDWFcbkxa+bv7vVU8JDl63lRd9hkjEwHesQBUdwQGJqViBZQe6VFagq02YdZU7 fjvOnKMZW+wiyyT1qHwahn4pDA3ibR2RNnnTH5IkI27xpnc40XczW/Xc/QN4DB1RqcMKSg LOD8U+9Nupk8et7x2LQbAmn/5/il5rU= X-MC-Unique: kdT5Kp00P4iwlZXn4uOyGg-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 8/9] qemu-img: Add convert --bitmaps option Date: Fri, 8 May 2020 13:03:39 -0500 Message-Id: <20200508180340.675712-9-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 01:34:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com 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" Make it easier to copy all the persistent bitmaps of (the top layer of) a source image along with its guest-visible contents, by adding a boolean flag for use with qemu-img convert. This is basically shorthand, as the same effect could be accomplished with a series of 'qemu-img bitmap --add' and 'qemu-img bitmap --merge -b source' commands, or by QMP commands. See also https://bugzilla.redhat.com/show_bug.cgi?id=3D1779893 While touching this, clean up a couple coding issues spotted in the same function: an extra blank line, and merging back-to-back 'if (!skip_create)' blocks. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- docs/tools/qemu-img.rst | 6 ++- qemu-img.c | 81 +++++++++++++++++++++++++++++++++++++++-- qemu-img-cmds.hx | 4 +- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst index 68393c357386..444030861cd7 100644 --- a/docs/tools/qemu-img.rst +++ b/docs/tools/qemu-img.rst @@ -162,6 +162,10 @@ Parameters to convert subcommand: .. program:: qemu-img-convert +.. option:: --bitmaps + + Additionally copy all persistent bitmaps from the top layer of the source + .. option:: -n Skip the creation of the target volume @@ -396,7 +400,7 @@ Command description: 4 Error on reading data -.. 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 +.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [= -t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l= SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-m NUM_COROUTINES] [-W] FILENAME [FILENA= ME2 [...]] OUTPUT_FILENAME 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.c b/qemu-img.c index 0e747247e0c5..5c60d0fc8c39 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -78,6 +78,7 @@ enum { OPTION_ENABLE =3D 272, OPTION_DISABLE =3D 273, OPTION_MERGE =3D 274, + OPTION_BITMAPS =3D 275, }; typedef enum OutputFormat { @@ -191,6 +192,7 @@ static void QEMU_NORETURN help(void) " hiding corruption that has already occurred.\n" "\n" "Parameters to convert subcommand:\n" + " '--bitmaps' copies all top-level persistent bitmaps to desti= nation\n" " '-m' specifies how many coroutines work in parallel during t= he convert\n" " process (defaults to 8)\n" " '-W' allow to write to the target out of order rather than s= equential\n" @@ -2108,6 +2110,47 @@ static int convert_do_copy(ImgConvertState *s) return s->ret; } +static int convert_copy_bitmaps(BlockDriverState *src, BlockDriverState *d= st) +{ + BdrvDirtyBitmap *bm; + Error *err =3D NULL; + BlockDirtyBitmapMergeSource *merge; + BlockDirtyBitmapMergeSourceList *list; + + FOR_EACH_DIRTY_BITMAP(src, bm) { + const char *name; + + if (!bdrv_dirty_bitmap_get_persistence(bm)) { + continue; + } + name =3D bdrv_dirty_bitmap_name(bm); + qmp_block_dirty_bitmap_add(dst->node_name, name, + true, bdrv_dirty_bitmap_granularity(bm), + true, true, + true, !bdrv_dirty_bitmap_enabled(bm), + &err); + if (err) { + error_reportf_err(err, "Failed to create bitmap %s: ", name); + return -1; + } + + merge =3D g_new0(BlockDirtyBitmapMergeSource, 1); + merge->type =3D QTYPE_QDICT; + merge->u.external.node =3D g_strdup(src->node_name); + merge->u.external.name =3D g_strdup(name); + list =3D g_new0(BlockDirtyBitmapMergeSourceList, 1); + list->value =3D merge; + qmp_block_dirty_bitmap_merge(dst->node_name, name, list, &err); + qapi_free_BlockDirtyBitmapMergeSourceList(list); + if (err) { + error_reportf_err(err, "Failed to populate bitmap %s: ", name); + return -1; + } + } + + return 0; +} + #define MAX_BUF_SECTORS 32768 static int img_convert(int argc, char **argv) @@ -2129,6 +2172,8 @@ static int img_convert(int argc, char **argv) int64_t ret =3D -EINVAL; bool force_share =3D false; bool explict_min_sparse =3D false; + bool bitmaps =3D false; + size_t nbitmaps =3D 0; ImgConvertState s =3D (ImgConvertState) { /* Need at least 4k of zeros for sparse detection */ @@ -2148,6 +2193,7 @@ static int img_convert(int argc, char **argv) {"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}, + {"bitmaps", no_argument, 0, OPTION_BITMAPS}, {0, 0, 0, 0} }; c =3D getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WU", @@ -2271,6 +2317,9 @@ static int img_convert(int argc, char **argv) */ s.has_zero_init =3D true; break; + case OPTION_BITMAPS: + bitmaps =3D true; + break; } } @@ -2332,7 +2381,6 @@ static int img_convert(int argc, char **argv) goto fail_getopt; } - /* ret is still -EINVAL until here */ ret =3D bdrv_parse_cache_mode(src_cache, &src_flags, &src_writethrough= ); if (ret < 0) { @@ -2492,6 +2540,22 @@ static int img_convert(int argc, char **argv) } } + /* Determine how many bitmaps need copying */ + if (bitmaps) { + BdrvDirtyBitmap *bm; + + if (s.src_num > 1) { + error_report("Copying bitmaps only possible with single source= "); + ret =3D -1; + goto out; + } + FOR_EACH_DIRTY_BITMAP(blk_bs(s.src[0]), bm) { + if (bdrv_dirty_bitmap_get_persistence(bm)) { + nbitmaps++; + } + } + } + /* * The later open call will need any decryption secrets, and * bdrv_create() will purge "opts", so extract them now before @@ -2500,9 +2564,7 @@ static int img_convert(int argc, char **argv) if (!skip_create) { open_opts =3D qdict_new(); qemu_opt_foreach(opts, img_add_key_secrets, open_opts, &error_abor= t); - } - if (!skip_create) { /* Create the new image */ ret =3D bdrv_create(drv, out_filename, opts, &local_err); if (ret < 0) { @@ -2540,6 +2602,13 @@ static int img_convert(int argc, char **argv) } out_bs =3D blk_bs(s.target); + if (nbitmaps > 0 && !bdrv_dirty_bitmap_supported(out_bs)) { + error_report("Format driver '%s' does not support bitmaps", + out_fmt); + ret =3D -1; + goto out; + } + if (s.compressed && !block_driver_can_compress(out_bs->drv)) { error_report("Compression not supported for this file format"); ret =3D -1; @@ -2599,6 +2668,12 @@ static int img_convert(int argc, char **argv) } ret =3D convert_do_copy(&s); + + /* Now copy the bitmaps */ + if (nbitmaps > 0 && ret =3D=3D 0) { + ret =3D convert_copy_bitmaps(blk_bs(s.src[0]), out_bs); + } + out: if (!ret) { qemu_progress_print(100, 0); diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 011688245668..5eb9daa55dc3 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -46,9 +46,9 @@ SRST ERST DEF("convert", img_convert, - "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") + "convert [--object objectdef] [--image-opts] [--target-image-opts] [--= target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cach= e] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapsh= ot_param] [-S sparse_size] [-m num_coroutines] [-W] [--salvage] filename [f= ilename2 [...]] output_filename") SRST -.. 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 +.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-op= ts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [= -t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l= SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-m NUM_COROUTINES] [-W] [--salvage] FILE= NAME [FILENAME2 [...]] OUTPUT_FILENAME ERST DEF("create", img_create, --=20 2.26.2 From nobody Sun May 19 16:31:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588961378; cv=none; d=zohomail.com; s=zohoarc; b=I8XcLkT/MbxGXsMUdjPDaIGjr7lVt7vwQX6jSUHEBnZXZvyK+884tdGQ9+EC99bqDxqJ7RD1VUocYQOqyfoR2VLgedWh4bicBfVOWaS9eeWF0QnI8rnMqGxapdkAh8Dvjqf7d0ePEDOtjAhr7y7If4/QnbS2h95aNBGKIbnDgvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588961378; 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=+TSSoAZroxem0Yd917FV7Xtx/aN+rspekNnxqhDQ4pU=; b=hl9kg6Krvy6QHJqXErb9kbyWw2kU2bQGgO/gJ9+yPrf9/Z1gLDZi3wCEWhHU6akUw8oNLp7ivKKmRYrfZYDaaYUM/4CcrVV5bH6qUJ7i9lActWVbKt083JWmhBrRVuV+r3wLiMTCKrP6hvcv6+Mdvd1baxp/wXY/vsC3wlmSVic= 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 1588961378374446.63889049715556; Fri, 8 May 2020 11:09:38 -0700 (PDT) Received: from localhost ([::1]:47008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7RJ-0001WB-4m for importer@patchew.org; Fri, 08 May 2020 14:09:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lv-0000UB-CF for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:03 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54289 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jX7Lt-0007ef-9k for qemu-devel@nongnu.org; Fri, 08 May 2020 14:04:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-82-j0kldlEwOt-gaVC1YuzvJA-1; Fri, 08 May 2020 14:03:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8057835B52; Fri, 8 May 2020 18:03:53 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-73.phx2.redhat.com [10.3.114.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87CFB6109E; Fri, 8 May 2020 18:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588961040; 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=+TSSoAZroxem0Yd917FV7Xtx/aN+rspekNnxqhDQ4pU=; b=WEFcRFxzFz5WduO/MhAQ9pbRzZ/LqsoXW/v+6maLijrISzw0ixFgep+cyVWB8rk2LU7YVA o/1rKrm/Tsg7E+z8CH4fw10uq2qL8yCCWeAswQkEvErhXfn7DNY4KMJ4Qj4Ml6AsuMI2iC cZOyD/BIL+dyqofJ2iA1ABPO03ECzDM= X-MC-Unique: j0kldlEwOt-gaVC1YuzvJA-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v3 9/9] iotests: Add test 291 to for qemu-img bitmap coverage Date: Fri, 8 May 2020 13:03:40 -0500 Message-Id: <20200508180340.675712-10-eblake@redhat.com> In-Reply-To: <20200508180340.675712-1-eblake@redhat.com> References: <20200508180340.675712-1-eblake@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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 08:00:48 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com 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 new test covering the 'qemu-img bitmap' subcommand, as well as 'qemu-img convert --bitmaps', both added in recent patches. Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- tests/qemu-iotests/291 | 112 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/291.out | 78 ++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 191 insertions(+) create mode 100755 tests/qemu-iotests/291 create mode 100644 tests/qemu-iotests/291.out diff --git a/tests/qemu-iotests/291 b/tests/qemu-iotests/291 new file mode 100755 index 000000000000..3ca83b9cd1f7 --- /dev/null +++ b/tests/qemu-iotests/291 @@ -0,0 +1,112 @@ +#!/usr/bin/env bash +# +# Test qemu-img bitmap handling +# +# Copyright (C) 2018-2020 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 + nbd_server_stop +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.nbd + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux +_require_command QEMU_NBD + +echo +echo "=3D=3D=3D Initial image setup =3D=3D=3D" +echo + +# Create backing image with one bitmap +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 10M +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG.base" b0 +$QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG.base" | _filter_qemu_io + +# Create initial image and populate two bitmaps: one active, one inactive. +ORIG_IMG=3D$TEST_IMG +TEST_IMG=3D$TEST_IMG.orig +_make_test_img -b "$ORIG_IMG.base" -F $IMGFMT 10M +$QEMU_IO -c 'w 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG bitmap --add -g 512k -f $IMGFMT "$TEST_IMG" b1 +$QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b2 +$QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG bitmap --clear -f $IMGFMT "$TEST_IMG" b1 +$QEMU_IO -c 'w 1M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG bitmap --disable -f $IMGFMT "$TEST_IMG" b1 +$QEMU_IMG bitmap --enable -f $IMGFMT "$TEST_IMG" b2 +$QEMU_IO -c 'w 2M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io + +echo +echo "=3D=3D=3D Bitmap preservation not possible to non-qcow2 =3D=3D=3D" +echo + +TEST_IMG=3D$ORIG_IMG +$QEMU_IMG convert --bitmaps -O raw "$TEST_IMG.orig" "$TEST_IMG" && + echo "unexpected success" + +echo +echo "=3D=3D=3D Convert with bitmap preservation =3D=3D=3D" +echo + +# Only bitmaps from the active layer are copied +$QEMU_IMG convert --bitmaps -O qcow2 "$TEST_IMG.orig" "$TEST_IMG" +$QEMU_IMG info "$TEST_IMG" | _filter_img_info --format-specific +# But we can also merge in bitmaps from other layers. This test is a bit +# contrived to cover more code paths, in reality, you could merge directly +# into b0 without going through tmp +$QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b0 +$QEMU_IMG bitmap --add --merge b0 -b "$TEST_IMG.base" -F $IMGFMT \ + -f $IMGFMT "$TEST_IMG" tmp +$QEMU_IMG bitmap --merge tmp -f $IMGFMT "$TEST_IMG" b0 +$QEMU_IMG bitmap --remove --image-opts \ + driver=3D$IMGFMT,file.driver=3Dfile,file.filename=3D"$TEST_IMG" tmp +$QEMU_IMG info "$TEST_IMG" | _filter_img_info --format-specific + +echo +echo "=3D=3D=3D Check bitmap contents =3D=3D=3D" +echo + +# x-dirty-bitmap is a hack for reading bitmaps; it abuses block status to +# report "data":false for portions of the bitmap which are set +IMG=3D"driver=3Dnbd,server.type=3Dunix,server.path=3D$nbd_unix_socket" +nbd_server_start_unix_socket -r -f qcow2 -B b0 "$TEST_IMG" +$QEMU_IMG map --output=3Djson --image-opts \ + "$IMG,x-dirty-bitmap=3Dqemu:dirty-bitmap:b0" | _filter_qemu_img_map +nbd_server_start_unix_socket -r -f qcow2 -B b1 "$TEST_IMG" +$QEMU_IMG map --output=3Djson --image-opts \ + "$IMG,x-dirty-bitmap=3Dqemu:dirty-bitmap:b1" | _filter_qemu_img_map +nbd_server_start_unix_socket -r -f qcow2 -B b2 "$TEST_IMG" +$QEMU_IMG map --output=3Djson --image-opts \ + "$IMG,x-dirty-bitmap=3Dqemu:dirty-bitmap:b2" | _filter_qemu_img_map + +# success, all done +echo '*** done' +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/291.out b/tests/qemu-iotests/291.out new file mode 100644 index 000000000000..14e5cfc96589 --- /dev/null +++ b/tests/qemu-iotests/291.out @@ -0,0 +1,78 @@ +QA output created by 291 + +=3D=3D=3D Initial image setup =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D10485760 +wrote 1048576/1048576 bytes at offset 3145728 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=3DIMGFMT size=3D10485760 backing_= file=3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 3145728 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 2097152 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Bitmap preservation not possible to non-qcow2 =3D=3D=3D + +qemu-img: Format driver 'raw' does not support bitmaps + +=3D=3D=3D Convert with bitmap preservation =3D=3D=3D + +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 10 MiB (10485760 bytes) +disk size: 4.39 MiB +Format specific information: + compat: 1.1 + lazy refcounts: false + bitmaps: + [0]: + flags: + name: b1 + granularity: 524288 + [1]: + flags: + [0]: auto + name: b2 + granularity: 65536 + refcount bits: 16 + corrupt: false +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 10 MiB (10485760 bytes) +disk size: 4.48 MiB +Format specific information: + compat: 1.1 + lazy refcounts: false + bitmaps: + [0]: + flags: + name: b1 + granularity: 524288 + [1]: + flags: + [0]: auto + name: b2 + granularity: 65536 + [2]: + flags: + name: b0 + granularity: 65536 + refcount bits: 16 + corrupt: false + +=3D=3D=3D Check bitmap contents =3D=3D=3D + +[{ "start": 0, "length": 3145728, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, +{ "start": 3145728, "length": 1048576, "depth": 0, "zero": false, "data": = false}, +{ "start": 4194304, "length": 6291456, "depth": 0, "zero": false, "data": = true, "offset": OFFSET}] +[{ "start": 0, "length": 1048576, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, +{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": = false}, +{ "start": 2097152, "length": 8388608, "depth": 0, "zero": false, "data": = true, "offset": OFFSET}] +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, +{ "start": 2097152, "length": 1048576, "depth": 0, "zero": false, "data": = false}, +{ "start": 3145728, "length": 7340032, "depth": 0, "zero": false, "data": = true, "offset": OFFSET}] +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index fe649c5b736e..206a23292688 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -298,4 +298,5 @@ 288 quick 289 rw quick 290 rw auto quick +291 rw quick 292 rw auto quick --=20 2.26.2