From: Lai Jiangshan Subject: [PATCH 08/13 V6] remus: implement the API to teardown network buffering Date: Tue, 21 Jan 2014 17:05:12 +0800 Message-ID: <1390295117-718-9-git-send-email-laijs@cn.fujitsu.com> References: <1390295117-718-1-git-send-email-laijs@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1390295117-718-1-git-send-email-laijs@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 , FNST-Wen Congyang , Stefano Stabellini , Andrew Cooper , Jiang Yunhong , Ian Jackson , Lai Jiangshan , Dong Eddie , Shriram Rajagopalan , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org From: Shriram Rajagopalan During teardown, the netlink resources are released, followed by invocation of hotplug scripts to remove the IFB devices. Signed-off-by: Shriram Rajagopalan Signed-off-by: Lai Jiangshan Reviewed-by: Wen Congyang --- tools/libxl/libxl_internal.h | 6 +++++ tools/libxl/libxl_netbuffer.c | 52 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nonetbuffer.c | 5 ++++ tools/libxl/libxl_remus.c | 6 +++++ 4 files changed, 69 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 7216f89..358590b 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2330,6 +2330,12 @@ _hidden int libxl__remus_netbuf_start_new_epoch(libxl__gc *gc, uint32_t domid, _hidden int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, libxl__remus_state *remus_state); +_hidden void libxl__remus_teardown_done(libxl__egc *egc, + libxl__domain_suspend_state *dss); + +_hidden void libxl__remus_netbuf_teardown(libxl__egc *egc, + libxl__domain_suspend_state *dss); + struct libxl__domain_suspend_state { /* set by caller of libxl__domain_suspend */ libxl__ao *ao; diff --git a/tools/libxl/libxl_netbuffer.c b/tools/libxl/libxl_netbuffer.c index 1b61597..686101b 100644 --- a/tools/libxl/libxl_netbuffer.c +++ b/tools/libxl/libxl_netbuffer.c @@ -490,6 +490,58 @@ int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, return remus_netbuf_op(gc, domid, remus_state, tc_buffer_release); } +static void netbuf_teardown_script_cb(libxl__egc *egc, + libxl__ev_child *child, + pid_t pid, int status) +{ + libxl__remus_state *remus_state = CONTAINER_OF(child, *remus_state, child); + + /* Convenience aliases */ + libxl__remus_netbuf_state *const netbuf_state = remus_state->netbuf_state; + + STATE_AO_GC(remus_state->dss->ao); + + libxl__ev_time_deregister(gc, &remus_state->timeout); + + if (status) { + libxl_report_child_exitstatus(CTX, LIBXL__LOG_ERROR, + remus_state->netbufscript, + pid, status); + } + + remus_state->dev_id++; + if (remus_state->dev_id < netbuf_state->num_netbufs) { + if (exec_netbuf_script(gc, remus_state, + "teardown", netbuf_teardown_script_cb)) + goto out; + return; + } + + out: + libxl__remus_teardown_done(egc, remus_state->dss); +} + +/* Note: This function will be called in the same gc context as + * libxl__remus_netbuf_setup, created during the libxl_domain_remus_start + * API call. + */ +void libxl__remus_netbuf_teardown(libxl__egc *egc, + libxl__domain_suspend_state *dss) +{ + /* Convenience aliases */ + libxl__remus_state *const remus_state = dss->remus_state; + libxl__remus_netbuf_state *const netbuf_state = remus_state->netbuf_state; + + STATE_AO_GC(dss->ao); + + free_qdiscs(netbuf_state); + + remus_state->dev_id = 0; + if (exec_netbuf_script(gc, remus_state, "teardown", + netbuf_teardown_script_cb)) + libxl__remus_teardown_done(egc, dss); +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_nonetbuffer.c b/tools/libxl/libxl_nonetbuffer.c index a3e3f5c..ef7b513 100644 --- a/tools/libxl/libxl_nonetbuffer.c +++ b/tools/libxl/libxl_nonetbuffer.c @@ -42,6 +42,11 @@ int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, return ERROR_FAIL; } +void libxl__remus_netbuf_teardown(libxl__egc *egc, + libxl__domain_suspend_state *dss) +{ +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_remus.c b/tools/libxl/libxl_remus.c index b3342b3..6790c61 100644 --- a/tools/libxl/libxl_remus.c +++ b/tools/libxl/libxl_remus.c @@ -33,3 +33,9 @@ void libxl__remus_setup_done(libxl__egc *egc, " for guest with domid %u", dss->domid); domain_suspend_done(egc, dss, rc); } + +void libxl__remus_teardown_done(libxl__egc *egc, + libxl__domain_suspend_state *dss) +{ + dss->callback(egc, dss, dss->remus_state->saved_rc); +} -- 1.8.4.2