qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] Add dd-style SIGUSR1 progress reporting


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 1/2] Add dd-style SIGUSR1 progress reporting
Date: Wed, 27 Apr 2011 18:14:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

address@hidden writes:

> From: Jes Sorensen <address@hidden>
>
> This introduces support for dd-style progress reporting on POSIX
> systems, if the user hasn't specified -p to report progress. If sent a
> SIGUSR1, qemu-img will report current progress for commands that
> support progress reporting.
>
> Signed-off-by: Jes Sorensen <address@hidden>
> ---
>  qemu-progress.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
>  1 files changed, 48 insertions(+), 5 deletions(-)
>
> diff --git a/qemu-progress.c b/qemu-progress.c
> index 656e065..b4b751c 100644
> --- a/qemu-progress.c
> +++ b/qemu-progress.c
> @@ -26,12 +26,15 @@
>  #include "osdep.h"
>  #include "sysemu.h"
>  #include <stdio.h>
> +#include <signal.h>
>  
>  struct progress_state {
>      int enabled;
>      float current;
>      float last_print;
>      float min_skip;
> +    void (*print)(void);
> +    void (*end)(void);
>  };
>  
>  static struct progress_state state;
> @@ -51,20 +54,60 @@ static void progress_simple_print(void)
>  
>  static void progress_simple_end(void)
>  {
> -    if (state.enabled) {
> -        printf("\n");
> -    }
> +    printf("\n");
> +}
> +
> +static void progress_simple_init(void)
> +{
> +    state.print = progress_simple_print;
> +    state.end = progress_simple_end;
> +}
> +
> +#ifdef CONFIG_POSIX
> +static void sigusr_print(int signal)
> +{
> +    printf("    (%3.2f/100%%)\n", state.current);

printf() is not async-signal-safe.  I don't think you can safely call it
in a signal handler.

> +}
> +#endif
[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]