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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions crates/virtio-bindings/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@ repository on your machine:
git clone https://github.com/torvalds/linux.git
```

## Example for adding a new version
## Example for updating to a new kernel version

For this example we assume that you have both linux and virtio-bindings
repositories in your root.

```bash
# Step 1: Create a new module using a name with format "bindings_vVERSION" in
# src/
cd vm-virtio/crates/virtio-bindings
mkdir src/bindings_v5_0_0
cd ~

# Step 2: Copy the "mod.rs" file from the directory of an already existing
# version module to the one we've just created.
cd vm-virtio/crates/virtio-bindings/src
cp bindings_v4_14_0/mod.rs bindings_v5_0_0/mod.rs

# linux is the repository that you cloned at the previous step.
cd linux
# Step 3: Checkout the version you want to generate the bindings for.
# Step 1: Checkout the version you want to generate the bindings for.
git checkout v5.0

# Step 4: Generate the bindings from the kernel headers. We need to
# Step 2: Generate the bindings from the kernel headers. We need to
# generate a file for each one of the virtio headers we're interested on.
# For the moment, we're generating "virtio_blk", "virtio_net" and
# "virtio_ring". Feel free to add additional header files if you need them
Expand All @@ -55,16 +44,5 @@ done
cd ~

# Step 6: Copy the generated files to the new version module.
cp linux/v5_0_headers/*.rs vm-virtio/crates/virtio-bindings/src/bindings_v5_0_0
```

Once this is done, edit the generated files to add the proper license header,
and add the new version module to `vm-virtio/crates/virtio-bindings/lib.rs`. If
this version is newer than the others already present, make this version the
default one by getting it imported when there isn't any other version specified
as a feature:

```rust
#[cfg(all(not(feature = "virtio-v4_14_0"), not(feature = "virtio-v5_0_0")))]
pub use super::bindings_v5_0_0::*;
cp linux/v5_0_headers/*.rs vm-virtio/crates/virtio-bindings/src
```
6 changes: 5 additions & 1 deletion crates/virtio-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ edition = "2021"
keywords = ["virtio"]
license = "BSD-3-Clause OR Apache-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
# Kernel version features are deprecated and no longer have any effect,
# as the kernel headers are backwards compatible.
virtio-v4_14_0 = []
virtio-v5_0_0 = []

[dependencies]
5 changes: 1 addition & 4 deletions crates/virtio-bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ Rust FFI bindings to virtio generated using [bindgen](https://crates.io/crates/b
# Usage
Add this to your `Cargo.toml`:
```toml
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
virtio-bindings = "0.1"
```
You can then import the bindings where you need them. As an example, to grab the
bindings for virtio-blk, you can do:
```rust
use virtio_bindings::bindings::virtio_blk::*;
```
In the `virtio-bindings` crate each feature maps to exactly one Linux version as follows:
- `virtio-v4_14_0` contains the bindings for the Linux kernel version 4.14
- `virtio-v5_0_0` contains the bindings for the Linux kernel version 5.0
11 changes: 0 additions & 11 deletions crates/virtio-bindings/src/bindings_v4_14_0/mod.rs

This file was deleted.

Loading