Emulated serial port does not work with FreeBSD 8.0 guest

Bug #518346 reported by Garry Dolley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kvm (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: kvm

I'm running a handful of Jaunty systems and this bug appears in kvm 1:84+dfsg-0ubuntu12.4

Host:

$ lsb_release -rd
Description: Ubuntu 9.04
Release: 9.04
$

Description of bug:

If you start a FreeBSD 8.0 guest with "-serial telnet:127.0.0.1:<port>,server,nowait", and then try to connect to the guest's serial port with telnet, there will be no output to the telnet side. The FreeBSD 8.0 guest is running a getty process on /dev/ttyu0.

This is specific to FreeBSD 8.0. FreeBSD 7.1 and 7.2 guests did not exhibit this problem.

FreeBSD 8.0 uses a new uart(4) driver (/dev/ttyu0). Prior versions used sio(4) (/dev/ttyd0).

Proposed fix:

There is an upstream QEMU patch that fixes this.

I've rolled this patch into my PPA for kvm (among other changes): https://launchpad.net/~gdolley/+archive/ppa/+packages

A debdiff for just this specific issue that fixes the problem is:

diff -u kvm-84+dfsg/debian/changelog kvm-84+dfsg/debian/changelog
--- kvm-84+dfsg/debian/changelog
+++ kvm-84+dfsg/debian/changelog
@@ -1,3 +1,11 @@
+kvm (1:84+dfsg-0ubuntu12.5~ppa1) jaunty; urgency=low
+
+ * debian/patches/qemu-serial-lost-tx-irqs-affecting-freebsd-new-uart-driver.patch:
+ cherry-pick from upstream
+ - Fixes qemu serial vs. FreeBSD 8.0 uart(4) not working properly
+
+ -- Garry Dolley <email address hidden> Wed, 09 Dec 2009 03:53:31 -0800
+
 kvm (1:84+dfsg-0ubuntu12.4) jaunty-proposed; urgency=low

   * debian/patches/Fix-cluster-freeing-in-qcow2.patch: cherry-pick
diff -u kvm-84+dfsg/debian/control kvm-84+dfsg/debian/control
diff -u kvm-84+dfsg/debian/patches/series kvm-84+dfsg/debian/patches/series
--- kvm-84+dfsg/debian/patches/series
+++ kvm-84+dfsg/debian/patches/series
@@ -17,0 +18 @@
+qemu-serial-lost-tx-irqs-affecting-freebsd-new-uart-driver.patch
only in patch2:
unchanged:
--- kvm-84+dfsg.orig/debian/patches/qemu-serial-lost-tx-irqs-affecting-freebsd-new-uart-driver.patch
+++ kvm-84+dfsg/debian/patches/qemu-serial-lost-tx-irqs-affecting-freebsd-new-uart-driver.patch
@@ -0,0 +1,37 @@
+commit 2d6ee8e7e17227d5eb8c6e9a054dd88d5b37c5ae
+Author: Juergen Lock <email address hidden>
+Date: Sat Sep 12 18:52:22 2009 +0200
+
+ qemu serial: lost tx irqs (affecting FreeBSD's new uart(4) driver)
+
+ Well one problem seems to be the rx condition,
+ ... if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR))
+ is not enough to trigger an irq, yet still causes the following
+ conditions not to be checked anymore at all.
+
+ Signed-off-by: Juergen Lock <email address hidden>
+ Acked-by: Jan Kiszka <email address hidden>
+ Acked-by: Stefano Stabellini <email address hidden>
+ Signed-off-by: Aurelien Jarno <email address hidden>
+
+diff --git a/qemu/hw/serial.c b/qemu/hw/serial.c
+index 1f4ce77..a22770f 100644
+--- a/qemu/hw/serial.c
++++ b/qemu/hw/serial.c
+@@ -197,12 +197,10 @@ static void serial_update_irq(SerialState *s)
+ * this is not in the specification but is observed on existing
+ * hardware. */
+ tmp_iir = UART_IIR_CTI;
+- } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR)) {
+- if (!(s->fcr & UART_FCR_FE)) {
+- tmp_iir = UART_IIR_RDI;
+- } else if (s->recv_fifo.count >= s->recv_fifo.itl) {
+- tmp_iir = UART_IIR_RDI;
+- }
++ } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR) &&
++ (!(s->fcr & UART_FCR_FE) ||
++ s->recv_fifo.count >= s->recv_fifo.itl)) {
++ tmp_iir = UART_IIR_RDI;
+ } else if ((s->ier & UART_IER_THRI) && s->thr_ipending) {
+ tmp_iir = UART_IIR_THRI;
+ } else if ((s->ier & UART_IER_MSI) && (s->msr & UART_MSR_ANY_DELTA)) {

My modified kvm package with the above patch runs about 80 production virtual machines of the following flavors: FreeBSD 7.1, 7.2, and 8.0; OpenBSD 4.5 and 4.6; Ubuntu 9.04; Debian 5.02; ArchLinux; and Gentoo. None of these have had any serial port problems after the above patch was applied.

Might be worth applying to Karmic or Lucid kvm packages if the QEMU upstream in those kvm packages do not already include it.

Revision history for this message
Chuck Short (zulcss) wrote :

Hi,

This has been fixed on lucid already it might be a good candidate for an SRU.

Regards
chuck

Changed in kvm (Ubuntu):
status: New → Fix Released
Revision history for this message
Garry Dolley (gdolley) wrote :

Do you think it would have a good chance of being accepted as an SRU? I know those are not taken lightly.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.