Commit 42802d47 authored by Juan Quintela's avatar Juan Quintela

migration: use qemu_file_get_error() return value when possible

Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
parent 3961b4dd
......@@ -371,6 +371,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
{
ram_addr_t addr;
int flags;
int error;
if (version_id < 3 || version_id > 4) {
return -EINVAL;
......@@ -451,8 +452,9 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
}
if (qemu_file_get_error(f)) {
return -EIO;
error = qemu_file_get_error(f);
if (error) {
return error;
}
} while (!(flags & RAM_SAVE_FLAG_EOS));
......
......@@ -647,6 +647,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
uint8_t *buf;
int64_t total_sectors = 0;
int nr_sectors;
int ret;
do {
addr = qemu_get_be64(f);
......@@ -655,7 +656,6 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
addr >>= BDRV_SECTOR_BITS;
if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) {
int ret;
/* get device name */
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)device_name, len);
......@@ -705,8 +705,9 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
fprintf(stderr, "Unknown flags\n");
return -EINVAL;
}
if (qemu_file_get_error(f)) {
return -EIO;
ret = qemu_file_get_error(f);
if (ret != 0) {
return ret;
}
} while (!(flags & BLK_MIG_FLAG_EOS));
......
......@@ -71,9 +71,11 @@ static void buffered_append(QEMUFileBuffered *s,
static void buffered_flush(QEMUFileBuffered *s)
{
size_t offset = 0;
int error;
if (qemu_file_get_error(s->file)) {
DPRINTF("flush when error, bailing\n");
error = qemu_file_get_error(s->file);
if (error != 0) {
DPRINTF("flush when error, bailing: %s\n", strerror(-error));
return;
}
......@@ -108,14 +110,15 @@ static void buffered_flush(QEMUFileBuffered *s)
static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size)
{
QEMUFileBuffered *s = opaque;
int offset = 0;
int offset = 0, error;
ssize_t ret;
DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
if (qemu_file_get_error(s->file)) {
DPRINTF("flush when error, bailing\n");
return -EINVAL;
error = qemu_file_get_error(s->file);
if (error) {
DPRINTF("flush when error, bailing: %s\n", strerror(-error));
return error;
}
DPRINTF("unfreezing output\n");
......@@ -192,14 +195,16 @@ static int buffered_close(void *opaque)
* The meaning of the return values is:
* 0: We can continue sending
* 1: Time to stop
* -1: There has been an error
* negative: There has been an error
*/
static int buffered_rate_limit(void *opaque)
{
QEMUFileBuffered *s = opaque;
int ret;
if (qemu_file_get_error(s->file)) {
return -1;
ret = qemu_file_get_error(s->file);
if (ret) {
return ret;
}
if (s->freeze_output)
return 1;
......
......@@ -1885,8 +1885,8 @@ out:
g_free(le);
}
if (qemu_file_get_error(f)) {
ret = -EIO;
if (ret == 0) {
ret = qemu_file_get_error(f);
}
return ret;
......
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