From nobody Mon Feb 9 14:15:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579779912; cv=none; d=zohomail.com; s=zohoarc; b=FFb/msbZ/nSoDvO1wCOrsBS60DCo9HoRvJeFtGD+uY4x2/j1js7eaKLMG2ALE+lUVuk7npEOuTLZ5vPqeGoVZP+tRpyemJSCnc7uQH+2jJz1TnXJs9zBidFwoglQLVIAWIgW3MtIgOpy0MAaGdmGfnxGbsxSIY1XzVKWQmYGXnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579779912; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Or5csbEVrEUmyupc3LP49ggskEEqRNKBmGmyjlgSjGw=; b=e8yXDerwUmrECngmI8W7NoAb5zC5bHYpV83YcOBgFZBVA/qXzxOht5ApxkiovJs862X5LmvLXE0qJzAkYVOLOeJ9XvZb9OJ7SfyA4KOLMJXLsnxBzGa/JetQzIYQsx4Xjhef/Ue0uJLh/Cm2t0XhVCghkDrQfNqQ2eNBUTF+Anc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1579779912755250.54126522645788; Thu, 23 Jan 2020 03:45:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-fDKETBwyOLqS0oaqmXtZHA-1; Thu, 23 Jan 2020 06:44:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 911D51005F72; Thu, 23 Jan 2020 11:44:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E31410631CD; Thu, 23 Jan 2020 11:44:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 725D21802030; Thu, 23 Jan 2020 11:43:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00NBhss5025403 for ; Thu, 23 Jan 2020 06:43:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 634368575C; Thu, 23 Jan 2020 11:43:54 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 753A39CA3; Thu, 23 Jan 2020 11:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579779911; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Or5csbEVrEUmyupc3LP49ggskEEqRNKBmGmyjlgSjGw=; b=ST+ZynhJB5yg6NtMZLYa9emBrKwlbD45o/IlSF92n+U76VPYr0crm5sN4jcRv10yIKG/oK Gn+FqRZzcr/BzvNvkp8loGXi5wjVIkCsMUYNP/d66neWXWuNT7MjH9bf3xWZPF2uCuV+tf 6TOssY7z/8sjq49YzR6wf1iVS3I0I9M= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/32] rpc: conditionalize signal handling Date: Thu, 23 Jan 2020 11:43:05 +0000 Message-Id: <20200123114325.3860881-13-berrange@redhat.com> In-Reply-To: <20200123114325.3860881-1-berrange@redhat.com> References: <20200123114325.3860881-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: fDKETBwyOLqS0oaqmXtZHA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Windows platform does not have the signal handling support we need, so it must be disabled in several parts of the codebase. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetclient.c | 33 ++++++++++++++++++++++-------- src/rpc/virnetdaemon.c | 35 +++++++++++++++++++++++++++++--- src/rpc/virnetdaemon.h | 4 ++++ tools/virsh-domain.c | 46 +++++++++++++++++++++++++++++++++++++----- tools/vsh.c | 12 ++++++++++- 5 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 50489b754c..eac02282e6 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -845,16 +845,19 @@ int virNetClientSetTLSSession(virNetClientPtr client, char buf[1]; int len; struct pollfd fds[1]; + +# ifndef WIN32 sigset_t oldmask, blockedsigs; =20 sigemptyset(&blockedsigs); -# ifdef SIGWINCH +# ifdef SIGWINCH sigaddset(&blockedsigs, SIGWINCH); -# endif -# ifdef SIGCHLD +# endif +# ifdef SIGCHLD sigaddset(&blockedsigs, SIGCHLD); -# endif +# endif sigaddset(&blockedsigs, SIGPIPE); +# endif /* !WIN32 */ =20 virObjectLock(client); =20 @@ -880,19 +883,23 @@ int virNetClientSetTLSSession(virNetClientPtr client, else fds[0].events =3D POLLOUT; =20 +# ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs, * then restore the original signal mask again immediately * after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE * at the suggestion of Paolo Bonzini and Daniel Berrange. */ ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +# endif /* !WIN32 */ =20 repoll: ret =3D poll(fds, G_N_ELEMENTS(fds), -1); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll; =20 +# ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +# endif /* !WIN32 */ } =20 ret =3D virNetTLSContextCheckCertificate(tls, client->tls); @@ -908,15 +915,19 @@ int virNetClientSetTLSSession(virNetClientPtr client, fds[0].revents =3D 0; fds[0].events =3D POLLIN; =20 +# ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs */ ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +# endif /* !WIN32 */ =20 repoll2: ret =3D poll(fds, G_N_ELEMENTS(fds), -1); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll2; =20 +# ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +# endif /* !WIN32 */ =20 len =3D virNetTLSSessionRead(client->tls, buf, 1); if (len < 0 && errno !=3D ENOMSG) { @@ -1574,7 +1585,9 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, =20 for (;;) { char ignore; +#ifndef WIN32 sigset_t oldmask, blockedsigs; +#endif /* !WIN32 */ int timeout =3D -1; virNetMessagePtr msg =3D NULL; =20 @@ -1615,27 +1628,31 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, * can stuff themselves on the queue */ virObjectUnlock(client); =20 +#ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs, * then restore the original signal mask again immediately * after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE * at the suggestion of Paolo Bonzini and Daniel Berrange. */ sigemptyset(&blockedsigs); -#ifdef SIGWINCH +# ifdef SIGWINCH sigaddset(&blockedsigs, SIGWINCH); -#endif -#ifdef SIGCHLD +# endif +# ifdef SIGCHLD sigaddset(&blockedsigs, SIGCHLD); -#endif +# endif sigaddset(&blockedsigs, SIGPIPE); ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +#endif /* !WIN32 */ =20 repoll: ret =3D poll(fds, G_N_ELEMENTS(fds), timeout); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll; =20 +#ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +#endif /* !WIN32 */ =20 virObjectLock(client); =20 diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 570930436a..9634e93b52 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -45,6 +45,7 @@ =20 VIR_LOG_INIT("rpc.netdaemon"); =20 +#ifndef WIN32 typedef struct _virNetDaemonSignal virNetDaemonSignal; typedef virNetDaemonSignal *virNetDaemonSignalPtr; =20 @@ -54,17 +55,20 @@ struct _virNetDaemonSignal { virNetDaemonSignalFunc func; void *opaque; }; +#endif /* !WIN32 */ =20 struct _virNetDaemon { virObjectLockable parent; =20 bool privileged; =20 +#ifndef WIN32 size_t nsignals; virNetDaemonSignalPtr *signals; int sigread; int sigwrite; int sigwatch; +#endif /* !WIN32 */ =20 virHashTablePtr servers; virJSONValuePtr srvObject; @@ -84,10 +88,9 @@ static void virNetDaemonDispose(void *obj) { virNetDaemonPtr dmn =3D obj; +#ifndef WIN32 size_t i; =20 - VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); - for (i =3D 0; i < dmn->nsignals; i++) { sigaction(dmn->signals[i]->signum, &dmn->signals[i]->oldaction, NU= LL); VIR_FREE(dmn->signals[i]); @@ -97,6 +100,9 @@ virNetDaemonDispose(void *obj) VIR_FORCE_CLOSE(dmn->sigwrite); if (dmn->sigwatch > 0) virEventRemoveHandle(dmn->sigwatch); +#endif /* !WIN32 */ + + VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); =20 virHashFree(dmn->servers); =20 @@ -119,7 +125,9 @@ virNetDaemonPtr virNetDaemonNew(void) { virNetDaemonPtr dmn; +#ifndef WIN32 struct sigaction sig_action; +#endif /* !WIN32 */ =20 if (virNetDaemonInitialize() < 0) return NULL; @@ -130,16 +138,21 @@ virNetDaemonNew(void) if (!(dmn->servers =3D virHashCreate(5, virObjectFreeHashData))) goto error; =20 +#ifndef WIN32 dmn->sigwrite =3D dmn->sigread =3D -1; +#endif /* !WIN32 */ + dmn->privileged =3D geteuid() =3D=3D 0; dmn->autoShutdownInhibitFd =3D -1; =20 if (virEventRegisterDefaultImpl() < 0) goto error; =20 +#ifndef WIN32 memset(&sig_action, 0, sizeof(sig_action)); sig_action.sa_handler =3D SIG_IGN; sigaction(SIGPIPE, &sig_action, NULL); +#endif /* !WIN32 */ =20 return dmn; =20 @@ -587,7 +600,7 @@ virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dm= n) } =20 =20 - +#ifndef WIN32 static sig_atomic_t sigErrors; static int sigLastErrno; static int sigWrite =3D -1; @@ -689,6 +702,7 @@ virNetDaemonSignalSetup(virNetDaemonPtr dmn) return -1; } =20 + int virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, int signum, @@ -731,6 +745,21 @@ virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, return -1; } =20 +#else /* WIN32 */ + +int +virNetDaemonAddSignalHandler(virNetDaemonPtr dmn G_GNUC_UNUSED, + int signum G_GNUC_UNUSED, + virNetDaemonSignalFunc func G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Signal handling not available on this platform= ")); + return -1; +} + +#endif /* WIN32 */ + =20 static void virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h index 5a9842bee6..c2c7767037 100644 --- a/src/rpc/virnetdaemon.h +++ b/src/rpc/virnetdaemon.h @@ -55,6 +55,10 @@ void virNetDaemonAutoShutdown(virNetDaemonPtr dmn, void virNetDaemonAddShutdownInhibition(virNetDaemonPtr dmn); void virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dmn); =20 +#ifdef WIN32 +# define siginfo_t void +#endif + typedef void (*virNetDaemonSignalFunc)(virNetDaemonPtr dmn, siginfo_t *inf= o, void *opaque); =20 int virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e64e08e5da..df4a03290f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1697,12 +1697,14 @@ virshPrintJobProgress(const char *label, unsigned l= ong long remaining, =20 static volatile sig_atomic_t intCaught; =20 +#ifndef WIN32 static void virshCatchInt(int sig G_GNUC_UNUSED, siginfo_t *siginfo G_GNUC_UNUSED, void *context G_GNUC_UNUSED) { intCaught =3D 1; } +#endif /* !WIN32 */ =20 =20 typedef struct _virshBlockJobWaitData virshBlockJobWaitData; @@ -1842,11 +1844,11 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) * the event to the given block job we will wait for the number of ret= ries * before claiming that we entered synchronised phase */ unsigned int retries =3D 5; - +#ifndef WIN32 struct sigaction sig_action; struct sigaction old_sig_action; sigset_t sigmask, oldsigmask; - +#endif /* !WIN32 */ unsigned long long start =3D 0; unsigned long long curr =3D 0; =20 @@ -1861,6 +1863,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) if (data->async_abort) abort_flags |=3D VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC; =20 +#ifndef WIN32 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); =20 @@ -1869,6 +1872,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) sig_action.sa_flags =3D SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); +#endif /* !WIN32 */ =20 if (data->timeout && virTimeMillisNow(&start) < 0) { vshSaveLibvirtError(); @@ -1878,9 +1882,13 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) last.cur =3D last.end =3D 0; =20 while (true) { +#ifndef WIN32 pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); +#endif /* !WIN32 */ result =3D virDomainGetBlockJobInfo(data->dom, data->dev, &info, 0= ); +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); +#endif /* !WIN32 */ =20 if (result < 0) { vshError(data->ctl, _("failed to query job for disk %s"), data= ->dev); @@ -1944,7 +1952,9 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) virshPrintJobProgress(data->job_name, 0, 1); =20 cleanup: +#ifndef WIN32 sigaction(SIGINT, &old_sig_action, NULL); +#endif /* !WIN32 */ return ret; } =20 @@ -4226,12 +4236,14 @@ doSave(void *opaque) unsigned int flags =3D 0; const char *xmlfile =3D NULL; char *xml =3D NULL; +#ifndef WIN32 sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) goto out; @@ -4265,8 +4277,10 @@ doSave(void *opaque) ret =3D '0'; =20 out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virshDomainFree(dom); VIR_FREE(xml); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); @@ -4285,8 +4299,11 @@ virshWatchJob(vshControl *ctl, void *opaque, const char *label) { +#ifndef WIN32 struct sigaction sig_action; struct sigaction old_sig_action; + sigset_t sigmask, oldsigmask; +#endif /* !WIN32 */ struct pollfd pollfd[2] =3D {{.fd =3D pipe_fd, .events =3D POLLIN, .re= vents =3D 0}, {.fd =3D STDIN_FILENO, .events =3D POLLIN, = .revents =3D 0}}; unsigned long long start_us, curr_us; @@ -4294,10 +4311,10 @@ virshWatchJob(vshControl *ctl, int ret =3D -1; char retchar; bool functionReturn =3D false; - sigset_t sigmask, oldsigmask; bool jobStarted =3D false; nfds_t npollfd =3D 2; =20 +#ifndef WIN32 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); =20 @@ -4306,6 +4323,7 @@ virshWatchJob(vshControl *ctl, sig_action.sa_flags =3D SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); +#endif /* !WIN32 */ =20 /* don't poll on STDIN if we are not using a terminal */ if (!vshTTYAvailable(ctl)) @@ -4355,9 +4373,13 @@ virshWatchJob(vshControl *ctl, } =20 if (verbose || !jobStarted) { +#ifndef WIN32 pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); +#endif /* !WIN32 */ ret =3D virDomainGetJobInfo(dom, &jobinfo); +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); +#endif /* !WIN32 */ if (ret =3D=3D 0) { if (verbose && jobinfo.dataTotal > 0) virshPrintJobProgress(label, jobinfo.dataRemaining, @@ -4378,7 +4400,9 @@ virshWatchJob(vshControl *ctl, functionReturn =3D true; =20 cleanup: +#ifndef WIN32 sigaction(SIGINT, &old_sig_action, NULL); +#endif /* !WIN32 */ vshTTYRestore(ctl); return functionReturn; } @@ -4662,12 +4686,14 @@ doManagedsave(void *opaque) virDomainPtr dom =3D NULL; const char *name; unsigned int flags =3D 0; +#ifndef WIN32 sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptBool(cmd, "bypass-cache")) flags |=3D VIR_DOMAIN_SAVE_BYPASS_CACHE; @@ -4686,8 +4712,10 @@ doManagedsave(void *opaque) =20 ret =3D '0'; out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); } @@ -5340,17 +5368,19 @@ doDump(void *opaque) vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; virDomainPtr dom =3D NULL; - sigset_t sigmask, oldsigmask; const char *name =3D NULL; const char *to =3D NULL; unsigned int flags =3D 0; const char *format =3D NULL; unsigned int dumpformat =3D VIR_DOMAIN_CORE_DUMP_FORMAT_RAW; +#ifndef WIN32 + sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) goto out; @@ -5407,8 +5437,10 @@ doDump(void *opaque) =20 ret =3D '0'; out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ if (dom) virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); @@ -10601,7 +10633,6 @@ doMigrate(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - sigset_t sigmask, oldsigmask; virTypedParameterPtr params =3D NULL; int nparams =3D 0; int maxparams =3D 0; @@ -10609,11 +10640,14 @@ doMigrate(void *opaque) unsigned long long ullOpt =3D 0; int rv; virConnectPtr dconn =3D data->dconn; +#ifndef WIN32 + sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto out; @@ -10881,8 +10915,10 @@ doMigrate(void *opaque) } =20 out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virTypedParamsFree(params, nparams); virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); diff --git a/tools/vsh.c b/tools/vsh.c index 949c8dad7b..39bb75f192 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2013,6 +2013,7 @@ vshEventLoop(void *opaque) =20 /* We want to use SIGINT to cancel a wait; but as signal handlers * don't have an opaque argument, we have to use static storage. */ +#ifndef WIN32 static int vshEventFd =3D -1; static struct sigaction vshEventOldAction; =20 @@ -2027,6 +2028,7 @@ vshEventInt(int sig G_GNUC_UNUSED, if (vshEventFd >=3D 0) ignore_value(safewrite(vshEventFd, &reason, 1)); } +#endif /* !WIN32 */ =20 =20 /* Event loop handler used to limit length of waiting for any other event.= */ @@ -2057,10 +2059,13 @@ vshEventTimeout(int timer G_GNUC_UNUSED, int vshEventStart(vshControl *ctl, int timeout_ms) { +#ifndef WIN32 struct sigaction action; + assert(vshEventFd =3D=3D -1); +#endif /* !WIN32 */ =20 assert(ctl->eventPipe[0] =3D=3D -1 && ctl->eventPipe[1] =3D=3D -1 && - vshEventFd =3D=3D -1 && ctl->eventTimerId >=3D 0); + ctl->eventTimerId >=3D 0); if (pipe2(ctl->eventPipe, O_CLOEXEC) < 0) { char ebuf[1024]; =20 @@ -2068,12 +2073,15 @@ vshEventStart(vshControl *ctl, int timeout_ms) virStrerror(errno, ebuf, sizeof(ebuf))); return -1; } + +#ifndef WIN32 vshEventFd =3D ctl->eventPipe[1]; =20 action.sa_sigaction =3D vshEventInt; action.sa_flags =3D SA_SIGINFO; sigemptyset(&action.sa_mask); sigaction(SIGINT, &action, &vshEventOldAction); +#endif /* !WIN32 */ =20 if (timeout_ms) virEventUpdateTimeout(ctl->eventTimerId, timeout_ms); @@ -2140,10 +2148,12 @@ vshEventWait(vshControl *ctl) void vshEventCleanup(vshControl *ctl) { +#ifndef WIN32 if (vshEventFd >=3D 0) { sigaction(SIGINT, &vshEventOldAction, NULL); vshEventFd =3D -1; } +#endif /* !WIN32 */ VIR_FORCE_CLOSE(ctl->eventPipe[0]); VIR_FORCE_CLOSE(ctl->eventPipe[1]); virEventUpdateTimeout(ctl->eventTimerId, -1); --=20 2.24.1