[PATCH] tools/misc/xen-vmtrace: handle more signals and install by default

Tamas K Lengyel posted 1 patch 3 years, 6 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20210507152836.20026-1-tamas@tklengyel.com
tools/misc/Makefile      |  2 +-
tools/misc/xen-vmtrace.c | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
[PATCH] tools/misc/xen-vmtrace: handle more signals and install by default
Posted by Tamas K Lengyel 3 years, 6 months ago
Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 tools/misc/Makefile      |  2 +-
 tools/misc/xen-vmtrace.c | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index 2b683819d4..c32c42d546 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -25,6 +25,7 @@ INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
 INSTALL_SBIN-$(CONFIG_X86)     += xen-memshare
 INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
 INSTALL_SBIN-$(CONFIG_X86)     += xen-ucode
+INSTALL_SBIN-$(CONFIG_X86)     += xen-vmtrace
 INSTALL_SBIN                   += xencov
 INSTALL_SBIN                   += xenhypfs
 INSTALL_SBIN                   += xenlockprof
@@ -51,7 +52,6 @@ TARGETS_COPY += xenpvnetboot
 TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL))
 
 # ... including build-only targets
-TARGETS_BUILD-$(CONFIG_X86)    += xen-vmtrace
 TARGETS_BUILD += $(TARGETS_BUILD-y)
 
 .PHONY: all build
diff --git a/tools/misc/xen-vmtrace.c b/tools/misc/xen-vmtrace.c
index 35d14c6a9b..5b688a54af 100644
--- a/tools/misc/xen-vmtrace.c
+++ b/tools/misc/xen-vmtrace.c
@@ -44,7 +44,7 @@ static size_t size;
 static char *buf;
 
 static sig_atomic_t interrupted;
-static void int_handler(int signum)
+static void close_handler(int signum)
 {
     interrupted = 1;
 }
@@ -78,8 +78,14 @@ int main(int argc, char **argv)
     int rc, exit = 1;
     xenforeignmemory_resource_handle *fres = NULL;
 
-    if ( signal(SIGINT, int_handler) == SIG_ERR )
-        err(1, "Failed to register signal handler\n");
+    struct sigaction act;
+    act.sa_handler = close_handler;
+    act.sa_flags = 0;
+    sigemptyset(&act.sa_mask);
+    sigaction(SIGHUP,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+    sigaction(SIGINT,  &act, NULL);
+    sigaction(SIGALRM, &act, NULL);
 
     if ( argc != 3 )
     {
-- 
2.27.0


Re: [PATCH] tools/misc/xen-vmtrace: handle more signals and install by default
Posted by Tamas K Lengyel 3 years, 5 months ago
Patch ping.

On Fri, May 7, 2021 at 11:28 AM Tamas K Lengyel <tamas@tklengyel.com> wrote:
>
> Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
> ---
>  tools/misc/Makefile      |  2 +-
>  tools/misc/xen-vmtrace.c | 12 +++++++++---
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/tools/misc/Makefile b/tools/misc/Makefile
> index 2b683819d4..c32c42d546 100644
> --- a/tools/misc/Makefile
> +++ b/tools/misc/Makefile
> @@ -25,6 +25,7 @@ INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
>  INSTALL_SBIN-$(CONFIG_X86)     += xen-memshare
>  INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
>  INSTALL_SBIN-$(CONFIG_X86)     += xen-ucode
> +INSTALL_SBIN-$(CONFIG_X86)     += xen-vmtrace
>  INSTALL_SBIN                   += xencov
>  INSTALL_SBIN                   += xenhypfs
>  INSTALL_SBIN                   += xenlockprof
> @@ -51,7 +52,6 @@ TARGETS_COPY += xenpvnetboot
>  TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL))
>
>  # ... including build-only targets
> -TARGETS_BUILD-$(CONFIG_X86)    += xen-vmtrace
>  TARGETS_BUILD += $(TARGETS_BUILD-y)
>
>  .PHONY: all build
> diff --git a/tools/misc/xen-vmtrace.c b/tools/misc/xen-vmtrace.c
> index 35d14c6a9b..5b688a54af 100644
> --- a/tools/misc/xen-vmtrace.c
> +++ b/tools/misc/xen-vmtrace.c
> @@ -44,7 +44,7 @@ static size_t size;
>  static char *buf;
>
>  static sig_atomic_t interrupted;
> -static void int_handler(int signum)
> +static void close_handler(int signum)
>  {
>      interrupted = 1;
>  }
> @@ -78,8 +78,14 @@ int main(int argc, char **argv)
>      int rc, exit = 1;
>      xenforeignmemory_resource_handle *fres = NULL;
>
> -    if ( signal(SIGINT, int_handler) == SIG_ERR )
> -        err(1, "Failed to register signal handler\n");
> +    struct sigaction act;
> +    act.sa_handler = close_handler;
> +    act.sa_flags = 0;
> +    sigemptyset(&act.sa_mask);
> +    sigaction(SIGHUP,  &act, NULL);
> +    sigaction(SIGTERM, &act, NULL);
> +    sigaction(SIGINT,  &act, NULL);
> +    sigaction(SIGALRM, &act, NULL);
>
>      if ( argc != 3 )
>      {
> --
> 2.27.0
>

Re: [PATCH] tools/misc/xen-vmtrace: handle more signals and install by default
Posted by Andrew Cooper 3 years, 4 months ago
On 07/05/2021 16:28, Tamas K Lengyel wrote:
> Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>