All of lore.kernel.org
 help / color / mirror / Atom feed
* more about serial ports: do they even work?
@ 2009-01-26 20:20 Michael Tokarev
  2009-01-26 20:39 ` Michael Tokarev
  2009-02-05 18:33 ` [PATCH, finally]: " Michael Tokarev
  0 siblings, 2 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-01-26 20:20 UTC (permalink / raw)
  To: KVM list; +Cc: David S. Ahern

After some debugging and debugging, with a help
Hollis Blanchard on #kvm@freenode, I discovered
that kvm (or, rather, qemu) does not work correctly
with serial ports, at least on linux.  One problem
report has already here, author Cc'd -- see e.g.
http://marc.info/?l=kvm&m=122995568009533&w=2 .

Here's what's going on.

When opening a host's port, kvm resets the status
lines, doing this:

ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000])
ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS])

which results in the following set

ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR])

Note the difference between the default set and new one: the
missing bit, 0x4000, which is unknown to strace(1) but is defined
as TIOCM_OUT2 in linux headers.

After that change (resetting the TIOCM_OUT2 bit), no writes
to the serial port works anymore, they're all gets accepted
by host kernel and are buffered in the kernel.

After some time, when the kernel buffer fills up, and since
the port (on host side) is opened in non-blocking mode, the
writes starts returning EAGAIN, and kvm process starts
endless loop, which were seen by David.

Here's the trivial program to demonstrate the idea:

---- cut ---
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <termios.h>

int main(int argc, char **argv) {
  fd = open("/dev/ttyS0", O_RDWR|O_NONBLOCK);
  fcntl(fd, F_SETFL, O_RDWR);
  x = TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR // |0x4000
  ;
  ioctl(fd, TIOCMSET, &x);
  ioctl(fd, TIOCMGET, &x);
  write(fd, "at\r", 3);
  read(fd, buf, 20);
  close(fd);

  return 0;
}
--- cut ---


Run it under strace while a dialup modem is connected to /dev/ttyS0
(i used this way for testing).  It will stuck at read, and nothing
will be written, even when write() will happily return 3.  Un-comment
the |0x4000 thing, and it will work.

I'm not sure what should be done with this, and how much this is
linux-specific.  But it is obvious that bit (TIOCM_OUT2) should
be left in-place (after which the thing works), at least on linux.

Note that this bit is NOT shown in /proc/tty/driver/serial file
(which shows other bits).

Note also that this file (/proc/tty/driver/serial) helps to see
if any write were performed: compare the counters.  In 'tx'
there's number of bytes actually sent to device, as opposed to
accepted by the kernel.  When you write something to /dev/ttyS0,
that number increases, IF that something actually reached the
device.

Thanks.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-01-26 20:20 more about serial ports: do they even work? Michael Tokarev
@ 2009-01-26 20:39 ` Michael Tokarev
  2009-02-02 21:27     ` [Qemu-devel] " David S. Ahern
  2009-02-05 18:33 ` [PATCH, finally]: " Michael Tokarev
  1 sibling, 1 reply; 29+ messages in thread
From: Michael Tokarev @ 2009-01-26 20:39 UTC (permalink / raw)
  To: KVM list; +Cc: David S. Ahern

Michael Tokarev ?????:
> After some debugging and debugging, with a help
> Hollis Blanchard on #kvm@freenode, I discovered
> that kvm (or, rather, qemu) does not work correctly
> with serial ports, at least on linux.  One problem
> report has already here, author Cc'd -- see e.g.
> http://marc.info/?l=kvm&m=122995568009533&w=2 .
> 
> Here's what's going on.
> 
> When opening a host's port, kvm resets the status
> lines, doing this:
> 
> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000])
> ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS])
> 
> which results in the following set
> 
> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR])

Here's the possible solution (NotAPAtch(tm)):

In kvm-xx/qemu/qemu-char.c:

    case CHR_IOCTL_SERIAL_SET_TIOCM:
        {
            int sarg = *(int *)arg;
            int targ = 0;        <==== change this 0 to 0x4000
            if (sarg | CHR_TIOCM_DTR)
                targ |= TIOCM_DTR;
            if (sarg | CHR_TIOCM_RTS)
                targ |= TIOCM_RTS;
            ioctl(s->fd_in, TIOCMSET, &targ);
        }
        break;

This is obviously a hack, esp. since this bit is not
always present even on linux (after reading 8250.c
driver).

Real fix will be, I guess, to read the full set
first, and combine it with DTR|RTS received from
guest, something like this:

    case CHR_IOCTL_SERIAL_SET_TIOCM:
        {
            int sarg = *(int *)arg;
            int targ = 0;
            ioctl(s->fd_in, TIOCMGET, &targ);
            if (!(sarg | CHR_TIOCM_DTR))
                targ &= ~TIOCM_DTR;
            if (!(sarg | CHR_TIOCM_RTS))
                targ ~= ~TIOCM_RTS;
            ioctl(s->fd_in, TIOCMSET, &targ);
        }
        break;

I.e., to always keep all the other bits, but
allow changing DTR and RTS.

Again, I don't know how it's linux-specific, but
it seems the solution above should work on other
platforms just fine.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-01-26 20:39 ` Michael Tokarev
@ 2009-02-02 21:27     ` David S. Ahern
  0 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-02 21:27 UTC (permalink / raw)
  To: KVM list, qemu-devel; +Cc: Michael Tokarev

I don't recall seeing a followup to this post.

To put Michael's second suggestion into patch form, the following fixes
the problem for me:

--- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
+++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
@@ -1078,20 +1078,21 @@
             if (sarg | TIOCM_DTR)
                 *targ |= CHR_TIOCM_DTR;
             if (sarg | TIOCM_RTS)
                 *targ |= CHR_TIOCM_RTS;
         }
         break;
     case CHR_IOCTL_SERIAL_SET_TIOCM:
         {
             int sarg = *(int *)arg;
             int targ = 0;
+            ioctl(s->fd_in, TIOCMGET, &targ);
             if (sarg | CHR_TIOCM_DTR)
                 targ |= TIOCM_DTR;
             if (sarg | CHR_TIOCM_RTS)
                 targ |= TIOCM_RTS;
             ioctl(s->fd_in, TIOCMSET, &targ);
         }
         break;
     default:
         return -ENOTSUP;
     }

Is this approach palatable to folks?

david


Michael Tokarev wrote:
> Michael Tokarev ?????:
>> After some debugging and debugging, with a help
>> Hollis Blanchard on #kvm@freenode, I discovered
>> that kvm (or, rather, qemu) does not work correctly
>> with serial ports, at least on linux.  One problem
>> report has already here, author Cc'd -- see e.g.
>> http://marc.info/?l=kvm&m=122995568009533&w=2 .
>>
>> Here's what's going on.
>>
>> When opening a host's port, kvm resets the status
>> lines, doing this:
>>
>> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000])
>> ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS])
>>
>> which results in the following set
>>
>> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR])
> 
> Here's the possible solution (NotAPAtch(tm)):
> 
> In kvm-xx/qemu/qemu-char.c:
> 
>     case CHR_IOCTL_SERIAL_SET_TIOCM:
>         {
>             int sarg = *(int *)arg;
>             int targ = 0;        <==== change this 0 to 0x4000
>             if (sarg | CHR_TIOCM_DTR)
>                 targ |= TIOCM_DTR;
>             if (sarg | CHR_TIOCM_RTS)
>                 targ |= TIOCM_RTS;
>             ioctl(s->fd_in, TIOCMSET, &targ);
>         }
>         break;
> 
> This is obviously a hack, esp. since this bit is not
> always present even on linux (after reading 8250.c
> driver).
> 
> Real fix will be, I guess, to read the full set
> first, and combine it with DTR|RTS received from
> guest, something like this:
> 
>     case
>         {
>             int sarg = *(int *)arg;
>             int targ = 0;
>             ioctl(s->fd_in, TIOCMGET, &targ);
>             if (!(sarg | CHR_TIOCM_DTR))
>                 targ &= ~TIOCM_DTR;
>             if (!(sarg | CHR_TIOCM_RTS))
>                 targ ~= ~TIOCM_RTS;
>             ioctl(s->fd_in, TIOCMSET, &targ);
>         }
>         break;
> 
> I.e., to always keep all the other bits, but
> allow changing DTR and RTS.
> 
> Again, I don't know how it's linux-specific, but
> it seems the solution above should work on other
> platforms just fine.
> 
> /mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-02 21:27     ` David S. Ahern
  0 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-02 21:27 UTC (permalink / raw)
  To: KVM list, qemu-devel; +Cc: Michael Tokarev

