]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block-backend: Add blk_co_copy_range
authorFam Zheng <famz@redhat.com>
Fri, 1 Jun 2018 09:26:47 +0000 (17:26 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 1 Jun 2018 13:41:48 +0000 (14:41 +0100)
It's a BlockBackend wrapper of the BDS interface.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20180601092648.24614-10-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/block-backend.c
include/sysemu/block-backend.h

index 89f47b00ea24b7542375bc061c105f7da5bbf44c..d55c3287368538dd6fc9528b547b1e041ff52a1e 100644 (file)
@@ -2211,3 +2211,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);
+}
index 92ab624facac9bcda00138c872c07c8450482bdb..8d03d493c2933a702af29cd0cd1d9dc93bd2c5ff 100644 (file)
@@ -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 coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
+                                   BlockBackend *blk_out, int64_t off_out,
+                                   int bytes, BdrvRequestFlags flags);
+
 #endif