From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya430-0002gs-Vt for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:13:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya42u-0002dd-Om for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:13:46 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:62094 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya42u-0002dF-Cf for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:13:40 -0400 From: Alberto Garcia Date: Mon, 23 Mar 2015 17:12:49 +0200 Message-Id: <9a4bbe23bdb3a40ca9325f7ff1f7b7b6fcfabe2c.1427119793.git.berto@igalia.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 2/5] block: never cancel a streaming job without running stream_complete() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , Max Reitz , Stefan Hajnoczi 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 --- 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; -- 2.1.4