xref: /openbmc/qemu/include/block/block-copy.h (revision de15df5e)
1 /*
2  * block_copy API
3  *
4  * Copyright (C) 2013 Proxmox Server Solutions
5  * Copyright (c) 2019 Virtuozzo International GmbH.
6  *
7  * Authors:
8  *  Dietmar Maurer (dietmar@proxmox.com)
9  *  Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10  *
11  * This work is licensed under the terms of the GNU GPL, version 2 or later.
12  * See the COPYING file in the top-level directory.
13  */
14 
15 #ifndef BLOCK_COPY_H
16 #define BLOCK_COPY_H
17 
18 #include "block/block.h"
19 #include "qemu/co-shared-resource.h"
20 
21 typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque);
22 typedef struct BlockCopyState BlockCopyState;
23 
24 BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
25                                      int64_t cluster_size,
26                                      BdrvRequestFlags write_flags,
27                                      Error **errp);
28 
29 void block_copy_set_progress_callback(
30         BlockCopyState *s,
31         ProgressBytesCallbackFunc progress_bytes_callback,
32         void *progress_opaque);
33 
34 void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm);
35 
36 void block_copy_state_free(BlockCopyState *s);
37 
38 int64_t block_copy_reset_unallocated(BlockCopyState *s,
39                                      int64_t offset, int64_t *count);
40 
41 int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
42                             bool *error_is_read);
43 
44 BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s);
45 void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip);
46 
47 #endif /* BLOCK_COPY_H */
48