diff --git a/block/stream.c b/block/stream.c index cafaa07a0195c2751bf6eae6f386a60b5c143bd8..eea393862670579d3a160f661a41a8f45199bad9 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;