libqtest: handle zero length memwrite/memread

Some recently added tests pass a zero length to qtest_memwrite().
Unfortunately, the qtest protocol doesn't implement an on-the-wire
syntax for zero-length writes and the current code happily sends
garbage to QEMU. This causes intermittent failures.

It isn't worth the pain to enhance the protocol, so this patch
simply fixes the issue by "just return, doing nothing". The same
fix is applied to qtest_memread() since the issue also exists in
the QEMU part of the "memread" command.

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