From patchwork Wed Dec 30 02:28:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 7931291 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 BAEDA9F350 for ; Wed, 30 Dec 2015 02:32:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97776201EF for ; Wed, 30 Dec 2015 02:32:21 +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 670E7201DD for ; Wed, 30 Dec 2015 02:32:20 +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 1aE6Wk-0000As-5f; Wed, 30 Dec 2015 02:30:14 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aE6Wj-00008g-1i for xen-devel@lists.xen.org; Wed, 30 Dec 2015 02:30:13 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 5F/80-18316-4B143865; Wed, 30 Dec 2015 02:30:12 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1451442598!6039223!1 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 18346 invoked from network); 30 Dec 2015 02:30:01 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-13.tower-21.messagelabs.com with SMTP; 30 Dec 2015 02:30:01 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="2079688" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Dec 2015 10:29:38 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 1E19441890E7; Wed, 30 Dec 2015 10:29:22 +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; Wed, 30 Dec 2015 10:29:21 +0800 From: Wen Congyang To: xen devel , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Wed, 30 Dec 2015 10:28:56 +0800 Message-ID: <1451442548-26974-7-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1451442548-26974-1-git-send-email-wency@cn.fujitsu.com> References: <1451442548-26974-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-yoursite-MailScanner-ID: 1E19441890E7.A5BCB 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 , Wen Congyang , Gui Jianfeng , Jiang Yunhong , Dong Eddie , Shriram Rajagopalan , Yang Hongyang Subject: [Xen-devel] [PATCH v6 06/18] tools/libxl: introduce enum type libxl_checkpointed_stream 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 introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed. NOTE: libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang --- tools/libxl/libxl.h | 7 +++++++ tools/libxl/libxl_create.c | 8 ++++++-- tools/libxl/libxl_stream_read.c | 7 +++++-- tools/libxl/libxl_types.idl | 5 +++++ tools/libxl/xl_cmdimpl.c | 18 ++++++++++++------ 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 05606a7..a01e448 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -867,6 +867,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); */ #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1 +/* + * LIBXL_HAVE_CHECKPOINTED_STREAM + * + * If this is defined, then libxl_checkpointed_stream exists. + */ +#define LIBXL_HAVE_CHECKPOINTED_STREAM 1 + typedef char **libxl_string_list; void libxl_string_list_dispose(libxl_string_list *sl); int libxl_string_list_length(const libxl_string_list *sl); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index bfa0552..8d3896f 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1015,9 +1015,13 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.completion_callback = domcreate_stream_done; if (restore_fd >= 0) { - if (checkpointed_stream) + switch (checkpointed_stream) { + case LIBXL_CHECKPOINTED_STREAM_REMUS: libxl__remus_restore_setup(egc, dcs); - libxl__stream_read_start(egc, &dcs->srs); + /* fall through */ + case LIBXL_CHECKPOINTED_STREAM_NONE: + libxl__stream_read_start(egc, &dcs->srs); + } return; } diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c index 42c087f..6ad2a27 100644 --- a/tools/libxl/libxl_stream_read.c +++ b/tools/libxl/libxl_stream_read.c @@ -780,15 +780,18 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, * If the stream is not still alive, we must not continue any work. */ if (libxl__stream_read_inuse(stream)) { - if (checkpointed_stream) { + switch (checkpointed_stream) { + case LIBXL_CHECKPOINTED_STREAM_REMUS: /* failover */ stream_complete(egc, stream, 0); - } else { + break; + case LIBXL_CHECKPOINTED_STREAM_NONE: /* * Libxc has indicated that it is done with the stream. * Resume reading libxl records from it. */ stream_continue(egc, stream); + break; } } } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9658356..3ef11aa 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -228,6 +228,11 @@ libxl_hdtype = Enumeration("hdtype", [ (2, "AHCI"), ], init_val = "LIBXL_HDTYPE_IDE") +libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ + (0, "NONE"), + (1, "REMUS"), + ]) + # # Complex libxl types # diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index f9933cb..c1cd696 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4424,7 +4424,8 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug, } static void migrate_receive(int debug, int daemonize, int monitor, - int send_fd, int recv_fd, int remus) + int send_fd, int recv_fd, + libxl_checkpointed_stream checkpointed) { uint32_t domid; int rc, rc2; @@ -4449,7 +4450,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.paused = 1; dom_info.migrate_fd = recv_fd; dom_info.migration_domname_r = &migration_domname; - dom_info.checkpointed_stream = remus; + dom_info.checkpointed_stream = checkpointed; rc = create_domain(&dom_info); if (rc < 0) { @@ -4460,7 +4461,8 @@ static void migrate_receive(int debug, int daemonize, int monitor, domid = rc; - if (remus) { + switch (checkpointed) { + case LIBXL_CHECKPOINTED_STREAM_REMUS: /* If we are here, it means that the sender (primary) has crashed. * TODO: Split-Brain Check. */ @@ -4493,6 +4495,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, common_domname, domid, rc); exit(rc ? -ERROR_FAIL: 0); + default: + /* do nothing */ + break; } fprintf(stderr, "migration target: Transfer complete," @@ -4630,7 +4635,8 @@ int main_restore(int argc, char **argv) int main_migrate_receive(int argc, char **argv) { - int debug = 0, daemonize = 1, monitor = 1, remus = 0; + int debug = 0, daemonize = 1, monitor = 1; + libxl_checkpointed_stream checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE; int opt; SWITCH_FOREACH_OPT(opt, "Fedr", NULL, "migrate-receive", 0) { @@ -4645,7 +4651,7 @@ int main_migrate_receive(int argc, char **argv) debug = 1; break; case 'r': - remus = 1; + checkpointed = LIBXL_CHECKPOINTED_STREAM_REMUS; break; } @@ -4655,7 +4661,7 @@ int main_migrate_receive(int argc, char **argv) } migrate_receive(debug, daemonize, monitor, STDOUT_FILENO, STDIN_FILENO, - remus); + checkpointed); return 0; }