From nobody Sun May 12 06:50:26 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=1653392470; cv=none; d=zohomail.com; s=zohoarc; b=JfxoGdwpx9NbRpOCjksNYY7NdM+GSw1E9Ik0GQ+k58/IUSW7nI98e9rovHFhEy+UsOxxHYOWOHc/NZhTpvo9ISwXS9wGdhj6ggmnp9vPbB9CM68ihdTdXetjJ+8HG5HA77A4j4P0sOhxJBE1oQ9+3vLzelcki57PC6UQdezgY84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392470; 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=TpTddFflBx7UhNlvYx7rz2/V+lqajvJktYICSUTHhjk=; b=CO3weZitGKCspuR2I+ciLwuFrvs0mqcG+LukSkeRsY4rdKkhHxcJlwgUKxggXp0aWA3uUHsX1A3IpX0E5yy0Dz83WrOAQoxNVXaUs+9E8YMsqy5ndTDidgw7YQF59ouCFBeETlHdyOfSljJN3K9aATcm2CLhWIBEK7qMCe/lRIY= 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 1653392470784600.8970671978152; Tue, 24 May 2022 04:41:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-ab7f3DzCPyGhc7pdX_Zvkg-1; Tue, 24 May 2022 07:41:05 -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 7B0B9851786; Tue, 24 May 2022 11:41:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5079CC27E8A; Tue, 24 May 2022 11:41:00 +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 0A6BE1949761; Tue, 24 May 2022 11:41:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B76F1949759 for ; Tue, 24 May 2022 11:40:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 059B9C23DC9; Tue, 24 May 2022 11:40:59 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A17C0C202D1 for ; Tue, 24 May 2022 11:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653392469; 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=TpTddFflBx7UhNlvYx7rz2/V+lqajvJktYICSUTHhjk=; b=EhB4GpjtFQaBPLWp1tgTHkZYYrrC2PdOAlL/O1iffDM5gyn/Yy9NOVD39JM+BOEJvk5Eq5 0CxrDuX1+N2XaCG+YU0jGkHmd1bkEbOWOroD/tO2fFwbuXq7sx4rMcGKdGfVfYW9Ao9lTp y28nWyJu2E795NUhrsZzMIQErchmrF8= X-MC-Unique: ab7f3DzCPyGhc7pdX_Zvkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virprocess: Drop workaround for setns() wrt old glibc Date: Tue, 24 May 2022 13:40:54 +0200 Message-Id: <2ce81dd0ae96b16893c718e7b068019bfff91096.1653392454.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: 1653392471126100001 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 --- src/util/virprocess.c | 55 +++++++++---------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 36d7df050a..f0a79396e7 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 +#if WITH_SETNS 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