qmp: handle stop/cont in INMIGRATE state

Right now, stop followed by an incoming migration will let the
virtual machine start.  cont before an incoming migration instead
will fail.

This is bad because the actual behavior is not predictable; it is
racy with respect to the start of the incoming migration.  That's
because incoming migration is blocking, and thus will delay the
processing of stop/cont until the end of the migration.

In addition, there's nothing that really prevents the user from
typing the block device's passwords before incoming migration is
done, so returning the DeviceEncrypted error is also helpful in
the QMP case.

Both things can be fixed by just toggling the autostart variable when
stop/cont are called in INMIGRATE state.

Note that libvirt is currently working around the race by looping
if the MigrationExpected answer is returned.  After this patch, the
command will return right away without ever raising an error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
3 files changed
tree: 614b2fb31ba681b4bde1d2ed2f3a97b9f790227a
  1. audio/
  2. block/
  3. bsd-user/
  4. default-configs/
  5. docs/
  6. fpu/
  7. fsdev/
  8. gdb-xml/
  9. hw/
  10. include/
  11. libcacard/
  12. linux-headers/
  13. linux-user/
  14. net/
  15. pc-bios/
  16. qapi/
  17. qga/
  18. QMP/
  19. qom/
  20. roms/
  21. scripts/
  22. slirp/
  23. sysconfigs/
  24. target-alpha/
  25. target-arm/
  26. target-cris/
  27. target-i386/
  28. target-lm32/
  29. target-m68k/
  30. target-microblaze/
  31. target-mips/
  32. target-openrisc/
  33. target-ppc/
  34. target-s390x/
  35. target-sh4/
  36. target-sparc/
  37. target-unicore32/
  38. target-xtensa/
  39. tcg/
  40. tests/
  41. trace/
  42. ui/
  43. .exrc
  44. .gitignore
  45. .gitmodules
  46. .mailmap
  47. a.out.h
  48. acl.c
  49. acl.h
  50. aes.c
  51. aes.h
  52. aio.c
  53. alpha-dis.c
  54. alpha.ld
  55. arch_init.c
  56. arch_init.h
  57. arm-dis.c
  58. arm.ld
  59. async.c
  60. balloon.c
  61. balloon.h
  62. bitmap.c
  63. bitmap.h
  64. bitops.c
  65. bitops.h
  66. block-migration.c
  67. block-migration.h
  68. block.c
  69. block.h
  70. block_int.h
  71. blockdev.c
  72. blockdev.h
  73. blockjob.c
  74. blockjob.h
  75. bswap.h
  76. bt-host.c
  77. bt-host.h
  78. bt-vhci.c
  79. buffered_file.c
  80. buffered_file.h
  81. cache-utils.c
  82. cache-utils.h
  83. Changelog
  84. cmd.c
  85. cmd.h
  86. CODING_STYLE
  87. compatfd.c
  88. compatfd.h
  89. compiler.h
  90. config.h
  91. configure
  92. console.c
  93. console.h
  94. COPYING
  95. COPYING.LIB
  96. coroutine-gthread.c
  97. coroutine-sigaltstack.c
  98. coroutine-ucontext.c
  99. coroutine-win32.c
  100. cpu-all.h
  101. cpu-common.h
  102. cpu-defs.h
  103. cpu-exec.c
  104. cpus.c
  105. cpus.h
  106. cputlb.c
  107. cputlb.h
  108. cris-dis.c
  109. cursor.c
  110. cursor_hidden.xpm
  111. cursor_left_ptr.xpm
  112. cutils.c
  113. def-helper.h
  114. device_tree.c
  115. device_tree.h
  116. dis-asm.h
  117. disas.c
  118. disas.h
  119. dma-helpers.c
  120. dma.h
  121. dump-stub.c
  122. dump.c
  123. dump.h
  124. elf.h
  125. envlist.c
  126. envlist.h
  127. error.c
  128. error.h
  129. event_notifier.c
  130. event_notifier.h
  131. exec-all.h
  132. exec-memory.h
  133. exec.c
  134. gdbstub.c
  135. gdbstub.h
  136. gen-icount.h
  137. HACKING
  138. hmp-commands.hx
  139. hmp.c
  140. hmp.h
  141. host-utils.c
  142. host-utils.h
  143. hppa-dis.c
  144. hppa.ld
  145. hwaddr.h
  146. i386-dis.c
  147. i386.ld
  148. ia64-dis.c
  149. ia64.ld
  150. input.c
  151. int128.h
  152. iohandler.c
  153. ioport.c
  154. ioport.h
  155. iorange.h
  156. iov.c
  157. iov.h
  158. json-lexer.c
  159. json-lexer.h
  160. json-parser.c
  161. json-parser.h
  162. json-streamer.c
  163. json-streamer.h
  164. kvm-all.c
  165. kvm-stub.c
  166. kvm.h
  167. libfdt_env.h
  168. LICENSE
  169. linux-aio.c
  170. lm32-dis.c
  171. m68k-dis.c
  172. m68k.ld
  173. main-loop.c
  174. main-loop.h
  175. MAINTAINERS
  176. Makefile
  177. Makefile.dis
  178. Makefile.objs
  179. Makefile.target
  180. Makefile.user
  181. memory-internal.h
  182. memory.c
  183. memory.h
  184. memory_mapping-stub.c
  185. memory_mapping.c
  186. memory_mapping.h
  187. microblaze-dis.c
  188. migration-exec.c
  189. migration-fd.c
  190. migration-tcp.c
  191. migration-unix.c
  192. migration.c
  193. migration.h
  194. mips-dis.c
  195. mips.ld
  196. module.c
  197. module.h
  198. monitor.c
  199. monitor.h
  200. nbd.c
  201. nbd.h
  202. net.c
  203. net.h
  204. notify.c
  205. notify.h
  206. os-posix.c
  207. os-win32.c
  208. osdep.c
  209. osdep.h
  210. oslib-posix.c
  211. oslib-win32.c
  212. page_cache.c
  213. path.c
  214. pci-ids.txt
  215. pflib.c
  216. pflib.h
  217. poison.h
  218. posix-aio-compat.c
  219. ppc-dis.c
  220. ppc.ld
  221. ppc64.ld
  222. qapi-schema-guest.json
  223. qapi-schema-test.json
  224. qapi-schema.json
  225. qbool.c
  226. qbool.h
  227. qdict-test-data.txt
  228. qdict.c
  229. qdict.h
  230. qemu-aio.h
  231. qemu-barrier.h
  232. qemu-bridge-helper.c
  233. qemu-char.c
  234. qemu-char.h
  235. qemu-common.h
  236. qemu-config.c
  237. qemu-config.h
  238. qemu-coroutine-int.h
  239. qemu-coroutine-io.c
  240. qemu-coroutine-lock.c
  241. qemu-coroutine-sleep.c
  242. qemu-coroutine.c
  243. qemu-coroutine.h
  244. qemu-doc.texi
  245. qemu-error.c
  246. qemu-error.h
  247. qemu-file.h
  248. qemu-ga.c
  249. qemu-img-cmds.hx
  250. qemu-img.c
  251. qemu-img.texi
  252. qemu-io.c
  253. qemu-lock.h
  254. qemu-log.c
  255. qemu-log.h
  256. qemu-nbd.c
  257. qemu-nbd.texi
  258. qemu-objects.h
  259. qemu-option-internal.h
  260. qemu-option.c
  261. qemu-option.h
  262. qemu-options-wrapper.h
  263. qemu-options.h
  264. qemu-options.hx
  265. qemu-os-posix.h
  266. qemu-os-win32.h
  267. qemu-progress.c
  268. qemu-queue.h
  269. qemu-seccomp.c
  270. qemu-seccomp.h
  271. qemu-sockets.c
  272. qemu-tech.texi
  273. qemu-thread-posix.c
  274. qemu-thread-posix.h
  275. qemu-thread-win32.c
  276. qemu-thread-win32.h
  277. qemu-thread.h
  278. qemu-timer-common.c
  279. qemu-timer.c
  280. qemu-timer.h
  281. qemu-tls.h
  282. qemu-tool.c
  283. qemu-user.c
  284. qemu-x509.h
  285. qemu-xattr.h
  286. qemu.sasl
  287. qemu_socket.h
  288. qerror.c
  289. qerror.h
  290. qfloat.c
  291. qfloat.h
  292. qint.c
  293. qint.h
  294. qjson.c
  295. qjson.h
  296. qlist.c
  297. qlist.h
  298. qmp-commands.hx
  299. qmp.c
  300. qobject.h
  301. qstring.c
  302. qstring.h
  303. qtest.c
  304. qtest.h
  305. range.h
  306. readline.c
  307. readline.h
  308. README
  309. rules.mak
  310. s390-dis.c
  311. s390.ld
  312. savevm.c
  313. sh4-dis.c
  314. softmmu-semi.h
  315. softmmu_defs.h
  316. softmmu_exec.h
  317. softmmu_header.h
  318. softmmu_template.h
  319. sparc-dis.c
  320. sparc.ld
  321. sparc64.ld
  322. spice-qemu-char.c
  323. sysemu.h
  324. tcg-runtime.c
  325. tci-dis.c
  326. tci.c
  327. thunk.c
  328. thunk.h
  329. TODO
  330. trace-events
  331. translate-all.c
  332. uboot_image.h
  333. uri.c
  334. uri.h
  335. user-exec.c
  336. VERSION
  337. version.rc
  338. vgafont.h
  339. vl.c
  340. vmstate.h
  341. x86_64.ld
  342. xen-all.c
  343. xen-mapcache.c
  344. xen-mapcache.h
  345. xen-stub.c