virtio-console: fix receiving data from guest
virtio-console: set frontend open permanently for console devs

The virtio-console.c file handles both serial consoles
and interactive consoles, since they're backed by the
same device model.

Since serial devices are expected to be reliable and
need to notify the guest when the backend is opened
or closed, the virtio-console.c file wires up support
for chardev events. This affects both serial consoles
and interactive consoles, using a network connection
based chardev backend such as 'socket', but not when
using a PTY based backend or plain 'file' backends.

When the host side is not connected the handle_output()
method in virtio-serial-bus.c will drop any data sent
by the guest, before it even reaches the virtio-console.c
code. This means that if the chardev has a logfile
configured, the data will never get logged.

Consider for example, configuring a x86_64 guest with a
plain UART serial port

  -chardev socket,id=charserial1,host=127.0.0.1,port=9001,server,nowait,logfile=console1.log,logappend=on
  -device isa-serial,chardev=charserial1,id=serial1

vs a s390 guest which has to use the virtio-console port

  -chardev socket,id=charconsole1,host=127.0.0.1,port=9000,server,nowait,logfile=console2.log,logappend=on
  -device virtconsole,chardev=charconsole1,id=console1

The isa-serial one gets data written to the log regardless
of whether a client is connected, while the virtioconsole
one only gets data written to the log when a client is
connected.

There is no need for virtio-serial-bus.c to aggressively
drop the data for console devices, as the chardev code is
prefectly capable of discarding the data itself.

So this patch changes virtconsole devices so that they
are always marked as having the host side open. This
ensures that the guest OS will always send any data it
has (Linux virtio-console hvc driver actually ignores
the host open state and sends data regardless, but we
should not rely on that), and also prevents the
virtio-serial-bus code prematurely discarding data.

The behaviour of virtserialport devices is *not* changed,
only virtconsole, because for the former, it is important
that the guest OSknow exactly when the host side is opened
/ closed so it can do any protocol re-negotiation that may
be required.

Fixes bug: https://bugs.launchpad.net/qemu/+bug/1599214

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1470241360-3574-2-git-send-email-berrange@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
1 file changed
tree: 7a318c0a0d726d9fc2523a0da02e31f995bd5cc6
  1. .dir-locals.el
  2. .exrc
  3. .gitignore
  4. .gitmodules
  5. .mailmap
  6. .travis.yml
  7. CODING_STYLE
  8. COPYING
  9. COPYING.LIB
  10. Changelog
  11. HACKING
  12. LICENSE
  13. MAINTAINERS
  14. Makefile
  15. Makefile.objs
  16. Makefile.target
  17. README
  18. VERSION
  19. accel.c
  20. aio-posix.c
  21. aio-win32.c
  22. arch_init.c
  23. async.c
  24. audio/
  25. backends/
  26. balloon.c
  27. block.c
  28. block/
  29. blockdev-nbd.c
  30. blockdev.c
  31. blockjob.c
  32. bootdevice.c
  33. bsd-user/
  34. bt-host.c
  35. bt-vhci.c
  36. configure
  37. contrib/
  38. cpu-exec-common.c
  39. cpu-exec.c
  40. cpus.c
  41. cputlb.c
  42. crypto/
  43. default-configs/
  44. device-hotplug.c
  45. device_tree.c
  46. disas.c
  47. disas/
  48. dma-helpers.c
  49. docs/
  50. dump.c
  51. exec.c
  52. fpu/
  53. fsdev/
  54. gdb-xml/
  55. gdbstub.c
  56. hmp-commands-info.hx
  57. hmp-commands.hx
  58. hmp.c
  59. hmp.h
  60. hw/
  61. include/
  62. io/
  63. iohandler.c
  64. ioport.c
  65. iothread.c
  66. kvm-all.c
  67. kvm-stub.c
  68. libdecnumber/
  69. linux-headers/
  70. linux-user/
  71. main-loop.c
  72. memory.c
  73. memory_mapping.c
  74. migration/
  75. module-common.c
  76. monitor.c
  77. nbd/
  78. net/
  79. numa.c
  80. os-posix.c
  81. os-win32.c
  82. page_cache.c
  83. pc-bios/
  84. po/
  85. qapi-schema.json
  86. qapi/
  87. qdev-monitor.c
  88. qdict-test-data.txt
  89. qemu-bridge-helper.c
  90. qemu-char.c
  91. qemu-doc.texi
  92. qemu-ga.texi
  93. qemu-img-cmds.hx
  94. qemu-img.c
  95. qemu-img.texi
  96. qemu-io-cmds.c
  97. qemu-io.c
  98. qemu-nbd.c
  99. qemu-nbd.texi
  100. qemu-option-trace.texi
  101. qemu-options-wrapper.h
  102. qemu-options.h
  103. qemu-options.hx
  104. qemu-seccomp.c
  105. qemu-tech.texi
  106. qemu-timer.c
  107. qemu.nsi
  108. qemu.sasl
  109. qga/
  110. qmp-commands.hx
  111. qmp.c
  112. qobject/
  113. qom/
  114. qtest.c
  115. replay/
  116. roms/
  117. rules.mak
  118. scripts/
  119. slirp/
  120. softmmu_template.h
  121. spice-qemu-char.c
  122. stubs/
  123. target-alpha/
  124. target-arm/
  125. target-cris/
  126. target-i386/
  127. target-lm32/
  128. target-m68k/
  129. target-microblaze/
  130. target-mips/
  131. target-moxie/
  132. target-openrisc/
  133. target-ppc/
  134. target-s390x/
  135. target-sh4/
  136. target-sparc/
  137. target-tilegx/
  138. target-tricore/
  139. target-unicore32/
  140. target-xtensa/
  141. tcg-runtime.c
  142. tcg/
  143. tci.c
  144. tests/
  145. thread-pool.c
  146. thunk.c
  147. tpm.c
  148. trace-events
  149. trace/
  150. translate-all.c
  151. translate-all.h
  152. translate-common.c
  153. ui/
  154. user-exec.c
  155. util/
  156. version.rc
  157. vl.c
  158. xen-common-stub.c
  159. xen-common.c
  160. xen-hvm-stub.c
  161. xen-hvm.c
  162. xen-mapcache.c