From patchwork Mon Jul 23 20:16:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10540941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E1F617FD for ; Mon, 23 Jul 2018 20:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EBF82848F for ; Mon, 23 Jul 2018 20:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 023F5205AD; Mon, 23 Jul 2018 20:46:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99B86205AD for ; Mon, 23 Jul 2018 20:46:57 +0000 (UTC) Received: from localhost ([::1]:36500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhjM-0000yk-Pw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 16:46:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJB-0002L8-5c for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJA-0003vq-9x for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:53 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:44290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJA-0003vT-4E; Mon, 23 Jul 2018 16:19:52 -0400 Received: by mail-oi0-x241.google.com with SMTP id s198-v6so3460255oih.11; Mon, 23 Jul 2018 13:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LSW7cJQsGNP6NaUCPYsYqHrf1131Q3vBz4gLq9OQTek=; b=rxmUoRhC6BnVaEjhzF98kkAE0k1uoHfePOAmLSDrqrbl+ZdZxt+HQc/2ZOrABmTDgf FnCvktz1vxQVBKrzROriFZCr4jqKuQdP4YyECeN+TqoSAphYvAf0NfyR6U+l4/Pzbh+P BpIM0Cor/gNTdc555td5bXPwsDxW6uPreK8eS2jiRPM3Nx7iIqRxkKuFqp4EHlCReLOi XakUGuKZgo7I3VykuvZdGDdH/Qvhlo+5IhR/PRPt0FfqwvpfdVNvilCyb6Z+WOUveeQj HULvJcZs0sarQjW2ZU+4ras6SDW56Aj29hxhCNOcEnvUIp3IkAnOkp90fRVlqQFawlfS 9SxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=LSW7cJQsGNP6NaUCPYsYqHrf1131Q3vBz4gLq9OQTek=; b=Et92XzNPT7OKH4rXUiq8I0qvMbg30cjUSFh4Z9q2b1SWuvq7Jhu4hy4QXQhg+OhnZm 5skg57i+pAMJg8CHNrYIKxZwRPDAPE3oYx3zeLIzp+Gg6tPXNEQ+GFnoBGNRYkuicwb+ nlexWyAiwcbgy9rfOLnw7JfN1OnbvtQntoQk/OoLOslR9auSi8Kul09+28yUnLZB+AAM 450K8UdmzPaZCsLLjLfUbmXejZglqLTZs+bKnv6Pz4bHoT/EiXCHBH0DlAvFFcYfZmaM GaawhIK2d0aonTF0DH/OznGy1jNjseaf6Wpvf00iAwlykeLLmTedMM1tz4UNFjpzK14+ cyyg== X-Gm-Message-State: AOUpUlElufVL7FhtXPLjDW5/IyqzVASh4D0hiEYSMKnSfbF8D3WdXroZ Qqq0GDaDgPlDQ9ANdiWXtFkDkzLCmz8= X-Google-Smtp-Source: AAOMgpcXm5RccaLeneOOv88pakASAL76VfBA+DeDELqpd7BJJDPFzekgnhao/GrzhXEsROQKk38POw== X-Received: by 2002:aca:4ec6:: with SMTP id c189-v6mr329838oib.186.1532377191012; Mon, 23 Jul 2018 13:19:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id p132-v6sm7739726oia.31.2018.07.23.13.19.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:48 -0500 Message-Id: <20180723201748.25573-40-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 39/99] qcow2: Do not mark inactive images corrupt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Max Reitz When signaling a corruption on a read-only image, qcow2 already makes fatal events non-fatal (i.e., they will not result in the image being closed, and the image header's corrupt flag will not be set). This is necessary because we cannot set the corrupt flag on read-only images, and it is possible because further corruption of read-only images is impossible. Inactive images are effectively read-only, too, so we should do the same for them. bdrv_is_writable() can tell us whether an image can actually be written to, so use its result instead of !bs->read_only. (Otherwise, the assert(!(bs->open_flags & BDRV_O_INACTIVE)) in bdrv_co_pwritev() will fail, crashing qemu.) Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180606193702.7113-3-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Jeff Cody Signed-off-by: Max Reitz (cherry picked from commit ddf3b47ef4b5ed0bf6558d4c2c8ae130b8d8a580) Signed-off-by: Michael Roth --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index ef68772aca..a2b2e5d4cd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4386,7 +4386,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, char *message; va_list ap; - fatal = fatal && !bs->read_only; + fatal = fatal && bdrv_is_writable(bs); if (s->signaled_corruption && (!fatal || (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT)))