blockdev: Clean up automatic drive deletion

We automatically delete blockdev host parts on unplug of the guest
device.  Too much magic, but we can't change that now.

The delete happens early in the guest device teardown, before the
connection to the host part is severed.  Thus, the guest part's
pointer to the host part dangles for a brief time.  No actual harm
comes from this, but we'll catch such dangling pointers a few commits
down the road.  Clean up the dangling pointers by delaying the
automatic deletion until the guest part's pointer is gone.

Device usb-storage deliberately makes two qdev properties refer to the
same drive, because it automatically creates a second device.  Again,
too much magic we can't change now.  Multiple references worked okay
before, but now free_drive() dies for the second one.  Zap the extra
reference.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 files changed
tree: ceb120945adedcbcdaf0bd18bb5558289fe92be6
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. linux-user/
  12. net/
  13. pc-bios/
  14. QMP/
  15. roms/
  16. slirp/
  17. sysconfigs/
  18. target-alpha/
  19. target-arm/
  20. target-cris/
  21. target-i386/
  22. target-m68k/
  23. target-microblaze/
  24. target-mips/
  25. target-ppc/
  26. target-s390x/
  27. target-sh4/
  28. target-sparc/
  29. tcg/
  30. tests/
  31. .gitignore
  32. .gitmodules
  33. a.out.h
  34. acl.c
  35. acl.h
  36. aes.c
  37. aes.h
  38. aio.c
  39. alpha-dis.c
  40. alpha.ld
  41. arch_init.c
  42. arch_init.h
  43. arm-dis.c
  44. arm-semi.c
  45. arm.ld
  46. async.c
  47. balloon.c
  48. balloon.h
  49. block-migration.c
  50. block-migration.h
  51. block.c
  52. block.h
  53. block_int.h
  54. blockdev.c
  55. blockdev.h
  56. bswap.h
  57. bt-host.c
  58. bt-host.h
  59. bt-vhci.c
  60. buffered_file.c
  61. buffered_file.h
  62. cache-utils.c
  63. cache-utils.h
  64. Changelog
  65. check-qdict.c
  66. check-qfloat.c
  67. check-qint.c
  68. check-qjson.c
  69. check-qlist.c
  70. check-qstring.c
  71. cmd.c
  72. cmd.h
  73. cocoa.m
  74. CODING_STYLE
  75. config.h
  76. configure
  77. console.c
  78. console.h
  79. COPYING
  80. COPYING.LIB
  81. cpu-all.h
  82. cpu-common.h
  83. cpu-defs.h
  84. cpu-exec.c
  85. cpus.c
  86. cpus.h
  87. create_config
  88. cris-dis.c
  89. curses.c
  90. curses_keys.h
  91. cursor.c
  92. cursor_hidden.xpm
  93. cursor_left_ptr.xpm
  94. cutils.c
  95. d3des.c
  96. d3des.h
  97. def-helper.h
  98. device_tree.c
  99. device_tree.h
  100. dis-asm.h
  101. disas.c
  102. disas.h
  103. dma-helpers.c
  104. dma.h
  105. dyngen-exec.h
  106. elf.h
  107. envlist.c
  108. envlist.h
  109. exec-all.h
  110. exec.c
  111. feature_to_c.sh
  112. gdbstub.c
  113. gdbstub.h
  114. gen-icount.h
  115. host-utils.c
  116. host-utils.h
  117. hpet.h
  118. hppa-dis.c
  119. hppa.ld
  120. hxtool
  121. i386-dis.c
  122. i386.ld
  123. ia64-dis.c
  124. ia64.ld
  125. input.c
  126. ioport-user.c
  127. ioport.c
  128. ioport.h
  129. iov.c
  130. iov.h
  131. json-lexer.c
  132. json-lexer.h
  133. json-parser.c
  134. json-parser.h
  135. json-streamer.c
  136. json-streamer.h
  137. keymaps.c
  138. keymaps.h
  139. kvm-all.c
  140. kvm-stub.c
  141. kvm.h
  142. libfdt_env.h
  143. LICENSE
  144. linux-aio.c
  145. m68k-dis.c
  146. m68k-semi.c
  147. m68k.ld
  148. MAINTAINERS
  149. Makefile
  150. Makefile.dis
  151. Makefile.hw
  152. Makefile.objs
  153. Makefile.target
  154. Makefile.user
  155. microblaze-dis.c
  156. migration-exec.c
  157. migration-fd.c
  158. migration-tcp.c
  159. migration-unix.c
  160. migration.c
  161. migration.h
  162. mips-dis.c
  163. mips.ld
  164. module.c
  165. module.h
  166. monitor.c
  167. monitor.h
  168. nbd.c
  169. nbd.h
  170. net-checksum.c
  171. net.c
  172. net.h
  173. notify.c
  174. notify.h
  175. os-posix.c
  176. os-win32.c
  177. osdep.c
  178. osdep.h
  179. path.c
  180. pci-ids.txt
  181. poison.h
  182. posix-aio-compat.c
  183. ppc-dis.c
  184. ppc.ld
  185. ppc64.ld
  186. qbool.c
  187. qbool.h
  188. qdict-test-data.txt
  189. qdict.c
  190. qdict.h
  191. qemu-aio.h
  192. qemu-barrier.h
  193. qemu-binfmt-conf.sh
  194. qemu-char.c
  195. qemu-char.h
  196. qemu-common.h
  197. qemu-config.c
  198. qemu-config.h
  199. qemu-doc.texi
  200. qemu-error.c
  201. qemu-error.h
  202. qemu-img-cmds.hx
  203. qemu-img.c
  204. qemu-img.texi
  205. qemu-io.c
  206. qemu-lock.h
  207. qemu-log.h
  208. qemu-malloc.c
  209. qemu-monitor.hx
  210. qemu-nbd.c
  211. qemu-nbd.texi
  212. qemu-objects.h
  213. qemu-option.c
  214. qemu-option.h
  215. qemu-options.h
  216. qemu-options.hx
  217. qemu-os-posix.h
  218. qemu-os-win32.h
  219. qemu-queue.h
  220. qemu-sockets.c
  221. qemu-tech.texi
  222. qemu-thread.c
  223. qemu-thread.h
  224. qemu-timer.c
  225. qemu-timer.h
  226. qemu-tool.c
  227. qemu-x509.h
  228. qemu.sasl
  229. qemu_socket.h
  230. qerror.c
  231. qerror.h
  232. qfloat.c
  233. qfloat.h
  234. qint.c
  235. qint.h
  236. qjson.c
  237. qjson.h
  238. qlist.c
  239. qlist.h
  240. qobject.h
  241. qstring.c
  242. qstring.h
  243. readline.c
  244. readline.h
  245. README
  246. rules.mak
  247. rwhandler.c
  248. rwhandler.h
  249. s390-dis.c
  250. s390.ld
  251. savevm.c
  252. sdl.c
  253. sdl_keysym.h
  254. sdl_zoom.c
  255. sdl_zoom.h
  256. sdl_zoom_template.h
  257. sh4-dis.c
  258. softmmu-semi.h
  259. softmmu_defs.h
  260. softmmu_exec.h
  261. softmmu_header.h
  262. softmmu_template.h
  263. sparc-dis.c
  264. sparc.ld
  265. sparc64.ld
  266. sysemu.h
  267. targphys.h
  268. tcg-runtime.c
  269. texi2pod.pl
  270. thunk.c
  271. thunk.h
  272. TODO
  273. translate-all.c
  274. uboot_image.h
  275. usb-bsd.c
  276. usb-linux.c
  277. usb-stub.c
  278. VERSION
  279. vgafont.h
  280. vl.c
  281. vnc-auth-sasl.c
  282. vnc-auth-sasl.h
  283. vnc-auth-vencrypt.c
  284. vnc-auth-vencrypt.h
  285. vnc-encoding-hextile.c
  286. vnc-encoding-tight.c
  287. vnc-encoding-tight.h
  288. vnc-encoding-zlib.c
  289. vnc-tls.c
  290. vnc-tls.h
  291. vnc.c
  292. vnc.h
  293. vnc_keysym.h
  294. vnchextile.h
  295. x86_64.ld
  296. x_keymap.c
  297. x_keymap.h