summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-04-14 17:30:35 +0200
committerKevin Wolf <kwolf@redhat.com>2010-05-03 10:07:30 +0200
commitf2feebbd93c251ec0098a9ccf808f7cb1da7f67c (patch)
treefde14df96e8e8e8ebadde50eb0184183c2e59dc5 /block.c
parent66f82ceed6781261c09e65fb440ca76842fd0500 (diff)
block: bdrv_has_zero_init
This fixes the problem that qemu-img's use of no_zero_init only considered the no_zero_init flag of the format driver, but not of the underlying protocols. Between the raw/file split and this fix, converting to host devices is broken. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/block.c b/block.c
index eb1d5621b..56835afc5 100644
--- a/block.c
+++ b/block.c
@@ -1282,6 +1282,19 @@ void bdrv_flush_all(void)
}
}
+int bdrv_has_zero_init(BlockDriverState *bs)
+{
+ assert(bs->drv);
+
+ if (bs->drv->no_zero_init) {
+ return 0;
+ } else if (bs->file) {
+ return bdrv_has_zero_init(bs->file);
+ }
+
+ return 1;
+}
+
/*
* Returns true iff the specified sector is present in the disk image. Drivers
* not implementing the functionality are assumed to not support backing files,