[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/20] block/ssh: Set bdrv_has_zero_init according to
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 15/20] block/ssh: Set bdrv_has_zero_init according to the file type. |
Date: |
Fri, 28 Jun 2013 16:25:04 +0200 |
From: "Richard W.M. Jones" <address@hidden>
If the remote is a regular file, set it to true (ie. reads of
uninitialized areas in a newly created file will return zeroes).
If we can't prove that, return false (a safe default).
Tested by adding a debugging print statement [not part of this commit]
and creating a remote file and a remote block device:
$ ./qemu-img create ssh://localhost/tmp/new 100M
Formatting 'ssh://localhost/tmp/new', fmt=raw size=104857600
filename ssh://localhost/tmp/new: has_zero_init = 1
$ sudo lvcreate -L 1G -n tmp /dev/fedora
Logical volume "tmp" created
$ ./qemu-img create ssh://localhost/dev/fedora/tmp 1G
Formatting 'ssh://localhost/dev/fedora/tmp', fmt=raw size=1073741824
filename ssh://localhost/dev/fedora/tmp: has_zero_init = 0
Cc: Kevin Wolf <address@hidden>
Cc: address@hidden
Signed-off-by: Richard W.M. Jones <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/ssh.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/block/ssh.c b/block/ssh.c
index 246a70d..d7e7bf8 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -716,6 +716,21 @@ static void ssh_close(BlockDriverState *bs)
ssh_state_free(s);
}
+static int ssh_has_zero_init(BlockDriverState *bs)
+{
+ BDRVSSHState *s = bs->opaque;
+ /* Assume false, unless we can positively prove it's true. */
+ int has_zero_init = 0;
+
+ if (s->attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) {
+ if (s->attrs.permissions & LIBSSH2_SFTP_S_IFREG) {
+ has_zero_init = 1;
+ }
+ }
+
+ return has_zero_init;
+}
+
static void restart_coroutine(void *opaque)
{
Coroutine *co = opaque;
@@ -1037,6 +1052,7 @@ static BlockDriver bdrv_ssh = {
.bdrv_file_open = ssh_file_open,
.bdrv_create = ssh_create,
.bdrv_close = ssh_close,
+ .bdrv_has_zero_init = ssh_has_zero_init,
.bdrv_co_readv = ssh_co_readv,
.bdrv_co_writev = ssh_co_writev,
.bdrv_getlength = ssh_getlength,
--
1.8.1.4
- [Qemu-devel] [PULL 03/20] block: add bdrv_add_before_write_notifier(), (continued)
- [Qemu-devel] [PULL 03/20] block: add bdrv_add_before_write_notifier(), Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 06/20] blockdev: use bdrv_getlength() in qmp_drive_mirror(), Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 04/20] block: add basic backup support to block driver, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 05/20] blockdev: drop redundant proto_drv check, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 09/20] blockdev: allow BdrvActionOps->commit() to be NULL, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 07/20] block: add drive-backup QMP command, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 10/20] blockdev: add DriveBackup transaction, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 08/20] blockdev: rename BlkTransactionStates to singular, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 11/20] blockdev: add Abort transaction, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 12/20] qemu-iotests: extract wait_until_completed() into iotests.py, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 15/20] block/ssh: Set bdrv_has_zero_init according to the file type.,
Kevin Wolf <=
- [Qemu-devel] [PULL 13/20] qemu-iotests: add 055 drive-backup test case, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 14/20] block: Make BlockJobTypes const, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 16/20] gluster: Return bdrv_has_zero_init = 0, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 18/20] vpc: Implement .bdrv_has_zero_init, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 19/20] block: change default of .has_zero_init to 0, Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 20/20] cmd646: fix build when DEBUG_IDE is enabled., Kevin Wolf, 2013/06/28
- [Qemu-devel] [PULL 17/20] vmdk: remove wrong calculation of relative path, Kevin Wolf, 2013/06/28