qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] new feature: attach a process to emulated serial port
@ 2004-10-08 21:46 Johannes Martin
  2004-10-11 13:26 ` Derek Fawcus
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Martin @ 2004-10-08 21:46 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 571 bytes --]

Hi,

The attached patch adds another variety of the -serial and -monitor
options. You can now use
        -serial "exec:any shell command"
to redirect the input/output of named shell command to the guest's serial
port.

For example, you could attach slirp to the guest's serial port and then
start a pppd on the serial port in the guest:
host:	qemu -serial "exec:slirp ppp"
guest:	pppd /dev/ttyS0 57600 defaultroute

This will help getting network connectivity in guests that don't like
qemu's network drivers (like OS/2).

Tested on current (2004-10-08) cvs.

	Johannes

[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 1815 bytes --]

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-08 21:46 [Qemu-devel] new feature: attach a process to emulated serial port Johannes Martin
@ 2004-10-11 13:26 ` Derek Fawcus
  2004-10-11 15:22   ` André Braga
  0 siblings, 1 reply; 8+ messages in thread
From: Derek Fawcus @ 2004-10-11 13:26 UTC (permalink / raw)
  To: qemu-devel

On Fri, Oct 08, 2004 at 11:46:21PM +0200, Johannes Martin wrote:
> Hi,
> 
> The attached patch adds another variety of the -serial and -monitor
> options. You can now use
>         -serial "exec:any shell command"
> to redirect the input/output of named shell command to the guest's serial
> port.

Hmm.  How about simply using FIFO's instead,  then one doesn't have any
issues with fork/system/etc

i.e. add options of -serialin <path> -serialout <path> and have -serial <path>
set both of the above.  Then one can simply do:

mkfifo /tmp/serin /tmp/serout
anycmd < /tmp/serout > /tmp/serin &
qemu ... -serialin /tmp/serin -serialout /tmp/serialout

DF

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 13:26 ` Derek Fawcus
@ 2004-10-11 15:22   ` André Braga
  2004-10-11 15:47     ` Derek Fawcus
  2004-10-11 20:32     ` Johannes Martin
  0 siblings, 2 replies; 8+ messages in thread
From: André Braga @ 2004-10-11 15:22 UTC (permalink / raw)
  To: qemu-devel

On Mon, 11 Oct 2004 14:26:30 +0100, Derek Fawcus <dfawcus@cisco.com> wrote:
> Hmm.  How about simply using FIFO's instead,  then one doesn't have any
> issues with fork/system/etc
> 
> i.e. add options of -serialin <path> -serialout <path> and have -serial <path>
> set both of the above.  Then one can simply do:
> 
> mkfifo /tmp/serin /tmp/serout
> anycmd < /tmp/serout > /tmp/serin &
> qemu ... -serialin /tmp/serin -serialout /tmp/serialout

That would make this feature available only on operating systems that
support user-created named pipes. IOW, named pipes do exist on
Windows, but they're not easy to access by the user.

Forking is a more universal approach, as I see it.


cheers,
A.


-- 
"A year spent in artificial intelligence is enough to make one believe in God"
Alan J. Perlis

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 15:22   ` André Braga
@ 2004-10-11 15:47     ` Derek Fawcus
  2004-10-11 16:03       ` André Braga
  2004-10-11 20:32     ` Johannes Martin
  1 sibling, 1 reply; 8+ messages in thread
From: Derek Fawcus @ 2004-10-11 15:47 UTC (permalink / raw)
  To: André Braga, qemu-devel

On Mon, Oct 11, 2004 at 12:22:37PM -0300, André Braga wrote:
> On Mon, 11 Oct 2004 14:26:30 +0100, Derek Fawcus <dfawcus@cisco.com> wrote:
> > Hmm.  How about simply using FIFO's instead,  then one doesn't have any
> > issues with fork/system/etc
> > 
> > i.e. add options of -serialin <path> -serialout <path> and have -serial <path>
> > set both of the above.  Then one can simply do:
> > 
> > mkfifo /tmp/serin /tmp/serout
> > anycmd < /tmp/serout > /tmp/serin &
> > qemu ... -serialin /tmp/serin -serialout /tmp/serialout
> 
> That would make this feature available only on operating systems that
> support user-created named pipes.

Yeah - but they're the only interesting ones :-)  Hmm is it so easy
to connect process with a bi-dir like pipe on Windows (NT) machines?

> IOW, named pipes do exist on Windows, but they're not easy to access by the user.

Hmm - SFU?  The recent versions (w2k/xp only) are supposed to be very unix
like,  but even the earlier version would probably support fifo's well enougth.

Mind - connecting the GUI on the earlier versions would be difficult.

> Forking is a more universal approach, as I see it.

Modulo the above proviso?  Is there the ability to create "proper" pipes between
processes on NT from native win32 code?

DF

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 15:47     ` Derek Fawcus
@ 2004-10-11 16:03       ` André Braga
  0 siblings, 0 replies; 8+ messages in thread
From: André Braga @ 2004-10-11 16:03 UTC (permalink / raw)
  To: qemu-devel

On Mon, 11 Oct 2004 16:47:22 +0100, Derek Fawcus <dfawcus@cisco.com> wrote:
> Yeah - but they're the only interesting ones :-)  Hmm is it so easy
> to connect process with a bi-dir like pipe on Windows (NT) machines?

I do agree that Windows is garbage, but if you consider QEMU an
entry-level tool to ease migration to more robust platforms, then it
becomes interesting to actively support 'Doze.

> Hmm - SFU?  The recent versions (w2k/xp only) are supposed to be very unix
> like,  but even the earlier version would probably support fifo's well enougth.

Posix is supported as a subsystem in 2k, but in XP M$ stripped it out.
One would have to download the Interix subsystem (SFU), which is
farily large. Hardly an option to push onto users if forking is much
simpler.

> Modulo the above proviso?  Is there the ability to create "proper" pipes between
> processes on NT from native win32 code?

Yes, there is, from native win32 *code*. Not by userland tools (which
kills the 'mkfifo' approach). At least I haven't stumbled upon one
that does exactly this. 3rd party included.


-- 
"A year spent in artificial intelligence is enough to make one believe in God"
Alan J. Perlis

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 15:22   ` André Braga
  2004-10-11 15:47     ` Derek Fawcus
@ 2004-10-11 20:32     ` Johannes Martin
  2004-10-11 21:38       ` Derek Fawcus
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Martin @ 2004-10-11 20:32 UTC (permalink / raw)
  To: qemu-devel

Hi,

wow - I didn't think my patch would cause so much controversy :)

On Mon, 11 Oct 2004, Derek Fawcus wrote:
> > The attached patch adds another variety of the -serial and -monitor
> > options. You can now use
> >         -serial "exec:any shell command"
> > to redirect the input/output of named shell command to the guest's serial
> > port.
>
> Hmm.  How about simply using FIFO's instead,  then one doesn't have any
> issues with fork/system/etc
>
> i.e. add options of -serialin <path> -serialout <path> and have -serial <path>
> set both of the above.  Then one can simply do:
>
> mkfifo /tmp/serin /tmp/serout
> anycmd < /tmp/serout > /tmp/serin &
> qemu ... -serialin /tmp/serin -serialout /tmp/serialout
Actually, that's kind of what I tried before (-serial stdio, with
stdin/stdout redirected to a pipe). However, some programs don't like
that. Most importantly, slirp doesn't work with it - it seems to expect a
real tty.

I like my solution because
1. we don't need another command line argument but only extend an existing
   one
2. we don't create another library dependency (forkpty is declared in
   pty.h just as openpty is which we use for -serial pty)
3. I don't need to bother about communicating pty (or pipe) names between
   processes
4. programs like slirp and pppd work just fine with this approach


On Mon, 11 Oct 2004, André Braga wrote:
> That would make this feature available only on operating systems that
> support user-created named pipes. IOW, named pipes do exist on Windows,
> but they're not easy to access by the user.
>
> Forking is a more universal approach, as I see it.
Sorry if I have to disappoint: I'm not sure whether the forkpty() call is
available in Windoze. The -serial pty code is disabled for a Windows
compile, so I did the same for my -serial exec code. If there's a windows
guru out there who knows whether ptys are emulated in cygwin maybe you can
test whether it will work in windoze as well.

	Johannes

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 20:32     ` Johannes Martin
@ 2004-10-11 21:38       ` Derek Fawcus
  2004-10-11 21:47         ` Derek Fawcus
  0 siblings, 1 reply; 8+ messages in thread
