aboutsummaryrefslogtreecommitdiff
path: root/block/commit.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-01-18 18:08:22 +0100
committerKevin Wolf <kwolf@redhat.com>2018-05-15 16:11:49 +0200
commit05df8a6a2b4e36e8d69de2130e616d5ac28e8837 (patch)
tree69a1ee332e3b77767f2df4ced3066b08e9baae7b /block/commit.c
parent37aa19b63c46d933f1e4ea944cfccee54e2caf4a (diff)
downloadqemu-05df8a6a2b4e36e8d69de2130e616d5ac28e8837.zip
qemu-05df8a6a2b4e36e8d69de2130e616d5ac28e8837.tar.gz
qemu-05df8a6a2b4e36e8d69de2130e616d5ac28e8837.tar.bz2
blockjob: Wrappers for progress counter access
Block job drivers are not expected to mess with the internals of the BlockJob object, so provide wrapper functions for one of the cases where they still do it: Updating the progress counter. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'block/commit.c')
-rw-r--r--block/commit.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/block/commit.c b/block/commit.c
index 1432bae..50b191c 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -146,21 +146,21 @@ static void coroutine_fn commit_run(void *opaque)
int64_t n = 0; /* bytes */
void *buf = NULL;
int bytes_written = 0;
- int64_t base_len;
+ int64_t len, base_len;
- ret = s->common.len = blk_getlength(s->top);
-
- if (s->common.len < 0) {
+ ret = len = blk_getlength(s->top);
+ if (len < 0) {
goto out;
}
+ block_job_progress_set_remaining(&s->common, len);
ret = base_len = blk_getlength(s->base);
if (base_len < 0) {
goto out;
}
- if (base_len < s->common.len) {
- ret = blk_truncate(s->base, s->common.len, PREALLOC_MODE_OFF, NULL);
+ if (base_len < len) {
+ ret = blk_truncate(s->base, len, PREALLOC_MODE_OFF, NULL);
if (ret) {
goto out;
}
@@ -168,7 +168,7 @@ static void coroutine_fn commit_run(void *opaque)
buf = blk_blockalign(s->top, COMMIT_BUFFER_SIZE);
- for (offset = 0; offset < s->common.len; offset += n) {
+ for (offset = 0; offset < len; offset += n) {
bool copy;
/* Note that even when no rate limit is applied we need to yield
@@ -198,7 +198,7 @@ static void coroutine_fn commit_run(void *opaque)
}
}
/* Publish progress */
- s->common.offset += n;
+ block_job_progress_update(&s->common, n);
if (copy && s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);