mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
4a0e6714b0
commit
ad55ab42d4
2 changed files with 8 additions and 2 deletions
9
savevm.c
9
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue