incusd/device/unix_hotplug: Prevent duplicate uevent injection#2679
Merged
incusd/device/unix_hotplug: Prevent duplicate uevent injection#2679
Conversation
Duplicate remove uevents are injected into LXC containers when more than one unix-hotplug device is configured. The add uevent has a guard for the correct vendor/product device uevents but this doesn't work with remove because it lacks these fields. But, if no devices are marked for unmounting, we can exit early and avoid duplication. Example scenario: two unix-hotplugs where one matches the hidraw0 device Before (container udevadm monitor -k): KERNEL[1297805.870598] add /devices/platform/vhci_hcd.0/usb1/1-2 (usb) KERNEL[1297805.972898] add /devices/platform/vhci_hcd.0/usb1/1-2/1-2:1.0/0003:1050:0402.0008/hidraw/hidraw0 (hidraw) KERNEL[1297728.343559] remove /devices/platform/vhci_hcd.0/usb1/1-2/1-2:1.0/usbmisc/hiddev0 (usbmisc) KERNEL[1297728.355734] remove /devices/platform/vhci_hcd.0/usb1/1-2/1-2:1.0/usbmisc/hiddev0 (usbmisc) KERNEL[1297728.410647] remove /devices/platform/vhci_hcd.0/usb1/1-2/1-2:1.0/0003:1050:0402.0007/hidraw/hidraw0 (hidraw) KERNEL[1297728.424289] remove /devices/platform/vhci_hcd.0/usb1/1-2/1-2:1.0/0003:1050:0402.0007/hidraw/hidraw0 (hidraw) KERNEL[1297728.559130] remove /devices/platform/vhci_hcd.0/usb1/1-2 (usb) KERNEL[1297728.593145] remove /devices/platform/vhci_hcd.0/usb1/1-2 (usb) After: KERNEL[1302813.707669] add /devices/platform/vhci_hcd.0/usb1/1-1 (usb) KERNEL[1302813.796387] add /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0402.000C/hidraw/hidraw0 (hidraw) KERNEL[1302839.881288] remove /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0402.000C/hidraw/hidraw0 (hidraw) KERNEL[1302839.968908] remove /devices/platform/vhci_hcd.0/usb1/1-1 (usb) Signed-off-by: Gabriel Totev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Duplicate remove uevents are injected into LXC containers when more than one unix-hotplug device is configured. The add uevent has a guard for the correct vendor/product device uevents but this doesn't work with remove because it lacks these fields. But, if no devices are marked for unmounting, we can exit early and avoid duplication.
Example scenario: two unix-hotplugs where one matches the hidraw0 device
Before (container udevadm monitor -k):
After: