thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ae23c9
From 1d94395d19ccfd501c5ce7ed2b300a1ac72cf0c0 Mon Sep 17 00:00:00 2001
ae23c9
From: Fam Zheng <famz@redhat.com>
ae23c9
Date: Fri, 29 Jun 2018 06:11:49 +0200
ae23c9
Subject: [PATCH 175/268] block-backend: Add blk_co_copy_range
ae23c9
ae23c9
RH-Author: Fam Zheng <famz@redhat.com>
ae23c9
Message-id: <20180629061153.12687-10-famz@redhat.com>
ae23c9
Patchwork-id: 81161
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 09/13] block-backend: Add blk_co_copy_range
ae23c9
Bugzilla: 1482537
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
ae23c9
It's a BlockBackend wrapper of the BDS interface.
ae23c9
ae23c9
Signed-off-by: Fam Zheng <famz@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Message-id: 20180601092648.24614-10-famz@redhat.com
ae23c9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
(cherry picked from commit b5679fa49c9a70efa7bf01f6efad1a65e2349a0b)
ae23c9
Signed-off-by: Fam Zheng <famz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/block-backend.c          | 18 ++++++++++++++++++
ae23c9
 include/sysemu/block-backend.h |  4 ++++
ae23c9
 2 files changed, 22 insertions(+)
ae23c9
ae23c9
diff --git a/block/block-backend.c b/block/block-backend.c
ae23c9
index 681b240..5562ec4 100644
ae23c9
--- a/block/block-backend.c
ae23c9
+++ b/block/block-backend.c
ae23c9
@@ -2217,3 +2217,21 @@ void blk_unregister_buf(BlockBackend *blk, void *host)
ae23c9
 {
ae23c9
     bdrv_unregister_buf(blk_bs(blk), host);
ae23c9
 }
ae23c9
+
ae23c9
+int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
ae23c9
+                                   BlockBackend *blk_out, int64_t off_out,
ae23c9
+                                   int bytes, BdrvRequestFlags flags)
ae23c9
+{
ae23c9
+    int r;
ae23c9
+    r = blk_check_byte_request(blk_in, off_in, bytes);
ae23c9
+    if (r) {
ae23c9
+        return r;
ae23c9
+    }
ae23c9
+    r = blk_check_byte_request(blk_out, off_out, bytes);
ae23c9
+    if (r) {
ae23c9
+        return r;
ae23c9
+    }
ae23c9
+    return bdrv_co_copy_range(blk_in->root, off_in,
ae23c9
+                              blk_out->root, off_out,
ae23c9
+                              bytes, flags);
ae23c9
+}
ae23c9
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
ae23c9
index 92ab624..8d03d49 100644
ae23c9
--- a/include/sysemu/block-backend.h
ae23c9
+++ b/include/sysemu/block-backend.h
ae23c9
@@ -232,4 +232,8 @@ void blk_set_force_allow_inactivate(BlockBackend *blk);
ae23c9
 void blk_register_buf(BlockBackend *blk, void *host, size_t size);
ae23c9
 void blk_unregister_buf(BlockBackend *blk, void *host);
ae23c9
 
ae23c9
+int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
ae23c9
+                                   BlockBackend *blk_out, int64_t off_out,
ae23c9
+                                   int bytes, BdrvRequestFlags flags);
ae23c9
+
ae23c9
 #endif
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9