From patchwork Thu Oct 20 00:11:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 120712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6AD7AB71D3 for ; Thu, 20 Oct 2011 11:12:34 +1100 (EST) Received: from localhost ([::1]:36215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGgFB-0006xq-R7 for incoming@patchwork.ozlabs.org; Wed, 19 Oct 2011 20:12:21 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGgEw-0006ok-K6 for qemu-devel@nongnu.org; Wed, 19 Oct 2011 20:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGgEr-0004by-E5 for qemu-devel@nongnu.org; Wed, 19 Oct 2011 20:12:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGgEq-0004bQ-DM for qemu-devel@nongnu.org; Wed, 19 Oct 2011 20:12:01 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9K0Bx4Y004014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Oct 2011 20:11:59 -0400 Received: from trasno.mitica (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9K0BtOu003457; Wed, 19 Oct 2011 20:11:58 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 20 Oct 2011 02:11:46 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/37] migration: change has_error to contain errno values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We normally already have an errno value. When not, abuse EIO. Signed-off-by: Juan Quintela --- arch_init.c | 2 +- block-migration.c | 11 ++++++----- buffered_file.c | 4 ++-- hw/hw.h | 2 +- migration.c | 2 +- savevm.c | 8 ++++---- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch_init.c b/arch_init.c index a6c69c7..941d585 100644 --- a/arch_init.c +++ b/arch_init.c @@ -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) { - qemu_file_set_error(f); + qemu_file_set_error(f, -EINVAL); return 0; } diff --git a/block-migration.c b/block-migration.c index e2775ee..325c905 100644 --- a/block-migration.c +++ b/block-migration.c @@ -263,7 +263,7 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, error: 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); return 0; @@ -383,6 +383,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, int64_t total_sectors = bmds->total_sectors; int64_t sector; int nr_sectors; + int ret = -EIO; for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) { if (bmds_aio_inflight(bmds, sector)) { @@ -418,8 +419,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, block_mig_state.submitted++; bmds_set_aio_inflight(bmds, sector, nr_sectors, 1); } else { - if (bdrv_read(bmds->bs, sector, blk->buf, - nr_sectors) < 0) { + ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors); + if (ret < 0) { goto error; } blk_send(f, blk); @@ -439,7 +440,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, error: 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); return 0; @@ -473,7 +474,7 @@ static void flush_blks(QEMUFile* f) break; } if (blk->ret < 0) { - qemu_file_set_error(f); + qemu_file_set_error(f, blk->ret); break; } blk_send(f, blk); diff --git a/buffered_file.c b/buffered_file.c index 4f49763..94ca8d1 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -92,7 +92,7 @@ static void buffered_flush(QEMUFileBuffered *s) if (ret <= 0) { DPRINTF("error flushing data, %zd\n", ret); - qemu_file_set_error(s->file); + qemu_file_set_error(s->file, ret); break; } else { 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 if (ret <= 0) { DPRINTF("error putting\n"); - qemu_file_set_error(s->file); + qemu_file_set_error(s->file, ret); offset = -EINVAL; break; } diff --git a/hw/hw.h b/hw/hw.h index a124da9..6cf8cd2 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -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_get_rate_limit(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 * halted due to rate limiting or EAGAIN errors occur as it can be used to diff --git a/migration.c b/migration.c index a682168..d5876a9 100644 --- a/migration.c +++ b/migration.c @@ -455,7 +455,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque) } while (ret == -1 && (s->get_error(s)) == EINTR); if (ret == -1) { - qemu_file_set_error(s->file); + qemu_file_set_error(s->file, -s->get_error(s)); } } diff --git a/savevm.c b/savevm.c index bf4d0e7..8f00f0c 100644 --- a/savevm.c +++ b/savevm.c @@ -430,9 +430,9 @@ int qemu_file_has_error(QEMUFile *f) 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) @@ -447,7 +447,7 @@ void qemu_fflush(QEMUFile *f) if (len > 0) f->buf_offset += f->buf_index; else - f->has_error = 1; + f->has_error = -EINVAL; f->buf_index = 0; } } @@ -468,7 +468,7 @@ static void qemu_fill_buffer(QEMUFile *f) f->buf_size = len; f->buf_offset += len; } else if (len != -EAGAIN) - f->has_error = 1; + f->has_error = len; } int qemu_fclose(QEMUFile *f)