Skip to content
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

virtio-bindings: drop bindings for older kernels #192

Merged
merged 2 commits into from
Sep 14, 2022

Conversation

alyssais
Copy link
Contributor

Summary of the PR

As pointed out by @sboeuf, the kernel headers are backwards compatible, so there's no need to maintain the bindings for multiple kernel versions. And doing so will make updating the bindings easier, as it won't require adding a new feature each time.

But before we can do that, we actually have to re-add the kernel version features to the Cargo.toml, because they were lost when virtio-bindings was imported into vm-virtio, and this would break existing users of the crate next time a release is made.

It's unfortunately not possible for us to emit a deprecation warning for the features, as in Rust deprecation warnings have to be applied to functions/constants/etc. (not modules or re-exports](rust-lang/rust#30827)), so any deprecation warning in this crate would mean editing the generated bindings files. But it doesn't really do any harm to keep the feature declarations in the Cargo.toml around indefinitely.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • Any newly added unsafe code is properly documented.

@alyssais alyssais changed the title Drop bindings @alyssais virtio-bindings: drop unexposed bindings for older kernels Sep 12, 2022
@alyssais alyssais changed the title @alyssais virtio-bindings: drop unexposed bindings for older kernels virtio-bindings: drop unexposed bindings for older kernels Sep 12, 2022
@alyssais alyssais changed the title virtio-bindings: drop unexposed bindings for older kernels virtio-bindings: drop bindings for older kernels Sep 12, 2022
@alyssais
Copy link
Contributor Author

The CI failures seem to be due to the bindings being from a very old bindgen. That will be one of my next PRs, but it's not related to this one. I could add that onto the end of this PR to make CI happy if that's required.

mod bindings_v4_14_0;
#[cfg(feature = "virtio-v5_0_0")]
mod bindings_v5_0_0;
#![allow(clippy::all)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works as you intend it to work, which is also why the tests are failing. We want to allow clippy::all only in the bindings, now you are actually allowing it on the virtio_blk module which is the one that is immediately after the clippy macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you!

Copy link
Contributor Author

@alyssais alyssais Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this was correct. My understanding is that #! applies to the whole of the current module, whereas # applies only to the next item.

The tests were failing with normal Rust warnings, not clippy ones, because I had accidentally dropped this line:

// Keep this until https://github.com/rust-lang/rust-bindgen/issues/1651 is fixed.
#![cfg_attr(test, allow(deref_nullptr, unaligned_references))]

Now that I've added it back as well, they're passing.

(That issue in bindgen has now been fixed, so when I regenerate the bindings (next in my stack) we can remove that attribute.)

@alyssais alyssais force-pushed the drop-bindings branch 2 times, most recently from 54f69e4 to c10d05e Compare September 12, 2022 11:36
These were lost when virtio-bindings was imported into the vm-virtio
repository.  Without these features declared, crates that depended on
these features wouldn't compile.

Signed-off-by: Alyssa Ross <[email protected]>
sboeuf
sboeuf previously approved these changes Sep 14, 2022
Copy link

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

crates/virtio-bindings/CONTRIBUTING.md Outdated Show resolved Hide resolved
As pointed out by Sebastien Boeuf [1], the kernel headers are
backwards compatible, so there's no need to maintain the bindings for
multiple kernel versions.  And doing so will make updating the
bindings easier, as it won't require adding a new feature each time.

It's unfortunately not possible for us to emit a deprecation warning
for the features, as in Rust deprecation warnings have to be applied
to functions/constants/etc. (not modules or re-exports [2]), so any
deprecation warning in this crate would mean editing the generated
bindings files.  But it doesn't really do any harm to keep the feature
declarations in the Cargo.toml around indefinitely.

[1]: rust-vmm/virtio-bindings#35 (comment)
[2]: rust-lang/rust#30827

Signed-off-by: Alyssa Ross <[email protected]>
@lauralt lauralt merged commit 7e203db into rust-vmm:main Sep 14, 2022
@alyssais alyssais deleted the drop-bindings branch September 14, 2022 14:33
@alyssais alyssais mentioned this pull request Sep 15, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants