[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 04/27] tools/libxl: Introduce libxl__kill()



On 07/10/2015 02:26 AM, Andrew Cooper wrote:
as a wrapper to kill(2), and use it in preference to sendig in

s/sendig/sendsig/

libxl_save_callout.c.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>

---
Logically new in v2 - split out from a v1 change which was itself a
cherrypick-and-modify from the AO Abort series
---
  tools/libxl/libxl_aoutils.c      |   15 +++++++++++++++
  tools/libxl/libxl_internal.h     |    2 ++
  tools/libxl/libxl_save_callout.c |   10 ++--------
  3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c
index 0931eee..274ef39 100644
--- a/tools/libxl/libxl_aoutils.c
+++ b/tools/libxl/libxl_aoutils.c
@@ -621,3 +621,18 @@ 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);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 19fc425..9147de1 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -2244,6 +2244,8 @@ struct libxl__async_exec_state {
  int libxl__async_exec_start(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 087c2d5..b82a5c1 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -244,12 +244,6 @@ 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)
@@ -266,7 +260,7 @@ static void helper_failed(libxl__egc *egc, 
libxl__save_helper_state *shs,
          return;
      }

-    sendsig(gc, shs, SIGKILL);
+    libxl__kill(gc, shs->child.pid, SIGKILL, "save/restore helper");
  }

  static void helper_stop(libxl__egc *egc, libxl__ao_abortable *abrt, int rc)
@@ -282,7 +276,7 @@ static void helper_stop(libxl__egc *egc, 
libxl__ao_abortable *abrt, int rc)
      if (!shs->rc)
          shs->rc = rc;

-    sendsig(gc, shs, SIGTERM);
+    libxl__kill(gc, shs->child.pid, SIGTERM, "save/restore helper");
  }

  static void helper_stdout_readable(libxl__egc *egc, libxl__ev_fd *ev,


--
Thanks,
Yang.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.