From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 08/27] tools/libxl: Extra APIs for the save helper Date: Mon, 15 Jun 2015 14:44:21 +0100 Message-ID: <1434375880-30914-9-git-send-email-andrew.cooper3@citrix.com> References: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.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 Cc: Wei Liu , Yang Hongyang , Ian Jackson , Ian Campbell , Andrew Cooper List-Id: xen-devel@lists.xenproject.org With libxl migration v2, there will be other moving parts which might fail, requiring the helper to be stopped for reasons which are not its fault. Signed-off-by: Andrew Cooper CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- tools/libxl/libxl_internal.h | 8 ++++++++ tools/libxl/libxl_save_callout.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4f204f9..3fcc37a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3182,6 +3182,14 @@ _hidden void libxl__xc_domain_restore(libxl__egc *egc, _hidden void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, int rc, int retval, int errnoval); +_hidden void libxl__save_helper_abort(libxl__egc *egc, + libxl__save_helper_state *shs); + +static inline bool libxl__save_helper_inuse(const libxl__save_helper_state *shs) +{ + return libxl__ev_child_inuse(&shs->child); +} + /* Each time the dm needs to be saved, we must call suspend and then save */ _hidden int libxl__domain_suspend_device_model(libxl__gc *gc, libxl__domain_suspend_state *dss); diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c index 231de2f..71de297 100644 --- a/tools/libxl/libxl_save_callout.c +++ b/tools/libxl/libxl_save_callout.c @@ -256,6 +256,22 @@ static void helper_failed(libxl__egc *egc, libxl__save_helper_state *shs, libxl__kill(gc, shs->child.pid, SIGKILL, "save/restore helper"); } +void libxl__save_helper_abort(libxl__egc *egc, + libxl__save_helper_state *shs) +{ + STATE_AO_GC(shs->ao); + + if (!libxl__ev_child_inuse(&shs->child)) { + helper_failed(egc, shs, ERROR_FAIL); + return; + } + + if (!shs->rc) + shs->rc = ERROR_FAIL; + + libxl__kill(gc, shs->child.pid, SIGTERM, "save/restore helper"); +} + static void helper_stdout_readable(libxl__egc *egc, libxl__ev_fd *ev, int fd, short events, short revents) { -- 1.7.10.4