From nobody Sat Dec 21 13:03:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726477362027683.6734154037118; Mon, 16 Sep 2024 02:02:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 099EB12D2; Mon, 16 Sep 2024 05:02:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 65EEA1B26; Mon, 16 Sep 2024 05:00:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1E7241A89; Mon, 16 Sep 2024 05:00:40 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 19D231AB9 for ; Mon, 16 Sep 2024 05:00:11 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-_g91VnLKNFSH1nlEMM9Thg-1; Mon, 16 Sep 2024 05:00:09 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F6271955D4C for ; Mon, 16 Sep 2024 09:00:08 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DE32619560B0 for ; Mon, 16 Sep 2024 09:00:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726477210; h=from:from: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; bh=vzFu2n8wx1jLxXbwbZEmDInCtsobdNQy/k9Swujb5Kg=; b=bEs7ynEAWOSzWPP4sxziQrpFfuCCXW/nKSKyOrnnBs02sGy7bW56FttuG2RHq5anz+hrz5 EbKHnZHorS/MBUxC8iq8JfYfE/Q4o0H9ivdtkKMpSsgx0K7OU46s0R9p8RiEu1+OGlgbgl vruuAO0rp7hIw48Nz0FN58P5LaSl38w= X-MC-Unique: _g91VnLKNFSH1nlEMM9Thg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] Revert "vircommand: Parse /dev/fd on *BSD-like systems when looking for opened FDs" Date: Mon, 16 Sep 2024 11:00:04 +0200 Message-ID: <3481effd90c7bc63de9abf7a84e74dba02e81380.1726477204.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UJAIMXPNZAEXSDZSMUH7K5FPRCLQVAVC X-Message-ID-Hash: UJAIMXPNZAEXSDZSMUH7K5FPRCLQVAVC X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726477363796116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Unfortunately, devfs on FreeBSD (accessible via /dev/fd) exposes only those FDs which can be represented as a file. To cite manpage [1]: The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system. This means FDs representing pipes and/or unnamed sockets are not visible by default. To expose all FDs a slightly different filesystem must be mounted [2]: mount -t fdescfs none /dev/fd Apparently, on my test machine fdescfs is mounted by default and thus I haven't seen any problem. Only after aforementioned patch was merged our CI started reporting problems. While we could try to figure out whether correct FS is mounted, it's a needless micro optimization. Just revert the code to the state it was before I touched it. 1: https://man.freebsd.org/cgi/man.cgi?query=3Dfd&sektion=3D4&manpath=3Dfre= ebsd-release-ports 2: https://man.freebsd.org/cgi/man.cgi?query=3Dfdescfs&sektion=3D5&n=3D1 This reverts commit 308ec0fb2c77f4867179f00c628f05d1d784f370. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/util/vircommand.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 969d4c28ef..ea52acfbb8 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -472,7 +472,7 @@ virExecCommon(virCommand *cmd, gid_t *groups, int ngrou= ps) return 0; } =20 -# if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +# ifdef __linux__ static int virCommandMassCloseGetFDsDir(virBitmap *fds, const char *dirName) @@ -502,7 +502,7 @@ virCommandMassCloseGetFDsDir(virBitmap *fds, =20 return 0; } -# endif /* defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__= ) */ +# endif /* __linux__ */ =20 static int virCommandMassCloseGetFDs(virBitmap *fds) @@ -513,8 +513,6 @@ virCommandMassCloseGetFDs(virBitmap *fds) * onto child process (well, the one we will exec soon since this * is called from the child). */ return virCommandMassCloseGetFDsDir(fds, "/proc/self/fd"); -# elif defined(__APPLE__) || defined(__FreeBSD__) - return virCommandMassCloseGetFDsDir(fds, "/dev/fd"); # else virBitmapSetAll(fds); return 0; --=20 2.44.2