From 11ae32e3c04906b38faf9a263a2bec3b30d7c75a Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 6 Apr 2021 20:58:06 +1000 Subject: [PATCH] agent/device: Fix path matching for PCI devices For the case of virtio-blk PCI devices, when matching uevents we create a pci_p temporary. However, we build it incorrectly: the dev_addr values we use for PCI devices are a relative sysfs paths from the PCI root to the device in question *including an initial /*. But when we construct pci_p we add an extra /, meaning the resulting path will *not* match properly. AFAICT the only reason we got away with this is because in practice the virtio-blk devices where discovered by the kernel before we looked for them meaning the loosed matching in get_device_name() was used, rather than the pci_p logic in handle_block_add_event(). Signed-off-by: David Gibson --- src/agent/src/uevent.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/src/uevent.rs b/src/agent/src/uevent.rs index c4067ed5ab..b534282315 100644 --- a/src/agent/src/uevent.rs +++ b/src/agent/src/uevent.rs @@ -82,7 +82,7 @@ impl Uevent { let empties: Vec<_> = w .iter_mut() .filter(|(dev_addr, _)| { - let pci_p = format!("{}/{}", pci_root_bus_path, *dev_addr); + let pci_p = format!("{}{}", pci_root_bus_path, *dev_addr); // blk block device devpath.starts_with(pci_p.as_str()) ||