From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Hongyang Subject: [PATCH V8 5/8] libxl: use the API to setup/teardown network buffering Date: Wed, 2 Apr 2014 19:04:34 +0800 Message-ID: <1396436677-10872-6-git-send-email-yanghy@cn.fujitsu.com> References: <1396436677-10872-1-git-send-email-yanghy@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1396436677-10872-1-git-send-email-yanghy@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: ian.campbell@citrix.com, wency@cn.fujitsu.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, yunhong.jiang@intel.com, ian.jackson@eu.citrix.com, eddie.dong@intel.com, rshriram@cs.ubc.ca, roger.pau@citrix.com, laijs@cn.fujitsu.com List-Id: xen-devel@lists.xenproject.org If there is network buffering hotplug scripts, call libxl__remus_netbuf_setup() to setup the network buffering and libxl__remus_netbuf_teardown() to teardown network buffering. Signed-off-by: Shriram Rajagopalan Signed-off-by: Lai Jiangshan Reviewed-by: Wen Congyang --- tools/libxl/libxl.c | 6 +----- tools/libxl/libxl_dom.c | 11 +++++++++++ tools/libxl/libxl_internal.h | 7 +++++++ tools/libxl/libxl_remus.c | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index f7696a3..88b34a4 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -768,7 +768,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, } /* Point of no return */ - libxl__domain_suspend(egc, dss); + libxl__remus_setup_initiate(egc, dss); return AO_INPROGRESS; out: @@ -784,10 +784,6 @@ static void remus_failover_cb(libxl__egc *egc, * backup died or some network error occurred preventing us * from sending checkpoints. */ - - /* TBD: Remus cleanup - i.e. detach qdisc, release other - * resources. - */ libxl__ao_complete(egc, ao, rc); } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 20aaec8..0695f3e 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1715,6 +1715,17 @@ void domain_suspend_done(libxl__egc *egc, xc_suspend_evtchn_release(CTX->xch, CTX->xce, domid, dss->guest_evtchn.port, &dss->guest_evtchn_lockfd); + if (dss->remus_state) { + /* + * With Remus, if we reach this point, it means either + * backup died or some network error occurred preventing us + * from sending checkpoints. Teardown the network buffers and + * release netlink resources. This is an async op. + */ + libxl__remus_teardown_initiate(egc, dss, rc); + return; + } + dss->callback(egc, dss, rc); } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 1357f2d..34953ae 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2472,6 +2472,13 @@ _hidden int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, libxl__remus_state *remus_state); +_hidden void libxl__remus_setup_initiate(libxl__egc *egc, + libxl__domain_suspend_state *dss); + +_hidden void libxl__remus_teardown_initiate(libxl__egc *egc, + libxl__domain_suspend_state *dss, + int rc); + struct libxl__domain_suspend_state { /* set by caller of libxl__domain_suspend */ libxl__ao *ao; diff --git a/tools/libxl/libxl_remus.c b/tools/libxl/libxl_remus.c index 4e40412..da303e7 100644 --- a/tools/libxl/libxl_remus.c +++ b/tools/libxl/libxl_remus.c @@ -18,6 +18,15 @@ #include "libxl_internal.h" /*----- remus setup/teardown code -----*/ +void libxl__remus_setup_initiate(libxl__egc *egc, + libxl__domain_suspend_state *dss) +{ + libxl__ev_time_init(&dss->remus_state->timeout); + if (!dss->remus_state->netbufscript) + libxl__remus_setup_done(egc, dss, 0); + else + libxl__remus_netbuf_setup(egc, dss); +} void libxl__remus_setup_done(libxl__egc *egc, libxl__domain_suspend_state *dss, @@ -34,6 +43,19 @@ void libxl__remus_setup_done(libxl__egc *egc, domain_suspend_done(egc, dss, rc); } +void libxl__remus_teardown_initiate(libxl__egc *egc, + libxl__domain_suspend_state *dss, + int rc) +{ + /* stash rc somewhere before invoking teardown ops. */ + dss->remus_state->saved_rc = rc; + + if (!dss->remus_state->netbuf_state) + libxl__remus_teardown_done(egc, dss); + else + libxl__remus_netbuf_teardown(egc, dss); +} + void libxl__remus_teardown_done(libxl__egc *egc, libxl__domain_suspend_state *dss) { -- 1.8.3.2