Skip to content

Commit 5144541

Browse files
likebreathjinankjain
authored andcommitted
vfio-bindings: Avoid modifications to auto-generated code
Auto-generated bindings are not supposed to be modified manually. Instead, it is less error prone to ensure type compatibility from the consumer of the bindings, such as 'vfio-ioctls' crate. This patch also takes the opportunity to improve the CONTRIBUTING.md: * Clarify the version of `bindgen` being used; * Enable `--impl-debug` and `--impl-partialeq` with bindgen; Signed-off-by: Bo Chen <[email protected]>
1 parent 36e51d8 commit 5144541

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

vfio-bindings/CONTRIBUTING.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
### Bindgen
66
The bindings are currently generated using
7-
[bindgen](https://crates.io/crates/bindgen):
7+
[bindgen](https://crates.io/crates/bindgen) version 0.71.1:
88

99
```bash
10-
cargo install bindgen
10+
cargo install bindgen-cli --vers 0.71.1
1111
```
1212

1313
### Linux Kernel
@@ -45,30 +45,15 @@ git checkout v5.2
4545
make headers_install INSTALL_HDR_PATH=v5_2_headers
4646
cd v5_2_headers
4747
bindgen include/linux/vfio.h -o vfio.rs \
48-
--with-derive-default \
49-
--with-derive-partialeq \
48+
--impl-debug --with-derive-default \
49+
--with-derive-partialeq --impl-partialeq \
5050
-- -Iinclude
5151

5252
cd ~
5353

5454
# Step 5: Copy the generated files to the new version module.
5555
cp linux/v5_2_headers/vfio.rs vfio-bindings/src/bindings_v5_2_0
5656
```
57-
58-
Once this is done, you need some modifications to the generated vfio.rs.
59-
First change below line:
60-
```rust
61-
pub const VFIO_TYPE: u8 = 59u8;
62-
```
63-
to
64-
```rust
65-
pub const VFIO_TYPE: u32 = 59;
66-
```
67-
68-
This is required due to that bindgen can not generate VFIO_TYPE correctly
69-
at this moment. You might also want to add the proper license header to
70-
the file.
71-
7257
Finally add the new version module to `vfio-bindings/lib.rs`. If this version
7358
is newer than the others already present, make this version the default one by
7459
getting it imported when there isn't any other version specified as a feature:

0 commit comments

Comments
 (0)