cryptospore / rpms / qemu-kvm

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