[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 36/37] block/ssh: Add basic .bdrv_truncate()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 36/37] block/ssh: Add basic .bdrv_truncate() |
Date: |
Fri, 2 Mar 2018 19:54:47 +0100 |
From: Max Reitz <address@hidden>
libssh2 does not seem to offer real truncation support, so we can only
grow files -- but that is better than nothing.
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Richard W.M. Jones <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/ssh.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/block/ssh.c b/block/ssh.c
index 4bcf10334f..80a8b40dfa 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -1220,6 +1220,29 @@ static int64_t ssh_getlength(BlockDriverState *bs)
return length;
}
+static int ssh_truncate(BlockDriverState *bs, int64_t offset,
+ PreallocMode prealloc, Error **errp)
+{
+ BDRVSSHState *s = bs->opaque;
+
+ if (prealloc != PREALLOC_MODE_OFF) {
+ error_setg(errp, "Unsupported preallocation mode '%s'",
+ PreallocMode_str(prealloc));
+ return -ENOTSUP;
+ }
+
+ if (offset < s->attrs.filesize) {
+ error_setg(errp, "ssh driver does not support shrinking files");
+ return -ENOTSUP;
+ }
+
+ if (offset == s->attrs.filesize) {
+ return 0;
+ }
+
+ return ssh_grow_file(s, offset, errp);
+}
+
static BlockDriver bdrv_ssh = {
.format_name = "ssh",
.protocol_name = "ssh",
@@ -1232,6 +1255,7 @@ static BlockDriver bdrv_ssh = {
.bdrv_co_readv = ssh_co_readv,
.bdrv_co_writev = ssh_co_writev,
.bdrv_getlength = ssh_getlength,
+ .bdrv_truncate = ssh_truncate,
.bdrv_co_flush_to_disk = ssh_co_flush,
.create_opts = &ssh_create_opts,
};
--
2.13.6
- [Qemu-devel] [PULL 28/37] block: add BlockBackend->in_flight counter, (continued)
- [Qemu-devel] [PULL 28/37] block: add BlockBackend->in_flight counter, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 27/37] block: extract AIO_WAIT_WHILE() from BlockDriverState, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 30/37] Revert "IDE: Do not flush empty CDROM drives", Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 29/37] block: test blk_aio_flush() with blk->root == NULL, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 32/37] qcow2: make qcow2_co_create2() a coroutine_fn, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 33/37] qemu-img: Make resize error message more general, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 31/37] block: rename .bdrv_create() to .bdrv_co_create_opts(), Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 35/37] block/ssh: Make ssh_grow_file() blocking, Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 34/37] block/ssh: Pull ssh_grow_file() from ssh_create(), Kevin Wolf, 2018/03/02
- [Qemu-devel] [PULL 36/37] block/ssh: Add basic .bdrv_truncate(),
Kevin Wolf <=
- [Qemu-devel] [PULL 37/37] qcow2: Replace align_offset() with ROUND_UP(), Kevin Wolf, 2018/03/02
- Re: [Qemu-devel] [PULL 00/37] Block layer patches, Peter Maydell, 2018/03/05