summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2019-06-19 14:23:56 -0400
committerMatt Turner <mattst88@gmail.com>2020-08-18 17:20:09 +0000
commit5c96eb5f44e62a4cfe835023cde304eb5795b8fd (patch)
tree51db22b379ccdcab45d6b61b067e94b061c7e9cb
parent74b7427c41b4e4104af7abf70a996c086d3d7628 (diff)
linux: Fix platform device PCI detection for complex bus topologies
Suppose you're in a Hyper-V guest and are trying to use PCI passthrough. The ID_PATH that udev will construct for that looks something like "acpi-VMBUS:00-pci-b8c8:00:00.0", and obviously looking for "pci-" in the first four characters of that is going to not work. Instead, strstr. I suppose it's possible you could have _multiple_ PCI buses in the path, in which case you'd want strrstr, if that were a thing. (backported from commit 9acff309434a8029bcce1b22530043459bb71791) Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Huacai Chen <chenhc@lemote.com>
-rw-r--r--config/udev.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/config/udev.c b/config/udev.c
index 8c6c4b666..14409549b 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -470,7 +470,7 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path
config_odev_probe_proc_ptr probe_callback)
{
struct OdevAttributes *attribs = config_odev_allocate_attributes();
- const char *value;
+ const char *value, *str;
attribs->path = XNFstrdup(path);
attribs->syspath = XNFstrdup(syspath);
@@ -478,8 +478,8 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path
attribs->minor = minor;
value = udev_device_get_property_value(udev_device, "ID_PATH");
- if (value && !strncmp(value, "pci-", 4)) {
- attribs->busid = XNFstrdup(value);
+ if (value && (str = strstr(value, "pci-"))) {
+ attribs->busid = XNFstrdup(str);
attribs->busid[3] = ':';
}