From patchwork Fri Apr 24 15:01:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 464222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5A01F140150 for ; Sat, 25 Apr 2015 01:02:54 +1000 (AEST) Received: from localhost ([::1]:45204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylf80-0005Q7-Fs for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 11:02:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylf7H-00047S-RX for qemu-devel@nongnu.org; Fri, 24 Apr 2015 11:02:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ylf7D-0006F1-DA for qemu-devel@nongnu.org; Fri, 24 Apr 2015 11:02:07 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51751 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylf7C-0006EX-5i; Fri, 24 Apr 2015 11:02:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AucFALVZOlVbdWOb/2dsb2JhbABbgwyBLrRoBAUBgQKYPQKBPUwBAQEBAQGBC4QhAQEEJ1IQUTwbGYgvAcwaAQEIIoYWiiUHFoQXBYY/hRmMO4N4jBuCK4cPI2CBJxwVgT87MYJEAQEB X-IPAS-Result: AucFALVZOlVbdWOb/2dsb2JhbABbgwyBLrRoBAUBgQKYPQKBPUwBAQEBAQGBC4QhAQEEJ1IQUTwbGYgvAcwaAQEIIoYWiiUHFoQXBYY/hRmMO4N4jBuCK4cPI2CBJxwVgT87MYJEAQEB X-IronPort-AV: E=Sophos;i="5.11,640,1422918000"; d="scan'208";a="345267691" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 24 Apr 2015 17:01:59 +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_256_CBC_SHA1:32) (Exim) id 1Ylf79-0004vQ-Ky; Fri, 24 Apr 2015 17:01:59 +0200 Received: from fanzine.local.igalia.com ([192.168.10.13] helo=perseus.local) by mail.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Ylf78-0007GH-Pa; Fri, 24 Apr 2015 17:01:59 +0200 Received: from berto by perseus.local with local (Exim 4.84) (envelope-from ) id 1Ylf77-0005Ux-Eu; Fri, 24 Apr 2015 18:01:57 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 24 Apr 2015 18:01:47 +0300 Message-Id: <57648d5e1a5e192845f5a339970bf084b72eca5c.1429885069.git.berto@igalia.com> X-Mailer: git-send-email 2.1.4 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 , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 03/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 as we introduce support for streaming to any intermediate node. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block/stream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/stream.c b/block/stream.c index a628901..37bfd8b 100644 --- a/block/stream.c +++ b/block/stream.c @@ -114,21 +114,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_hd) { - 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; @@ -215,6 +215,7 @@ wait: qemu_vfree(buf); +out: /* Modify backing chain and close BDSes in main loop */ data = g_malloc(sizeof(*data)); data->ret = ret;