[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 10/56] block/ssh: Set bdrv_has_zero_init according
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 10/56] block/ssh: Set bdrv_has_zero_init according to the file type. |
Date: |
Tue, 13 Aug 2013 10:10:34 -0500 |
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>
(cherry picked from commit 0b3f21e6a99c025c829d342ee417f317fe2e03b2)
Signed-off-by: Michael Roth <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.7.9.5
- [Qemu-stable] Patch Round-up for stable 1.5.3, freeze on 2013-08-16, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 02/56] arm/boot: Free dtb blob memory after use, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 03/56] ppc: do not register IABR SPR twice for 603e, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 04/56] qxl: Fix QXLRam initialisation., Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 05/56] virtio-scsi: forward scsibus for virtio-scsi-pci., Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 01/56] s390/virtio-ccw: Fix virtio reset, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 06/56] acl: acl_add can't insert before last list element, fix, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 07/56] usb-host-libusb: set USB_DEV_FLAG_IS_HOST, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 08/56] s390/ipl: Fix boot order, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 09/56] Fix iSCSI crash on SG_IO with an iovector, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 10/56] block/ssh: Set bdrv_has_zero_init according to the file type.,
Michael Roth <=
- [Qemu-stable] [PATCH 11/56] gluster: Return bdrv_has_zero_init = 0, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 13/56] Revert "migration: do not sent zero pages in bulk stage", Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 12/56] vmdk: remove wrong calculation of relative path, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 14/56] migration: do not overwrite zero pages, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 15/56] raw-posix: Fix /dev/cdrom magic on OS X, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 16/56] kvmclock: clock should count only if vm is running, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 17/56] qemu-char: Fix ID reuse after chardev-remove for qapi-based init, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 19/56] target-lm32: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 20/56] target-microblaze: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-stable] [PATCH 18/56] target-cris: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13