new feature: attach a process to emulated serial port
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
Quoted 7 lines · Johannes Martin
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
Quoted 9 lines · Derek Fawcus
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.
Signature · 2 lines
"A year spent in artificial intelligence is enough to make one believe in God" Alan J. Perlis
Quoted 7 lines · André Braga
Quoted 6 lines · Derek Fawcus
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:
Quoted 6 lines
Quoted 3 lines
mkfifo
/tmp/serin/tmp/serout
anycmd </tmp/serout>/tmp/serin&
qemu ... -serialin/tmp/serin-serialout/tmp/serialoutThat 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?
Quoted 1 line
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.
Quoted 1 line
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
Quoted 2 lines · Derek Fawcus
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.
Quoted 2 lines
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.
Quoted 2 lines
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.
Signature · 2 lines
"A year spent in artificial intelligence is enough to make one believe in God" Alan J. Perlis
Hi,
wow - I didn't think my patch would cause so much controversy :)
Quoted 9 lines · Derek Fawcus
Quoted 5 lines
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
Quoted 6 lines
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
Quoted 5 lines · André Braga
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
Quoted 4 lines · Johannes Martin
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.
Quoted 5 lines
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
Quoted 1 line · Derek Fawcus
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