aboutsummaryrefslogtreecommitdiff
path: root/migration/qemu-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'migration/qemu-file.c')
-rw-r--r--migration/qemu-file.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 7e738743ce..d64500310d 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -262,14 +262,14 @@ static void qemu_iovec_release_ram(QEMUFile *f)
* This will flush all pending data. If data was only partially flushed, it
* will set an error state.
*/
-void qemu_fflush(QEMUFile *f)
+int qemu_fflush(QEMUFile *f)
{
if (!qemu_file_is_writable(f)) {
- return;
+ return f->last_error;
}
- if (qemu_file_get_error(f)) {
- return;
+ if (f->last_error) {
+ return f->last_error;
}
if (f->iovcnt > 0) {
Error *local_error = NULL;
@@ -287,6 +287,7 @@ void qemu_fflush(QEMUFile *f)
f->buf_index = 0;
f->iovcnt = 0;
+ return f->last_error;
}
/*
@@ -353,22 +354,12 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEMUFile *f)
*/
int qemu_fclose(QEMUFile *f)
{
- int ret, ret2;
- qemu_fflush(f);
- ret = qemu_file_get_error(f);
-
- ret2 = qio_channel_close(f->ioc, NULL);
+ int ret = qemu_fflush(f);
+ int ret2 = qio_channel_close(f->ioc, NULL);
if (ret >= 0) {
ret = ret2;
}
g_clear_pointer(&f->ioc, object_unref);
-
- /* If any error was spotted before closing, we should report it
- * instead of the close() return value.
- */
- if (f->last_error) {
- ret = f->last_error;
- }
error_free(f->last_error_obj);
g_free(f);
trace_qemu_file_fclose();