From nobody Mon Feb 9 19:05:28 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1710927015102944.4440681491567; Wed, 20 Mar 2024 02:30:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D49311A93; Wed, 20 Mar 2024 05:30:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9873A1EE7; Wed, 20 Mar 2024 05:20:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2902E1B65; Wed, 20 Mar 2024 05:19:36 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 2DE9D1BB1 for ; Wed, 20 Mar 2024 05:19:33 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-4sZxNtoUNKixnJ02cTi4Qw-1; Wed, 20 Mar 2024 05:19:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18D5B1C00B8E; Wed, 20 Mar 2024 09:19:29 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.225.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AB82C1576F; Wed, 20 Mar 2024 09:19:28 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 4sZxNtoUNKixnJ02cTi4Qw-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 08/10] utils: Use overrides in virFileIsSharedFS() Date: Wed, 20 Mar 2024 10:19:13 +0100 Message-ID: <20240320091915.369391-9-abologna@redhat.com> In-Reply-To: <20240320091915.369391-1-abologna@redhat.com> References: <20240320091915.369391-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: HKDDJHTZEZ2MV3OGYT47WKAB3OC2AR64 X-Message-ID-Hash: HKDDJHTZEZ2MV3OGYT47WKAB3OC2AR64 X-MailFrom: abologna@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 CC: Stefan Berger 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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710927015873100001 If the filesystem wasn't determined to be a shared one via the type check, try comparing it with the additional paths that have been configured by the local admin. Signed-off-by: Andrea Bolognani --- src/util/virfile.c | 86 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 14 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index a6a7de9829..ac9b5a77a6 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3795,22 +3795,80 @@ virFileGetDefaultHugepage(virHugeTLBFS *fs, return NULL; } =20 +static int +virFileIsSharedFSOverrideCompare(const char *path, + char *const *overrides) +{ + char *const *iter =3D overrides; + + while (*iter !=3D NULL) { + if (STREQ(path, *iter)) + return 1; + iter++; + } + + return 0; +} + +static int +virFileIsSharedFSOverride(const char *path, + char *const *overrides) +{ + g_autofree char *dirpath =3D NULL; + char *p =3D NULL; + int ret =3D 0; + + if (!path || path[0] !=3D '/' || !overrides) + return ret; + + dirpath =3D g_strdup(path); + + ret =3D virFileIsSharedFSOverrideCompare(dirpath, overrides); + + /* Continue until we've scanned the entire path or found a match */ + while (p !=3D dirpath && ret =3D=3D 0) { + + /* Find the last slash */ + if ((p =3D strrchr(dirpath, '/')) =3D=3D NULL) + break; + + /* Truncate the path by overwriting the slash that we've just + * found with a null byte. If it is the very first slash in + * the path, we need to handle things slightly differently */ + if (p =3D=3D dirpath) + *(p+1) =3D '\0'; + else + *p =3D '\0'; + + ret =3D virFileIsSharedFSOverrideCompare(dirpath, overrides); + } + + return ret; +} + int virFileIsSharedFS(const char *path, - char *const *overrides G_GNUC_UNUSED) + char *const *overrides) { - return virFileIsSharedFSType(path, - VIR_FILE_SHFS_NFS | - VIR_FILE_SHFS_GFS2 | - VIR_FILE_SHFS_OCFS | - VIR_FILE_SHFS_AFS | - VIR_FILE_SHFS_SMB | - VIR_FILE_SHFS_CIFS | - VIR_FILE_SHFS_CEPH | - VIR_FILE_SHFS_GPFS| - VIR_FILE_SHFS_QB | - VIR_FILE_SHFS_ACFS | - VIR_FILE_SHFS_GLUSTERFS | - VIR_FILE_SHFS_BEEGFS); + int ret; + + ret =3D virFileIsSharedFSType(path, + VIR_FILE_SHFS_NFS | + VIR_FILE_SHFS_GFS2 | + VIR_FILE_SHFS_OCFS | + VIR_FILE_SHFS_AFS | + VIR_FILE_SHFS_SMB | + VIR_FILE_SHFS_CIFS | + VIR_FILE_SHFS_CEPH | + VIR_FILE_SHFS_GPFS| + VIR_FILE_SHFS_QB | + VIR_FILE_SHFS_ACFS | + VIR_FILE_SHFS_GLUSTERFS | + VIR_FILE_SHFS_BEEGFS); + + if (ret =3D=3D 0) + ret =3D virFileIsSharedFSOverride(path, overrides); + + return ret; } =20 =20 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org