OK, solved this one myself (sort of) :
o Using the command line options:
... -append 'root=/dev/sda rw selinux=0 enforcing=0 console=ttyS0'
-m 2048 -k en-gb -nographic -vga none -vnc none -enable-kvm -serial
stdio -nodefaults
does get the kernel to launch the console on stdio .
So doing :
$ qemu-kvm ... -append 'root=/dev/sda rw selinux=0 enforcing=0
console=ttyS0' -m 2048 -k en-gb -nographic -vga none -vnc none
-enable-kvm -serial stdio -nodefaults \
<$MY_INPUT_PIPE >/tmp/$MY_OUPUT_PIPE 2>&1
does have exactly the effect I want . Hooray!
(where '...' are the other qemu-kvm arguments in quoted mail, and
$MY_*PIPE are /tmp/el6x32.in and /tmp/el6x32.out as in previous mail.
The above command works, so I can do:
$ cat $MY_OUTPUT_PIPE &'
$ cat >>$MY_INPUT_PIPE
and I get a login prompt.
But I still can't understand why this does not have the desired effect:
$ qemu-kvm ... -append 'root=/dev/sda rw selinux=0 enforcing=0
console=ttyS0' -m 2048 -k en-gb -nographic -vga none -vnc none
-enable-kvm -nodefault -chardev 'pipe,id=0,path=/tmp/el6x32'
No output is produced on the output pipe after connecting a writer
to the input pipe.
I'd like to understand how the '--chardev pipe,path=...' option is meant to
work if it does not have the effect of '-serial stdio' with I/O redirected
to the pipes.
On 05/01/2015, Jason Vas Dias <jason.vas.dias(a)gmail.com> wrote:
Aha! Thank you. Yes that does prevent the default stdio console .
But no output appears on the input pipe, and outputting to input end has
no effect:
In one terminal, I do:
$ cat /tmp/el6x32.out
in the main terminal, I run:
$ /usr/libexec/qemu-kvm -M rhel6.4.0 -cpu n270 -smp 1 -hda
/home/rpmbuild/OEL6/img/OEL6_32.img -kernel
/home/rpmbuild/OEL6/boot/vmlinuz-2.6.39-400.215.14.el6uek.i686 -initrd
/home/rpmbuild/OEL6/boot/initramfs-2.6.39-400.215.14.el6uek.i686.img
-append 'root=/dev/sda rw selinux=0 enforcing=0 console=0' -m 2048 -k
en-gb -nographic -vga none -vnc none -enable-kvm -chardev
pipe,id=0,path=/tmp/el6x32 -chardev tty,id=1,path=/dev/pts/4 -monitor
stdio -nodefaults
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) info status
VM status: running
(qemu)
In another terminal I connect to the input pipe:
$ cat >>/tmp/el632.in
But no output appears on the /tmp/el6x32.out pipe ,
regardless of what is typed on the input pipe .
I want to issue the login commands and then set up the shell
to run commands echo'ed to the input pipe on the physical - eg. :
$ echo 'ls' > /tmp/el6x32.in
and read the output from the guest on the output pipe:
$ cat /tmp/el632.out
Anyone know any way of doing this ?
I'm trying to run a nested guest in a VMware guest whose physical host CPU
has VMX enabled using qemu-kvm, but guest virtual networking is disabled
in VMware so I can't use ssh / telnet in the guest to run commands .
Thanks for any further replies,
Jason
On 05/01/2015, Michal Privoznik <mprivozn(a)redhat.com> wrote:
> On 05.01.2015 15:03, Jason Vas Dias wrote:
>> Please can anyone enlighten me as to why linux qemu-kvm always
>> creates the console on my terminal, when I am trying to direct
>> all of its input and output to a pipe ?
>>
>> I have created :
>> $ mkfifo /tmp/el6x32{.in,.out,.monitor}
>> and use the command:
>> $ /usr/libexec/qemu-kvm -M rhel6.4.0 -cpu n270 -smp 1 \
>> -hda /home/rpmbuild/OEL6/img/OEL6_32.img \
>> -kernel
>> /home/rpmbuild/OEL6/boot/vmlinuz-2.6.39-400.215.14.el6uek.i686 \
>> -initrd /home/rpmbuild/OEL6/boot/initramfs
>> 2.6.39-400.215.14.el6uek.i686.img \
>> -append 'root=/dev/sda rw selinux=0 enforcing=0 console=0' \
>> -m 2048 -k en-gb -nographic -vga none -vnc none -enable-kvm \
>> -chardev pipe,id=0,path=/tmp/el6x32 -monitor
>> pipe:/tmp/el6x32.monitor
>>
>> But this ends up with the kernel's console on qemu-kvm's STDIO .
>>
>> I actually want the console to be redirected to take input from
>> /tmp/el6x32.in and direct output to /tmp/el6x32.out -
>> I thought that was what the above '-chardev pipe,id=0,path=/tmp/el6x32'
>> should do if kernel boot params 'console=0' is also supplied ?
>> Why isn't this happening for me ? Anyone got a guest to read console
>> input
>> from a pipe and direct console output to a pipe ? If so, how?
>>
>> Thanks in advance for any replies, Jason.
>
> That's probably because qemu by default creates some
> serial/parallels/virtual console/... You may want to pass '-nodefaults'
> onto qemu-kvm command line.
>
> Michal
>