Commit ad55ab42 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Anthony Liguori
Browse files

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: default avatarStefan Hajnoczi <>
Reviewed-by: default avatarJuan Quintela <>
Signed-off-by: default avatarAnthony Liguori <>
parent 4a0e6714
......@@ -81,6 +81,7 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
int qemu_get_fd(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
int64_t qemu_ftell(QEMUFile *f);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
void qemu_put_byte(QEMUFile *f, int v);
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment