[qemu/f17] Fix fedora guest hang with virtio console (bz 837925)

Cole Robinson crobinso at fedoraproject.org
Wed Jul 18 22:02:02 UTC 2012


commit 9e4ae06b20e9a6461797ec19286e6a8b69c17f01
Author: Cole Robinson <crobinso at redhat.com>
Date:   Wed Jul 18 18:01:46 2012 -0400

    Fix fedora guest hang with virtio console (bz 837925)

 qemu-virtio-console-unconnected-pty.patch |   47 +++++++++++++++++++++++++++++
 qemu.spec                                 |    8 ++++-
 2 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/qemu-virtio-console-unconnected-pty.patch b/qemu-virtio-console-unconnected-pty.patch
new file mode 100644
index 0000000..7b95b82
--- /dev/null
+++ b/qemu-virtio-console-unconnected-pty.patch
@@ -0,0 +1,47 @@
+commit ed8e5a85a1741147ce06932b478a509ce3407061
+Author: Christian Borntraeger <borntraeger at de.ibm.com>
+Date:   Thu Dec 29 13:47:43 2011 +0100
+
+    virtio-console: Fix failure on unconnected pty
+    
+    when I tried qemu with -virtio-console pty the guest hangs and attaching
+    on /dev/pts/<x> does not return anything if the attachment is too late.
+    
+    This results in pty_chr_write() returning 0, which causes the port to
+    get throttled. This results in the guest getting frozen as the
+    guest->host virtio_console writes don't return until the host releases
+    the vq element back to the guest.
+    
+    For the virtio-serial use case we don't want to lose data but for the
+    console case we better drop data instead of "killing" the guest
+    console. If we get chardev->frontend notification and a better behaving
+    virtio-console we can revert this fix.
+    
+    Signed-off-by: Christian Borntraeger <borntraeger at de.ibm.com>
+    Signed-off-by: Amit Shah <amit.shah at redhat.com>
+
+diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
+index fe0233f..3a9004a 100644
+--- a/hw/virtio-serial-bus.c
++++ b/hw/virtio-serial-bus.c
+@@ -163,7 +163,19 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
+                 abort();
+             }
+             if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) {
+-                virtio_serial_throttle_port(port, true);
++		/*
++                 * this is a temporary check until chardevs can signal to
++                 * frontends that they are writable again. This prevents
++                 * the console from going into throttled mode (forever)
++                 * if virtio-console is connected to a pty without a
++                 * listener. Otherwise the guest spins forever.
++                 * We can revert this if
++                 * 1: chardevs can notify frondends
++                 * 2: the guest driver does not spin in these cases
++                 */
++                if (!info->is_console) {
++                    virtio_serial_throttle_port(port, true);
++                }
+                 port->iov_idx = i;
+                 if (ret > 0) {
+                     port->iov_offset += ret;
diff --git a/qemu.spec b/qemu.spec
index 909e2ce..5ac9289 100644
--- a/qemu.spec
+++ b/qemu.spec
@@ -38,7 +38,7 @@
 Summary: QEMU is a FAST! processor emulator
 Name: qemu
 Version: 1.0
-Release: 17%{?dist}
+Release: 18%{?dist}
 # Epoch because we pushed a qemu-1.0 package
 Epoch: 2
 License: GPLv2+ and LGPLv2+ and BSD
@@ -207,6 +207,8 @@ Patch506: 0506-audio-spice-add-support-for-volume-control.patch
 Patch507: 0507-Do-not-use-pa_simple-PulseAudio-API.patch
 Patch508: 0508-configure-pa_simple-is-not-needed-anymore.patch
 Patch509: 0509-Allow-controlling-volume-with-PulseAudio-backend.patch
+# Fix fedora guest hang with virtio console (bz 837925)
+Patch510: %{name}-virtio-console-unconnected-pty.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: SDL-devel zlib-devel which texi2html gnutls-devel cyrus-sasl-devel
@@ -578,6 +580,7 @@ such as kvm_stat.
 %patch507 -p1
 %patch508 -p1
 %patch509 -p1
+%patch510 -p1
 
 
 %build
@@ -1009,6 +1012,9 @@ fi
 %{_mandir}/man1/qemu-img.1*
 
 %changelog
+* Wed Jul 18 2012 Cole Robinson <crobinso at redhat.com> - 1.0-18
+- Fix fedora guest hang with virtio console (bz 837925)
+
 * Mon Apr 23 2012 Paolo Bonzini <pbonzini at redhat.com> - 2:1.0-17
 - Fix install failure due to set -e (rhbz #815272)
 


More information about the scm-commits mailing list