From patchwork Mon Mar 21 13:47:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 8633291 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC0AD9F294 for ; Mon, 21 Mar 2016 13:48:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35AD9201F5 for ; Mon, 21 Mar 2016 13:48:50 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 7C88520304 for ; Mon, 21 Mar 2016 13:48:49 +0000 (UTC) Received: from localhost ([::1]:57889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai0CO-00038m-UC for patchwork-qemu-devel@patchwork.kernel.org; Mon, 21 Mar 2016 09:48:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai0C4-0002ub-6Y for qemu-devel@nongnu.org; Mon, 21 Mar 2016 09:48:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai0C1-0003JL-Qs for qemu-devel@nongnu.org; Mon, 21 Mar 2016 09:48:28 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:63846 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai0C1-0003EU-CW; Mon, 21 Mar 2016 09:48:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BDAgCs+u9W/5tjdVteHYMWgUWmLAUBgQ+QVYIPAQ2BcIYNAoEmOBQBAQEBAQEBZCeEQgEBBCdSED8SPBsZiCsBvmYBAQEHIIVWgkOHUYUKBYdZj36IY4UhiTOFVESFY4hfHgEBQoIDGRSBN2iKFQEBAQ X-IPAS-Result: A2BDAgCs+u9W/5tjdVteHYMWgUWmLAUBgQ+QVYIPAQ2BcIYNAoEmOBQBAQEBAQEBZCeEQgEBBCdSED8SPBsZiCsBvmYBAQEHIIVWgkOHUYUKBYdZj36IY4UhiTOFVESFY4hfHgEBQoIDGRSBN2iKFQEBAQ X-IronPort-AV: E=Sophos;i="5.24,372,1454972400"; d="scan'208";a="33491410" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 21 Mar 2016 14:47:47 +0100 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ai0BP-0000Wu-3g; Mon, 21 Mar 2016 14:47:47 +0100 Received: from berto by perseus.local with local (Exim 4.86_2) (envelope-from ) id 1ai0B7-00045E-4P; Mon, 21 Mar 2016 15:47:29 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 21 Mar 2016 15:47:25 +0200 Message-Id: <2abedf2debc65c250560237f31a8e6756883c8fc.1458566441.git.berto@igalia.com> X-Mailer: git-send-email 2.8.0.rc3 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 Cc: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: [Qemu-devel] [PATCH v2 1/3] block: never cancel a streaming job without running stream_complete() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to call stream_complete() in order to do all the necessary clean-ups, even if there's an early failure. At the moment it's only useful to make sure that s->backing_file_str is not leaked, but it will become more important if we introduce support for streaming to any intermediate node. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/stream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/stream.c b/block/stream.c index cafaa07..eea3938 100644 --- a/block/stream.c +++ b/block/stream.c @@ -89,21 +89,21 @@ static void coroutine_fn stream_run(void *opaque) StreamCompleteData *data; BlockDriverState *bs = s->common.bs; BlockDriverState *base = s->base; - int64_t sector_num, end; + int64_t sector_num = 0; + int64_t end = -1; int error = 0; int ret = 0; int n = 0; void *buf; if (!bs->backing) { - block_job_completed(&s->common, 0); - return; + goto out; } s->common.len = bdrv_getlength(bs); if (s->common.len < 0) { - block_job_completed(&s->common, s->common.len); - return; + ret = s->common.len; + goto out; } end = s->common.len >> BDRV_SECTOR_BITS; @@ -190,6 +190,7 @@ wait: qemu_vfree(buf); +out: /* Modify backing chain and close BDSes in main loop */ data = g_malloc(sizeof(*data)); data->ret = ret;