From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> Hi, I'm interested in comments on the idea here, it's certainly not ready to go in yet; and VERY untested.
Here I've added a macro, VMSTATE_WITH_TMP which allows you to allocate a temporary structure, transmit that with a VMStateDescription and then free that temporary. A pointer to the parent structure is set up in the temporary allowing the pre_load/pre_save/post_load off the child vmsd to copy/calculate things to fill in the temporary. There are 4 patches: a) Add VMSTATE_WITH_TMP b) A test for (a) An easy read to see how (a) works c) Conversion of SLIRPs sbuf structure to a VMState This is a nice use of VMSTATE_WITH_TMP since it needs to calculate and send a couple of offsets based off the contents of the structure but not the raw fields. d) Conversion of virtio-net to VMState; this is pretty hairy, and the previous version I posted added a bunch of migration only variables into the structure; here I use 3 VMSTATE_WITH_TMP's to avoid it. Both (c) & (d) depend on a whole bunch of related patches I'm still cooking, but they should let people see how VMSTATE_WITH_TMP is used. I think it works OK; it's not exactly compact though, you often seem to end up with more VMStateDescription boiler plate and quite a few trivial pre_load/pre_save. Note this isn't standalone; it depends on Jianjun's patches that modify the .get/.put parameters and a bunch of smaller patches of mine. Comments welcome, Dave Dr. David Alan Gilbert (7): migration: Add VMSTATE_WITH_TMP tests/migration: Add test for VMSTATE_WITH_TMP virtio/migration: Migrate virtio-net to VMState slirp: VMStatify sbuf -- 2.9.3