Skip to content

Commit

Permalink
block/stream: Don't stream unbacked devices
Browse files Browse the repository at this point in the history
If a block device is unbacked, a streaming blockjob should immediately
finish instead of beginning to try to stream, then noticing the backing
file does not contain even the first sector (since it does not exist)
and then finishing normally.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
XanClic authored and kevmw committed Nov 28, 2013
1 parent 8582972 commit f4a193e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions block/stream.c
Expand Up @@ -88,6 +88,11 @@ static void coroutine_fn stream_run(void *opaque)
int n = 0;
void *buf;

if (!bs->backing_hd) {
block_job_completed(&s->common, 0);
return;
}

s->common.len = bdrv_getlength(bs);
if (s->common.len < 0) {
block_job_completed(&s->common, s->common.len);
Expand Down

0 comments on commit f4a193e

Please sign in to comment.