{
ram_addr_t addr;
int flags;
+ int error;
if (version_id < 3 || version_id > 4) {
return -EINVAL;
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));
uint8_t *buf;
int64_t total_sectors = 0;
int nr_sectors;
+ int ret;
do {
addr = qemu_get_be64(f);
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);
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));
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;
}
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");
* 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;