[v3,8/9] block-backend: Add blk_co_copy_range
diff mbox series

Message ID 20180509145815.3330-9-famz@redhat.com
State New
Headers show
Series
  • qemu-img convert with copy offloading
Related show

Commit Message

Fam Zheng May 9, 2018, 2:58 p.m. UTC
It's a BlockBackend wrapper of the BDS interface.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/block-backend.c          | 18 ++++++++++++++++++
 include/sysemu/block-backend.h |  4 ++++
 2 files changed, 22 insertions(+)

Comments

Stefan Hajnoczi May 10, 2018, 9:05 a.m. UTC | #1
On Wed, May 09, 2018 at 10:58:14PM +0800, Fam Zheng wrote:
> It's a BlockBackend wrapper of the BDS interface.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/block-backend.c          | 18 ++++++++++++++++++
>  include/sysemu/block-backend.h |  4 ++++
>  2 files changed, 22 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Patch
diff mbox series

diff --git a/block/block-backend.c b/block/block-backend.c
index 681b240b12..5562ec4238 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2217,3 +2217,21 @@  void blk_unregister_buf(BlockBackend *blk, void *host)
 {
     bdrv_unregister_buf(blk_bs(blk), host);
 }
+
+int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
+                                   BlockBackend *blk_out, int64_t off_out,
+                                   int bytes, BdrvRequestFlags flags)
+{
+    int r;
+    r = blk_check_byte_request(blk_in, off_in, bytes);
+    if (r) {
+        return r;
+    }
+    r = blk_check_byte_request(blk_out, off_out, bytes);
+    if (r) {
+        return r;
+    }
+    return bdrv_co_copy_range(blk_in->root, off_in,
+                              blk_out->root, off_out,
+                              bytes, flags);
+}
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 92ab624fac..6f043b6b51 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -232,4 +232,8 @@  void blk_set_force_allow_inactivate(BlockBackend *blk);
 void blk_register_buf(BlockBackend *blk, void *host, size_t size);
 void blk_unregister_buf(BlockBackend *blk, void *host);
 
+int blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
+                      BlockBackend *blk_out, int64_t off_out,
+                      int bytes, BdrvRequestFlags flags);
+
 #endif