Commit dcd1d224 authored by Juan Quintela's avatar Juan Quintela

migration: change has_error to contain errno values

We normally already have an errno value.  When not, abuse EIO.
Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
parent af509450
...@@ -263,7 +263,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) ...@@ -263,7 +263,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
} }
if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) { if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
qemu_file_set_error(f); qemu_file_set_error(f, -EINVAL);
return 0; return 0;
} }
......
...@@ -263,7 +263,7 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, ...@@ -263,7 +263,7 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
error: error:
monitor_printf(mon, "Error reading sector %" PRId64 "\n", cur_sector); monitor_printf(mon, "Error reading sector %" PRId64 "\n", cur_sector);
qemu_file_set_error(f); qemu_file_set_error(f, -EIO);
g_free(blk->buf); g_free(blk->buf);
g_free(blk); g_free(blk);
return 0; return 0;
...@@ -383,6 +383,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, ...@@ -383,6 +383,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
int64_t total_sectors = bmds->total_sectors; int64_t total_sectors = bmds->total_sectors;
int64_t sector; int64_t sector;
int nr_sectors; int nr_sectors;
int ret = -EIO;
for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) { for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
if (bmds_aio_inflight(bmds, sector)) { if (bmds_aio_inflight(bmds, sector)) {
...@@ -418,8 +419,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, ...@@ -418,8 +419,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
block_mig_state.submitted++; block_mig_state.submitted++;
bmds_set_aio_inflight(bmds, sector, nr_sectors, 1); bmds_set_aio_inflight(bmds, sector, nr_sectors, 1);
} else { } else {
if (bdrv_read(bmds->bs, sector, blk->buf, ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors);
nr_sectors) < 0) { if (ret < 0) {
goto error; goto error;
} }
blk_send(f, blk); blk_send(f, blk);
...@@ -439,7 +440,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, ...@@ -439,7 +440,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
error: error:
monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector); monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector);
qemu_file_set_error(f); qemu_file_set_error(f, ret);
g_free(blk->buf); g_free(blk->buf);
g_free(blk); g_free(blk);
return 0; return 0;
...@@ -473,7 +474,7 @@ static void flush_blks(QEMUFile* f) ...@@ -473,7 +474,7 @@ static void flush_blks(QEMUFile* f)
break; break;
} }
if (blk->ret < 0) { if (blk->ret < 0) {
qemu_file_set_error(f); qemu_file_set_error(f, blk->ret);
break; break;
} }
blk_send(f, blk); blk_send(f, blk);
......
...@@ -92,7 +92,7 @@ static void buffered_flush(QEMUFileBuffered *s) ...@@ -92,7 +92,7 @@ static void buffered_flush(QEMUFileBuffered *s)
if (ret <= 0) { if (ret <= 0) {
DPRINTF("error flushing data, %zd\n", ret); DPRINTF("error flushing data, %zd\n", ret);
qemu_file_set_error(s->file); qemu_file_set_error(s->file, ret);
break; break;
} else { } else {
DPRINTF("flushed %zd byte(s)\n", ret); DPRINTF("flushed %zd byte(s)\n", ret);
...@@ -138,7 +138,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in ...@@ -138,7 +138,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in
if (ret <= 0) { if (ret <= 0) {
DPRINTF("error putting\n"); DPRINTF("error putting\n");
qemu_file_set_error(s->file); qemu_file_set_error(s->file, ret);
offset = -EINVAL; offset = -EINVAL;
break; break;
} }
......
...@@ -86,7 +86,7 @@ int qemu_file_rate_limit(QEMUFile *f); ...@@ -86,7 +86,7 @@ int qemu_file_rate_limit(QEMUFile *f);
int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate);
int64_t qemu_file_get_rate_limit(QEMUFile *f); int64_t qemu_file_get_rate_limit(QEMUFile *f);
int qemu_file_has_error(QEMUFile *f); int qemu_file_has_error(QEMUFile *f);
void qemu_file_set_error(QEMUFile *f); void qemu_file_set_error(QEMUFile *f, int error);
/* Try to send any outstanding data. This function is useful when output is /* Try to send any outstanding data. This function is useful when output is
* halted due to rate limiting or EAGAIN errors occur as it can be used to * halted due to rate limiting or EAGAIN errors occur as it can be used to
......
...@@ -455,7 +455,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque) ...@@ -455,7 +455,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque)
} while (ret == -1 && (s->get_error(s)) == EINTR); } while (ret == -1 && (s->get_error(s)) == EINTR);
if (ret == -1) { if (ret == -1) {
qemu_file_set_error(s->file); qemu_file_set_error(s->file, -s->get_error(s));
} }
} }
......
...@@ -430,9 +430,9 @@ int qemu_file_has_error(QEMUFile *f) ...@@ -430,9 +430,9 @@ int qemu_file_has_error(QEMUFile *f)
return f->has_error; return f->has_error;
} }
void qemu_file_set_error(QEMUFile *f) void qemu_file_set_error(QEMUFile *f, int ret)
{ {
f->has_error = 1; f->has_error = ret;
} }
void qemu_fflush(QEMUFile *f) void qemu_fflush(QEMUFile *f)
...@@ -447,7 +447,7 @@ void qemu_fflush(QEMUFile *f) ...@@ -447,7 +447,7 @@ void qemu_fflush(QEMUFile *f)
if (len > 0) if (len > 0)
f->buf_offset += f->buf_index; f->buf_offset += f->buf_index;
else else
f->has_error = 1; f->has_error = -EINVAL;
f->buf_index = 0; f->buf_index = 0;
} }
} }
...@@ -476,7 +476,7 @@ static void qemu_fill_buffer(QEMUFile *f) ...@@ -476,7 +476,7 @@ static void qemu_fill_buffer(QEMUFile *f)
f->buf_size += len; f->buf_size += len;
f->buf_offset += len; f->buf_offset += len;
} else if (len != -EAGAIN) } else if (len != -EAGAIN)
f->has_error = 1; f->has_error = len;
} }
int qemu_fclose(QEMUFile *f) int qemu_fclose(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