hw/arm/virt: Consolidate GIC finalize logic
[qemu.git] / include / block / block-copy.h
blobd0f83865542d6b62bcb1f3ce1595c6be40732c2b
1 /*
2 * block_copy API
4 * Copyright (C) 2013 Proxmox Server Solutions
5 * Copyright (c) 2019 Virtuozzo International GmbH.
7 * Authors:
8 * Dietmar Maurer (dietmar@proxmox.com)
9 * Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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.
15 #ifndef BLOCK_COPY_H
16 #define BLOCK_COPY_H
18 #include "block/block-common.h"
19 #include "qemu/progress_meter.h"
21 /* All APIs are thread-safe */
23 typedef void (*BlockCopyAsyncCallbackFunc)(void *opaque);
24 typedef struct BlockCopyState BlockCopyState;
25 typedef struct BlockCopyCallState BlockCopyCallState;
27 BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
28 const BdrvDirtyBitmap *bitmap,
29 Error **errp);
31 /* Function should be called prior any actual copy request */
32 void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range,
33 bool compress);
34 void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm);
36 void block_copy_state_free(BlockCopyState *s);
38 void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes);
39 int64_t coroutine_fn block_copy_reset_unallocated(BlockCopyState *s,
40 int64_t offset,
41 int64_t *count);
43 int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
44 bool ignore_ratelimit, uint64_t timeout_ns,
45 BlockCopyAsyncCallbackFunc cb,
46 void *cb_opaque);
49 * Run block-copy in a coroutine, create corresponding BlockCopyCallState
50 * object and return pointer to it. Never returns NULL.
52 * Caller is responsible to call block_copy_call_free() to free
53 * BlockCopyCallState object.
55 * @max_workers means maximum of parallel coroutines to execute sub-requests,
56 * must be > 0.
58 * @max_chunk means maximum length for one IO operation. Zero means unlimited.
60 BlockCopyCallState *block_copy_async(BlockCopyState *s,
61 int64_t offset, int64_t bytes,
62 int max_workers, int64_t max_chunk,
63 BlockCopyAsyncCallbackFunc cb,
64 void *cb_opaque);
67 * Free finished BlockCopyCallState. Trying to free running
68 * block-copy will crash.
70 void block_copy_call_free(BlockCopyCallState *call_state);
73 * Note, that block-copy call is marked finished prior to calling
74 * the callback.
76 bool block_copy_call_finished(BlockCopyCallState *call_state);
77 bool block_copy_call_succeeded(BlockCopyCallState *call_state);
78 bool block_copy_call_failed(BlockCopyCallState *call_state);
79 bool block_copy_call_cancelled(BlockCopyCallState *call_state);
80 int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read);
82 void block_copy_set_speed(BlockCopyState *s, uint64_t speed);
83 void block_copy_kick(BlockCopyCallState *call_state);
86 * Cancel running block-copy call.
88 * Cancel leaves block-copy state valid: dirty bits are correct and you may use
89 * cancel + <run block_copy with same parameters> to emulate pause/resume.
91 * Note also, that the cancel is async: it only marks block-copy call to be
92 * cancelled. So, the call may be cancelled (block_copy_call_cancelled() reports
93 * true) but not yet finished (block_copy_call_finished() reports false).
95 void block_copy_call_cancel(BlockCopyCallState *call_state);
97 BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s);
98 int64_t block_copy_cluster_size(BlockCopyState *s);
99 void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip);
101 #endif /* BLOCK_COPY_H */