From patchwork Fri Feb 5 20:45:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 8239261 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 365539F3CD for ; Fri, 5 Feb 2016 20:48:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B14342039D for ; Fri, 5 Feb 2016 20:48:01 +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 950B920265 for ; Fri, 5 Feb 2016 20:48:00 +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 1aRnFY-0002lx-Gi; Fri, 05 Feb 2016 20:45:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRnFW-0002ll-Pn for xen-devel@lists.xen.org; Fri, 05 Feb 2016 20:45:02 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id A4/93-21594-EC905B65; Fri, 05 Feb 2016 20:45:02 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1454705100!20624057!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5867 invoked from network); 5 Feb 2016 20:45:01 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-3.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 5 Feb 2016 20:45:01 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u15KixbR006359 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Feb 2016 20:44:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u15Kix0P029973 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 5 Feb 2016 20:44:59 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u15KixrP014201; Fri, 5 Feb 2016 20:44:59 GMT Received: from localhost.localdomain (/77.54.175.82) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 05 Feb 2016 12:44:59 -0800 From: Joao Martins To: libvir-list@redhat.com Date: Fri, 5 Feb 2016 20:45:03 +0000 Message-Id: <1454705103-25456-2-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454705103-25456-1-git-send-email-joao.m.martins@oracle.com> References: <1454705103-25456-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Joao Martins , Jim Fehlig , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v4 2/2] libxl: keepalive messages support 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: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces keep alive messages support for P2P migration and it adds two new configuration entries namely 'keepalive_interval' 'keepalive_count' to control it. Behavior of these entries is the same as qemu driver thus the description is copied from there with just a few simplifications. Signed-off-by: Joao Martins --- Note: v4 series requires the patch ("remote: set VIR_TYPED_PARAM_STRING_OKAY on migration") to make migration work again, but it's not reviewed yet. [https://www.redhat.com/archives/libvir-list/2016-February/msg00317.html] --- src/libxl/libvirtd_libxl.aug | 4 ++++ src/libxl/libxl.conf | 18 ++++++++++++++++++ src/libxl/libxl_conf.c | 26 ++++++++++++++++++++++++++ src/libxl/libxl_conf.h | 3 +++ src/libxl/libxl_migration.c | 6 ++++++ src/libxl/test_libvirtd_libxl.aug.in | 2 ++ 6 files changed, 59 insertions(+) diff --git a/src/libxl/libvirtd_libxl.aug b/src/libxl/libvirtd_libxl.aug index d5aa150..b31cc07 100644 --- a/src/libxl/libvirtd_libxl.aug +++ b/src/libxl/libvirtd_libxl.aug @@ -26,10 +26,14 @@ module Libvirtd_libxl = (* Config entry grouped by function - same order as example config *) let autoballoon_entry = bool_entry "autoballoon" let lock_entry = str_entry "lock_manager" + let keepalive_interval_entry = int_entry "keepalive_interval" + let keepalive_count_entry = int_entry "keepalive_count" (* Each entry in the config is one of the following ... *) let entry = autoballoon_entry | lock_entry + | keepalive_interval_entry + | keepalive_count_entry let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let empty = [ label "#empty" . eol ] diff --git a/src/libxl/libxl.conf b/src/libxl/libxl.conf index ba3de7a..82abdb6 100644 --- a/src/libxl/libxl.conf +++ b/src/libxl/libxl.conf @@ -20,3 +20,21 @@ # "lockd". Accepted values are "sanlock" and "lockd". # #lock_manager = "lockd" + + +# A keepalive message is sent to the daemon after keepalive_interval +# seconds of inactivity to check if the daemon is still responding; +# keepalive_count is a maximum number of keepalive messages that are +# allowed to be sent to the deamon without getting any response before +# the connection is considered broken. In other words, the connection +# is automatically closed approximately after keepalive_interval * +# (keepalive_count + 1) seconds since the last message received from +# the daemon. If keepalive_interval is set to -1, libxl driver will +# not send keepalive requests during peer-to-peer migration; however, +# the remote libvirtd can still send them and source libvirtd will +# send responses. When keepalive_count is set to 0, connections will +# be automatically closed after keepalive_interval seconds of +# inactivity without sending any keepalive messages. +# +#keepalive_interval = 5 +#keepalive_count = 5 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index d7fb533..48b77d2 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1659,6 +1659,10 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg, virConfValuePtr p; int ret = -1; + /* defaults for keepalive messages */ + cfg->keepAliveInterval = 5; + cfg->keepAliveCount = 5; + /* Check the file is readable before opening it, otherwise * libvirt emits an error. */ @@ -1686,6 +1690,28 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg, goto cleanup; } + if ((p = virConfGetValue(conf, "keepalive_interval"))) { + if (p->type != VIR_CONF_LONG && p->type != VIR_CONF_ULONG) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Unexpected type for 'keepalive_interval' setting")); + goto cleanup; + } + + cfg->keepAliveInterval = p->l; + } + + if ((p = virConfGetValue(conf, "keepalive_count"))) { + if (p->type != VIR_CONF_ULONG) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Unexpected type for 'keepalive_count' setting")); + goto cleanup; + } + + cfg->keepAliveCount = p->l; + } + ret = 0; cleanup: diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index 6ad9ad3..3c0eafb 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -105,6 +105,9 @@ struct _libxlDriverConfig { char *lockManagerName; + int keepAliveInterval; + unsigned int keepAliveCount; + /* Once created, caps are immutable */ virCapsPtr caps; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 5993abc..ab1f76e 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -615,6 +615,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver, bool useParams; virConnectPtr dconn = NULL; virErrorPtr orig_err = NULL; + libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); virObjectUnlock(vm); dconn = virConnectOpenAuth(dconnuri, &virConnectAuthConfig, 0); @@ -627,6 +628,10 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver, return ret; } + if (virConnectSetKeepAlive(dconn, cfg->keepAliveInterval, + cfg->keepAliveCount) < 0) + goto cleanup; + virObjectUnlock(vm); useParams = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_PARAMS); @@ -645,6 +650,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver, orig_err = virSaveLastError(); virObjectUnlock(vm); virObjectUnref(dconn); + virObjectUnref(cfg); virObjectLock(vm); if (orig_err) { virSetError(orig_err); diff --git a/src/libxl/test_libvirtd_libxl.aug.in b/src/libxl/test_libvirtd_libxl.aug.in index baa8c79..63558e5 100644 --- a/src/libxl/test_libvirtd_libxl.aug.in +++ b/src/libxl/test_libvirtd_libxl.aug.in @@ -4,3 +4,5 @@ module Test_libvirtd_libxl = test Libvirtd_libxl.lns get conf = { "autoballoon" = "1" } { "lock_manager" = "lockd" } +{ "keepalive_interval" = "5" } +{ "keepalive_count" = "5" }