From patchwork Tue Oct 11 10:00:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 118928 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 A29A4B6F18 for ; Tue, 11 Oct 2011 21:57:39 +1100 (EST) Received: from localhost ([::1]:46595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZBg-0004Gm-8D for incoming@patchwork.ozlabs.org; Tue, 11 Oct 2011 06:03:52 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZBN-0003lE-Lx for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:03:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDZBH-0000BH-AV for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:03:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZBH-0000BC-3U for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:03:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9BA3QOe023796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Oct 2011 06:03:26 -0400 Received: from neno.neno (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9BA1lvv021320; Tue, 11 Oct 2011 06:03:21 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 11 Oct 2011 12:00:34 +0200 Message-Id: <68d954d70dd163e6b1d1048039f2d6656a015445.1318326683.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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 14/36] migration: use qemu_file_get_error() return value when possible 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 Signed-off-by: Juan Quintela Reviewed-by: Anthony Liguori --- arch_init.c | 6 ++++-- block-migration.c | 7 ++++--- buffered_file.c | 13 ++++++++----- savevm.c | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/arch_init.c b/arch_init.c index 9128be0..98daaf3 100644 --- a/arch_init.c +++ b/arch_init.c @@ -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)); diff --git a/block-migration.c b/block-migration.c index 8308753..e36f2e3 100644 --- a/block-migration.c +++ b/block-migration.c @@ -646,6 +646,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); @@ -654,7 +655,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); @@ -704,8 +704,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)); diff --git a/buffered_file.c b/buffered_file.c index 82f4001..42bbbd3 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -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,13 +110,14 @@ 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"); + error = qemu_file_get_error(s->file); + if (error) { + DPRINTF("flush when error, bailing: %s\n", strerror(-error)); return -EINVAL; } diff --git a/savevm.c b/savevm.c index 69a2ccd..3042ae5 100644 --- a/savevm.c +++ b/savevm.c @@ -1835,8 +1835,8 @@ out: g_free(le); } - if (qemu_file_get_error(f)) { - ret = -EIO; + if (ret == 0) { + ret = qemu_file_get_error(f); } return ret;