-
Notifications
You must be signed in to change notification settings - Fork 31
Description
vmm-serde
Short Description
Build serde infrastructure to support snapshot, live migration and live upgrade
Why is this crate relevant to the rust-vmm project?
A common requirement for virtual machine snapshot, live migration and live upgrading is to serialize
and deserialize VMM internal objects and data structures. The rust community has the excellent
serde/serde_derive framework for data serialization/deserialization. But the serde/serde_derive
framework have very heavy dependency chain, and it's a common concern of the rust-vmm project to
reduce dependency chain as small as possible. So this helper crate uses rust features to
opt-in/opt-out data serialization/deserialization code and dependencies.
Currently following features are supported:
-
Feature
export_as_pub
. The data serializer often needs to access private data structures or
private fields in data structures. But rust has no support forfriend
visibility yet, though
there's proposals for C++ likefriend
relationship. So a proc macroexport_as_pub()
is
introduced to rewrite private data structs/fields aspub
on demand when the feature
export_as_pub
is enabled. Otherwiseexport_as_pub()
becomes a null operation. -
Feature
serde_derive
. When this feature is enabled, the proc_macro_derive for De/Serialize
is reexported from the serde_derive crate, otherwise#[derive(Serialize, Deserialize)]
becomes
a null operation. -
Feature
serde_derive_ffi
. Often the bindgen utiltily is used to auto-generate FFI bindings for
Linux syscalls and system libraries. And data structures with flexible array member are often used
for input and/or output parameters. So three derive macros, SerializeFfi, DeserializeFfi and
DeserializeFfiFam, are introduced to serialize data structures generated by bindgen.