-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
udev: Implement a way to group devices of a same tree #564
Conversation
/version minor |
087bdf9
to
009c01d
Compare
@@ -543,6 +543,24 @@ fn device_or_parents_have_tag(device: &impl DeviceExt, value_regex: &Regex) -> b | |||
} | |||
} | |||
|
|||
/// Retrieve Parent or Children of a device using their sysfs path. | |||
pub fn get_device_relatives<'a>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diconico07 can you write a few unit tests for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a test case, tell me if you feel I missed something 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits but overall this looks great. Thanks! A couple unit tests here would be helpful. We also want to be mindful of version here. I believe we have another pr in queue that bumps to 0.10.0.
if !discovery_handler_config.group_recursive { | ||
devpaths.insert(path.0.clone(), vec![path]); | ||
} else { | ||
match get_device_relatives(&path.0, devpaths.keys()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i would put this else block in a separate function so we can unit test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do this next week, as I'll do the unit tests as well (won't have enough time before that), if you want to merge before that, I'll do it in a separate PR.
This commit adds the `groupRecursive` option to the udev device discovery handler, this configuration switch allows to group devices that share a parent/child relation. This can be used to group into one akri instance a complex device that is split into multiple nodes. It is up to the user to define the boundaries of the device as there are no standard way to do so. It works by comparing sysfs path for a device prefixing another one (i.e `/devices/pci0` is a parent of `/devices/pci0/0.1/0.1.1/0.1.1:1`, this example is obviously fictive) It adds all devnodes to the mounts and add a UDEV_DEVNODE_n property for each one of them. The UDEV_DEVPATH just need the topmost one as all other are subdirectories of it. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
009c01d
to
24de50a
Compare
As indicated in project-akri#564 the new grouping behavior could get more test coverage. This commit moves the grouping logic to a separate function and adds relevant tests. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
As indicated in project-akri#564 the new grouping behavior could get more test coverage. This commit moves the grouping logic to a separate function and adds relevant tests. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
As indicated in project-akri#564 the new grouping behavior could get more test coverage. This commit moves the grouping logic to a separate function and adds relevant tests. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
This commit prevents duplicate device node from being listed when multiple rules match the same devices. This fixes a regression introduced by project-akri#564. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
As indicated in project-akri#564 the new grouping behavior could get more test coverage. This commit moves the grouping logic to a separate function and adds relevant tests. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
This commit prevents duplicate device node from being listed when multiple rules match the same devices. This fixes a regression introduced by project-akri#564. Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
What this PR does / why we need it:
This PR adds the
groupRecursive
option to the udev device discovery handler, this configuration switch allows to group devices that share a parent/child relation.This can be used to group into one akri instance a complex device that is split into multiple nodes. It is up to the user to define the boundaries of the device as there are no standard way to do so.
It works by comparing sysfs path for a device prefixing another one (i.e
/devices/pci0
is a parent of/devices/pci0/0.1/0.1.1/0.1.1:1
, this example is obviously fictive)It adds all devnodes to the mounts and add a UDEV_DEVNODE_n property for each one of them.
The UDEV_DEVPATH just need the topmost one as all other are subdirectories of it.
This closes #490
Special notes for your reviewer:
I will cross-link with a documentation PR as soon as I finish writing it.
If applicable:
groupRecursive
option akri-docs#64cargo fmt
)cargo build
)cargo clippy
)cargo test
)cargo doc
)