From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmRDV-0004Mr-L8 for qemu-devel@nongnu.org; Fri, 29 Nov 2013 11:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VmRDP-0002uo-MH for qemu-devel@nongnu.org; Fri, 29 Nov 2013 11:46:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmRDP-0002ue-By for qemu-devel@nongnu.org; Fri, 29 Nov 2013 11:46:51 -0500 From: Kevin Wolf Date: Fri, 29 Nov 2013 17:45:36 +0100 Message-Id: <1385743555-27888-22-git-send-email-kwolf@redhat.com> In-Reply-To: <1385743555-27888-1-git-send-email-kwolf@redhat.com> References: <1385743555-27888-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 21/41] block/stream: Don't stream unbacked devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Max Reitz 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 Reviewed-by: Wenchao Xia Signed-off-by: Kevin Wolf --- block/stream.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/stream.c b/block/stream.c index 694fd42..46bec7d 100644 --- a/block/stream.c +++ b/block/stream.c @@ -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); -- 1.8.1.4