From patchwork Thu Sep 29 11:06:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 9356343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C00DB6077B for ; Thu, 29 Sep 2016 11:09:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B115A298F2 for ; Thu, 29 Sep 2016 11:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A46F429924; Thu, 29 Sep 2016 11:09:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE8ED298F2 for ; Thu, 29 Sep 2016 11:09:36 +0000 (UTC) Received: from localhost ([::1]:36424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZDb-0001uO-Ha for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Sep 2016 07:09:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZDB-0001rk-Ng for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:09:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpZD7-0007w7-J6 for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:09:09 -0400 Received: from [59.151.112.132] (port=21339 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpZD5-0007rr-7b for qemu-devel@nongnu.org; Thu, 29 Sep 2016 07:09:05 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="11523949" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Sep 2016 19:08:39 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 610E2466F721; Thu, 29 Sep 2016 19:08:37 +0800 (CST) Received: from G08FNSTD140138.localdomain (10.167.226.45) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Thu, 29 Sep 2016 19:08:36 +0800 From: Li Zhijian To: , , Date: Thu, 29 Sep 2016 19:06:31 +0800 Message-ID: <1475147192-31228-1-git-send-email-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.45] X-yoursite-MailScanner-ID: 610E2466F721.ABC52 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 1/2] migration: split qemu_loadvm_section_start_full() to qemu_loadvm_section_{start(), full()} 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: Li Zhijian Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Li Zhijian --- migration/savevm.c | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 33a2911..09d8e99 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1729,48 +1729,65 @@ void loadvm_free_handlers(MigrationIncomingState *mis) } } + static int -qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) +qemu_loadvm_section_start(QEMUFile *f, MigrationIncomingState *mis, + SaveStateEntry **se, + uint32_t *version_id, uint32_t *section_id) { - uint32_t instance_id, version_id, section_id; - SaveStateEntry *se; - LoadStateEntry *le; + uint32_t instance_id; char idstr[256]; - int ret; /* Read section start */ - section_id = qemu_get_be32(f); + *section_id = qemu_get_be32(f); if (!qemu_get_counted_string(f, idstr)) { error_report("Unable to read ID string for section %u", - section_id); + *section_id); return -EINVAL; } instance_id = qemu_get_be32(f); - version_id = qemu_get_be32(f); + *version_id = qemu_get_be32(f); - trace_qemu_loadvm_state_section_startfull(section_id, idstr, - instance_id, version_id); + trace_qemu_loadvm_state_section_startfull(*section_id, idstr, + instance_id, *version_id); /* Find savevm section */ - se = find_se(idstr, instance_id); - if (se == NULL) { + *se = find_se(idstr, instance_id); + if (*se == NULL) { error_report("Unknown savevm section or instance '%s' %d", idstr, instance_id); return -EINVAL; } /* Validate version */ - if (version_id > se->version_id) { + if (*version_id > (*se)->version_id) { error_report("savevm: unsupported version %d for '%s' v%d", - version_id, idstr, se->version_id); + *version_id, idstr, (*se)->version_id); return -EINVAL; } /* Validate if it is a device's state */ - if (xen_enabled() && se->is_ram) { + if (xen_enabled() && (*se)->is_ram) { error_report("loadvm: %s RAM loading not allowed on Xen", idstr); return -EINVAL; } + return 0; +} + +static int +qemu_loadvm_section_full(QEMUFile *f, MigrationIncomingState *mis) +{ + uint32_t version_id, section_id; + SaveStateEntry *se; + LoadStateEntry *le; + char idstr[256]; + int ret; + + ret = qemu_loadvm_section_start(f, mis, &se, &version_id, §ion_id); + if (ret) { + return ret; + } + /* Add entry */ le = g_malloc0(sizeof(*le)); @@ -1781,8 +1798,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { - error_report("error while loading state for instance 0x%x of" - " device '%s'", instance_id, idstr); + error_report("error while loading state for" + " device '%s'", idstr); return ret; } if (!check_section_footer(f, le)) { @@ -1836,7 +1853,7 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret = qemu_loadvm_section_start_full(f, mis); + ret = qemu_loadvm_section_full(f, mis); if (ret < 0) { return ret; }