From patchwork Thu Feb 18 02:43:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 8345141 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04B629F372 for ; Thu, 18 Feb 2016 02:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02407203C0 for ; Thu, 18 Feb 2016 02:46:06 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D8D02203A5 for ; Thu, 18 Feb 2016 02:46:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWEYd-0007tc-0Q; Thu, 18 Feb 2016 02:43:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWEYb-0007tT-9i for xen-devel@lists.xen.org; Thu, 18 Feb 2016 02:43:05 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 76/B8-12072-8BF25C65; Thu, 18 Feb 2016 02:43:04 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1455763380!13590680!2 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15200 invoked from network); 18 Feb 2016 02:43:03 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-4.tower-31.messagelabs.com with SMTP; 18 Feb 2016 02:43:03 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="3658298" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Feb 2016 10:42:39 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id E4AF442AC845; Thu, 18 Feb 2016 10:40:59 +0800 (CST) Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 18 Feb 2016 10:42:38 +0800 From: Wen Congyang To: xen devel , Konrad Rzeszutek Wilk , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Thu, 18 Feb 2016 10:43:11 +0800 Message-ID: <1455763403-18641-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455763403-18641-1-git-send-email-wency@cn.fujitsu.com> References: <1455763403-18641-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-yoursite-MailScanner-ID: E4AF442AC845.A9957 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wency@cn.fujitsu.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Cc: Lars Kurth , Changlong Xie , Ian Campbell , Wen Congyang , Gui Jianfeng , Jiang Yunhong , Dong Eddie , Shriram Rajagopalan , Ian Jackson , Yang Hongyang Subject: [Xen-devel] [PATCH v8 01/13] libxl/remus: init checkpoint callback in Remus setup callback X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Init stream {read/write} state checkpoint_callback, suspend/resume/checkpoint callback in Remus setup callback. There's no functional change, it's just refactoring so that we can move all remus code into one file. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang CC: Andrew Cooper CC: Ian Campbell CC: Ian Jackson CC: Wei Liu Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Wei Liu --- tools/libxl/libxl.c | 8 ++++++++ tools/libxl/libxl_create.c | 18 ++++++++++++++---- tools/libxl/libxl_dom.c | 18 +++++------------- tools/libxl/libxl_internal.h | 7 +++++++ 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2d18b8d..38029cd 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -899,6 +899,8 @@ static void libxl__remus_setup(libxl__egc *egc, /* Convenience aliases */ libxl__remus_devices_state *const rds = &dss->rds; const libxl_domain_remus_info *const info = dss->remus; + libxl__srm_save_autogen_callbacks *const callbacks = + &dss->sws.shs.callbacks.save.a; STATE_AO_GC(dss->ao); @@ -917,6 +919,12 @@ static void libxl__remus_setup(libxl__egc *egc, rds->domid = dss->domid; rds->callback = remus_setup_done; + dss->sws.checkpoint_callback = remus_checkpoint_stream_written; + + callbacks->suspend = libxl__remus_domain_suspend_callback; + callbacks->postcopy = libxl__remus_domain_resume_callback; + callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback; + libxl__remus_devices_setup(egc, rds); return; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index de5d27f..7293d0b 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -730,6 +730,17 @@ static void remus_checkpoint_stream_done( libxl__xc_domain_saverestore_async_callback_done(egc, &stream->shs, rc); } +static void libxl__remus_restore_setup(libxl__egc *egc, + libxl__domain_create_state *dcs) +{ + /* Convenience aliases */ + libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a; + + callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback; + dcs->srs.checkpoint_callback = remus_checkpoint_stream_done; +} + /*----- main domain creation -----*/ /* We have a linear control flow; only one event callback is @@ -1014,8 +1025,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, libxl_domain_config *const d_config = dcs->guest_config; const int restore_fd = dcs->restore_fd; libxl__domain_build_state *const state = &dcs->build_state; - libxl__srm_restore_autogen_callbacks *const callbacks = - &dcs->srs.shs.callbacks.restore.a; + const int checkpointed_stream = dcs->restore_params.checkpointed_stream; if (rc) { domcreate_rebuild_done(egc, dcs, rc); @@ -1043,7 +1053,6 @@ static void domcreate_bootloader_done(libxl__egc *egc, } /* Restore */ - callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback; rc = libxl__build_pre(gc, domid, d_config, state); if (rc) @@ -1054,9 +1063,10 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version == 1); dcs->srs.completion_callback = domcreate_stream_done; - dcs->srs.checkpoint_callback = remus_checkpoint_stream_done; if (restore_fd >= 0) { + if (checkpointed_stream) + libxl__remus_restore_setup(egc, dcs); libxl__stream_read_start(egc, &dcs->srs); return; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 2269998..7835d4d 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1489,7 +1489,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc); -static void libxl__remus_domain_suspend_callback(void *data) +void libxl__remus_domain_suspend_callback(void *data) { libxl__save_helper_state *shs = data; libxl__egc *egc = shs->egc; @@ -1532,7 +1532,7 @@ out: libxl__xc_domain_saverestore_async_callback_done(egc, &dss->sws.shs, !rc); } -static void libxl__remus_domain_resume_callback(void *data) +void libxl__remus_domain_resume_callback(void *data) { libxl__save_helper_state *shs = data; libxl__egc *egc = shs->egc; @@ -1569,8 +1569,6 @@ out: /*----- remus asynchronous checkpoint callback -----*/ -static void remus_checkpoint_stream_written( - libxl__egc *egc, libxl__stream_write_state *sws, int rc); static void remus_devices_commit_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc); @@ -1578,7 +1576,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev, const struct timeval *requested_abs, int rc); -static void libxl__remus_domain_save_checkpoint_callback(void *data) +void libxl__remus_domain_save_checkpoint_callback(void *data) { libxl__save_helper_state *shs = data; libxl__domain_suspend_state *dss = shs->caller_state; @@ -1588,7 +1586,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data) libxl__stream_write_start_checkpoint(egc, &dss->sws); } -static void remus_checkpoint_stream_written( +void remus_checkpoint_stream_written( libxl__egc *egc, libxl__stream_write_state *sws, int rc) { libxl__domain_suspend_state *dss = CONTAINER_OF(sws, *dss, sws); @@ -1756,13 +1754,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss) } } - memset(callbacks, 0, sizeof(*callbacks)); - if (r_info != NULL) { - callbacks->suspend = libxl__remus_domain_suspend_callback; - callbacks->postcopy = libxl__remus_domain_resume_callback; - callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback; - dss->sws.checkpoint_callback = remus_checkpoint_stream_written; - } else + if (r_info == NULL) callbacks->suspend = libxl__domain_suspend_callback; callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 650a958..29c87a2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3508,6 +3508,13 @@ _hidden void libxl__domain_suspend(libxl__egc *egc, /* used by libxc to suspend the guest during migration */ _hidden void libxl__domain_suspend_callback(void *data); +/* Remus callbacks for save */ +_hidden void remus_checkpoint_stream_written( + libxl__egc *egc, libxl__stream_write_state *sws, int rc); +_hidden void libxl__remus_domain_suspend_callback(void *data); +_hidden void libxl__remus_domain_resume_callback(void *data); +_hidden void libxl__remus_domain_save_checkpoint_callback(void *data); + /* * Convenience macros.