From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 25/29] libxl: cancellation: Preparations for save/restore cancellation Date: Tue, 10 Feb 2015 20:10:12 +0000 Message-ID: <1423599016-32639-26-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.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@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org 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 --- v2: New in this version of the series. --- tools/libxl/libxl_save_callout.c | 10 +++++++--- tools/libxl/libxl_save_helper.c | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c index 40b25e4..1d584f1 100644 --- a/tools/libxl/libxl_save_callout.c +++ b/tools/libxl/libxl_save_callout.c @@ -237,6 +237,12 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, libxl__carefd_close(childs_pipes[1]); helper_failed(egc, shs, rc);; } +static void sendsig(libxl__gc *gc, libxl__save_helper_state *shs, int sig) +{ + int r = kill(shs->child.pid, sig); + if (r) LOGE(WARN, "failed to kill save/restore helper [%lu] (signal %d)", + (unsigned long)shs->child.pid, sig); +} static void helper_failed(libxl__egc *egc, libxl__save_helper_state *shs, int rc) @@ -253,9 +259,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); + sendsig(gc, shs, SIGKILL); } 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 xentoollog_logger logger = { 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