Skip to contentSkip to conversation

qemu-img: Fix progress printing on SIGUSR1

PATCH In review Kevin Wolf 2 participants 7 messages Jan 20, 2014 – Jan 21, 2014

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover qemu-img: Fix progress printing on SIGUSR1

Kevin Wolf (3):
qemu-progress: Drop unused include
qemu-progress: Fix progress printing on SIGUSR1
Documentation: qemu-img: Mention SIGUSR1 progress report

 qemu-img.texi        |  4 +++-
 util/qemu-progress.c | 11 ++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH 1/3 qemu-progress: Drop unused include

---
 util/qemu-progress.c | 1 -
 1 file changed, 1 deletion(-)
util/qemu-progress.c +0 -1
index 9a3f96c..ad33fee 100644
@@ -24,7 +24,6 @@
 
 #include "qemu-common.h"
 #include "qemu/osdep.h"
-#include "sysemu/sysemu.h"
 #include <stdio.h>
 
 struct progress_state {
Signature · 1 line
1.8.1.4
Reviewed-by Benoit Canet on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] qemu-progress: Drop unused include

Quoted 21 lines · Kevin Wolf
---
 util/qemu-progress.c | 1 -
 1 file changed, 1 deletion(-)
util/qemu-progress.c +0 -1
index 9a3f96c..ad33fee 100644
@@ -24,7 +24,6 @@
 
 #include "qemu-common.h"
 #include "qemu/osdep.h"
-#include "sysemu/sysemu.h"
 #include <stdio.h>
 
 struct progress_state {
Signature · 1 line
1.8.1.4
author
#3 lore raw

PATCH 2/3 qemu-progress: Fix progress printing on SIGUSR1

In reply to Kevin Wolf

Since commit a7aae221 ('Switch SIG_IPI to SIGUSR1'), SIGUSR1 is blocked during startup, breaking the progress report in tools.

This patch reenables the signal when initialising a progress report.

---
 util/qemu-progress.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
util/qemu-progress.c +10 -0
index ad33fee..4ee5cd0 100644
@@ -82,12 +82,22 @@ static void progress_dummy_init(void)
 {
 #ifdef CONFIG_POSIX
     struct sigaction action;
+    sigset_t set;
 
     memset(&action, 0, sizeof(action));
     sigfillset(&action.sa_mask);
     action.sa_handler = sigusr_print;
     action.sa_flags = 0;
     sigaction(SIGUSR1, &action, NULL);
+
+    /*
+     * SIGUSR1 is SIG_IPI and gets blocked in qemu_init_main_loop(). In the
+     * tools that use the progress report SIGUSR1 isn't used in this meaning
+     * and instead should print the progress, so reenable it.
+     */
+    sigemptyset(&set);
+    sigaddset(&set, SIGUSR1);
+    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 #endif
 
     state.print = progress_dummy_print;
Signature · 1 line
1.8.1.4
Reviewed-by Benoit Canet on v1 2/3
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] qemu-progress: Fix progress printing on SIGUSR1

Quoted 41 lines · Kevin Wolf

Since commit a7aae221 ('Switch SIG_IPI to SIGUSR1'), SIGUSR1 is blocked during startup, breaking the progress report in tools.

This patch reenables the signal when initialising a progress report.

---
 util/qemu-progress.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
util/qemu-progress.c +10 -0
index ad33fee..4ee5cd0 100644
@@ -82,12 +82,22 @@ static void progress_dummy_init(void)
 {
 #ifdef CONFIG_POSIX
     struct sigaction action;
+    sigset_t set;
 
     memset(&action, 0, sizeof(action));
     sigfillset(&action.sa_mask);
     action.sa_handler = sigusr_print;
     action.sa_flags = 0;
     sigaction(SIGUSR1, &action, NULL);
+
+    /*
+     * SIGUSR1 is SIG_IPI and gets blocked in qemu_init_main_loop(). In the
+     * tools that use the progress report SIGUSR1 isn't used in this meaning
+     * and instead should print the progress, so reenable it.
+     */
+    sigemptyset(&set);
+    sigaddset(&set, SIGUSR1);
+    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 #endif
 
     state.print = progress_dummy_print;
Signature · 1 line
1.8.1.4

I wonder if it worth it to restore the signal blocking state in progress_dummy_end to avoid future side effects.

author
#5 lore raw

PATCH 3/3 Documentation: qemu-img: Mention SIGUSR1 progress report

In reply to Kevin Wolf

Document the SIGUSR1 behaviour of qemu-img. Also, added compare to the list of subcommands that support -p.

---
 qemu-img.texi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-img.texi +3 -1
index 778e967..f86a86d 100644
@@ -57,7 +57,9 @@ indicates that target image must be compressed (qcow format only)
 @item -h
 with or without a command shows help and lists the supported formats
 @item -p
-display progress bar (convert and rebase commands only)
+display progress bar (compare, convert and rebase commands only).
+If the @var{-p} option is not used for a command that supports it, the
+progress is reported when the process receives a @code{SIGUSR1} signal.
 @item -q
 Quiet mode - do not print any output (except errors). There's no progress bar
 in case both @var{-q} and @var{-p} options are used.
Signature · 1 line
1.8.1.4
Reviewed-by Benoit Canet on v1 3/3
#6 lore raw

Re: [Qemu-devel] [PATCH 3/3] Documentation: qemu-img: Mention SIGUSR1 progress report

Quoted 27 lines · Kevin Wolf

Document the SIGUSR1 behaviour of qemu-img. Also, added compare to the list of subcommands that support -p.

---
 qemu-img.texi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-img.texi +3 -1
index 778e967..f86a86d 100644
@@ -57,7 +57,9 @@ indicates that target image must be compressed (qcow format only)
 @item -h
 with or without a command shows help and lists the supported formats
 @item -p
-display progress bar (convert and rebase commands only)
+display progress bar (compare, convert and rebase commands only).
+If the @var{-p} option is not used for a command that supports it, the
+progress is reported when the process receives a @code{SIGUSR1} signal.
 @item -q
 Quiet mode - do not print any output (except errors). There's no progress bar
 in case both @var{-q} and @var{-p} options are used.
Signature · 1 line
1.8.1.4