diff options
author | Eric Blake <eblake@redhat.com> | 2017-07-07 07:44:42 -0500 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-07-10 13:18:06 +0200 |
commit | 158c6492571c82c5632070c7ccee36b3dffd3ca9 (patch) | |
tree | fa69751bc86ce53b92b600b6f3397b88a649f4a1 /block/stream.c | |
parent | 8493211c02bbc74d1ae051422f90bbfd20debb5e (diff) | |
download | qemu-158c6492571c82c5632070c7ccee36b3dffd3ca9.zip |
stream: Drop reached_end for stream_complete()
stream_complete() skips the work of rewriting the backing file if
the job was cancelled, if data->reached_end is false, or if there
was an error detected (non-zero data->ret) during the streaming.
But note that in stream_run(), data->reached_end is only set if the
loop ran to completion, and data->ret is only 0 in two cases:
either the loop ran to completion (possibly by cancellation, but
stream_complete checks for that), or we took an early goto out
because there is no bs->backing. Thus, we can preserve the same
semantics without the use of reached_end, by merely checking for
bs->backing (and logically, if there was no backing file, streaming
is a no-op, so there is no backing file to rewrite).
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/stream.c')
-rw-r--r-- | block/stream.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/block/stream.c b/block/stream.c index 746d525cac..12f1659942 100644 --- a/block/stream.c +++ b/block/stream.c @@ -59,7 +59,6 @@ static int coroutine_fn stream_populate(BlockBackend *blk, typedef struct { int ret; - bool reached_end; } StreamCompleteData; static void stream_complete(BlockJob *job, void *opaque) @@ -70,7 +69,7 @@ static void stream_complete(BlockJob *job, void *opaque) BlockDriverState *base = s->base; Error *local_err = NULL; - if (!block_job_is_cancelled(&s->common) && data->reached_end && + if (!block_job_is_cancelled(&s->common) && bs->backing && data->ret == 0) { const char *base_id = NULL, *base_fmt = NULL; if (base) { @@ -211,7 +210,6 @@ out: /* Modify backing chain and close BDSes in main loop */ data = g_malloc(sizeof(*data)); data->ret = ret; - data->reached_end = sector_num == end; block_job_defer_to_main_loop(&s->common, stream_complete, data); } |