I don't recall seeing a followup to this post.

To put Michael's second suggestion into patch form, the following fixes
the problem for me:

--- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
+++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
@@ -1078,20 +1078,21 @@
             if (sarg | TIOCM_DTR)
                 *targ |= CHR_TIOCM_DTR;
             if (sarg | TIOCM_RTS)
                 *targ |= CHR_TIOCM_RTS;
         }
         break;
     case CHR_IOCTL_SERIAL_SET_TIOCM:
         {
             int sarg = *(int *)arg;
             int targ = 0;
+            ioctl(s->fd_in, TIOCMGET, &targ);
             if (sarg | CHR_TIOCM_DTR)
                 targ |= TIOCM_DTR;
             if (sarg | CHR_TIOCM_RTS)
                 targ |= TIOCM_RTS;
             ioctl(s->fd_in, TIOCMSET, &targ);
         }
         break;
     default:
         return -ENOTSUP;
     }

Is this approach palatable to folks?

david


Michael Tokarev wrote:
> Michael Tokarev ?????:
>> After some debugging and debugging, with a help
>> Hollis Blanchard on #kvm@freenode, I discovered
>> that kvm (or, rather, qemu) does not work correctly
>> with serial ports, at least on linux.  One problem
>> report has already here, author Cc'd -- see e.g.
>> http://marc.info/?l=kvm&m=122995568009533&w=2 .
>>
>> Here's what's going on.
>>
>> When opening a host's port, kvm resets the status
>> lines, doing this:
>>
>> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000])
>> ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS])
>>
>> which results in the following set
>>
>> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR])
> 
> Here's the possible solution (NotAPAtch(tm)):
> 
> In kvm-xx/qemu/qemu-char.c:
> 
>     case CHR_IOCTL_SERIAL_SET_TIOCM:
>         {
>             int sarg = *(int *)arg;
>             int targ = 0;        <==== change this 0 to 0x4000
>             if (sarg | CHR_TIOCM_DTR)
>                 targ |= TIOCM_DTR;
>             if (sarg | CHR_TIOCM_RTS)
>                 targ |= TIOCM_RTS;
>             ioctl(s->fd_in, TIOCMSET, &targ);
>         }
>         break;
> 
> This is obviously a hack, esp. since this bit is not
> always present even on linux (after reading 8250.c
> driver).
> 
> Real fix will be, I guess, to read the full set
> first, and combine it with DTR|RTS received from
> guest, something like this:
> 
>     case
>         {
>             int sarg = *(int *)arg;
>             int targ = 0;
>             ioctl(s->fd_in, TIOCMGET, &targ);
>             if (!(sarg | CHR_TIOCM_DTR))
>                 targ &= ~TIOCM_DTR;
>             if (!(sarg | CHR_TIOCM_RTS))
>                 targ ~= ~TIOCM_RTS;
>             ioctl(s->fd_in, TIOCMSET, &targ);
>         }
>         break;
> 
> I.e., to always keep all the other bits, but
> allow changing DTR and RTS.
> 
> Again, I don't know how it's linux-specific, but
> it seems the solution above should work on other
> platforms just fine.
> 
> /mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-02 21:27     ` [Qemu-devel] " David S. Ahern
@ 2009-02-02 21:32       ` Michael Tokarev
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-02 21:32 UTC (permalink / raw)
  To: David S. Ahern; +Cc: KVM list, qemu-devel

David S. Ahern wrote:
> I don't recall seeing a followup to this post.
> 
> To put Michael's second suggestion into patch form, the following fixes
> the problem for me:
> 
> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
> @@ -1078,20 +1078,21 @@
>              if (sarg | TIOCM_DTR)
>                  *targ |= CHR_TIOCM_DTR;
>              if (sarg | TIOCM_RTS)
>                  *targ |= CHR_TIOCM_RTS;
>          }
>          break;
>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>          {
>              int sarg = *(int *)arg;
>              int targ = 0;
> +            ioctl(s->fd_in, TIOCMGET, &targ);

here, one more operation is necessary:
               targ &= ~(TIOCM_DTR|TIOCM_RTS);

>              if (sarg | CHR_TIOCM_DTR)
>                  targ |= TIOCM_DTR;
>              if (sarg | CHR_TIOCM_RTS)
>                  targ |= TIOCM_RTS;
>              ioctl(s->fd_in, TIOCMSET, &targ);
>          }
>          break;
>      default:
>          return -ENOTSUP;
>      }
> 
> Is this approach palatable to folks?
> 
> david

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-02 21:32       ` Michael Tokarev
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-02 21:32 UTC (permalink / raw)
  To: David S. Ahern; +Cc: qemu-devel, KVM list

David S. Ahern wrote:
> I don't recall seeing a followup to this post.
> 
> To put Michael's second suggestion into patch form, the following fixes
> the problem for me:
> 
> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
> @@ -1078,20 +1078,21 @@
>              if (sarg | TIOCM_DTR)
>                  *targ |= CHR_TIOCM_DTR;
>              if (sarg | TIOCM_RTS)
>                  *targ |= CHR_TIOCM_RTS;
>          }
>          break;
>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>          {
>              int sarg = *(int *)arg;
>              int targ = 0;
> +            ioctl(s->fd_in, TIOCMGET, &targ);

here, one more operation is necessary:
               targ &= ~(TIOCM_DTR|TIOCM_RTS);

>              if (sarg | CHR_TIOCM_DTR)
>                  targ |= TIOCM_DTR;
>              if (sarg | CHR_TIOCM_RTS)
>                  targ |= TIOCM_RTS;
>              ioctl(s->fd_in, TIOCMSET, &targ);
>          }
>          break;
>      default:
>          return -ENOTSUP;
>      }
> 
> Is this approach palatable to folks?
> 
> david

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-02 21:32       ` [Qemu-devel] " Michael Tokarev
@ 2009-02-02 21:36         ` David S. Ahern
  -1 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-02 21:36 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: KVM list, qemu-devel



Michael Tokarev wrote:
> David S. Ahern wrote:
>> I don't recall seeing a followup to this post.
>>
>> To put Michael's second suggestion into patch form, the following fixes
>> the problem for me:
>>
>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>> @@ -1078,20 +1078,21 @@
>>              if (sarg | TIOCM_DTR)
>>                  *targ |= CHR_TIOCM_DTR;
>>              if (sarg | TIOCM_RTS)
>>                  *targ |= CHR_TIOCM_RTS;
>>          }
>>          break;
>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>          {
>>              int sarg = *(int *)arg;
>>              int targ = 0;
>> +            ioctl(s->fd_in, TIOCMGET, &targ);
> 
> here, one more operation is necessary:
>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
> 


Interesting. that change was not needed to fix my problem.

david


>>              if (sarg | CHR_TIOCM_DTR)
>>                  targ |= TIOCM_DTR;
>>              if (sarg | CHR_TIOCM_RTS)
>>                  targ |= TIOCM_RTS;
>>              ioctl(s->fd_in, TIOCMSET, &targ);
>>          }
>>          break;
>>      default:
>>          return -ENOTSUP;
>>      }
>>
>> Is this approach palatable to folks?
>>
>> david
> 
> /mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-02 21:36         ` David S. Ahern
  0 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-02 21:36 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-devel, KVM list



Michael Tokarev wrote:
> David S. Ahern wrote:
>> I don't recall seeing a followup to this post.
>>
>> To put Michael's second suggestion into patch form, the following fixes
>> the problem for me:
>>
>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>> @@ -1078,20 +1078,21 @@
>>              if (sarg | TIOCM_DTR)
>>                  *targ |= CHR_TIOCM_DTR;
>>              if (sarg | TIOCM_RTS)
>>                  *targ |= CHR_TIOCM_RTS;
>>          }
>>          break;
>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>          {
>>              int sarg = *(int *)arg;
>>              int targ = 0;
>> +            ioctl(s->fd_in, TIOCMGET, &targ);
> 
> here, one more operation is necessary:
>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
> 


Interesting. that change was not needed to fix my problem.

david


>>              if (sarg | CHR_TIOCM_DTR)
>>                  targ |= TIOCM_DTR;
>>              if (sarg | CHR_TIOCM_RTS)
>>                  targ |= TIOCM_RTS;
>>              ioctl(s->fd_in, TIOCMSET, &targ);
>>          }
>>          break;
>>      default:
>>          return -ENOTSUP;
>>      }
>>
>> Is this approach palatable to folks?
>>
>> david
> 
> /mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-02 21:36         ` [Qemu-devel] " David S. Ahern
@ 2009-02-03  8:13           ` Michael Tokarev
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-03  8:13 UTC (permalink / raw)
  To: David S. Ahern; +Cc: KVM list, qemu-devel

