9ae3a8
From b8159f39be879b1133ce89bcb2c892e0d6711fdb Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Sun, 22 Dec 2013 16:12:39 +0100
9ae3a8
Subject: [PATCH 1/8] block/stream: Don't stream unbacked devices
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <1387728759-7141-2-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 56422
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH] block/stream: Don't stream unbacked devices
9ae3a8
Bugzilla: 965636
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
BZ: 965636
9ae3a8
9ae3a8
If a block device is unbacked, a streaming blockjob should immediately
9ae3a8
finish instead of beginning to try to stream, then noticing the backing
9ae3a8
file does not contain even the first sector (since it does not exist)
9ae3a8
and then finishing normally.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit f4a193e717e6b5179a2e57423bfe110b724662d8)
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
---
9ae3a8
 block/stream.c | 5 +++++
9ae3a8
 1 file changed, 5 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/stream.c |    5 +++++
9ae3a8
 1 files changed, 5 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/stream.c b/block/stream.c
9ae3a8
index 276487c..cbae815 100644
9ae3a8
--- a/block/stream.c
9ae3a8
+++ b/block/stream.c
9ae3a8
@@ -84,6 +84,11 @@ static void coroutine_fn stream_run(void *opaque)
9ae3a8
     int n = 0;
9ae3a8
     void *buf;
9ae3a8
 
9ae3a8
+    if (!bs->backing_hd) {
9ae3a8
+        block_job_completed(&s->common, 0);
9ae3a8
+        return;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     s->common.len = bdrv_getlength(bs);
9ae3a8
     if (s->common.len < 0) {
9ae3a8
         block_job_completed(&s->common, s->common.len);
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8