summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-01-14 22:44:33 +0000
committerKevin Wolf <kwolf@redhat.com>2011-01-24 16:41:50 +0100
commitbe33439e4ca7d8c774d2c5009f8698ce3be97693 (patch)
tree1589e05d6532aac2679c9b84fd6adb97c767ef94 /block
parent0efa7ba3056ce96260a6bfef0725cc548505c3b0 (diff)
downloadqemu-be33439e4ca7d8c774d2c5009f8698ce3be97693.tar.gz
qemu-be33439e4ca7d8c774d2c5009f8698ce3be97693.tar.bz2
qemu-be33439e4ca7d8c774d2c5009f8698ce3be97693.zip
qed: Refuse to create images on block devices
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> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qed.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/block/qed.c b/block/qed.c
index 085c4f2210..a46f9ef419 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);