From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VggGC-0001DC-UD for qemu-devel@nongnu.org; Wed, 13 Nov 2013 14:38:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VggG6-00034C-Vm for qemu-devel@nongnu.org; Wed, 13 Nov 2013 14:37:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VggG6-000340-Nv for qemu-devel@nongnu.org; Wed, 13 Nov 2013 14:37:50 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rADJbnX4017950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Nov 2013 14:37:49 -0500 From: Max Reitz Date: Wed, 13 Nov 2013 20:37:58 +0100 Message-Id: <1384371478-20021-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] block/stream: Don't stream unbacked devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi , 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 --- 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.4.2