From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 06/27] libxl: cancellation: Preparations for save/restore cancellation Date: Mon, 15 Jun 2015 14:44:19 +0100 Message-ID: <1434375880-30914-7-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 From: Ian Jackson Two unrelated non-functional changes, broken out into a pre-patch for easier review: Break out a function sendsig() in libxl_save_callout.c. Move io_fd to be a global variable in libxl_save_helper.c. Signed-off-by: Ian Jackson Alter sendsig() to being libxl__kill() as it is needed in other translation units. Signed-off-by: Andrew Cooper CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- tools/libxl/libxl_aoutils.c | 7 +++++++ tools/libxl/libxl_internal.h | 2 ++ tools/libxl/libxl_save_callout.c | 4 +--- tools/libxl/libxl_save_helper.c | 5 +++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index ef679dd..bea0282 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -593,3 +593,10 @@ bool libxl__async_exec_inuse(const libxl__async_exec_state *aes) assert(time_inuse == child_inuse); return child_inuse; } + +void libxl__kill(libxl__gc *gc, pid_t pid, int sig, const char *what) +{ + int r = kill(pid, sig); + if (r) LOGE(WARN, "failed to kill() %s [%lu] (signal %d)", + what, (unsigned long)pid, sig); +} diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a4636ca..4f204f9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2161,6 +2161,8 @@ struct libxl__async_exec_state { int libxl__async_exec_start(libxl__gc *gc, libxl__async_exec_state *aes); bool libxl__async_exec_inuse(const libxl__async_exec_state *aes); +void libxl__kill(libxl__gc *gc, pid_t pid, int sig, const char *what); + /*----- device addition/removal -----*/ typedef struct libxl__ao_device libxl__ao_device; diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c index 3585a84..231de2f 100644 --- a/tools/libxl/libxl_save_callout.c +++ b/tools/libxl/libxl_save_callout.c @@ -253,9 +253,7 @@ static void helper_failed(libxl__egc *egc, libxl__save_helper_state *shs, return; } - int r = kill(shs->child.pid, SIGKILL); - if (r) LOGE(WARN, "failed to kill save/restore helper [%lu]", - (unsigned long)shs->child.pid); + libxl__kill(gc, shs->child.pid, SIGKILL, "save/restore helper"); } static void helper_stdout_readable(libxl__egc *egc, libxl__ev_fd *ev, diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index 74826a1..7514b2e 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -85,6 +85,7 @@ static void tellparent_destroy(struct xentoollog_logger *logger_in) tellparent_destroy, }; static xc_interface *xch; +static int io_fd; /*----- error handling -----*/ @@ -211,7 +212,7 @@ int main(int argc, char **argv) if (!strcmp(mode,"--save-domain")) { - int io_fd = atoi(NEXTARG); + io_fd = atoi(NEXTARG); uint32_t dom = strtoul(NEXTARG,0,10); uint32_t max_iters = strtoul(NEXTARG,0,10); uint32_t max_factor = strtoul(NEXTARG,0,10); @@ -234,7 +235,7 @@ int main(int argc, char **argv) } else if (!strcmp(mode,"--restore-domain")) { - int io_fd = atoi(NEXTARG); + io_fd = atoi(NEXTARG); uint32_t dom = strtoul(NEXTARG,0,10); unsigned store_evtchn = strtoul(NEXTARG,0,10); domid_t store_domid = strtoul(NEXTARG,0,10); -- 1.7.10.4