From 13fefaf37fd083ed2a928c414a983b16b0f2d5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 11 Oct 2012 17:12:13 +0200 Subject: [PATCH] virsh: block SIGINT while getting BlockJobInfo SIGINT hasn't been blocked, which could lead to losing it somewhere in virDomainGetBlockJobInfo and not aborting the job. --- tools/virsh-domain.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1df0872df2..903242038b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1308,7 +1308,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd) int timeout = 0; struct sigaction sig_action; struct sigaction old_sig_action; - sigset_t sigmask; + sigset_t sigmask, oldsigmask; struct timeval start; struct timeval curr; const char *path = NULL; @@ -1361,7 +1361,11 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd) while (blocking) { virDomainBlockJobInfo info; - int result = virDomainGetBlockJobInfo(dom, path, &info, 0); + int result; + + pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); + result = virDomainGetBlockJobInfo(dom, path, &info, 0); + pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); if (result < 0) { vshError(ctl, _("failed to query job for disk %s"), path); @@ -1450,7 +1454,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd) int timeout = 0; struct sigaction sig_action; struct sigaction old_sig_action; - sigset_t sigmask; + sigset_t sigmask, oldsigmask; struct timeval start; struct timeval curr; const char *path = NULL; @@ -1507,7 +1511,11 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd) while (blocking) { virDomainBlockJobInfo info; - int result = virDomainGetBlockJobInfo(dom, path, &info, 0); + int result; + + pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); + result = virDomainGetBlockJobInfo(dom, path, &info, 0); + pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); if (result <= 0) { vshError(ctl, _("failed to query job for disk %s"), path); @@ -1674,7 +1682,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) int timeout = 0; struct sigaction sig_action; struct sigaction old_sig_action; - sigset_t sigmask; + sigset_t sigmask, oldsigmask; struct timeval start; struct timeval curr; const char *path = NULL; @@ -1727,7 +1735,11 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) while (blocking) { virDomainBlockJobInfo info; - int result = virDomainGetBlockJobInfo(dom, path, &info, 0); + int result; + + pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); + result = virDomainGetBlockJobInfo(dom, path, &info, 0); + pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); if (result < 0) { vshError(ctl, _("failed to query job for disk %s"), path);