From patchwork Fri Feb 15 17:46:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 220832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84A182C007B for ; Sat, 16 Feb 2013 06:24:56 +1100 (EST) Received: from localhost ([::1]:52174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6POL-00067z-Bw for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 12:48:09 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PNz-0005NX-T7 for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6PNp-0004CR-Nh for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:47:47 -0500 Received: from mail-vb0-f43.google.com ([209.85.212.43]:40920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PNp-0004CK-Ft for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:47:37 -0500 Received: by mail-vb0-f43.google.com with SMTP id fs19so2289180vbb.16 for ; Fri, 15 Feb 2013 09:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=qmSR5vFj293RrXlCtKNGRWdZN+DysFqxu83XtDPgf50=; b=rp49DgPgF62VOIUU1WcWNmcDbhrDOk/ip3ikJX7pH31AOLLq1HWkrFo3Pm8Cuf4lCn PHoTn59r1g6Sgda652nolGNpcbELPLn2UfaZR5BvMculzCUqEwrbuTYclmL4TvRYU5+a Swm21ui++y8tREF3K4d4nLu6D0QCzY/8hKUiyZMfwi3/lzSN+pbJv9kNK3T1lcB1obPh Qoniilr3xMjj0VsA+ihrlVAy7S3iWcCV4fxIW/rOe4B+naZXNxely9Lg45KsyGo9ga9J Ej2bHSzRvZnpgKQYA6txafeWlwPuGhu/3Zeh+Tp1Zm7MPWraA6aXQq5lImkHaL6e6lIu DOag== X-Received: by 10.52.96.7 with SMTP id do7mr3663110vdb.115.1360950457025; Fri, 15 Feb 2013 09:47:37 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id yu12sm65402142vec.6.2013.02.15.09.47.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 09:47:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 18:46:39 +0100 Message-Id: <1360950433-17106-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> References: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.212.43 Cc: owasserm@redhat.com, chegu_vinod@hp.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 07/41] migration: use qemu_file_set_error to pass error codes back to qemu_savevm_state 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: Paolo Bonzini Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela --- include/sysemu/sysemu.h | 6 +++--- savevm.c | 44 ++++++++++++++++++-------------------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 1d9599e..28a9221 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -73,10 +73,10 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict); void qemu_announce_self(void); bool qemu_savevm_state_blocked(Error **errp); -int qemu_savevm_state_begin(QEMUFile *f, - const MigrationParams *params); +void qemu_savevm_state_begin(QEMUFile *f, + const MigrationParams *params); int qemu_savevm_state_iterate(QEMUFile *f); -int qemu_savevm_state_complete(QEMUFile *f); +void qemu_savevm_state_complete(QEMUFile *f); void qemu_savevm_state_cancel(void); uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); int qemu_loadvm_state(QEMUFile *f); diff --git a/savevm.c b/savevm.c index a681177..a1690b4 100644 --- a/savevm.c +++ b/savevm.c @@ -1579,8 +1579,8 @@ bool qemu_savevm_state_blocked(Error **errp) return false; } -int qemu_savevm_state_begin(QEMUFile *f, - const MigrationParams *params) +void qemu_savevm_state_begin(QEMUFile *f, + const MigrationParams *params) { SaveStateEntry *se; int ret; @@ -1620,11 +1620,10 @@ int qemu_savevm_state_begin(QEMUFile *f, ret = se->ops->save_live_setup(f, se->opaque); if (ret < 0) { - return ret; + qemu_file_set_error(f, ret); + break; } } - ret = qemu_file_get_error(f); - return ret; } /* @@ -1658,6 +1657,9 @@ int qemu_savevm_state_iterate(QEMUFile *f) ret = se->ops->save_live_iterate(f, se->opaque); trace_savevm_section_end(se->section_id); + if (ret < 0) { + qemu_file_set_error(f, ret); + } if (ret <= 0) { /* Do not proceed to the next vmstate before this one reported completion of the current stage. This serializes the migration @@ -1666,14 +1668,10 @@ int qemu_savevm_state_iterate(QEMUFile *f) break; } } - if (ret != 0) { - return ret; - } - ret = qemu_file_get_error(f); return ret; } -int qemu_savevm_state_complete(QEMUFile *f) +void qemu_savevm_state_complete(QEMUFile *f) { SaveStateEntry *se; int ret; @@ -1697,7 +1695,8 @@ int qemu_savevm_state_complete(QEMUFile *f) ret = se->ops->save_live_complete(f, se->opaque); trace_savevm_section_end(se->section_id); if (ret < 0) { - return ret; + qemu_file_set_error(f, ret); + return; } } @@ -1725,8 +1724,6 @@ int qemu_savevm_state_complete(QEMUFile *f) } qemu_put_byte(f, QEMU_VM_EOF); - - return qemu_file_get_error(f); } uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size) @@ -1771,26 +1768,21 @@ static int qemu_savevm_state(QEMUFile *f) return -EINVAL; } - ret = qemu_savevm_state_begin(f, ¶ms); - if (ret < 0) - goto out; - - do { - ret = qemu_savevm_state_iterate(f); - if (ret < 0) - goto out; - } while (ret == 0); - - ret = qemu_savevm_state_complete(f); + qemu_savevm_state_begin(f, ¶ms); + while (qemu_file_get_error(f) == 0) { + if (qemu_savevm_state_iterate(f) > 0) { + break; + } + } -out: + ret = qemu_file_get_error(f); if (ret == 0) { + qemu_savevm_state_complete(f); ret = qemu_file_get_error(f); } if (ret != 0) { qemu_savevm_state_cancel(); } - return ret; }