From patchwork Fri May 27 10:53:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9138143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6873E6075C for ; Fri, 27 May 2016 10:58:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5837C2793B for ; Fri, 27 May 2016 10:58:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48FD328135; Fri, 27 May 2016 10:58:34 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 B47742793B for ; Fri, 27 May 2016 10:58:33 +0000 (UTC) Received: from localhost ([::1]:45243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FTM-0007uI-1Z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 06:58:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPj-0004mu-EG for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6FPc-0002L2-3T for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:46 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:20733 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPb-0002KN-Rw; Fri, 27 May 2016 06:54:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AnBQDmJkhX/5tjdVtcHAGDHIFTpTYBAQEBAQEFAYEPAZEOgh2BeIYRAoE7OhIBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBAQYCJYVfgkaHWYRyHAWYN44ggWmHe4U4j0wnBzSCBhyBTToyiggBAQE X-IPAS-Result: A2AnBQDmJkhX/5tjdVtcHAGDHIFTpTYBAQEBAQEFAYEPAZEOgh2BeIYRAoE7OhIBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBAQYCJYVfgkaHWYRyHAWYN44ggWmHe4U4j0wnBzSCBhyBTToyiggBAQE X-IronPort-AV: E=Sophos;i="5.26,373,1459807200"; d="scan'208";a="64793584" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 27 May 2016 12:53:57 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1b6FOv-00066G-Bh; Fri, 27 May 2016 12:53:57 +0200 Received: from ip159.dynamic.igalia.com ([192.168.10.159] helo=perseus.local) by mail.igalia.com with esmtps (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1b6FOv-0002ON-6s; Fri, 27 May 2016 12:53:57 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1b6FOv-0002T2-4P; Fri, 27 May 2016 13:53:57 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 12:53:39 +0200 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH 4/4] block: Create the commit block job before reopening any image 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: Kevin Wolf , Alberto Garcia , qemu-block@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 If the base or overlay images need to be reopened in read-write mode but the block_job_create() call fails then no one will put those images back in read-only mode. We can solve this problem easily by calling block_job_create() first. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block/commit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/commit.c b/block/commit.c index 8a00e11..444333b 100644 --- a/block/commit.c +++ b/block/commit.c @@ -236,6 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, return; } + s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp); + if (!s) { + return; + } + orig_base_flags = bdrv_get_flags(base); orig_overlay_flags = bdrv_get_flags(overlay_bs); @@ -252,16 +257,12 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, bdrv_reopen_multiple(reopen_queue, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); + block_job_unref(&s->common); return; } } - s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp); - if (!s) { - return; - } - s->base = blk_new(); blk_insert_bs(s->base, base);