block/drive-mirror: Check for NULL backing_hd

It should be possible to execute the QMP "drive-mirror" command in
"none" sync mode and "absolute-paths" mode even for block devices
lacking a backing file.

"absolute-paths" does in fact not require a backing file to be present,
as can be seen from the "top" sync mode code path. "top" basically
states that the device should indeed have a backing file - however, the
current code catches the case if it doesn't and then simply treats it as
"full" sync mode, creating a target image without a backing file (in
"absolute-paths" mode). Thus, "absolute-paths" does not imply the target
file must indeed have a backing file.

Therefore, the target file may be left unbacked in case of "none" sync
mode as well, if the specified device is not backed either. Currently,
qemu will crash trying to dereference the backing file pointer since it
assumes that it will always be non-NULL in that case ("none" with
"absolute-paths").

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 file changed
tree: 46183b6590029d2c370bf1b1f80ec03de2363f9f
  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. libcacard/
  14. linux-headers/
  15. linux-user/
  16. net/
  17. pc-bios/
  18. po/
  19. qapi/
  20. qga/
  21. qobject/
  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-moxie/
  37. target-openrisc/
  38. target-ppc/
  39. target-s390x/
  40. target-sh4/
  41. target-sparc/
  42. target-unicore32/
  43. target-xtensa/
  44. tcg/
  45. tests/
  46. trace/
  47. ui/
  48. util/
  49. .exrc
  50. .gitignore
  51. .gitmodules
  52. .mailmap
  53. aio-posix.c
  54. aio-win32.c
  55. arch_init.c
  56. async.c
  57. balloon.c
  58. block-migration.c
  59. block.c
  60. blockdev-nbd.c
  61. blockdev.c
  62. blockjob.c
  63. bt-host.c
  64. bt-vhci.c
  65. Changelog
  66. CODING_STYLE
  67. configure
  68. COPYING
  69. COPYING.LIB
  70. coroutine-gthread.c
  71. coroutine-sigaltstack.c
  72. coroutine-ucontext.c
  73. coroutine-win32.c
  74. cpu-exec.c
  75. cpus.c
  76. cputlb.c
  77. device-hotplug.c
  78. device_tree.c
  79. disas.c
  80. dma-helpers.c
  81. dump.c
  82. exec.c
  83. gdbstub.c
  84. HACKING
  85. hmp-commands.hx
  86. hmp.c
  87. hmp.h
  88. iohandler.c
  89. ioport.c
  90. kvm-all.c
  91. kvm-stub.c
  92. LICENSE
  93. main-loop.c
  94. MAINTAINERS
  95. Makefile
  96. Makefile.objs
  97. Makefile.target
  98. memory.c
  99. memory_mapping.c
  100. migration-exec.c
  101. migration-fd.c
  102. migration-rdma.c
  103. migration-tcp.c
  104. migration-unix.c
  105. migration.c
  106. monitor.c
  107. nbd.c
  108. os-posix.c
  109. os-win32.c
  110. page_cache.c
  111. qapi-schema.json
  112. qdev-monitor.c
  113. qdict-test-data.txt
  114. qemu-bridge-helper.c
  115. qemu-char.c
  116. qemu-coroutine-io.c
  117. qemu-coroutine-lock.c
  118. qemu-coroutine-sleep.c
  119. qemu-coroutine.c
  120. qemu-doc.texi
  121. qemu-img-cmds.hx
  122. qemu-img.c
  123. qemu-img.texi
  124. qemu-io-cmds.c
  125. qemu-io.c
  126. qemu-log.c
  127. qemu-nbd.c
  128. qemu-nbd.texi
  129. qemu-options-wrapper.h
  130. qemu-options.h
  131. qemu-options.hx
  132. qemu-seccomp.c
  133. qemu-tech.texi
  134. qemu-timer.c
  135. qemu.nsi
  136. qemu.sasl
  137. qmp-commands.hx
  138. qmp.c
  139. qtest.c
  140. readline.c
  141. README
  142. rules.mak
  143. savevm.c
  144. spice-qemu-char.c
  145. tcg-runtime.c
  146. tci.c
  147. thread-pool.c
  148. thunk.c
  149. tpm.c
  150. trace-events
  151. translate-all.c
  152. translate-all.h
  153. user-exec.c
  154. VERSION
  155. version.rc
  156. vl.c
  157. xbzrle.c
  158. xen-all.c
  159. xen-mapcache.c
  160. xen-stub.c