@@ -45,3 +45,30 @@ bindings happens as opaque binary blobs via [`zerocopy`](https://google.github.i
45
45
Due to the kernel's ABI compatibility, this means that bindings serialized
46
46
in version ` x ` of ` kvm-bindings ` can be deserialized in version ` y ` of the
47
47
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