Patchwork qed: Refuse to create images on block devices

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 14, 2011, 10:44 p.m.
Message ID <1295045073-17529-1-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/79017/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 14, 2011, 10:44 p.m.
QED relies on the underlying filesystem to extend the file and maintain
its size.  Check that images are not created on a block device.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 block/qed.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Kevin Wolf - Jan. 17, 2011, 5:48 p.m.
Am 14.01.2011 23:44, schrieb Stefan Hajnoczi:
> QED relies on the underlying filesystem to extend the file and maintain
> its size.  Check that images are not created on a block device.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block/qed.c b/block/qed.c
index 085c4f2..a46f9ef 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -469,6 +469,12 @@  static int qed_create(const char *filename, uint32_t cluster_size,
         return ret;
     }
 
+    /* File must start empty and grow, check truncate is supported */
+    ret = bdrv_truncate(bs, 0);
+    if (ret < 0) {
+        goto out;
+    }
+
     if (backing_file) {
         header.features |= QED_F_BACKING_FILE;
         header.backing_filename_offset = sizeof(le_header);