David S. Ahern wrote:
> Michael Tokarev wrote:
>> David S. Ahern wrote:
>>> I don't recall seeing a followup to this post.
>>>
>>> To put Michael's second suggestion into patch form, the following fixes
>>> the problem for me:
>>>
>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>> @@ -1078,20 +1078,21 @@
>>>              if (sarg | TIOCM_DTR)
>>>                  *targ |= CHR_TIOCM_DTR;
>>>              if (sarg | TIOCM_RTS)
>>>                  *targ |= CHR_TIOCM_RTS;
>>>          }
>>>          break;
>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>          {
>>>              int sarg = *(int *)arg;
>>>              int targ = 0;
>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>> here, one more operation is necessary:
>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
> 
> Interesting. that change was not needed to fix my problem.

It just means you (or, rather, your guests) never really needed to
DROP those signal lines, only to raise them.

>>>              if (sarg | CHR_TIOCM_DTR)
>>>                  targ |= TIOCM_DTR;
>>>              if (sarg | CHR_TIOCM_RTS)
>>>                  targ |= TIOCM_RTS;

Without that line above, the code never drops the two bits, once
set they can't be "removed" anymore.

By the way, this is upstream qemu issue, not kvm one, and has to be
pushed as such.  Good you CC'd qemu list.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-03  8:13           ` Michael Tokarev
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-03  8:13 UTC (permalink / raw)
  To: David S. Ahern; +Cc: qemu-devel, KVM list

David S. Ahern wrote:
> Michael Tokarev wrote:
>> David S. Ahern wrote:
>>> I don't recall seeing a followup to this post.
>>>
>>> To put Michael's second suggestion into patch form, the following fixes
>>> the problem for me:
>>>
>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>> @@ -1078,20 +1078,21 @@
>>>              if (sarg | TIOCM_DTR)
>>>                  *targ |= CHR_TIOCM_DTR;
>>>              if (sarg | TIOCM_RTS)
>>>                  *targ |= CHR_TIOCM_RTS;
>>>          }
>>>          break;
>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>          {
>>>              int sarg = *(int *)arg;
>>>              int targ = 0;
>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>> here, one more operation is necessary:
>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
> 
> Interesting. that change was not needed to fix my problem.

It just means you (or, rather, your guests) never really needed to
DROP those signal lines, only to raise them.

>>>              if (sarg | CHR_TIOCM_DTR)
>>>                  targ |= TIOCM_DTR;
>>>              if (sarg | CHR_TIOCM_RTS)
>>>                  targ |= TIOCM_RTS;

Without that line above, the code never drops the two bits, once
set they can't be "removed" anymore.

By the way, this is upstream qemu issue, not kvm one, and has to be
pushed as such.  Good you CC'd qemu list.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-03  8:13           ` [Qemu-devel] " Michael Tokarev
@ 2009-02-03  8:41             ` Mark Marshall
  -1 siblings, 0 replies; 29+ messages in thread
From: Mark Marshall @ 2009-02-03  8:41 UTC (permalink / raw)
  To: kvm; +Cc: qemu-devel

Michael Tokarev wrote:
> David S. Ahern wrote:
>> Michael Tokarev wrote:
>>> David S. Ahern wrote:
>>>> I don't recall seeing a followup to this post.
>>>>
>>>> To put Michael's second suggestion into patch form, the following fixes
>>>> the problem for me:
>>>>
>>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>>> @@ -1078,20 +1078,21 @@
>>>>              if (sarg | TIOCM_DTR)
>>>>                  *targ |= CHR_TIOCM_DTR;
>>>>              if (sarg | TIOCM_RTS)
>>>>                  *targ |= CHR_TIOCM_RTS;
>>>>          }
>>>>          break;
>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>          {
>>>>              int sarg = *(int *)arg;
>>>>              int targ = 0;
>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>> here, one more operation is necessary:
>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>> Interesting. that change was not needed to fix my problem.
> 
> It just means you (or, rather, your guests) never really needed to
> DROP those signal lines, only to raise them.
> 
>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>                  targ |= TIOCM_DTR;
>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>                  targ |= TIOCM_RTS;
Is this code really correct.  If it is is there a comment somewhere 
describing why it's correct?  I would have expected the lines above to be:

               if (sarg & CHR_TIOCM_DTR)
                   targ |= TIOCM_DTR;
               if (sarg & CHR_TIOCM_RTS)
                   targ |= TIOCM_RTS;

(Just an observation as this went past).

MM

> 
> Without that line above, the code never drops the two bits, once
> set they can't be "removed" anymore.
> 
> By the way, this is upstream qemu issue, not kvm one, and has to be
> pushed as such.  Good you CC'd qemu list.
> 
> /mjt
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-03  8:41             ` Mark Marshall
  0 siblings, 0 replies; 29+ messages in thread
From: Mark Marshall @ 2009-02-03  8:41 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: KVM list, David S. Ahern, qemu-devel

Michael Tokarev wrote:
> David S. Ahern wrote:
>> Michael Tokarev wrote:
>>> David S. Ahern wrote:
>>>> I don't recall seeing a followup to this post.
>>>>
>>>> To put Michael's second suggestion into patch form, the following fixes
>>>> the problem for me:
>>>>
>>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>>> @@ -1078,20 +1078,21 @@
>>>>              if (sarg | TIOCM_DTR)
>>>>                  *targ |= CHR_TIOCM_DTR;
>>>>              if (sarg | TIOCM_RTS)
>>>>                  *targ |= CHR_TIOCM_RTS;
>>>>          }
>>>>          break;
>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>          {
>>>>              int sarg = *(int *)arg;
>>>>              int targ = 0;
>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>> here, one more operation is necessary:
>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>> Interesting. that change was not needed to fix my problem.
> 
> It just means you (or, rather, your guests) never really needed to
> DROP those signal lines, only to raise them.
> 
>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>                  targ |= TIOCM_DTR;
>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>                  targ |= TIOCM_RTS;
Is this code really correct.  If it is is there a comment somewhere 
describing why it's correct?  I would have expected the lines above to be:

               if (sarg & CHR_TIOCM_DTR)
                   targ |= TIOCM_DTR;
               if (sarg & CHR_TIOCM_RTS)
                   targ |= TIOCM_RTS;

(Just an observation as this went past).

MM

> 
> Without that line above, the code never drops the two bits, once
> set they can't be "removed" anymore.
> 
> By the way, this is upstream qemu issue, not kvm one, and has to be
> pushed as such.  Good you CC'd qemu list.
> 
> /mjt
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-03  8:41             ` [Qemu-devel] " Mark Marshall
@ 2009-02-04  8:09               ` Marcelo Tosatti
  -1 siblings, 0 replies; 29+ messages in thread
From: Marcelo Tosatti @ 2009-02-04  8:09 UTC (permalink / raw)
  To: Mark Marshall, Stefano Stabellini
  Cc: Michael Tokarev, David S. Ahern, KVM list, qemu-devel

On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
> Michael Tokarev wrote:
>> David S. Ahern wrote:
>>> Michael Tokarev wrote:
>>>> David S. Ahern wrote:
>>>>> I don't recall seeing a followup to this post.
>>>>>
>>>>> To put Michael's second suggestion into patch form, the following fixes
>>>>> the problem for me:
>>>>>
>>>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>>>> @@ -1078,20 +1078,21 @@
>>>>>              if (sarg | TIOCM_DTR)
>>>>>                  *targ |= CHR_TIOCM_DTR;
>>>>>              if (sarg | TIOCM_RTS)
>>>>>                  *targ |= CHR_TIOCM_RTS;
>>>>>          }
>>>>>          break;
>>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>>          {
>>>>>              int sarg = *(int *)arg;
>>>>>              int targ = 0;
>>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>>> here, one more operation is necessary:
>>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>>> Interesting. that change was not needed to fix my problem.
>>
>> It just means you (or, rather, your guests) never really needed to
>> DROP those signal lines, only to raise them.
>>
>>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>>                  targ |= TIOCM_DTR;
>>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>>                  targ |= TIOCM_RTS;
> Is this code really correct.  If it is is there a comment somewhere  
> describing why it's correct?  I would have expected the lines above to 
> be:
>
>               if (sarg & CHR_TIOCM_DTR)
>                   targ |= TIOCM_DTR;
>               if (sarg & CHR_TIOCM_RTS)
>                   targ |= TIOCM_RTS;
>
> (Just an observation as this went past).

Right. I don't understand the point of converting to an "internal"
representation of TIOCM control bits. 

CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
least preserve the bits it does not control.

diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
index ac431c7..66971e1 100644
--- a/qemu/qemu-char.c
+++ b/qemu/qemu-char.c
@@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
         break;
     case CHR_IOCTL_SERIAL_GET_TIOCM:
         {
-            int sarg = 0;
-            int *targ = (int *)arg;
-            ioctl(s->fd_in, TIOCMGET, &sarg);
-            *targ = 0;
-            if (sarg | TIOCM_CTS)
-                *targ |= CHR_TIOCM_CTS;
-            if (sarg | TIOCM_CAR)
-                *targ |= CHR_TIOCM_CAR;
-            if (sarg | TIOCM_DSR)
-                *targ |= CHR_TIOCM_DSR;
-            if (sarg | TIOCM_RI)
-                *targ |= CHR_TIOCM_RI;
-            if (sarg | TIOCM_DTR)
-                *targ |= CHR_TIOCM_DTR;
-            if (sarg | TIOCM_RTS)
-                *targ |= CHR_TIOCM_RTS;
+            ioctl(s->fd_in, TIOCMGET, arg);
         }
         break;
     case CHR_IOCTL_SERIAL_SET_TIOCM:
         {
-            int sarg = *(int *)arg;
-            int targ = 0;
-            if (sarg | CHR_TIOCM_DTR)
-                targ |= TIOCM_DTR;
-            if (sarg | CHR_TIOCM_RTS)
-                targ |= TIOCM_RTS;
-            ioctl(s->fd_in, TIOCMSET, &targ);
+            ioctl(s->fd_in, TIOCMSET, arg);
         }
         break;
     default:

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04  8:09               ` Marcelo Tosatti
  0 siblings, 0 replies; 29+ messages in thread
From: Marcelo Tosatti @ 2009-02-04  8:09 UTC (permalink / raw)
  To: Mark Marshall, Stefano Stabellini
  Cc: Michael Tokarev, KVM list, David S. Ahern, qemu-devel

On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
> Michael Tokarev wrote:
>> David S. Ahern wrote:
>>> Michael Tokarev wrote:
>>>> David S. Ahern wrote:
>>>>> I don't recall seeing a followup to this post.
>>>>>
>>>>> To put Michael's second suggestion into patch form, the following fixes
>>>>> the problem for me:
>>>>>
>>>>> --- kvm-81.orig/qemu/qemu-char.c        2008-12-14 06:16:27.000000000 -0700
>>>>> +++ kvm-81/qemu/qemu-char.c     2009-02-02 14:12:20.000000000 -0700
>>>>> @@ -1078,20 +1078,21 @@
>>>>>              if (sarg | TIOCM_DTR)
>>>>>                  *targ |= CHR_TIOCM_DTR;
>>>>>              if (sarg | TIOCM_RTS)
>>>>>                  *targ |= CHR_TIOCM_RTS;
>>>>>          }
>>>>>          break;
>>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>>          {
>>>>>              int sarg = *(int *)arg;
>>>>>              int targ = 0;
>>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>>> here, one more operation is necessary:
>>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>>> Interesting. that change was not needed to fix my problem.
>>
>> It just means you (or, rather, your guests) never really needed to
>> DROP those signal lines, only to raise them.
>>
>>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>>                  targ |= TIOCM_DTR;
>>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>>                  targ |= TIOCM_RTS;
> Is this code really correct.  If it is is there a comment somewhere  
> describing why it's correct?  I would have expected the lines above to 
> be:
>
>               if (sarg & CHR_TIOCM_DTR)
>                   targ |= TIOCM_DTR;
>               if (sarg & CHR_TIOCM_RTS)
>                   targ |= TIOCM_RTS;
>
> (Just an observation as this went past).

Right. I don't understand the point of converting to an "internal"
representation of TIOCM control bits. 

CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
least preserve the bits it does not control.

diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
index ac431c7..66971e1 100644
--- a/qemu/qemu-char.c
+++ b/qemu/qemu-char.c
@@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
         break;
     case CHR_IOCTL_SERIAL_GET_TIOCM:
         {
-            int sarg = 0;
-            int *targ = (int *)arg;
-            ioctl(s->fd_in, TIOCMGET, &sarg);
-            *targ = 0;
-            if (sarg | TIOCM_CTS)
-                *targ |= CHR_TIOCM_CTS;
-            if (sarg | TIOCM_CAR)
-                *targ |= CHR_TIOCM_CAR;
-            if (sarg | TIOCM_DSR)
-                *targ |= CHR_TIOCM_DSR;
-            if (sarg | TIOCM_RI)
-                *targ |= CHR_TIOCM_RI;
-            if (sarg | TIOCM_DTR)
-                *targ |= CHR_TIOCM_DTR;
-            if (sarg | TIOCM_RTS)
-                *targ |= CHR_TIOCM_RTS;
+            ioctl(s->fd_in, TIOCMGET, arg);
         }
         break;
     case CHR_IOCTL_SERIAL_SET_TIOCM:
         {
-            int sarg = *(int *)arg;
-            int targ = 0;
-            if (sarg | CHR_TIOCM_DTR)
-                targ |= TIOCM_DTR;
-            if (sarg | CHR_TIOCM_RTS)
-                targ |= TIOCM_RTS;
-            ioctl(s->fd_in, TIOCMSET, &targ);
+            ioctl(s->fd_in, TIOCMSET, arg);
         }
         break;
     default:

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-04  8:09               ` [Qemu-devel] " Marcelo Tosatti
@ 2009-02-04  8:37                 ` Michael Tokarev
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-04  8:37 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: Mark Marshall, Stefano Stabellini, David S. Ahern, KVM list, qemu-devel

Marcelo Tosatti wrote:
> On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
[]
> Right. I don't understand the point of converting to an "internal"
> representation of TIOCM control bits. 

<fun mode>
Well, the same goes for the IOCTL values themselves too -- like
this CHR_IOCTL_SERIAL_SET_TIOCM itself.  I mean, TIOCMSET is
the right name for it ;)  But see below.

> CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
> least preserve the bits it does not control.
> 
> diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
> index ac431c7..66971e1 100644
> --- a/qemu/qemu-char.c
> +++ b/qemu/qemu-char.c
> @@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
>          break;
>      case CHR_IOCTL_SERIAL_GET_TIOCM:
>          {
> +            ioctl(s->fd_in, TIOCMGET, arg);
>          }
>          break;

And those parens too, let it die, die! ;)
</fun mode>

Other than that, an.. excellent idea, I wanted to propose
just that when I first saw all this stuff, but was somewhat
afraid.  And I *think* there's at least *some* sense.  Qemu
is a CPU emulator and may work on another arch where those
bits are defined differently.  Maybe that was the reason for
all this converting - to be safe than sorry, so to say.  No?

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04  8:37                 ` Michael Tokarev
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-04  8:37 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: qemu-devel, KVM list, David S. Ahern, Mark Marshall, Stefano Stabellini

Marcelo Tosatti wrote:
> On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
[]
> Right. I don't understand the point of converting to an "internal"
> representation of TIOCM control bits. 

<fun mode>
Well, the same goes for the IOCTL values themselves too -- like
this CHR_IOCTL_SERIAL_SET_TIOCM itself.  I mean, TIOCMSET is
the right name for it ;)  But see below.

> CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
> least preserve the bits it does not control.
> 
> diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
> index ac431c7..66971e1 100644
> --- a/qemu/qemu-char.c
> +++ b/qemu/qemu-char.c
> @@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
>          break;
>      case CHR_IOCTL_SERIAL_GET_TIOCM:
>          {
> +            ioctl(s->fd_in, TIOCMGET, arg);
>          }
>          break;

And those parens too, let it die, die! ;)
</fun mode>

Other than that, an.. excellent idea, I wanted to propose
just that when I first saw all this stuff, but was somewhat
afraid.  And I *think* there's at least *some* sense.  Qemu
is a CPU emulator and may work on another arch where those
bits are defined differently.  Maybe that was the reason for
all this converting - to be safe than sorry, so to say.  No?

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-04  8:37                 ` [Qemu-devel] " Michael Tokarev
@ 2009-02-04  8:52                   ` Marcelo Tosatti
  -1 siblings, 0 replies; 29+ messages in thread
From: Marcelo Tosatti @ 2009-02-04  8:52 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Mark Marshall, Stefano Stabellini, David S. Ahern, KVM list, qemu-devel

On Wed, Feb 04, 2009 at 11:37:14AM +0300, Michael Tokarev wrote:
> Marcelo Tosatti wrote:
> > On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
> []
> > Right. I don't understand the point of converting to an "internal"
> > representation of TIOCM control bits. 
> 
> <fun mode>
> Well, the same goes for the IOCTL values themselves too -- like
> this CHR_IOCTL_SERIAL_SET_TIOCM itself.  I mean, TIOCMSET is
> the right name for it ;)  But see below.
> 
> > CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
> > least preserve the bits it does not control.
> > 
> > diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
> > index ac431c7..66971e1 100644
> > --- a/qemu/qemu-char.c
> > +++ b/qemu/qemu-char.c
> > @@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
> >          break;
> >      case CHR_IOCTL_SERIAL_GET_TIOCM:
> >          {
> > +            ioctl(s->fd_in, TIOCMGET, arg);
> >          }
> >          break;
> 
> And those parens too, let it die, die! ;)

Kill it!

> </fun mode>
> 
> Other than that, an.. excellent idea, I wanted to propose
> just that when I first saw all this stuff, but was somewhat
> afraid.  And I *think* there's at least *some* sense.  Qemu
> is a CPU emulator and may work on another arch where those
> bits are defined differently.  Maybe that was the reason for
> all this converting - to be safe than sorry, so to say.  No?

Probably, yes.

Does it work for you?

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04  8:52                   ` Marcelo Tosatti
  0 siblings, 0 replies; 29+ messages in thread
From: Marcelo Tosatti @ 2009-02-04  8:52 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: qemu-devel, KVM list, David S. Ahern, Mark Marshall, Stefano Stabellini

On Wed, Feb 04, 2009 at 11:37:14AM +0300, Michael Tokarev wrote:
> Marcelo Tosatti wrote:
> > On Tue, Feb 03, 2009 at 08:41:14AM +0000, Mark Marshall wrote:
> []
> > Right. I don't understand the point of converting to an "internal"
> > representation of TIOCM control bits. 
> 
> <fun mode>
> Well, the same goes for the IOCTL values themselves too -- like
> this CHR_IOCTL_SERIAL_SET_TIOCM itself.  I mean, TIOCMSET is
> the right name for it ;)  But see below.
> 
> > CHR_IOCTL_SERIAL_SET_TIOCM is clearly broken as mentioned. It should at 
> > least preserve the bits it does not control.
> > 
> > diff --git a/qemu/qemu-char.c b/qemu/qemu-char.c
> > index ac431c7..66971e1 100644
> > --- a/qemu/qemu-char.c
> > +++ b/qemu/qemu-char.c
> > @@ -1063,33 +1063,12 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
> >          break;
> >      case CHR_IOCTL_SERIAL_GET_TIOCM:
> >          {
> > +            ioctl(s->fd_in, TIOCMGET, arg);
> >          }
> >          break;
> 
> And those parens too, let it die, die! ;)

Kill it!

> </fun mode>
> 
> Other than that, an.. excellent idea, I wanted to propose
> just that when I first saw all this stuff, but was somewhat
> afraid.  And I *think* there's at least *some* sense.  Qemu
> is a CPU emulator and may work on another arch where those
> bits are defined differently.  Maybe that was the reason for
> all this converting - to be safe than sorry, so to say.  No?

Probably, yes.

Does it work for you?

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-04  8:52                   ` [Qemu-devel] " Marcelo Tosatti
@ 2009-02-04  8:56                     ` Michael Tokarev
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-04  8:56 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: Mark Marshall, Stefano Stabellini, David S. Ahern, KVM list, qemu-devel

Marcelo Tosatti wrote:
[]
>> Other than that, an.. excellent idea, I wanted to propose
>> just that when I first saw all this stuff, but was somewhat
>> afraid.  And I *think* there's at least *some* sense.  Qemu
>> is a CPU emulator and may work on another arch where those
>> bits are defined differently.  Maybe that was the reason for
>> all this converting - to be safe than sorry, so to say.  No?
> 
> Probably, yes.

It's a question for qemu folks.

> Does it work for you?

Sure it does, since I only use it with kvm with the same arch
in guest and host, even with the same operating system.

Wug.  So much for so tiny issue.... Well, I'd not call non-working
serial port a "tiny issue".  Oh well.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04  8:56                     ` Michael Tokarev
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-04  8:56 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: qemu-devel, KVM list, David S. Ahern, Mark Marshall, Stefano Stabellini

Marcelo Tosatti wrote:
[]
>> Other than that, an.. excellent idea, I wanted to propose
>> just that when I first saw all this stuff, but was somewhat
>> afraid.  And I *think* there's at least *some* sense.  Qemu
>> is a CPU emulator and may work on another arch where those
>> bits are defined differently.  Maybe that was the reason for
>> all this converting - to be safe than sorry, so to say.  No?
> 
> Probably, yes.

It's a question for qemu folks.

> Does it work for you?

