summaryrefslogtreecommitdiff
path: root/hw/char/virtio-console.c
AgeCommit message (Collapse)AuthorFilesLines
2016-09-13hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_allDaniel P. Berrange1-0/+21
The qemu_chr_fe_write method will return -1 on EAGAIN if the chardev backend write would block. Almost no callers of the qemu_chr_fe_write() method check the return value, instead blindly assuming data was successfully sent. In most cases this will lead to silent data loss on interactive consoles, but in some cases (eg RNG EGD) it'll just cause corruption of the protocol being spoken. We unfortunately can't fix the virtio-console code, due to a bug in the Linux guest drivers, which would cause the entire Linux kernel to hang if we delay processing of the incoming data in any way. Fixing this requires first fixing the guest driver to not hold spinlocks while writing to the hvc device backend. Fixes bug: https://bugs.launchpad.net/qemu/+bug/1586756 Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1473170165-540-4-git-send-email-berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-08-11virtio-console: set frontend open permanently for console devsDaniel P. Berrange1-4/+21
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>
2016-01-29virtio: Clean up includesPeter Maydell1-0/+1
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1453832250-766-15-git-send-email-peter.maydell@linaro.org
2015-05-29virtio-console: notify chardev when writableMarc-André Lureau1-0/+10
When the virtio serial is writable, notify the chardev backend with qemu_chr_accept_input(). Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-30serial: poll the serial console with G_IO_HUPRoger Pau Monne1-1/+2
On FreeBSD polling a master pty while the other end is not connected with G_IO_OUT only results in an endless wait. This is different from the Linux behaviour, that returns immediately. In order to demonstrate this, I have the following example code: http://xenbits.xen.org/people/royger/test_poll.c When executed on Linux: $ ./test_poll In callback On FreeBSD instead, the callback never gets called: $ ./test_poll So, in order to workaround this, poll the source with G_IO_HUP (which makes the code behave the same way on both Linux and FreeBSD). Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Cc: Michael Tokarev <mjt@tls.msk.ru> Cc: "Andreas Färber" <afaerber@suse.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: xen-devel@lists.xenproject.org [Add hw/char/cadence_uart.c too. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-06-27virtio-serial: report frontend connection state via monitorLaszlo Ersek1-3/+9
Libvirt wants to know about the guest-side connection state of some virtio-serial ports (in particular the one(s) assigned to guest agent(s)). Report such states with a new monitor event. RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-03-13virtio-console: Fix VIRTIO_CONSOLE() cast macroAndreas Färber1-18/+6
Commit 0399a3819b27083ba69b88a9baa9025facab85bd (virtio-console: QOM cast cleanup for VirtConsole) broke virtserialport since it shares functions and state struct with virtconsole. Let virtconsole inherit from virtserialport, and use virtserialport type for casting. Note that virtio-serial-port is the abstract base type in virtio-serial-bus.c, whereas virtserialport is the user-instantiatable type in virtio-console.c. Therefore using TYPE_VIRTIO_CONSOLE_SERIAL_PORT. Reported-by: Richard W.M. Jones <rjones@redhat.com> Acked-by: Richard W.M. Jones <rjones@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-03-13virtio-serial-port: Convert to QOM realize/unrealizeAndreas Färber1-15/+13
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-03-13virtio-console: QOM cast cleanup for VirtConsoleAndreas Färber1-13/+20
Introduce type constant, cast macro and rename parent field. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-08-01virtio-console: Use exitfn for virtserialport, tooAndreas Färber1-0/+1
virtconsole and virtserialport are identical in every other aspect except for the distinguishing VirtIOSerialPortClass::is_console field. Cc: qemu-stable@nongnu.org Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Andreas Färber <afaerber@suse.de> Message-id: 1375313326-14966-1-git-send-email-afaerber@suse.de Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-16virtio-console: Remove any pending watches on closeHans de Goede1-2/+22
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-16virtio-console: Also throttle when less was written then requestedHans de Goede1-3/+5
This is necessary so that we get properly woken up to write the rest. This patch also changes the len argument to the have_data callback, to avoid doing an unsigned signed comparison. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-04-15sysemu: avoid proliferation of include/ subdirectoriesPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08hw: move target-independent files to subdirectoriesPaolo Bonzini1-0/+184
This patch tackles all files that are compiled once, moving them to subdirectories of hw/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>