Patchwork [7/8] qed: Add QED_CF_STREAM flag to auto-enable streaming

login
register
mail settings
Submitter Stefan Hajnoczi
Date April 27, 2011, 1:27 p.m.
Message ID <1303910855-28999-8-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/93044/
State New
Headers show

Comments

Stefan Hajnoczi - April 27, 2011, 1:27 p.m.
The QED_CF_STREAM flag can be set to automatically stream from the
backing file.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 block/qed.c |    5 +++++
 block/qed.h |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

Patch

diff --git a/block/qed.c b/block/qed.c
index 2c155d9..a61cee9 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -373,6 +373,11 @@  static int bdrv_qed_open(BlockDriverState *bs, int flags)
         if (s->header.features & QED_F_BACKING_FORMAT_NO_PROBE) {
             pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw");
         }
+
+        if ((s->header.compat_features & QED_CF_STREAM) &&
+            !bdrv_is_read_only(bs->file)) {
+            bs->stream = 1;
+        }
     }
 
     /* Reset unknown autoclear feature bits.  This is a backwards
diff --git a/block/qed.h b/block/qed.h
index 8e9e415..23a9bde 100644
--- a/block/qed.h
+++ b/block/qed.h
@@ -59,13 +59,17 @@  enum {
     /* Reads to the backing file should populate the image file */
     QED_CF_COPY_ON_READ = 0x01,
 
+    /* Stream until the backing image is no longer needed */
+    QED_CF_STREAM = 0x02,
+
     /* Supported feature bits */
     QED_FEATURE_MASK = QED_F_BACKING_FILE |
                        QED_F_NEED_CHECK |
                        QED_F_BACKING_FORMAT_NO_PROBE,
 
     /* Supported compat feature bits */
-    QED_COMPAT_FEATURE_MASK = QED_CF_COPY_ON_READ,
+    QED_COMPAT_FEATURE_MASK = QED_CF_COPY_ON_READ |
+                              QED_CF_STREAM,
 
     /* Supported autoclear feature bits */
     QED_AUTOCLEAR_FEATURE_MASK = 0,