Sure it does, since I only use it with kvm with the same arch
in guest and host, even with the same operating system.

Wug.  So much for so tiny issue.... Well, I'd not call non-working
serial port a "tiny issue".  Oh well.

/mjt

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-04  8:37                 ` [Qemu-devel] " Michael Tokarev
@ 2009-02-04 11:09                   ` Stefano Stabellini
  -1 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-04 11:09 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: qemu-devel, Marcelo Tosatti, David S. Ahern, Mark Marshall, KVM list

Michael Tokarev wrote:

> Other than that, an.. excellent idea, I wanted to propose
> just that when I first saw all this stuff, but was somewhat
> afraid.  And I *think* there's at least *some* sense.  Qemu
> is a CPU emulator and may work on another arch where those
> bits are defined differently.  Maybe that was the reason for
> all this converting - to be safe than sorry, so to say.  No?
> 

Yes, this is exactly the reason why they were introduced in the first place.
Let's suppose that the guest defines those constants differently: we
need to parse them and covert them appropriately to the host format.
CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
version of TIOCMSET and TIOCM_DTR and can be defined differently
depending on the particular guest arch.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04 11:09                   ` Stefano Stabellini
  0 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-04 11:09 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: qemu-devel, Marcelo Tosatti, David S. Ahern, Mark Marshall, KVM list

Michael Tokarev wrote:

> Other than that, an.. excellent idea, I wanted to propose
> just that when I first saw all this stuff, but was somewhat
> afraid.  And I *think* there's at least *some* sense.  Qemu
> is a CPU emulator and may work on another arch where those
> bits are defined differently.  Maybe that was the reason for
> all this converting - to be safe than sorry, so to say.  No?
> 

Yes, this is exactly the reason why they were introduced in the first place.
Let's suppose that the guest defines those constants differently: we
need to parse them and covert them appropriately to the host format.
CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
version of TIOCMSET and TIOCM_DTR and can be defined differently
depending on the particular guest arch.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] Re: more about serial ports: do they even work?
  2009-02-03  8:13           ` [Qemu-devel] " Michael Tokarev
@ 2009-02-04 11:17             ` Stefano Stabellini
  -1 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-04 11:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: David S. Ahern, KVM list

Michael Tokarev wrote:

> David S. Ahern wrote:
>> Michael Tokarev wrote:
>>> David S. Ahern wrote:
>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>          {
>>>>              int sarg = *(int *)arg;
>>>>              int targ = 0;
>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>> here, one more operation is necessary:
>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>> Interesting. that change was not needed to fix my problem.
> 
> It just means you (or, rather, your guests) never really needed to
> DROP those signal lines, only to raise them.
> 
>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>                  targ |= TIOCM_DTR;
>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>                  targ |= TIOCM_RTS;
> 
> Without that line above, the code never drops the two bits, once
> set they can't be "removed" anymore.
> 
> By the way, this is upstream qemu issue, not kvm one, and has to be
> pushed as such.  Good you CC'd qemu list.
> 


Either the two lines above or we could parse the whole set of possible
flags, like we do in the CHR_IOCTL_SERIAL_GET_TIOCM case.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-04 11:17             ` Stefano Stabellini
  0 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-04 11:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: KVM list, David S. Ahern

Michael Tokarev wrote:

> David S. Ahern wrote:
>> Michael Tokarev wrote:
>>> David S. Ahern wrote:
>>>>      case CHR_IOCTL_SERIAL_SET_TIOCM:
>>>>          {
>>>>              int sarg = *(int *)arg;
>>>>              int targ = 0;
>>>> +            ioctl(s->fd_in, TIOCMGET, &targ);
>>> here, one more operation is necessary:
>>>                targ &= ~(TIOCM_DTR|TIOCM_RTS);
>> Interesting. that change was not needed to fix my problem.
> 
> It just means you (or, rather, your guests) never really needed to
> DROP those signal lines, only to raise them.
> 
>>>>              if (sarg | CHR_TIOCM_DTR)
>>>>                  targ |= TIOCM_DTR;
>>>>              if (sarg | CHR_TIOCM_RTS)
>>>>                  targ |= TIOCM_RTS;
> 
> Without that line above, the code never drops the two bits, once
> set they can't be "removed" anymore.
> 
> By the way, this is upstream qemu issue, not kvm one, and has to be
> pushed as such.  Good you CC'd qemu list.
> 


Either the two lines above or we could parse the whole set of possible
flags, like we do in the CHR_IOCTL_SERIAL_GET_TIOCM case.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH, finally]: more about serial ports: do they even work?
  2009-01-26 20:20 more about serial ports: do they even work? Michael Tokarev
  2009-01-26 20:39 ` Michael Tokarev
@ 2009-02-05 18:33 ` Michael Tokarev
  1 sibling, 0 replies; 29+ messages in thread
From: Michael Tokarev @ 2009-02-05 18:33 UTC (permalink / raw)
  To: KVM list
  Cc: David S. Ahern, Mark Marshall, Marcelo Tosatti, Stefano Stabellini

[-- Attachment #1: Type: text/plain, Size: 4194 bytes --]

Michael Tokarev wrote:
> After some debugging and debugging, with a help
> Hollis Blanchard on #kvm@freenode, I discovered
> that kvm (or, rather, qemu) does not work correctly
> with serial ports, at least on linux.  One problem
> report has already here, author Cc'd -- see e.g.
> http://marc.info/?l=kvm&m=122995568009533&w=2 .

... [quoted in full below]...

Ok, It's a real shame to see SO many wrong attempts to
do it all, with so many idiotic mistakes all over...
But c'est la vie, it seems... ;)

So here we go.  Attached is a patch that fixes two
problems with serial ports &qemu (yes it's a qemu
issue, and, as far as I can see, both probs were
here for a long time).

First is completely f*cked up flags reporting and
setup for TIOCMGET and TIOCMSET ioctls, where ALL
known flags were reported and set in case at least
one flag is set, misusing "if(a|b) foo" instead of
"if(a&b) foo" -- just a typo I assume, but heck of
a typo... ;)

And second - for TIOCMSET it preserves other, unknown
flags.  Which fixes the problem that started it all,
since there was a bit set internally in kernel which,
when unset, makes serial port non-working, but TIOCMSET
dropped all "other" bits on the floor.

And for this second one, I'm still unsure.  The patch
I'm sending only tries to remove TIOCM_DTR and _RTS
bits (RTS is useless since it's controlled by the connected
device, isn't it?), leaving all others, incl., say,
CAR, RI, CTS etc, in place.  The question is -- some
of those bits are "input" lines, i.e., the ones controlled
by the attached device, and I don't know if all platforms
will ignore those instead of reporting error.  I.e, maybe
filter also those who are known "inputs"?  And while we're
at it, still, how about RTS?

Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>

Thanks!

/ashamed mjt

--- original content follows ---
> Here's what's going on.
> 
> When opening a host's port, kvm resets the status
> lines, doing this:
> 
> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR|0x4000])
> ioctl(13, TIOCMSET, [TIOCM_DTR|TIOCM_RTS])
> 
> which results in the following set
> 
> ioctl(13, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR])
> 
> Note the difference between the default set and new one: the
> missing bit, 0x4000, which is unknown to strace(1) but is defined
> as TIOCM_OUT2 in linux headers.
> 
> After that change (resetting the TIOCM_OUT2 bit), no writes
> to the serial port works anymore, they're all gets accepted
> by host kernel and are buffered in the kernel.
> 
> After some time, when the kernel buffer fills up, and since
> the port (on host side) is opened in non-blocking mode, the
> writes starts returning EAGAIN, and kvm process starts
> endless loop, which were seen by David.
> 
> Here's the trivial program to demonstrate the idea:
> 
> ---- cut ---
> #include <sys/types.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <sys/ioctl.h>
> #include <termios.h>
> 
> int main(int argc, char **argv) {
>   fd = open("/dev/ttyS0", O_RDWR|O_NONBLOCK);
>   fcntl(fd, F_SETFL, O_RDWR);
>   x = TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR // |0x4000
>   ;
>   ioctl(fd, TIOCMSET, &x);
>   ioctl(fd, TIOCMGET, &x);
>   write(fd, "at\r", 3);
>   read(fd, buf, 20);
>   close(fd);
> 
>   return 0;
> }
> --- cut ---
> 
> 
> Run it under strace while a dialup modem is connected to /dev/ttyS0
> (i used this way for testing).  It will stuck at read, and nothing
> will be written, even when write() will happily return 3.  Un-comment
> the |0x4000 thing, and it will work.
> 
> I'm not sure what should be done with this, and how much this is
> linux-specific.  But it is obvious that bit (TIOCM_OUT2) should
> be left in-place (after which the thing works), at least on linux.
> 
> Note that this bit is NOT shown in /proc/tty/driver/serial file
> (which shows other bits).
> 
> Note also that this file (/proc/tty/driver/serial) helps to see
> if any write were performed: compare the counters.  In 'tx'
> there's number of bytes actually sent to device, as opposed to
> accepted by the kernel.  When you write something to /dev/ttyS0,
> that number increases, IF that something actually reached the
> device.
> 
> Thanks.
> 
> /mjt


