diff mbox

qed: Refuse to create images on block devices

Message ID 1295045073-17529-1-git-send-email-stefanha@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Hajnoczi Jan. 14, 2011, 10:44 p.m. UTC
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(-)

Comments

Kevin Wolf Jan. 17, 2011, 5:48 p.m. UTC | #1
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
diff mbox

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);