Never cancel a streaming job without running stream_complete()
cover Never cancel a streaming job without running stream_complete()
Hi,
this is a simple fix that was ready one year ago but never made it through because it was part of the intermediate block streaming series.
While I'm retaking the work on that series and I plan to send a new version sooner or later, I think there's no reason to delay this patch even more.
Although the patch is one year old, I decided to keep all the R-b lines because nothing has really changed in this code since then and I don't believe the change is controversial.
Berto
Alberto Garcia (1):
block: never cancel a streaming job without running stream_complete()
block/stream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.0
PATCH 1/1 block: never cancel a streaming job without running stream_complete()
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.
--- block/stream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
block/stream.c +6 -5
@@ -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;
Signature · 1 line
2.7.0