[-- Attachment #2: qemu-serial.diff --]
[-- Type: text/x-patch, Size: 1513 bytes --]

--- kvm-83/qemu/qemu-char.c.orig	2009-01-13 16:29:42.000000000 +0300
+++ kvm-83/qemu/qemu-char.c	2009-02-05 21:19:35.972015110 +0300
@@ -1067,17 +1067,17 @@ static int tty_serial_ioctl(CharDriverSt
             int *targ = (int *)arg;
             ioctl(s->fd_in, TIOCMGET, &sarg);
             *targ = 0;
-            if (sarg | TIOCM_CTS)
+            if (sarg & TIOCM_CTS)
                 *targ |= CHR_TIOCM_CTS;
-            if (sarg | TIOCM_CAR)
+            if (sarg & TIOCM_CAR)
                 *targ |= CHR_TIOCM_CAR;
-            if (sarg | TIOCM_DSR)
+            if (sarg & TIOCM_DSR)
                 *targ |= CHR_TIOCM_DSR;
-            if (sarg | TIOCM_RI)
+            if (sarg & TIOCM_RI)
                 *targ |= CHR_TIOCM_RI;
-            if (sarg | TIOCM_DTR)
+            if (sarg & TIOCM_DTR)
                 *targ |= CHR_TIOCM_DTR;
-            if (sarg | TIOCM_RTS)
+            if (sarg & TIOCM_RTS)
                 *targ |= CHR_TIOCM_RTS;
         }
         break;
@@ -1085,9 +1085,11 @@ static int tty_serial_ioctl(CharDriverSt
         {
             int sarg = *(int *)arg;
             int targ = 0;
-            if (sarg | CHR_TIOCM_DTR)
+            ioctl(s->fd_in, TIOCMGET, &targ);
+            targ &= ~(TIOCM_DTR|TIOCM_RTS);
+            if (sarg & CHR_TIOCM_DTR)
                 targ |= TIOCM_DTR;
-            if (sarg | CHR_TIOCM_RTS)
+            if (sarg & CHR_TIOCM_RTS)
                 targ |= TIOCM_RTS;
             ioctl(s->fd_in, TIOCMSET, &targ);
         }

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-04 11:09                   ` [Qemu-devel] " Stefano Stabellini
@ 2009-02-05 18:36                     ` David S. Ahern
  -1 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-05 18:36 UTC (permalink / raw)
  To: Stefano Stabellini, Michael Tokarev
  Cc: Marcelo Tosatti, Mark Marshall, KVM list, qemu-devel



Stefano Stabellini wrote:
> Michael Tokarev wrote:
> 
>> Other than that, an.. excellent idea, I wanted to propose
>> just that when I first saw all this stuff, but was somewhat
>> afraid.  And I *think* there's at least *some* sense.  Qemu
>> is a CPU emulator and may work on another arch where those
>> bits are defined differently.  Maybe that was the reason for
>> all this converting - to be safe than sorry, so to say.  No?
>>
> 
> Yes, this is exactly the reason why they were introduced in the first place.
> Let's suppose that the guest defines those constants differently: we
> need to parse them and covert them appropriately to the host format.
> CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
> version of TIOCMSET and TIOCM_DTR and can be defined differently
> depending on the particular guest arch.

The following works for me.  It fixes the existing checks in place for
the GET and replicates that for the SET. The ioctl initialization is
needed in the SET is needed.


Index: trunk/qemu-char.c
===================================================================
--- trunk/qemu-char.c   (revision 6519)
+++ trunk/qemu-char.c   (working copy)
@@ -1067,17 +1067,17 @@
             int *targ = (int *)arg;
             ioctl(s->fd_in, TIOCMGET, &sarg);
             *targ = 0;
-            if (sarg | TIOCM_CTS)
+            if (sarg & TIOCM_CTS)
                 *targ |= CHR_TIOCM_CTS;
-            if (sarg | TIOCM_CAR)
+            if (sarg & TIOCM_CAR)
                 *targ |= CHR_TIOCM_CAR;
-            if (sarg | TIOCM_DSR)
+            if (sarg & TIOCM_DSR)
                 *targ |= CHR_TIOCM_DSR;
-            if (sarg | TIOCM_RI)
+            if (sarg & TIOCM_RI)
                 *targ |= CHR_TIOCM_RI;
-            if (sarg | TIOCM_DTR)
+            if (sarg & TIOCM_DTR)
                 *targ |= CHR_TIOCM_DTR;
-            if (sarg | TIOCM_RTS)
+            if (sarg & TIOCM_RTS)
                 *targ |= CHR_TIOCM_RTS;
         }
         break;
@@ -1085,9 +1085,20 @@
         {
             int sarg = *(int *)arg;
             int targ = 0;
-            if (sarg | CHR_TIOCM_DTR)
+            ioctl(s->fd_in, TIOCMGET, &targ);
+            targ &= ~(CHR_TIOCM_CTS | CHR_TIOCM_CAR | CHR_TIOCM_DSR
+                     | CHR_TIOCM_RI | CHR_TIOCM_DTR | CHR_TIOCM_RTS);
+            if (sarg & CHR_TIOCM_CTS)
+                targ |= TIOCM_CTS;
+            if (sarg & CHR_TIOCM_CAR)
+                targ |= TIOCM_CAR;
+            if (sarg & CHR_TIOCM_DSR)
+                targ |= TIOCM_DSR;
+            if (sarg & CHR_TIOCM_RI)
+                targ |= TIOCM_RI;
+            if (sarg & CHR_TIOCM_DTR)
                 targ |= TIOCM_DTR;
-            if (sarg | CHR_TIOCM_RTS)
+            if (sarg & CHR_TIOCM_RTS)
                 targ |= TIOCM_RTS;
             ioctl(s->fd_in, TIOCMSET, &targ);
         }


david

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-05 18:36                     ` David S. Ahern
  0 siblings, 0 replies; 29+ messages in thread
From: David S. Ahern @ 2009-02-05 18:36 UTC (permalink / raw)
  To: Stefano Stabellini, Michael Tokarev
  Cc: Marcelo Tosatti, KVM list, Mark Marshall, qemu-devel



Stefano Stabellini wrote:
> Michael Tokarev wrote:
> 
>> Other than that, an.. excellent idea, I wanted to propose
>> just that when I first saw all this stuff, but was somewhat
>> afraid.  And I *think* there's at least *some* sense.  Qemu
>> is a CPU emulator and may work on another arch where those
>> bits are defined differently.  Maybe that was the reason for
>> all this converting - to be safe than sorry, so to say.  No?
>>
> 
> Yes, this is exactly the reason why they were introduced in the first place.
> Let's suppose that the guest defines those constants differently: we
> need to parse them and covert them appropriately to the host format.
> CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
> version of TIOCMSET and TIOCM_DTR and can be defined differently
> depending on the particular guest arch.

The following works for me.  It fixes the existing checks in place for
the GET and replicates that for the SET. The ioctl initialization is
needed in the SET is needed.


Index: trunk/qemu-char.c
===================================================================
--- trunk/qemu-char.c   (revision 6519)
+++ trunk/qemu-char.c   (working copy)
@@ -1067,17 +1067,17 @@
             int *targ = (int *)arg;
             ioctl(s->fd_in, TIOCMGET, &sarg);
             *targ = 0;
-            if (sarg | TIOCM_CTS)
+            if (sarg & TIOCM_CTS)
                 *targ |= CHR_TIOCM_CTS;
-            if (sarg | TIOCM_CAR)
+            if (sarg & TIOCM_CAR)
                 *targ |= CHR_TIOCM_CAR;
-            if (sarg | TIOCM_DSR)
+            if (sarg & TIOCM_DSR)
                 *targ |= CHR_TIOCM_DSR;
-            if (sarg | TIOCM_RI)
+            if (sarg & TIOCM_RI)
                 *targ |= CHR_TIOCM_RI;
-            if (sarg | TIOCM_DTR)
+            if (sarg & TIOCM_DTR)
                 *targ |= CHR_TIOCM_DTR;
-            if (sarg | TIOCM_RTS)
+            if (sarg & TIOCM_RTS)
                 *targ |= CHR_TIOCM_RTS;
         }
         break;
@@ -1085,9 +1085,20 @@
         {
             int sarg = *(int *)arg;
             int targ = 0;
-            if (sarg | CHR_TIOCM_DTR)
+            ioctl(s->fd_in, TIOCMGET, &targ);
+            targ &= ~(CHR_TIOCM_CTS | CHR_TIOCM_CAR | CHR_TIOCM_DSR
+                     | CHR_TIOCM_RI | CHR_TIOCM_DTR | CHR_TIOCM_RTS);
+            if (sarg & CHR_TIOCM_CTS)
+                targ |= TIOCM_CTS;
+            if (sarg & CHR_TIOCM_CAR)
+                targ |= TIOCM_CAR;
+            if (sarg & CHR_TIOCM_DSR)
+                targ |= TIOCM_DSR;
+            if (sarg & CHR_TIOCM_RI)
+                targ |= TIOCM_RI;
+            if (sarg & CHR_TIOCM_DTR)
                 targ |= TIOCM_DTR;
-            if (sarg | CHR_TIOCM_RTS)
+            if (sarg & CHR_TIOCM_RTS)
                 targ |= TIOCM_RTS;
             ioctl(s->fd_in, TIOCMSET, &targ);
         }


david

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: more about serial ports: do they even work?
  2009-02-05 18:36                     ` [Qemu-devel] " David S. Ahern
@ 2009-02-05 20:50                       ` Stefano Stabellini
  -1 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-05 20:50 UTC (permalink / raw)
  To: David S. Ahern
  Cc: Michael Tokarev, Marcelo Tosatti, Mark Marshall, KVM list, qemu-devel

David S. Ahern wrote:

> 
> Stefano Stabellini wrote:
>> Michael Tokarev wrote:
>>
>>> Other than that, an.. excellent idea, I wanted to propose
>>> just that when I first saw all this stuff, but was somewhat
>>> afraid.  And I *think* there's at least *some* sense.  Qemu
>>> is a CPU emulator and may work on another arch where those
>>> bits are defined differently.  Maybe that was the reason for
>>> all this converting - to be safe than sorry, so to say.  No?
>>>
>> Yes, this is exactly the reason why they were introduced in the first place.
>> Let's suppose that the guest defines those constants differently: we
>> need to parse them and covert them appropriately to the host format.
>> CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
>> version of TIOCMSET and TIOCM_DTR and can be defined differently
>> depending on the particular guest arch.
> 
> The following works for me.  It fixes the existing checks in place for
> the GET and replicates that for the SET. The ioctl initialization is
> needed in the SET is needed.

It looks pretty good to me.

Acked-by: stefano.stabellini@eu.citrix.com


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] Re: more about serial ports: do they even work?
@ 2009-02-05 20:50                       ` Stefano Stabellini
  0 siblings, 0 replies; 29+ messages in thread
From: Stefano Stabellini @ 2009-02-05 20:50 UTC (permalink / raw)
  To: David S. Ahern
  Cc: Marcelo Tosatti, Michael Tokarev, KVM list, Mark Marshall, qemu-devel

David S. Ahern wrote:

> 
> Stefano Stabellini wrote:
>> Michael Tokarev wrote:
>>
>>> Other than that, an.. excellent idea, I wanted to propose
>>> just that when I first saw all this stuff, but was somewhat
>>> afraid.  And I *think* there's at least *some* sense.  Qemu
>>> is a CPU emulator and may work on another arch where those
>>> bits are defined differently.  Maybe that was the reason for
>>> all this converting - to be safe than sorry, so to say.  No?
>>>
>> Yes, this is exactly the reason why they were introduced in the first place.
>> Let's suppose that the guest defines those constants differently: we
>> need to parse them and covert them appropriately to the host format.
>> CHR_IOCTL_SERIAL_SET_TIOCM and CHR_TIOCM_DTR correspond to the guest
>> version of TIOCMSET and TIOCM_DTR and can be defined differently
>> depending on the particular guest arch.
> 
> The following works for me.  It fixes the existing checks in place for
> the GET and replicates that for the SET. The ioctl initialization is
> needed in the SET is needed.

It looks pretty good to me.

Acked-by: stefano.stabellini@eu.citrix.com

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2009-02-05 20:54 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-26 20:20 more about serial ports: do they even work? Michael Tokarev
2009-01-26 20:39 ` Michael Tokarev
2009-02-02 21:27   ` David S. Ahern
2009-02-02 21:27     ` [Qemu-devel] " David S. Ahern
2009-02-02 21:32     ` Michael Tokarev
2009-02-02 21:32       ` [Qemu-devel] " Michael Tokarev
2009-02-02 21:36       ` David S. Ahern
2009-02-02 21:36         ` [Qemu-devel] " David S. Ahern
2009-02-03  8:13         ` Michael Tokarev
2009-02-03  8:13           ` [Qemu-devel] " Michael Tokarev
2009-02-03  8:41           ` Mark Marshall
2009-02-03  8:41             ` [Qemu-devel] " Mark Marshall
2009-02-04  8:09             ` Marcelo Tosatti
2009-02-04  8:09               ` [Qemu-devel] " Marcelo Tosatti
2009-02-04  8:37               ` Michael Tokarev
2009-02-04  8:37                 ` [Qemu-devel] " Michael Tokarev
2009-02-04  8:52                 ` Marcelo Tosatti
2009-02-04  8:52                   ` [Qemu-devel] " Marcelo Tosatti
2009-02-04  8:56                   ` Michael Tokarev
2009-02-04  8:56                     ` [Qemu-devel] " Michael Tokarev
2009-02-04 11:09                 ` Stefano Stabellini
2009-02-04 11:09                   ` [Qemu-devel] " Stefano Stabellini
2009-02-05 18:36                   ` David S. Ahern
2009-02-05 18:36                     ` [Qemu-devel] " David S. Ahern
2009-02-05 20:50                     ` Stefano Stabellini
2009-02-05 20:50                       ` [Qemu-devel] " Stefano Stabellini
2009-02-04 11:17           ` Stefano Stabellini
2009-02-04 11:17             ` Stefano Stabellini
2009-02-05 18:33 ` [PATCH, finally]: " Michael Tokarev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.