aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/block.c b/block.c
index 3e698e9cab..874a29a983 100644
--- a/block.c
+++ b/block.c
@@ -5078,6 +5078,27 @@ int bdrv_has_zero_init(BlockDriverState *bs)
return 0;
}
+int bdrv_has_zero_init_truncate(BlockDriverState *bs)
+{
+ if (!bs->drv) {
+ return 0;
+ }
+
+ if (bs->backing) {
+ /* Depends on the backing image length, but better safe than sorry */
+ return 0;
+ }
+ if (bs->drv->bdrv_has_zero_init_truncate) {
+ return bs->drv->bdrv_has_zero_init_truncate(bs);
+ }
+ if (bs->file && bs->drv->is_filter) {
+ return bdrv_has_zero_init_truncate(bs->file->bs);
+ }
+
+ /* safe default */
+ return 0;
+}
+
bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)
{
BlockDriverInfo bdi;