From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aH9Yd-0007uw-2N for qemu-devel@nongnu.org; Thu, 07 Jan 2016 07:20:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aH9YY-0004Kr-B5 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 07:20:47 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:36943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aH9YX-0004Ip-M0 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 07:20:42 -0500 From: zhanghailiang Date: Thu, 7 Jan 2016 20:20:02 +0800 Message-ID: <1452169208-840-8-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1452169208-840-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1452169208-840-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC 07/13] savevm: Split qemu_savevm_state_complete_precopy() into two helper functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, zhanghailiang , hanweidong@huawei.com, quintela@redhat.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, amit.shah@redhat.com We splited qemu_savevm_state_complete_precopy() into two helper functions, qemu_savevm_section_full() and qemu_savevm_section_end(). The main reason to do that is, sometimes we may want to do this two works separately. Signed-off-by: zhanghailiang --- migration/savevm.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 9b22498..1b4e5bd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1026,18 +1026,12 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) qemu_fflush(f); } -void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) +static int qemu_savevm_section_end(QEMUFile *f, bool iterable_only) { - QJSON *vmdesc; - int vmdesc_len; SaveStateEntry *se; int ret; bool in_postcopy = migration_in_postcopy(migrate_get_current()); - trace_savevm_state_complete_precopy(); - - cpu_synchronize_all_states(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || (in_postcopy && se->ops->save_live_complete_postcopy) || @@ -1060,13 +1054,18 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) save_section_footer(f, se); if (ret < 0) { qemu_file_set_error(f, ret); - return; + return -1; } } + return 0; +} - if (iterable_only) { - return; - } +static void qemu_savevm_section_full(QEMUFile *f) +{ + QJSON *vmdesc; + int vmdesc_len; + SaveStateEntry *se; + bool in_postcopy = migration_in_postcopy(migrate_get_current()); vmdesc = qjson_new(); json_prop_int(vmdesc, "page_size", TARGET_PAGE_SIZE); @@ -1111,6 +1110,26 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len); } object_unref(OBJECT(vmdesc)); +} + +void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) +{ + int ret; + + trace_savevm_state_complete_precopy(); + + cpu_synchronize_all_states(); + + ret = qemu_savevm_section_end(f, iterable_only); + if (ret < 0) { + return; + } + + if (iterable_only) { + return; + } + + qemu_savevm_section_full(f); qemu_fflush(f); } -- 1.8.3.1