From nobody Fri Jul 26 23:58:34 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=1678264149; cv=none; d=zohomail.com; s=zohoarc; b=T6bvY9UHOliEVa/bK5oqXO/uI0EG2Y7RB1IDxztCCJx5qgolG2zfLj3B5B2TSBZWrUJAUhlwRWM/TNdcADTFuiobpkWNQSOqKQX8ShmWuVd2iZ0Smkhd8h2hyviAbtFwvCgdc47oo1ao7GBbyq1QxV8cQ33DjmMx+ZAPGGPNPD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678264149; 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=r5hdTVJ6HqZhK3KEVxHG7p12mXdi95hgWCNipJtHn5s=; b=mbODRSMTHkqxGbXWsOqiAkuEH3oYuspc+vKpeAbQ1DmNfcDSIXyOh2Jiv6MRgvhYDW8ctUpBr7jJE1GqTjkOxARZKIuNgKC/FHPMbskZoLzqyNdyP5kvBZjRMOHnD7HDM5YwaiZfLoeKtsAFveciDr1YxRaenW8YYi7vn5p6KYA= 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 1678264149790714.8749297768946; Wed, 8 Mar 2023 00:29:09 -0800 (PST) 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-42-2mGPoEPdOLS2N9o5oumjzg-1; Wed, 08 Mar 2023 03:28:48 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CE2038035A0; Wed, 8 Mar 2023 08:28:45 +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 0A35E492B08; Wed, 8 Mar 2023 08:28:45 +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 EC9C01946A7A; Wed, 8 Mar 2023 08:28:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A0B5019465B6 for ; Wed, 8 Mar 2023 08:28:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0DE5E47CE3; Wed, 8 Mar 2023 08:28:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3C40440DD for ; Wed, 8 Mar 2023 08:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678264148; 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=r5hdTVJ6HqZhK3KEVxHG7p12mXdi95hgWCNipJtHn5s=; b=Q6GdjoOdAZ8f+9yquc/bTal4VsaJw18truURHi8JsLKZ023BGNfOUwHvFUwifZB7LgVr3v q+oMKuAeisL1CxbjkIh4OJjmJV3h/mZoi6R/3KWVEGlyY9qnQqBhdLS66RRmQO5MV+3Els DPzHWEwQQ2SSLVSEsAHopQ8SWVRF8CM= X-MC-Unique: 2mGPoEPdOLS2N9o5oumjzg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virSCSIHostFindByPCI: Fix link detection Date: Wed, 8 Mar 2023 09:28:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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 3.1 on 10.11.54.9 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: 1678264151422100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of virSCSIHostFindByPCI() there's a loop which iterates of entries of "/sys/class/scsi_host" directory trying to identify all symlinks (which then point to a SCSI device, but that's not important right now). But the way virFileIsLink() is called can never return a truthful reply - because it's called over dent->d_name instead of full path. Fix this by moving the virFileIsLink() call and passing constructed path into it. Signed-off-by: Michal Privoznik --- src/util/virscsihost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index 014b96452c..32d7f2312f 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -107,11 +107,11 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, char *p =3D NULL; unsigned int read_unique_id; =20 - if (!virFileIsLink(entry->d_name)) - continue; - host_link =3D g_strdup_printf("%s/%s", prefix, entry->d_name); =20 + if (!virFileIsLink(host_link)) + continue; + if (virFileResolveLink(host_link, &host_path) < 0) return NULL; =20 --=20 2.39.2