savevm: New save live migration method: pending

Code just now does (simplified for clarity)

    if (qemu_savevm_state_iterate(s->file) == 1) {
       vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
       qemu_savevm_state_complete(s->file);
    }

Problem here is that qemu_savevm_state_iterate() returns 1 when it
knows that remaining memory to sent takes less than max downtime.

But this means that we could end spending 2x max_downtime, one
downtime in qemu_savevm_iterate, and the other in
qemu_savevm_state_complete.

Changed code to:

    pending_size = qemu_savevm_state_pending(s->file, max_size);
    DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
    if (pending_size >= max_size) {
        ret = qemu_savevm_state_iterate(s->file);
     } else {
        vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
        qemu_savevm_state_complete(s->file);
     }

So what we do is: at current network speed, we calculate the maximum
number of bytes we can sent: max_size.

Then we ask every save_live section how much they have pending.  If
they are less than max_size, we move to complete phase, otherwise we
do an iterate one.

This makes things much simpler, because now individual sections don't
have to caluclate the bandwidth (it was implossible to do right from
there).

Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8 files changed
tree: 38a01a9697455a8e8f376372cbf9557513f118f5
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. default-configs/
  6. disas/
  7. docs/
  8. fpu/
  9. fsdev/
  10. gdb-xml/
  11. hw/
  12. include/
  13. ldscripts/
  14. libcacard/
  15. linux-headers/
  16. linux-user/
  17. net/
  18. pc-bios/
  19. qapi/
  20. qga/
  21. QMP/
  22. qom/
  23. roms/
  24. scripts/
  25. slirp/
  26. stubs/
  27. sysconfigs/
  28. target-alpha/
  29. target-arm/
  30. target-cris/
  31. target-i386/
  32. target-lm32/
  33. target-m68k/
  34. target-microblaze/
  35. target-mips/
  36. target-openrisc/
  37. target-ppc/
  38. target-s390x/
  39. target-sh4/
  40. target-sparc/
  41. target-unicore32/
  42. target-xtensa/
  43. tcg/
  44. tests/
  45. trace/
  46. ui/
  47. .exrc
  48. .gitignore
  49. .gitmodules
  50. .mailmap
  51. acl.c
  52. aes.c
  53. aio-posix.c
  54. aio-win32.c
  55. arch_init.c
  56. async.c
  57. balloon.c
  58. bitmap.c
  59. bitops.c
  60. block-migration.c
  61. block.c
  62. blockdev-nbd.c
  63. blockdev.c
  64. blockjob.c
  65. bt-host.c
  66. bt-vhci.c
  67. buffered_file.c
  68. buffered_file.h
  69. cache-utils.c
  70. Changelog
  71. cmd.c
  72. cmd.h
  73. CODING_STYLE
  74. compatfd.c
  75. configure
  76. COPYING
  77. COPYING.LIB
  78. coroutine-gthread.c
  79. coroutine-sigaltstack.c
  80. coroutine-ucontext.c
  81. coroutine-win32.c
  82. cpu-exec.c
  83. cpus.c
  84. cputlb.c
  85. cutils.c
  86. device_tree.c
  87. disas.c
  88. dma-helpers.c
  89. dump-stub.c
  90. dump.c
  91. envlist.c
  92. error.c
  93. event_notifier-posix.c
  94. event_notifier-win32.c
  95. exec.c
  96. gdbstub.c
  97. HACKING
  98. hmp-commands.hx
  99. hmp.c
  100. hmp.h
  101. host-utils.c
  102. iohandler.c
  103. ioport.c
  104. iov.c
  105. json-lexer.c
  106. json-parser.c
  107. json-streamer.c
  108. kvm-all.c
  109. kvm-stub.c
  110. LICENSE
  111. main-loop.c
  112. MAINTAINERS
  113. Makefile
  114. Makefile.objs
  115. Makefile.target
  116. memory.c
  117. memory_mapping-stub.c
  118. memory_mapping.c
  119. migration-exec.c
  120. migration-fd.c
  121. migration-tcp.c
  122. migration-unix.c
  123. migration.c
  124. module.c
  125. monitor.c
  126. nbd.c
  127. notify.c
  128. os-posix.c
  129. os-win32.c
  130. osdep.c
  131. oslib-posix.c
  132. oslib-win32.c
  133. page_cache.c
  134. path.c
  135. pci-ids.txt
  136. qapi-schema-test.json
  137. qapi-schema.json
  138. qbool.c
  139. qdict-test-data.txt
  140. qdict.c
  141. qemu-bridge-helper.c
  142. qemu-char.c
  143. qemu-config.c
  144. qemu-coroutine-io.c
  145. qemu-coroutine-lock.c
  146. qemu-coroutine-sleep.c
  147. qemu-coroutine.c
  148. qemu-doc.texi
  149. qemu-error.c
  150. qemu-img-cmds.hx
  151. qemu-img.c
  152. qemu-img.texi
  153. qemu-io.c
  154. qemu-log.c
  155. qemu-nbd.c
  156. qemu-nbd.texi
  157. qemu-option.c
  158. qemu-options-wrapper.h
  159. qemu-options.h
  160. qemu-options.hx
  161. qemu-progress.c
  162. qemu-seccomp.c
  163. qemu-sockets.c
  164. qemu-tech.texi
  165. qemu-thread-posix.c
  166. qemu-thread-win32.c
  167. qemu-timer-common.c
  168. qemu-timer.c
  169. qemu-tool.c
  170. qemu-user.c
  171. qemu.sasl
  172. qerror.c
  173. qfloat.c
  174. qint.c
  175. qjson.c
  176. qlist.c
  177. qmp-commands.hx
  178. qmp.c
  179. qstring.c
  180. qtest.c
  181. readline.c
  182. README
  183. rules.mak
  184. savevm.c
  185. spice-qemu-char.c
  186. tcg-runtime.c
  187. tci.c
  188. thread-pool.c
  189. thunk.c
  190. TODO
  191. trace-events
  192. translate-all.c
  193. translate-all.h
  194. uri.c
  195. user-exec.c
  196. VERSION
  197. version.rc
  198. vl.c
  199. xen-all.c
  200. xen-mapcache.c
  201. xen-stub.c