From patchwork Tue Oct 11 10:00:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 118951 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 B66C4B6F6F for ; Tue, 11 Oct 2011 22:39:10 +1100 (EST) Received: from localhost ([::1]:42818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZAd-0002GJ-VN for incoming@patchwork.ozlabs.org; Tue, 11 Oct 2011 06:02:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZA9-0000hV-C1 for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:02:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDZA3-00088Y-7r for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:02:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZA2-00088R-Rh for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:02:11 -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 p9BA2Ake012041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Oct 2011 06:02:10 -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 p9BA1lvl021320; Tue, 11 Oct 2011 06:02:08 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 11 Oct 2011 12:00:24 +0200 Message-Id: <2b00816a14ba18f4059297337f9b6f78ca82d685.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 04/36] migration: return real error code 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 make functions propagate errno, instead of just using -EIO. Signed-off-by: Juan Quintela Reviewed-by: Anthony Liguori --- migration.c | 6 +++++- savevm.c | 33 +++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/migration.c b/migration.c index 71b8aad..2d3a55b 100644 --- a/migration.c +++ b/migration.c @@ -363,6 +363,7 @@ void migrate_fd_connect(FdMigrationState *s) void migrate_fd_put_ready(void *opaque) { FdMigrationState *s = opaque; + int ret; if (s->state != MIG_STATE_ACTIVE) { DPRINTF("put_ready returning because of non-active state\n"); @@ -370,7 +371,10 @@ void migrate_fd_put_ready(void *opaque) } DPRINTF("iterate\n"); - if (qemu_savevm_state_iterate(s->mon, s->file) == 1) { + ret = qemu_savevm_state_iterate(s->mon, s->file); + if (ret < 0) { + migrate_fd_error(s); + } else if (ret == 1) { int old_vm_running = runstate_is_running(); DPRINTF("done iterating\n"); diff --git a/savevm.c b/savevm.c index bf4d0e7..15c9c52 100644 --- a/savevm.c +++ b/savevm.c @@ -1466,6 +1466,7 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, int shared) { SaveStateEntry *se; + int ret; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if(se->set_params == NULL) { @@ -1497,13 +1498,13 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque); } - - if (qemu_file_has_error(f)) { + ret = qemu_file_has_error(f); + if (ret != 0) { qemu_savevm_state_cancel(mon, f); - return -EIO; } - return 0; + return ret; + } int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) @@ -1528,16 +1529,14 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) break; } } - - if (ret) - return 1; - - if (qemu_file_has_error(f)) { + if (ret != 0) { + return ret; + } + ret = qemu_file_has_error(f); + if (ret != 0) { qemu_savevm_state_cancel(mon, f); - return -EIO; } - - return 0; + return ret; } int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) @@ -1580,10 +1579,7 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) qemu_put_byte(f, QEMU_VM_EOF); - if (qemu_file_has_error(f)) - return -EIO; - - return 0; + return qemu_file_has_error(f); } void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f) @@ -1623,8 +1619,9 @@ static int qemu_savevm_state(Monitor *mon, QEMUFile *f) ret = qemu_savevm_state_complete(mon, f); out: - if (qemu_file_has_error(f)) - ret = -EIO; + if (ret == 0) { + ret = qemu_file_has_error(f); + } if (!ret && saved_vm_running) vm_start();