From nobody Thu Dec 18 13:19:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583515583; cv=none; d=zohomail.com; s=zohoarc; b=eNyNAXDIE57jh9DSgHwu1qiX+E4WfnhbTsMsPEs4q4g2DbCBZC55gceplirPOEglAysklCP4RuZXzQVhYOo4oZ/uZDwT3L2np+oP2GQ+oIjCix13weXl0gI2eISW6x5UZreWqa7KhqiMTUqBbUU9rEdOO+Y22aFnfJOHtOKfClQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583515583; 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=Zk24Gz6842BbVOxvfiB5Wtlxhvz/vvXj7Ef18Q4kwtQ=; b=asnvrLKxlZVii+PzUPABdqQhUui04pVvRmwbwC8ZPcAb/bsltowUccNcbQzSxyLv4vB3GjO96+6DSXnqJIfMT/KgvbKrWSpI9OYejdSijLdXaq+Q6nzhUYu/sKU2XjqLc//03NZOGe7NWH9ONCfG2W1qbJ0c0shSPRpTZXif188= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 158351558304420.23640905587331; Fri, 6 Mar 2020 09:26:23 -0800 (PST) Received: from localhost ([::1]:39956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAGjt-0004OM-Su for importer@patchew.org; Fri, 06 Mar 2020 12:26:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48629) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAGZX-00051C-4z for qemu-devel@nongnu.org; Fri, 06 Mar 2020 12:15:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAGZU-00085x-Vp for qemu-devel@nongnu.org; Fri, 06 Mar 2020 12:15:38 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51334 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAGZS-0007yS-Oo for qemu-devel@nongnu.org; Fri, 06 Mar 2020 12:15:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-6uQ8F1S0O5uSBqDBfTfLvQ-1; Fri, 06 Mar 2020 12:15:14 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A414800D6C; Fri, 6 Mar 2020 17:15:13 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FE3273873; Fri, 6 Mar 2020 17:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583514933; 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=Zk24Gz6842BbVOxvfiB5Wtlxhvz/vvXj7Ef18Q4kwtQ=; b=PXkR4twq6/OxLrWfs26a6oynAjw5Qe9+s803iPWKJZXP6yzh7AgdVDA0KcCsEVW3HLZQ1v h3+DchbxjXUTNmKLPfk8zAMwV+e1N9ouAx9xWWQ59qDOI9j4+10fk2uvbvtqaToDvRnV5V A5XC3ZvIrwoCY7E4fhTHDpEdTkImG/c= X-MC-Unique: 6uQ8F1S0O5uSBqDBfTfLvQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 06/29] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_post Date: Fri, 6 Mar 2020 18:14:35 +0100 Message-Id: <20200306171458.1848-7-kwolf@redhat.com> In-Reply-To: <20200306171458.1848-1-kwolf@redhat.com> References: <20200306171458.1848-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Peter Krempa The bitmap code requires writing the 'file' child when the qcow2 driver is reopened in read-write mode. If the 'file' child is being reopened due to a permissions change, the modification is commited yet when qcow2_reopen_commit is called. This means that any attempt to write the 'file' child will end with EBADFD as the original fd was already closed. Moving bitmap reopening to the new callback which is called after permission modifications are commited fixes this as the file descriptor will be replaced with the correct one. The above problem manifests itself when reopening 'qcow2' format layer which uses a 'file-posix' file child which was opened with the 'auto-read-only' property set. Signed-off-by: Peter Krempa Message-Id: Signed-off-by: Kevin Wolf --- block/qcow2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 3c754f616b..3640e8c07d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1884,6 +1884,11 @@ fail: static void qcow2_reopen_commit(BDRVReopenState *state) { qcow2_update_options_commit(state->bs, state->opaque); + g_free(state->opaque); +} + +static void qcow2_reopen_commit_post(BDRVReopenState *state) +{ if (state->flags & BDRV_O_RDWR) { Error *local_err =3D NULL; =20 @@ -1898,7 +1903,6 @@ static void qcow2_reopen_commit(BDRVReopenState *stat= e) bdrv_get_node_name(state->bs)); } } - g_free(state->opaque); } =20 static void qcow2_reopen_abort(BDRVReopenState *state) @@ -5534,6 +5538,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_close =3D qcow2_close, .bdrv_reopen_prepare =3D qcow2_reopen_prepare, .bdrv_reopen_commit =3D qcow2_reopen_commit, + .bdrv_reopen_commit_post =3D qcow2_reopen_commit_post, .bdrv_reopen_abort =3D qcow2_reopen_abort, .bdrv_join_options =3D qcow2_join_options, .bdrv_child_perm =3D bdrv_format_default_perms, --=20 2.20.1