RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 624620 - Can't write to virtio-serial when in blocking read
Summary: Can't write to virtio-serial when in blocking read
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Amit Shah
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 580953
TreeView+ depends on / blocked
 
Reported: 2010-08-17 09:33 UTC by Gal Hammer
Modified: 2014-01-17 12:42 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-08-26 04:52:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Gal Hammer 2010-08-17 09:33:54 UTC
I'm trying to work with two threads. One thread is blocking on read from virtio-serial port and the second write to the port when needed. What happen is that the write doesn't return until something is read from the port.

How reproducible:

---< snip >---

#!/usr/bin/python

import os, socket, struct, platform, threading

class ListenThread(threading.Thread):
    def __init__(self, vio):
        self._vio = vio
        threading.Thread.__init__(self)

    def run(self):
        while not False:
            print "Read from vport: %s" % (self._vio.readline())

def main():
    vio = open('/dev/vport0p0', 'r+b')    
    listen = ListenThread(vio)
    listen.start()    
    input = raw_input()
    while input != 'quit':
        print "Before write()"
        vio.write(input)
        print "After write()"
        input = raw_input()    
    vio.close()

if __name__ == "__main__":
    main()

---< snip >---

Comment 2 Amit Shah 2010-08-18 07:21:51 UTC
(In reply to comment #0)
> I'm trying to work with two threads. One thread is blocking on read from
> virtio-serial port and the second write to the port when needed. What happen is
> that the write doesn't return until something is read from the port.

You're going to have to use poll and condition variables to work on the same file descriptor in two different threads.

Comment 3 Gal Hammer 2010-08-18 07:51:01 UTC
(In reply to comment #2)

> You're going to have to use poll and condition variables to work on the same
> file descriptor in two different threads.

I don't want to. This is why I open the bug.

Comment 5 Amit Shah 2010-08-23 08:44:40 UTC
I just wrote a testcase for this bug in the virtio-console test suite:

http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git

The test passes, so I guess there's a bug in the userspace app.

This is the testcase I committed:

http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git;a=commitdiff;h=e1f100f1fbe0285c7efdfc30f38bece766e59efe

It opens a port in the guest, creates a thread, blocks the thread on read, and then in the parent thread writes some stuff, host reads it and then writes something to the guest to unblock the read. This works as expected.

Comment 6 Gal Hammer 2010-08-23 09:13:15 UTC
On your test case. Does the write() exit *before* the host write something? Or in other words, does the test works if the host doesn't reply?

Comment 7 Amit Shah 2010-08-23 11:25:45 UTC
Which write are you talking about? The write in the guest does complete, it's independent of the host's reply.

I suggest you see the code yourself.

Comment 8 Amit Shah 2010-08-26 04:52:09 UTC
Since this works for me I'm closing this bug. Please re-open if you think this still needs work.


Note You need to log in before you can comment on or make changes to this bug.