aboutsummaryrefslogtreecommitdiff
path: root/block/rbd.c
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@dreamhost.com>2011-05-26 16:07:34 -0700
committerKevin Wolf <kwolf@redhat.com>2011-06-08 11:56:40 +0200
commit30cdc48cc8c9ad28e1b95460021d0c121b3ed4f4 (patch)
treebed18eaea81048779d0e23b4d6c50f05bb0c7bfa /block/rbd.c
parent51a135287ae6be62d54d7ac2a99e647cbab1a828 (diff)
rbd: Add bdrv_truncate implementation
Reviewed-by: Christian Brunner <chb@muc.de> Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/rbd.c')
-rw-r--r--block/rbd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/block/rbd.c b/block/rbd.c
index f4da6ab13a..bdc448aa9f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -688,6 +688,19 @@ static int64_t qemu_rbd_getlength(BlockDriverState *bs)
return info.size;
}
+static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset)
+{
+ BDRVRBDState *s = bs->opaque;
+ int r;
+
+ r = rbd_resize(s->image, offset);
+ if (r < 0) {
+ return r;
+ }
+
+ return 0;
+}
+
static int qemu_rbd_snap_create(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info)
{
@@ -784,6 +797,7 @@ static BlockDriver bdrv_rbd = {
.bdrv_get_info = qemu_rbd_getinfo,
.create_options = qemu_rbd_create_options,
.bdrv_getlength = qemu_rbd_getlength,
+ .bdrv_truncate = qemu_rbd_truncate,
.protocol_name = "rbd",
.bdrv_aio_readv = qemu_rbd_aio_readv,