qemu-file: Make qemu_fflush() return errors

This let us simplify code of this shape.

   qemu_fflush(f);
   int ret = qemu_file_get_error(f);
   if (ret) {
      return ret;
   }

into:

   int ret = qemu_fflush(f);
   if (ret) {
      return ret;
   }

I updated all callers where there is any error check.
qemu_fclose() don't need to check for f->last_error because
qemu_fflush() returns it at the beggining of the function.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Message-ID: <20231025091117.6342-13-quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Juan Quintela 2023-10-25 11:11:17 +02:00
parent 0f8596180a
commit be07a0ed22
7 changed files with 21 additions and 51 deletions

View file

@ -314,9 +314,7 @@ static void colo_send_message(QEMUFile *f, COLOMessage msg,
return;
}
qemu_put_be32(f, msg);
qemu_fflush(f);
ret = qemu_file_get_error(f);
ret = qemu_fflush(f);
if (ret < 0) {
error_setg_errno(errp, -ret, "Can't send COLO message");
}
@ -335,9 +333,7 @@ static void colo_send_message_value(QEMUFile *f, COLOMessage msg,
return;
}
qemu_put_be64(f, value);
qemu_fflush(f);
ret = qemu_file_get_error(f);
ret = qemu_fflush(f);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to send value for message:%s",
COLOMessage_str(msg));
@ -483,8 +479,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
}
qemu_put_buffer(s->to_dst_file, bioc->data, bioc->usage);
qemu_fflush(s->to_dst_file);
ret = qemu_file_get_error(s->to_dst_file);
ret = qemu_fflush(s->to_dst_file);
if (ret < 0) {
goto out;
}