Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 878aaeb

Browse files
committed
doc: Add instructions for generating bindings
Describe what needs to be done to not break serialization support. Signed-off-by: Patrick Roy <[email protected]>
1 parent 80aafbf commit 878aaeb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,30 @@ bindings happens as opaque binary blobs via [`zerocopy`](https://google.github.i
4545
Due to the kernel's ABI compatibility, this means that bindings serialized
4646
in version `x` of `kvm-bindings` can be deserialized in version `y` of the
4747
crate, even if the bindings have had been regenerated in the meantime.
48+
49+
## Regenerating Bindings
50+
51+
When regenerating bindings, care must be taken to re-add various `zerocopy`
52+
derives under the `with-serde` feature. All items that require derives are
53+
listed in the `x86_64/serialize.rs` and `arm64/serialize.rs` inside the
54+
`serde_impls!` macro invocation, and missing derives will cause these
55+
modules to fail compilation. For all items listed here, the following
56+
derive should be present:
57+
58+
```rs
59+
#[cfg_attr(
60+
feature = "with-serde",
61+
derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes)
62+
)]
63+
```
64+
65+
Any types whose name contains a suffix akin to `__bindgen_ty_<number>` and
66+
which is contained in any struct listed in `serialize.rs` will also need
67+
to have this derive added (otherwise compilation will fail). Note that
68+
these types are not explicitly listed in `serialize.rs`, as their names
69+
can change across `bindgen.rs` versions.
70+
71+
Lastly, in `x86_64/bindings.rs`, the derives also need to be added to
72+
`struct __BindgenBitfieldUnit<Storage>` and `struct __IncompleteArrayField<T>`.
73+
Additionally, these structs need to have their layout changed from `#[repr(C)]`
74+
to `#[repr(transparent)]`.

0 commit comments

Comments
 (0)