From patchwork Wed Oct 5 13:44:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 678453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3spxwL1vgyz9s3s for ; Thu, 6 Oct 2016 00:49:22 +1100 (AEDT) Received: from localhost ([::1]:49266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brmZR-0007aL-Sx for incoming@patchwork.ozlabs.org; Wed, 05 Oct 2016 09:49:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brmVf-0004V6-Qq for qemu-devel@nongnu.org; Wed, 05 Oct 2016 09:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brmVd-0000Zz-NJ for qemu-devel@nongnu.org; Wed, 05 Oct 2016 09:45:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brmVd-0000Zq-Gr for qemu-devel@nongnu.org; Wed, 05 Oct 2016 09:45:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCA493D97D for ; Wed, 5 Oct 2016 13:45:20 +0000 (UTC) Received: from emacs.mitica (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u95DjCfL031257; Wed, 5 Oct 2016 09:45:19 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 5 Oct 2016 15:44:58 +0200 Message-Id: <1475675109-8105-5-git-send-email-quintela@redhat.com> In-Reply-To: <1475675109-8105-1-git-send-email-quintela@redhat.com> References: <1475675109-8105-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 05 Oct 2016 13:45:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/15] migration: Make failed migration load set file error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" If an error occurs in a section load, set the file error flag so that the transport can get notified to do a cleanup. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Michael R. Hines Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 33a2911..a831ec2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1828,40 +1828,45 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; - int ret; + int ret = 0; while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { - + ret = 0; trace_qemu_loadvm_state_section(section_type); switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: ret = qemu_loadvm_section_start_full(f, mis); if (ret < 0) { - return ret; + goto out; } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: ret = qemu_loadvm_section_part_end(f, mis); if (ret < 0) { - return ret; + goto out; } break; case QEMU_VM_COMMAND: ret = loadvm_process_command(f); trace_qemu_loadvm_state_section_command(ret); if ((ret < 0) || (ret & LOADVM_QUIT)) { - return ret; + goto out; } break; default: error_report("Unknown savevm section type %d", section_type); - return -EINVAL; + ret = -EINVAL; + goto out; } } - return 0; +out: + if (ret < 0) { + qemu_file_set_error(f, ret); + } + return ret; } int qemu_loadvm_state(QEMUFile *f)