File libvirt-virsh-block-SIGINT-while-getting-BlockJobInfo.patch of Package libvirt
From 0007d23e00cae47990ce96fc3eb87f4f933b10f4 Mon Sep 17 00:00:00 2001
Message-Id: <0007d23e00cae47990ce96fc3eb87f4f933b10f4.1350297261.git.jdenemar@redhat.com>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 12 Oct 2012 16:19:38 +0200
Subject: [PATCH] virsh: block SIGINT while getting BlockJobInfo
https://bugzilla.redhat.com/show_bug.cgi?id=845448
SIGINT hasn't been blocked, which could lead to losing it somewhere in
virDomainGetBlockJobInfo and not aborting the job.
(cherry picked from commit 13fefaf37fd083ed2a928c414a983b16b0f2d5b7)
---
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 1df0872..9032420 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);
--
1.7.12.3