-
Notifications
You must be signed in to change notification settings - Fork 75
RFC: enhance kvm-binding to optionally support serde #7
Conversation
The kvm-binding is a library crate, so remove the Cargo.lock file to avoid unnecessary changes. Signed-off-by: Liu Jiang <[email protected]>
Import the vmm-serde crate and implement trait SizeofFamStruct for KVM structs with flexible array member. Signed-off-by: Liu Jiang <[email protected]>
Import add_serde.py from https://github.com/aghecenco/kvm-bindings/tree/serde_old with modifications to integrate with the vmm_serde crate. Rules for preprocess the bindgen generated sources files: For each `struct` with attribute `#[derive(xxx)]` - skip if it already implements the Serialize trait. - skip if it's in the black list. - add `#[derive(SerializeFfi, DeserializeFfiFam)]` if it's a struct with a flexible array as the last field. - otherwise add `#[derive(SerializeFfi, DeserializeFfi)]`. Signed-off-by: Xingjun Liu <[email protected]> Signed-off-by: Alexandra Iordache <[email protected]>
Add #[derive(SerializeFfi, DeserializeFfi) to KVM structs using the script tool/add_derive.py. Signed-off-by: Liu Jiang <[email protected]>
4923b87
to
fe9b240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can serde.rs be common, i.e. work for arm too?
|
On 19-09-24 18:57:26, Jiang Liu wrote:
> Can serde.rs be common, i.e. work for arm too?
serde is platform independent, but I have no ARM env available so only enabled it fort x86.
Ok. There are some data structures are common so I think we may
propagate at least part of serde.rs to upper layer. We can do it
when there is real requirement.
… --
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#7 (comment)
|
@jiangliu For kvm_nested_state, is it sensible to have serde_ffi_fam_impl implemented on it? The structure does not meet the condition to work with SizeofFamStruct trait. Cargo test --all-features has associated failures. Please help confirm this. |
To apply the serde functions provided by the following links for kvm-bindings serialize/deserialize, switch both kvm-bindings and kvm-ioctls urls to internal branch links. rust-vmm/kvm-bindings#7 Signed-off-by: Cathy Zhang <[email protected]>
To apply the serde functions provided by the following links for kvm-bindings serialize/deserialize, switch both kvm-bindings and kvm-ioctls urls to internal branch links. rust-vmm/kvm-bindings#7 Signed-off-by: Cathy Zhang <[email protected]>
Hey @jiangliu, I've been giving this extensive thought and come to the following conclusions:
I initially formulated these points in #11 but that didn't exactly generate traction so would you take a peek at #14 instead? |
Hi Alexandra, |
Trying to revive this thread! I'd really like to see every project rely on the same This means we'd need to send a PR with this patch firecracker-microvm@b581698 to derive all KVM structures with That being said, if we agree on this move, I think it'd be important to move @sameo @rbradford @aghecenco @andreeaflorescu @jiangliu |
I'm OK to migrate to versionize crate once it's moved to rust-vmm, so we could have common code base. |
We were also looking at using a proxy crate for the state instead of adding the serialization macros in the kvm-bindings structure directly. I find adding either serde or versionize macros directly in kvm-bindings as a bit too intrusive because there is not getting away from it :)) I believe @alexandruag is working on a prototype, and can probably give you some more details. Are we actually okay with closing this PR or do we want to keep it open for the discussions? |
It's OK to close this PR and open another issue for discussion. |
But if we add one more layer between
Cool!
Let's keep it open for the discussion. |
@sboeuf I don't think that the cost is so high TBH, but then it's probably better to discuss it on the actual proposal :)) I have a few concerns with adding serialize support directly on the bindings. Over time it can add a non-negligible size overhead. Then the second thing is that bindings in their current form (with the padding definition and FAM structs) is not exactly the "KVM state" in a sens. |
Closing to continue the discussion on #24 |
This PR implements serde for kvm-binding based on the proposed vmm-serde crate (rust-vmm/community#76).
It's based on the @aghecenco work (#4), but optionally implementing de/serialization by using rust proc macro.
It implements the Serialize/Deserialize trait by:
bindgen
, adding `#[derive(SerializeFfi, DeserializeFfi/DeserializeFfiFam)]' to suitable structs.The first patch remvoes Cargo.lock from the crate, the second patch imports add_serde.py from @aghecenco previous work with modification, the third patch builds the infrastructure to serde, and the last patch commits code generated by add_serde.py.