From nobody Thu May 9 22:15:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1653394874; cv=none; d=zohomail.com; s=zohoarc; b=e3Gsy0nhoV/JCJgWIp1mQYu1PtfHyGzqMhTSdRThVwDimpW8FDkLU5Zzz+Z3aEm7VtqKqGvv2a2hKrVLX4BvRNdggifwiBuQ7i2rW9xpDqInwa3ZN/+xIdvTIsHZoVBXPgQuJpG29eJOh/42d6vpA6R9yH/qZBP7OUnfOxOIgEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653394874; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=rwhOZJGyHsr36ORhZuJXWGfgRPF6B5RsSwBbBXvA0sU=; b=V9z9HfiZhQPVbsUxLZJwSwvpdRwxp+ncuKv3hZHnR+e19BgCAkQusNSVavMSErb1fHH6kRcRIt9FoOHNRaWFjenCMVZXznJ6J1wA2MWr7aK7Oga6tqMJBXQPrGGD6x+qMjG9gkEmd5PHTWLSJCPBME/n1mUWhVXlVqtcz3KvazI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1653394874565306.205459198728; Tue, 24 May 2022 05:21:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-9_J-qxMqNRGLmlGUKX-b-Q-1; Tue, 24 May 2022 08:21:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A69D01C05EAA; Tue, 24 May 2022 12:21:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13FCFC27E8A; Tue, 24 May 2022 12:21:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D9933194E101; Tue, 24 May 2022 12:21:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9ACF7194E100 for ; Tue, 24 May 2022 12:21:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 41BC8401E74; Tue, 24 May 2022 12:21:04 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD53F492C3B for ; Tue, 24 May 2022 12:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653394872; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rwhOZJGyHsr36ORhZuJXWGfgRPF6B5RsSwBbBXvA0sU=; b=VcaIJnZgVbbCil+q30G/IXIUmx3G8EVGuLEX4euohPWwrsQRt/wbYwdd6mmprWQdenFzgb TnqvECD3RhbAG7T8A6IOwA7HYRKZ13XmmaCl0VYMqywrvhkdoUz2FcV1LzQbIUKjhOGKHs 39+3L+XbA86qohlzltXJ8hluquNWRbU= X-MC-Unique: 9_J-qxMqNRGLmlGUKX-b-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] virprocess: Drop workaround for setns() wrt old glibc Date: Tue, 24 May 2022 14:21:01 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653394875686100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We have our own implementation of setns() which was introduced in v1.2.9-rc1~190 and extended afterwards. The reason was that back in 2014 we were dealing with glibc that in some of its older versions did not provide the function. Mostly for non-intel arches. Nevertheless, glibc now offers the function for all architectures we care about (aarch64 being the freshest architecture where the function was introduced, in glibc-2.17). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- v2 of: https://listman.redhat.com/archives/libvir-list/2022-May/231773.html diff to v1: - drop setns() detection in meson - make virProcessSetNamespaces() impl depend on __linux__ meson.build | 1 - src/util/virprocess.c | 55 +++++++++---------------------------------- 2 files changed, 11 insertions(+), 45 deletions(-) diff --git a/meson.build b/meson.build index a1c802b00d..c4585bd92c 100644 --- a/meson.build +++ b/meson.build @@ -557,7 +557,6 @@ functions =3D [ 'prlimit', 'sched_setscheduler', 'setgroups', - 'setns', 'setrlimit', 'symlink', 'sysctlbyname', diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 36d7df050a..5ed0b5d0db 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -27,7 +27,6 @@ #ifndef WIN32 # include #endif -#include #if WITH_SYS_MOUNT_H # include #endif @@ -70,49 +69,6 @@ =20 VIR_LOG_INIT("util.process"); =20 -#ifdef __linux__ -/* - * Workaround older glibc. While kernel may support the setns - * syscall, the glibc wrapper might not exist. If that's the - * case, use our own. - */ -# ifndef __NR_setns -# if defined(__x86_64__) -# define __NR_setns 308 -# elif defined(__i386__) -# define __NR_setns 346 -# elif defined(__arm__) -# define __NR_setns 375 -# elif defined(__aarch64__) -# define __NR_setns 375 -# elif defined(__powerpc__) -# define __NR_setns 350 -# elif defined(__s390__) -# define __NR_setns 339 -# endif -# endif - -# ifndef WITH_SETNS -# if defined(__NR_setns) -# include - -static inline int setns(int fd, int nstype) -{ - return syscall(__NR_setns, fd, nstype); -} -# else /* !__NR_setns */ -# error Please determine the syscall number for setns on your architectu= re -# endif -# endif -#else /* !__linux__ */ -static inline int setns(int fd G_GNUC_UNUSED, int nstype G_GNUC_UNUSED) -{ - virReportSystemError(ENOSYS, "%s", - _("Namespaces are not supported on this platform.= ")); - return -1; -} -#endif - VIR_ENUM_IMPL(virProcessSchedPolicy, VIR_PROC_POLICY_LAST, "none", @@ -714,6 +670,7 @@ int virProcessGetNamespaces(pid_t pid, } =20 =20 +#ifdef __linux__ int virProcessSetNamespaces(size_t nfdlist, int *fdlist) { @@ -742,6 +699,16 @@ int virProcessSetNamespaces(size_t nfdlist, } return 0; } +#else +int virProcessSetNamespaces(size_t nfdlist G_GNUC_UNUSED, + int *fdlist G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform.= ")); + return -1; +} +#endif + =20 #if WITH_PRLIMIT static int --=20 2.35.1