]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: block SIGINT while getting BlockJobInfo
authorJán Tomko <jtomko@redhat.com>
Thu, 11 Oct 2012 15:12:13 +0000 (17:12 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 12 Oct 2012 03:01:54 +0000 (21:01 -0600)
SIGINT hasn't been blocked, which could lead to losing it somewhere in
virDomainGetBlockJobInfo and not aborting the job.

tools/virsh-domain.c

index 1df0872df2e0d6e5b1a61b2e9b876d704d81e6c9..903242038bc340a26e11fd6b27da3280fb6ba231 100644 (file)
@@ -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);