From nobody Mon Feb 9 14:15:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1579779913; cv=none; d=zohomail.com; s=zohoarc; b=eh51pXtNMOtojfm5Ul9dB5Ljm++plExU6LJjm8MzUgzhjR3KrqxfC1j0sOL5+vUvIL2gj1qZtttjP1i33FjOax9CFCOcOBo5wWrlGdWJo1e4N+bAnFIrrtLQAPmvIU+Rm3OCoFqLgxYzbPUvGLbwtDiPJm8KGYS4H1wsScTCYFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579779913; 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=IuCbYmFS4GPY5usoqlkllqZs6Qntdd0BpB7z5jBA1qo=; b=ZrYKToG3NNtkTdWtC3rIaHc7sJewNrFw0GpIzkdDvwWmQ9fRDdHrtnuv1/5DZiPekgUAl664DKnstfjQzMleKr/CrjazRrlNWAKj4BZICQJBbLOuyaeTzQEL5a6nwLJL7KFJhWBv6movHP3j5MsEhr9F68QBxg2dVqw3HRaHp2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1579779913909812.7965552873112; Thu, 23 Jan 2020 03:45:13 -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-293-gVElXhwWMriU3QFegTLJxw-1; Thu, 23 Jan 2020 06:44:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6FDD4800D41; Thu, 23 Jan 2020 11:44:04 +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 431FD28991; Thu, 23 Jan 2020 11:44:04 +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 D9A831803C33; Thu, 23 Jan 2020 11:44:03 +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 00NBi0Ml025456 for ; Thu, 23 Jan 2020 06:44:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 558118575D; Thu, 23 Jan 2020 11:44:00 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06C288575C; Thu, 23 Jan 2020 11:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579779912; 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=IuCbYmFS4GPY5usoqlkllqZs6Qntdd0BpB7z5jBA1qo=; b=H7lbKcv7oWhJiRTnGEyQO1pWxcTP83/cAM7OoLNn9+Wb/pP8x9nm8QZu8xGcsL674FOvtl AFKwET5NJaqQGsIxI3489i0PmxLr35TaogbxcJ1K5HvHufYlITzPVH85XyAVXwk7cK8wZ9 dYkPNn36gyNQuOJGHMP0UcLjke831nY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 18/32] util: conditionalize virProcess APIs on Windows Date: Thu, 23 Jan 2020 11:43:11 +0000 Message-Id: <20200123114325.3860881-19-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.23 X-MC-Unique: gVElXhwWMriU3QFegTLJxw-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" Many of the virProcess APIs are relying on GNULIB providing POSIX API stubs. Even with these stubs the APIs don't do anything useful once compiled. We can thus conditionalize the code so that we don't compile anything at all. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virprocess.c | 98 +++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d8ee3142da..60419538e2 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -24,7 +24,9 @@ =20 #include #include -#include +#ifndef WIN32 +# include +#endif #include #if HAVE_SYS_MOUNT_H # include @@ -121,6 +123,8 @@ VIR_ENUM_IMPL(virProcessSchedPolicy, "rr", ); =20 + +#ifndef WIN32 /** * virProcessTranslateStatus: * @status: child exit status to translate @@ -146,7 +150,6 @@ virProcessTranslateStatus(int status) } =20 =20 -#ifndef WIN32 /** * virProcessAbort: * @pid: child process to kill @@ -206,14 +209,6 @@ virProcessAbort(pid_t pid) cleanup: errno =3D saved_errno; } -#else -void -virProcessAbort(pid_t pid) -{ - /* Not yet ported to mingw. Any volunteers? */ - VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid); -} -#endif =20 =20 /** @@ -282,6 +277,33 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw) return -1; } =20 +#else /* WIN32 */ + +char * +virProcessTranslateStatus(int status) +{ + return g_strdup_printf(_("invalid value %d"), status); +} + + +void +virProcessAbort(pid_t pid) +{ + /* Not yet ported to mingw. Any volunteers? */ + VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid); +} + + +int +virProcessWait(pid_t pid, int *exitstatus G_GNUC_UNUSED, bool raw G_GNUC_U= NUSED) +{ + virReportSystemError(ENOSYS, _("unable to wait for process %lld"), + (long long) pid); + return -1; +} + +#endif /* WIN32 */ + =20 /* send signal to a single process */ int virProcessKill(pid_t pid, int sig) @@ -1036,6 +1058,7 @@ int virProcessGetStartTime(pid_t pid, #endif =20 =20 +#ifdef __linux__ typedef struct _virProcessNamespaceHelperData virProcessNamespaceHelperDat= a; struct _virProcessNamespaceHelperData { pid_t pid; @@ -1088,7 +1111,22 @@ virProcessRunInMountNamespace(pid_t pid, return virProcessRunInFork(virProcessNamespaceHelper, &data); } =20 +#else /* ! __linux__ */ =20 +int +virProcessRunInMountNamespace(pid_t pid G_GNUC_UNUSED, + virProcessNamespaceCallback cb G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform"= )); + return -1; +} + +#endif /* ! __linux__ */ + + +#ifndef WIN32 static int virProcessRunInForkHelper(int errfd, pid_t ppid, @@ -1174,8 +1212,21 @@ virProcessRunInFork(virProcessForkCallback cb, return ret; } =20 +#else /* WIN32 */ + +int +virProcessRunInFork(virProcessForkCallback cb G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Process spawning is not supported on this plat= form")); + return -1; +} + +#endif /* WIN32 */ =20 -#if defined(HAVE_SYS_MOUNT_H) && defined(HAVE_UNSHARE) + +#if defined(__linux__) int virProcessSetupPrivateMountNS(void) { @@ -1194,24 +1245,14 @@ virProcessSetupPrivateMountNS(void) return 0; } =20 -#else /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */ - -int -virProcessSetupPrivateMountNS(void) -{ - virReportSystemError(ENOSYS, "%s", - _("Namespaces are not supported on this platform.= ")); - return -1; -} -#endif /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */ =20 -#if defined(__linux__) G_GNUC_NORETURN static int virProcessDummyChild(void *argv G_GNUC_UNUSED) { _exit(0); } =20 + /** * virProcessNamespaceAvailable: * @ns: what namespaces to check (bitwise-OR of virProcessNamespaceFlags) @@ -1269,6 +1310,14 @@ virProcessNamespaceAvailable(unsigned int ns) =20 #else /* !defined(__linux__) */ =20 +int +virProcessSetupPrivateMountNS(void) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform.= ")); + return -1; +} + int virProcessNamespaceAvailable(unsigned int ns G_GNUC_UNUSED) { @@ -1276,6 +1325,7 @@ virProcessNamespaceAvailable(unsigned int ns G_GNUC_U= NUSED) _("Namespaces are not supported on this platform.= ")); return -1; } + #endif /* !defined(__linux__) */ =20 /** @@ -1296,6 +1346,7 @@ virProcessExitWithStatus(int status) { int value =3D EXIT_CANNOT_INVOKE; =20 +#ifndef WIN32 if (WIFEXITED(status)) { value =3D WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { @@ -1312,6 +1363,9 @@ virProcessExitWithStatus(int status) raise(WTERMSIG(status)); value =3D 128 + WTERMSIG(status); } +#else /* WIN32 */ + (void)status; +#endif /* WIN32 */ exit(value); } =20 --=20 2.24.1