From: Derek Fawcus @ 2004-10-11 21:38 UTC (permalink / raw)
  To: qemu-devel

On Mon, Oct 11, 2004 at 10:32:29PM +0200, Johannes Martin wrote:
> Actually, that's kind of what I tried before (-serial stdio, with
> stdin/stdout redirected to a pipe). However, some programs don't like
> that. Most importantly, slirp doesn't work with it - it seems to expect a
> real tty.

Huh?  I've not played with the slirp code,  but why should it care?

I note that the misc.c file in the slirp code can use pty's internally,
but that shouldn't matter.  Just what requires that a pty be used as
a form of IPC to slirp?

Frankly,  i should be able to work with any form of byte stream.

> Sorry if I have to disappoint: I'm not sure whether the forkpty() call is
> available in Windoze. The -serial pty code is disabled for a Windows
> compile, so I did the same for my -serial exec code. If there's a windows
> guru out there who knows whether ptys are emulated in cygwin maybe you can
> test whether it will work in windoze as well.

The other problem with this for windows style programs is that most of them
(as I understand) pay no attention to stdin/stdout.  So this is a bit pointless.

BTW:  Just what sort of program do you fork off of the serial port?

DF

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

* Re: [Qemu-devel] new feature: attach a process to emulated serial port
  2004-10-11 21:38       ` Derek Fawcus
@ 2004-10-11 21:47         ` Derek Fawcus
  0 siblings, 0 replies; 8+ messages in thread
From: Derek Fawcus @ 2004-10-11 21:47 UTC (permalink / raw)
  To: qemu-devel

On Mon, Oct 11, 2004 at 10:38:03PM +0100, Derek Fawcus wrote:
> BTW:  Just what sort of program do you fork off of the serial port?

Aha.  You mentioned that at the start.  So this is an issue with
the standalone slirp package,  not the slirp code compiled into
qemu.  It should be possible to 'fix' that in slirp,  but that's
a seperate issue.

Another problem with the code (wrt windows) is simply does windows
support a pseudo-terminal like thing?  As this patch also requires
them.

It seems to support this under windows one would have to add a packet
protocol on top of the byte stream (however connected) which can then
pass the info about the status of the modem control lines.

So all in all,  there is no point in worrying about windows wrt this
code :-)

DF

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

end of thread, other threads:[~2004-10-11 21:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-08 21:46 [Qemu-devel] new feature: attach a process to emulated serial port Johannes Martin
2004-10-11 13:26 ` Derek Fawcus
2004-10-11 15:22   ` André Braga
2004-10-11 15:47     ` Derek Fawcus
2004-10-11 16:03       ` André Braga
2004-10-11 20:32     ` Johannes Martin
2004-10-11 21:38       ` Derek Fawcus
2004-10-11 21:47         ` Derek Fawcus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).