From: Yang Hongyang Subject: [PATCH V8 4/8] remus: implement the API to buffer/release packages Date: Wed, 2 Apr 2014 19:04:33 +0800 Message-ID: <1396436677-10872-5-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 This patch implements two APIs: 1. libxl__remus_netbuf_start_new_epoch() It marks a new epoch. The packages before this epoch will be flushed, and the packages after this epoch will be buffered. It will be called after the guest is suspended. 2. libxl__remus_netbuf_release_prev_epoch() It flushes the buffered packages to client, and it will be called when a checkpoint finishes. Signed-off-by: Shriram Rajagopalan Signed-off-by: Lai Jiangshan Reviewed-by: Wen Congyang --- tools/libxl/libxl_internal.h | 7 ++++++ tools/libxl/libxl_netbuffer.c | 52 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nonetbuffer.c | 14 +++++++++++ 3 files changed, 73 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a6e5cff..1357f2d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2465,6 +2465,13 @@ _hidden void libxl__remus_teardown_done(libxl__egc *egc, _hidden void libxl__remus_netbuf_teardown(libxl__egc *egc, libxl__domain_suspend_state *dss); +_hidden int +libxl__remus_netbuf_start_new_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state); +_hidden int +libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state); + 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 865cbb2..22fffec 100644 --- a/tools/libxl/libxl_netbuffer.c +++ b/tools/libxl/libxl_netbuffer.c @@ -509,6 +509,58 @@ void libxl__remus_netbuf_teardown(libxl__egc *egc, libxl__remus_teardown_done(egc, dss); } +/* The buffer_op's value, not the value passed to kernel */ +enum { + tc_buffer_start, + tc_buffer_release +}; + +static int remus_netbuf_op(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state, + int buffer_op) +{ + int i, ret; + + /* Convenience aliases */ + libxl__remus_netbuf_state *const netbuf_state = remus_state->netbuf_state; + + for (i = 0; i < netbuf_state->num_netbufs; ++i) { + if (buffer_op == tc_buffer_start) + ret = rtnl_qdisc_plug_buffer(netbuf_state->netbuf_qdisc_list[i]); + else + ret = rtnl_qdisc_plug_release_one(netbuf_state->netbuf_qdisc_list[i]); + + if (!ret) { + ret = rtnl_qdisc_add(netbuf_state->nlsock, + netbuf_state->netbuf_qdisc_list[i], + NLM_F_REQUEST); + if (ret) + goto out; + } + } + + return 0; + +out: + LOG(ERROR, "Remus: cannot do netbuf op %s on %s:%s", + ((buffer_op == tc_buffer_start) ? + "start_new_epoch" : "release_prev_epoch"), + netbuf_state->ifb_list[i], nl_geterror(ret)); + return ERROR_FAIL; +} + +int libxl__remus_netbuf_start_new_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state) +{ + return remus_netbuf_op(gc, domid, remus_state, tc_buffer_start); +} + +int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state) +{ + return remus_netbuf_op(gc, domid, remus_state, tc_buffer_release); +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_nonetbuffer.c b/tools/libxl/libxl_nonetbuffer.c index 559d0a6..92f35bc 100644 --- a/tools/libxl/libxl_nonetbuffer.c +++ b/tools/libxl/libxl_nonetbuffer.c @@ -33,6 +33,20 @@ void libxl__remus_netbuf_teardown(libxl__egc *egc, { } +int libxl__remus_netbuf_start_new_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state) +{ + LOG(ERROR, "Remus: No support for network buffering"); + return ERROR_FAIL; +} + +int libxl__remus_netbuf_release_prev_epoch(libxl__gc *gc, uint32_t domid, + libxl__remus_state *remus_state) +{ + LOG(ERROR, "Remus: No support for network buffering"); + return ERROR_FAIL; +} + /* * Local variables: * mode: C -- 1.8.3.2