virtio-console: fix receiving data from guest

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXrF7jAAoJEOsLTfxlfvZwGiUP/2g0/I89SuzyWHlys8KMSCtf
 v/07FcYzSCfEScBadNcAoDgByzPXwV3mWwdluxYETa+HeA88CrRnwhPc4vMh7n2e
 99+vOfYLGEgpxuOrFuzNeI2H9y5i/OZ6GkPVlGL5aKasLL/F4wl9lOu/i3//SyX0
 yGzArg3ldbdcEAGQKPELg1MK/GLwaGpgoHApAZtkgD3F7qyToWiLBCmuEc7/P0VT
 WfHaVQYizXlptPyfKk2Syl02wNaOih96aCEjItKgyZmTa3GT6K+biMI9gz8CznX9
 aVdKKvtvVIBnwsdljCcptu1rjYfDVKElFHdkQyUO3ZPE7MZWsnp3POYz8FAsTBD5
 EWc7TRAA0mM3rzbGVqwcV0qGn/uC9wNoeLKepRl9gQqeC0h2TuFu3G+pJ1eCIYfi
 P+MFY8OodCd+o0P1CHKR/Rg/g1StK2kxXfz436I/F6H5H1RgNbJnzbReM2YHfCQO
 QVSv0VartNmonOsq0RSIkffn+RMDnx+Hd5jDZiTM2saWt5Kr3ySpIoTOQ4wa1kBB
 YwUqWGLBkIiX+7Sqsz9E5rsMd4pG8OJsaMcDOrPeTwLpdZ+k61Vfrv/Uyr7hSEKD
 2Fbf+HAM8GiRH7SvblOdVoCDKSccGj50kNCuXk+EVsi9O+DbNBRPJ8BqbJf7Xlfa
 wweVRq3CPIF9AsHrA4R+
 =7jsV
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/amit/tags/vser-for-2.7-1' into staging

virtio-console: fix receiving data from guest

# gpg: Signature made Thu 11 Aug 2016 12:17:55 BST
# gpg:                using RSA key 0xEB0B4DFC657EF670
# gpg: Good signature from "Amit Shah <amit@amitshah.net>"
# gpg:                 aka "Amit Shah <amit@kernel.org>"
# gpg:                 aka "Amit Shah <amitshah@gmx.net>"
# Primary key fingerprint: 48CA 3722 5FE7 F4A8 B337  2735 1E9A 3B5F 8540 83B6
#      Subkey fingerprint: CC63 D332 AB8F 4617 4529  6534 EB0B 4DFC 657E F670

* remotes/amit/tags/vser-for-2.7-1:
  virtio-console: set frontend open permanently for console devs

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2016-08-11 13:26:35 +01:00
commit bea048dcb9
1 changed files with 21 additions and 4 deletions

View File

@ -85,8 +85,9 @@ static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
{
VirtConsole *vcon = VIRTIO_CONSOLE(port);
DeviceState *dev = DEVICE(port);
VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(port);
if (vcon->chr) {
if (vcon->chr && !k->is_console) {
qemu_chr_fe_set_open(vcon->chr, guest_connected);
}
@ -156,9 +157,25 @@ static void virtconsole_realize(DeviceState *dev, Error **errp)
}
if (vcon->chr) {
vcon->chr->explicit_fe_open = 1;
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
vcon);
/*
* For consoles we don't block guest data transfer just
* because nothing is connected - we'll just let it go
* whetherever the chardev wants - /dev/null probably.
*
* For serial ports we need 100% reliable data transfer
* so we use the opened/closed signals from chardev to
* trigger open/close of the device
*/
if (k->is_console) {
vcon->chr->explicit_fe_open = 0;
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read,
NULL, vcon);
virtio_serial_open(port);
} else {
vcon->chr->explicit_fe_open = 1;
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read,
chr_event, vcon);
}
}
}