提交 63dfbd7e 编写于 作者: P Paolo Bonzini 提交者: Juan Quintela

migration: use qemu_file_set_error

Remove the return value of buffered_flush, pass it via the error code
of s->file.  Once this is done, the error can be retrieved simply
via migrate_fd_close's call to qemu_fclose.
Reviewed-by: NOrit Wasserman <owasserm@redhat.com>
Reviewed-by: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
上级 f5821518
...@@ -518,7 +518,7 @@ int64_t migrate_xbzrle_cache_size(void) ...@@ -518,7 +518,7 @@ int64_t migrate_xbzrle_cache_size(void)
/* migration thread support */ /* migration thread support */
static ssize_t buffered_flush(MigrationState *s) static void buffered_flush(MigrationState *s)
{ {
size_t offset = 0; size_t offset = 0;
ssize_t ret = 0; ssize_t ret = 0;
...@@ -545,9 +545,8 @@ static ssize_t buffered_flush(MigrationState *s) ...@@ -545,9 +545,8 @@ static ssize_t buffered_flush(MigrationState *s)
s->buffer_size -= offset; s->buffer_size -= offset;
if (ret < 0) { if (ret < 0) {
return ret; qemu_file_set_error(s->file, ret);
} }
return offset;
} }
static int buffered_put_buffer(void *opaque, const uint8_t *buf, static int buffered_put_buffer(void *opaque, const uint8_t *buf,
...@@ -586,25 +585,15 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, ...@@ -586,25 +585,15 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf,
static int buffered_close(void *opaque) static int buffered_close(void *opaque)
{ {
MigrationState *s = opaque; MigrationState *s = opaque;
ssize_t ret = 0;
int ret2;
DPRINTF("closing\n"); DPRINTF("closing\n");
s->xfer_limit = INT_MAX; s->xfer_limit = INT_MAX;
while (!qemu_file_get_error(s->file) && s->buffer_size) { while (!qemu_file_get_error(s->file) && s->buffer_size) {
ret = buffered_flush(s); buffered_flush(s);
if (ret < 0) {
break;
}
}
ret2 = migrate_fd_close(s);
if (ret >= 0) {
ret = ret2;
} }
s->complete = true; s->complete = true;
return ret; return migrate_fd_close(s);
} }
static int buffered_get_fd(void *opaque) static int buffered_get_fd(void *opaque)
...@@ -750,7 +739,8 @@ static void *buffered_file_thread(void *opaque) ...@@ -750,7 +739,8 @@ static void *buffered_file_thread(void *opaque)
g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
sleep_time += qemu_get_clock_ms(rt_clock) - current_time; sleep_time += qemu_get_clock_ms(rt_clock) - current_time;
} }
ret = buffered_flush(s); buffered_flush(s);
ret = qemu_file_get_error(s->file);
} }
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册