From: Michal Privoznik Date: Wed, 8 Mar 2023 07:42:19 +0000 (+0100) Subject: virSCSIHostFindByPCI: Fix link detection X-Git-Tag: v9.2.0-rc1~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8a83aab5d312df01c4d669569d0472d0ee8a261;p=thirdparty%2Flibvirt.git virSCSIHostFindByPCI: Fix link detection 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 Reviewed-by: Ján Tomko --- 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 = NULL; unsigned int read_unique_id; - if (!virFileIsLink(entry->d_name)) - continue; - host_link = g_strdup_printf("%s/%s", prefix, entry->d_name); + if (!virFileIsLink(host_link)) + continue; + if (virFileResolveLink(host_link, &host_path) < 0) return NULL;