aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/block.c b/block.c
index f5eabaa032..c09a766f54 100644
--- a/block.c
+++ b/block.c
@@ -5065,6 +5065,29 @@ bool bdrv_is_sg(BlockDriverState *bs)
return bs->sg;
}
+/**
+ * Return whether the given node supports compressed writes.
+ */
+bool bdrv_supports_compressed_writes(BlockDriverState *bs)
+{
+ BlockDriverState *filtered;
+
+ if (!bs->drv || !block_driver_can_compress(bs->drv)) {
+ return false;
+ }
+
+ filtered = bdrv_filter_bs(bs);
+ if (filtered) {
+ /*
+ * Filters can only forward compressed writes, so we have to
+ * check the child.
+ */
+ return bdrv_supports_compressed_writes(filtered);
+ }
+
+ return true;
+}
+
const char *bdrv_get_format_name(BlockDriverState *bs)
{
return bs->drv ? bs->drv->format_name : NULL;