Bug 617220

Summary: KVM guest hangs when writing to unopen virtio-console port.
Product: [Fedora] Fedora Reporter: Jiri Zupka <jzupka>
Component: qemuAssignee: Justin M. Forbes <jforbes>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: 13CC: amit.shah, berrange, clalance, dwmw2, ehabkost, extras-orphan, gcosta, hdegoede, itamar, jaswinder, jforbes, knoel, markmc, mjenner, notting, ondrejj, quintela, scottt.tw, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-29 09:08:38 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Jiri Zupka 2010-07-22 10:12:10 EDT
Description of problem:
KVM guest hangs after opening the virtio-console port, when data already in virtioconsole buffer. 

Version-Release number of selected component (if applicable):
kernel-2.6.33.6-147.fc13.x86_64
qemu-kvm-0.12.3-8.fc13.x86_64

guest:
  fedora13 x86_64

How reproducible:
100%


Steps to Reproduce:
1. Start qemu-kvm with commandline 
qemu-kvm -device virtio-serial -drive file=/data/Virtual/fedora-Vconsole.img,if=virtio,boot=on,serial=s,cache=writeback -m 512 -chardev socket,path=/tmp/aaa,id=aaa,server,nowait -device virtconsole,chardev=aaa,name=org.fedoraproject.console.aaa -enable-kvm -monitor stdio -chardev socket,path=/tmp/b,id=b,server,nowait -device virtconsole,chardev=b,name=org.fedoraproject.console.b
2. send 10KB to port /tmp/b
3. in guest open (/dev/hvc1)
  
Actual results:
Guest hangs in infinite loops (cpu usage 100% never end)


Expected results:
On guest side open console /dev/hvc1 and recieve data.


Additional info:
Comment 1 Jiri Zupka 2010-07-22 11:43:31 EDT
I test same stuff using virtserialport with positive results. 

PASS:
1) Start guest 
2) First send data from host (socket /tmp/data) to serial port to guest (/dev/vport0p1).
3) after data are sent open port with 'cat /dev/vport0p1' 

Result:
  cat listens on port, old data are truncated and new are correctly received.
Comment 2 Amit Shah 2010-07-27 04:56:28 EDT
Works for me with Linus' git kernel in the guest. Most likely looks like a guest kernel issue. I'll update when I have more data or a fix.
Comment 3 Hans de Goede 2010-10-17 16:03:05 EDT
I believe this is the same issue as I discussed with Amit on irc this is a feature ^W bug on how the virtio_console driver in the guest handles writes when no one is listening on the host side.

The problem is this "beauty" in virtio_console.c: send_buf()

        /*
         * Wait till the host acknowledges it pushed out the data we
         * sent.  This is done for ports in blocking mode or for data
         * from the hvc_console; the tty operations are performed with
         * spinlocks held so we can't sleep here.
         */
        while (!virtqueue_get_buf(out_vq, &len))
                cpu_relax();

I see a number of possible (partial) solutions here:

1) the code says it is using cpu_relux rather then sleep, because the tty functions are called with a spinlock held. but fops-write is not called with any spinlock held, I believe. How about a parameter to send_buf, called "may_sleep" and then use sleep rather then relax if may_sleep is true?

2) The waiting is done for: "This is done for ports in blocking mode or for data from the hvc_console". I wonder why the waiting is done in blocking mode too, I guess this is some sort of workaround for the missing waitqueue wakeups, see bug 643750, with those waitqueue wakeups added I would think / expect the waiting for the host acknowledge is only needed for tty usage, and that we could skip the wait entirely (making 1 mute) when called from fops_write ?
Comment 4 Bug Zapper 2011-06-01 09:12:45 EDT
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 5 Bug Zapper 2011-06-29 09:08:38 EDT
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.