migration: Add VMSTATE_WITH_TMP

VMSTATE_WITH_TMP is for handling structures where some calculation
or rearrangement of the data needs to be performed before the data
hits the wire.
For example,  where the value on the wire is an offset from a
non-migrated base, but the data in the structure is the actual pointer.

To use it, a temporary type is created and a vmsd used on that type.
The first element of the type must be 'parent' a pointer back to the
type of the main structure.  VMSTATE_WITH_TMP takes care of allocating
and freeing the temporary before running the child vmsd.

The post_load/pre_save on the child vmsd can copy things from the parent
to the temporary using the parent pointer and do any other calculations
needed; it can then use normal VMSD entries to do the actual data
storage without having to fiddle around with qemu_get_*/qemu_put_*

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20170203160651.19917-3-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2 files changed
tree: 76da0209b74a753d4cabed500f7a9689358da85d
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. chardev/
  6. contrib/
  7. crypto/
  8. default-configs/
  9. disas/
  10. docs/
  11. fpu/
  12. fsdev/
  13. gdb-xml/
  14. hw/
  15. include/
  16. io/
  17. libdecnumber/
  18. linux-headers/
  19. linux-user/
  20. migration/
  21. nbd/
  22. net/
  23. pc-bios/
  24. po/
  25. qapi/
  26. qga/
  27. qobject/
  28. qom/
  29. replay/
  30. roms/
  31. scripts/
  32. slirp/
  33. stubs/
  34. target/
  35. tcg/
  36. tests/
  37. trace/
  38. ui/
  39. util/
  40. .dir-locals.el
  41. .exrc
  42. .gitignore
  43. .gitmodules
  44. .mailmap
  45. .travis.yml
  46. accel.c
  47. aio-posix.c
  48. aio-win32.c
  49. arch_init.c
  50. async.c
  51. atomic_template.h
  52. balloon.c
  53. block.c
  54. blockdev-nbd.c
  55. blockdev.c
  56. blockjob.c
  57. bootdevice.c
  58. bt-host.c
  59. bt-vhci.c
  60. Changelog
  61. CODING_STYLE
  62. configure
  63. COPYING
  64. COPYING.LIB
  65. cpu-exec-common.c
  66. cpu-exec.c
  67. cpus-common.c
  68. cpus.c
  69. cputlb.c
  70. device-hotplug.c
  71. device_tree.c
  72. disas.c
  73. dma-helpers.c
  74. dump.c
  75. exec.c
  76. gdbstub.c
  77. HACKING
  78. hax-stub.c
  79. hmp-commands-info.hx
  80. hmp-commands.hx
  81. hmp.c
  82. hmp.h
  83. iohandler.c
  84. ioport.c
  85. iothread.c
  86. kvm-all.c
  87. kvm-stub.c
  88. LICENSE
  89. main-loop.c
  90. MAINTAINERS
  91. Makefile
  92. Makefile.objs
  93. Makefile.target
  94. memory.c
  95. memory_ldst.inc.c
  96. memory_mapping.c
  97. module-common.c
  98. monitor.c
  99. numa.c
  100. os-posix.c
  101. os-win32.c
  102. page_cache.c
  103. qapi-schema.json
  104. qdev-monitor.c
  105. qdict-test-data.txt
  106. qemu-bridge-helper.c
  107. qemu-doc.texi
  108. qemu-ga.texi
  109. qemu-img-cmds.hx
  110. qemu-img.c
  111. qemu-img.texi
  112. qemu-io-cmds.c
  113. qemu-io.c
  114. qemu-nbd.c
  115. qemu-nbd.texi
  116. qemu-option-trace.texi
  117. qemu-options-wrapper.h
  118. qemu-options.h
  119. qemu-options.hx
  120. qemu-seccomp.c
  121. qemu-tech.texi
  122. qemu-timer.c
  123. qemu.nsi
  124. qemu.sasl
  125. qmp.c
  126. qtest.c
  127. README
  128. replication.c
  129. replication.h
  130. rules.mak
  131. softmmu_template.h
  132. spice-qemu-char.c
  133. tcg-runtime.c
  134. tci.c
  135. thread-pool.c
  136. thunk.c
  137. tpm.c
  138. trace-events
  139. translate-all.c
  140. translate-all.h
  141. translate-common.c
  142. user-exec-stub.c
  143. user-exec.c
  144. VERSION
  145. version.rc
  146. vl.c
  147. xen-common-stub.c
  148. xen-common.c
  149. xen-hvm-stub.c
  150. xen-hvm.c
  151. xen-mapcache.c