From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FqWem-0001fR-Ax for qemu-devel@nongnu.org; Wed, 14 Jun 2006 10:47:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FqWel-0001f6-3c for qemu-devel@nongnu.org; Wed, 14 Jun 2006 10:47:43 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FqWel-0001f3-0O for qemu-devel@nongnu.org; Wed, 14 Jun 2006 10:47:43 -0400 Received: from [84.96.92.56] (helo=smTp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FqWnw-0005xl-Od for qemu-devel@nongnu.org; Wed, 14 Jun 2006 10:57:12 -0400 Received: from [84.102.211.151] by sp604003mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0J0U00I85SHC3G61@sp604003mt.gpm.neuf.ld> for qemu-devel@nongnu.org; Wed, 14 Jun 2006 16:05:36 +0200 (CEST) Date: Wed, 14 Jun 2006 16:05:18 +0200 From: Fabrice Bellard Subject: Re: [Qemu-devel] Two question on serial port emulation In-reply-to: Message-id: <4490179E.7000403@bellard.org> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Jiang, Yunhong wrote: > Hi, all > I'm using qemu on linux, and I have two questions on the serial port > emulation. The serial port means the hardware serial port (/dev/ttyS0 on > Linux). > > 1) Currently tty_serial_init() set the c_oflags as following: > tty.c_oflag |= OPOST > but it didn't clear the ONLCR/ONLRET etc. This may cause some problem > on binary transfer. For example, when transfer "0x0d 0x0a" for "0x0a". > Following patch may fix this problem, although I'm not sure if we clear > OPOST, do we still need to clear ONLCR/OCRNL etc bits. > > --- vl.c 2006-05-04 04:32:58.000000000 +0800 > +++ ../qemu-0.8.1_bogus/vl.c 2006-06-01 22:34:09.000000000 +0800 > @@ -1586,7 +1586,8 @@ > > tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP > |INLCR|IGNCR|ICRNL|IXON); > - tty.c_oflag |= OPOST; > + tty.c_oflag &= ~(ONLCR | OCRNL | ONOCR |ONLRET) ; > + tty.c_oflag &= ~OPOST; > tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG); > tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS); > switch(data_bits) { So forcing all the flags to known values may be even better ! > 2) Currently all write to the serial port will through unix_write(). > Considering : a) if the return value is -EAGAIN, it will not try to > re-write this again. b) all write will return immetiately. So when guest > try to write a lot of data continuously, like using zmodem to transfer > file or using serial port for debugger, it may cause application failure > (the data is write successfuly from guest point of view, while it failed > on the host environment). I changed the write process to multi-thread, > but I don't think it is a good method, so how do you think of these? You should use the callback based I/Os. An output FIFO must be maintained in the serial driver itself. Unfortunately an API is missing on the QEMU char devices to do proper asynchronous outputs. Fabrice.