aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-02-12 10:37:14 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-12 16:26:44 -0600
commitad55ab42d494c5f4ebc5199c5c9db473b7d5fbf9 (patch)
treedfd4bec5aa01431745dac36de8186c908a1f5416 /savevm.c
parent4a0e6714b06453078e02029e1432fab052927691 (diff)
migration: make qemu_ftell() public and support writable files
Migration .save_live_iterate() functions return the number of bytes transferred. The easiest way of doing this is by calling qemu_ftell(f) at the beginning and end of the function to calculate the difference. Make qemu_ftell() public so that block-migration will be able to use it. Also adjust the ftell calculation for writable files where buf_offset does not include buf_size. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-id: 1360661835-28663-2-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/savevm.c b/savevm.c
index 0b6724dddb..a8a53efc9b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -673,9 +673,14 @@ int qemu_get_byte(QEMUFile *f)
return result;
}
-static int64_t qemu_ftell(QEMUFile *f)
+int64_t qemu_ftell(QEMUFile *f)
{
- return f->buf_offset - f->buf_size + f->buf_index;
+ /* buf_offset excludes buffer for writing but includes it for reading */
+ if (f->is_write) {
+ return f->buf_offset + f->buf_index;
+ } else {
+ return f->buf_offset - f->buf_size + f->buf_index;
+ }
}
int qemu_file_rate_limit(QEMUFile *f)