From patchwork Wed Jan 25 06:54:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9536481 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 8DA0B6046A for ; Wed, 25 Jan 2017 06:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9721D26E75 for ; Wed, 25 Jan 2017 06:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D9626E94; Wed, 25 Jan 2017 06:58:55 +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 EE52D26E75 for ; Wed, 25 Jan 2017 06:58:54 +0000 (UTC) Received: from localhost ([::1]:57712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWHXh-00079L-TW for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Jan 2017 01:58:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWHVE-00057X-4D for qemu-devel@nongnu.org; Wed, 25 Jan 2017 01:56:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWHVB-0006SZ-2R for qemu-devel@nongnu.org; Wed, 25 Jan 2017 01:56:20 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:29791) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cWHVA-0006Rx-AL for qemu-devel@nongnu.org; Wed, 25 Jan 2017 01:56:16 -0500 Received: from 172.24.1.36 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DYH79070; Wed, 25 Jan 2017 14:55:10 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Wed, 25 Jan 2017 14:55:00 +0800 From: zhanghailiang To: Date: Wed, 25 Jan 2017 14:54:01 +0800 Message-ID: <1485327241-15104-3-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1485327241-15104-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1485327241-15104-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.58884BD0.017A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c166073a0b96f44139af6997a0aacc44 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH 2/2] savevm: Add new helpers to process the different stages of loadvm/savevm 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: xuquan8@huawei.com, zhanghailiang , Li Zhijian , quintela@redhat.com, dgilbert@redhat.com, amit.shah@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are several stages during loadvm/savevm process. In different stage, migration incoming processes different types of sections. We want to control these stages more accuracy, it will benefit COLO performance, we don't have to save type of QEMU_VM_SECTION_START sections everytime while do checkpoint, besides, we want to separate the process of saving/loading memory and devices state. So we add three new helper functions: qemu_loadvm_state_begin(), qemu_load_device_state() and qemu_savevm_live_state() to achieve different process during migration. Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- include/sysemu/sysemu.h | 4 ++++ migration/savevm.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ff8ffb5..d9214bf 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -126,7 +126,11 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, uint64_t *start_list, uint64_t *length_list); +void qemu_savevm_live_state(QEMUFile *f); + int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state_begin(QEMUFile *f); +int qemu_load_device_state(QEMUFile *f); extern int autostart; diff --git a/migration/savevm.c b/migration/savevm.c index 92b3d6c..04dee4f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1264,6 +1264,13 @@ done: return ret; } +void qemu_savevm_live_state(QEMUFile *f) +{ + /* save QEMU_VM_SECTION_END section */ + qemu_savevm_state_complete_precopy(f, true); + qemu_put_byte(f, QEMU_VM_EOF); +} + static int qemu_save_device_state(QEMUFile *f) { SaveStateEntry *se; @@ -2064,6 +2071,40 @@ int qemu_loadvm_state(QEMUFile *f) return ret; } +int qemu_loadvm_state_begin(QEMUFile *f) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); + Error *local_err = NULL; + int ret; + + if (qemu_savevm_state_blocked(&local_err)) { + error_report_err(local_err); + return -EINVAL; + } + /* Load QEMU_VM_SECTION_START section */ + ret = qemu_loadvm_state_main(f, mis); + if (ret < 0) { + error_report("Failed to loadvm begin work: %d", ret); + } + return ret; +} + +int qemu_load_device_state(QEMUFile *f) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); + int ret; + + /* Load QEMU_VM_SECTION_FULL section */ + ret = qemu_loadvm_state_main(f, mis); + if (ret < 0) { + error_report("Failed to load device state: %d", ret); + return ret; + } + + cpu_synchronize_all_post_init(); + return 0; +} + void hmp_savevm(Monitor *mon, const QDict *qdict) { BlockDriverState *bs, *bs1;