qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Dummy question for setting up a serial connection between host and guest
@ 2015-03-11  1:12 Alex Sun
  2015-03-12 16:33 ` Christopher Covington
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Sun @ 2015-03-11  1:12 UTC (permalink / raw)
  To: qemu-devel

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

I downloaded QEMU 2.2.0, and built a qemu-system-arm from there.
I loaded a versatile kernel 2.6.32.5 and my own file system.

#qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile
-append "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive
file=fat:rw:./data -nographic -no-reboot

I see following message while the kernel is booting:

[    3.873429] dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
[    3.884631] console [ttyAMA0] enabled
[    3.889783] dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
[    3.890646] dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011

I think the serial ports of ttyAMA[0-2] are enabled.
Then I try to do serial redirection:

#qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile
-append "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive
file=fat:rw:./data -nographic -no-reboot *-serial stdio -serial pty*

However, I get error message:
QEMU 2.2.0 monitor - type 'help' for more information
*(qemu) qemu-system-arm: -serial stdio: cannot use stdio by multiple
character devices*

It's weired to me. I don't think there is another one other than qemu
itself holding the stdio.

Then I try to do redirect serial to both pty:
#qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile
-append "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive
file=fat:rw:./data -nographic -no-reboot -redir tcp:5000::22 *-serial pty
-serial pty*

It works fine this time. I got following output:
vvfat ./data chs 1024,16,63
QEMU 2.2.0 monitor - type 'help' for more information
(qemu) char device redirected to /dev/pts/87 (label serial0)
char device redirected to /dev/pts/88 (label serial1)

Then I do `cat /dev/pts/86` I see the kernel boot progress messages.
When the guest has booted, I ssh to guest and do following experiment:
(1)  on host:
#cat /dev/pts88

on guest:
#echo "alex" > /dev/ttyAMA1

I see "alex" on host.

(2) on guest:
#cat /dev/ttyAMA1

on host:
#echo "alex" > /dev/pts88

I see nothing on guest...

Why the serial connection is one-way (e.x. guest to host)? How to configure
it as dual-way?

Any advise on this is highly appreciated!!

Thanks!
Alex

[-- Attachment #2: Type: text/html, Size: 3217 bytes --]

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

* Re: [Qemu-devel] Dummy question for setting up a serial connection between host and guest
  2015-03-11  1:12 [Qemu-devel] Dummy question for setting up a serial connection between host and guest Alex Sun
@ 2015-03-12 16:33 ` Christopher Covington
  2015-03-12 22:19   ` Alex Sun
  2015-03-13  7:40   ` Markus Armbruster
  0 siblings, 2 replies; 4+ messages in thread
From: Christopher Covington @ 2015-03-12 16:33 UTC (permalink / raw)
  To: Alex Sun, qemu-devel

Hi Alex,

On 03/10/2015 09:12 PM, Alex Sun wrote:
> I downloaded QEMU 2.2.0, and built a qemu-system-arm from there.
> I loaded a versatile kernel 2.6.32.5 and my own file system.
> 
> #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
> efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile -append
> "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
> -nographic -no-reboot
> 
> I see following message while the kernel is booting:
> 
> [    3.873429] dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
> [    3.884631] console [ttyAMA0] enabled
> [    3.889783] dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
> [    3.890646] dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
> 
> I think the serial ports of ttyAMA[0-2] are enabled.
> Then I try to do serial redirection:
> 
> #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
> efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile -append
> "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
> -nographic -no-reboot *-serial stdio -serial pty*
>
> However, I get error message:
> QEMU 2.2.0 monitor - type 'help' for more information
> *(qemu) qemu-system-arm: -serial stdio: cannot use stdio by multiple character
> devices*
> 
> It's weired to me. I don't think there is another one other than qemu itself
> holding the stdio. 

I think the conflict is that when you specify -nographic, the QEMU monitor
uses stdio. I find it necessary to add "-monitor none" to all of my command lines.

Regards,
Chris

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [Qemu-devel] Dummy question for setting up a serial connection between host and guest
  2015-03-12 16:33 ` Christopher Covington
@ 2015-03-12 22:19   ` Alex Sun
  2015-03-13  7:40   ` Markus Armbruster
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Sun @ 2015-03-12 22:19 UTC (permalink / raw)
  To: Christopher Covington; +Cc: qemu-devel

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

Thank you Chris!
Your suggestion is really working!!! Awesome!!!
 I find in this way if I input "^C" in stdio I'm gonna kill the qemu
process. But I think it's fine to me ;-).

Did you managed to make serial communication between host (which holds QEMU
client) and guest (QEMU client)?
I tried to use -serial pty but realized that it is only one way traffic,
e.x. as I experimented,  I can send traffic from guest to host but I can't
do that from host to guest.

If it's not gonna work, I guess I have to use socket to make that
communication.

Thanks!
Alex


On Thu, Mar 12, 2015 at 9:33 AM, Christopher Covington <cov@codeaurora.org>
wrote:

> Hi Alex,
>
> On 03/10/2015 09:12 PM, Alex Sun wrote:
> > I downloaded QEMU 2.2.0, and built a qemu-system-arm from there.
> > I loaded a versatile kernel 2.6.32.5 and my own file system.
> >
> > #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb
> -option-rom
> > efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile
> -append
> > "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
> > -nographic -no-reboot
> >
> > I see following message while the kernel is booting:
> >
> > [    3.873429] dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a
> AMBA/PL011
> > [    3.884631] console [ttyAMA0] enabled
> > [    3.889783] dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a
> AMBA/PL011
> > [    3.890646] dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a
> AMBA/PL011
> >
> > I think the serial ports of ttyAMA[0-2] are enabled.
> > Then I try to do serial redirection:
> >
> > #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb
> -option-rom
> > efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile
> -append
> > "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
> > -nographic -no-reboot *-serial stdio -serial pty*
> >
> > However, I get error message:
> > QEMU 2.2.0 monitor - type 'help' for more information
> > *(qemu) qemu-system-arm: -serial stdio: cannot use stdio by multiple
> character
> > devices*
> >
> > It's weired to me. I don't think there is another one other than qemu
> itself
> > holding the stdio.
>
> I think the conflict is that when you specify -nographic, the QEMU monitor
> uses stdio. I find it necessary to add "-monitor none" to all of my
> command lines.
>
> Regards,
> Chris
>
> --
> Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>

[-- Attachment #2: Type: text/html, Size: 3366 bytes --]

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

* Re: [Qemu-devel] Dummy question for setting up a serial connection between host and guest
  2015-03-12 16:33 ` Christopher Covington
  2015-03-12 22:19   ` Alex Sun
@ 2015-03-13  7:40   ` Markus Armbruster
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2015-03-13  7:40 UTC (permalink / raw)
  To: Christopher Covington; +Cc: Alex Sun, qemu-devel

Christopher Covington <cov@codeaurora.org> writes:

> Hi Alex,
>
> On 03/10/2015 09:12 PM, Alex Sun wrote:
>> I downloaded QEMU 2.2.0, and built a qemu-system-arm from there.
>> I loaded a versatile kernel 2.6.32.5 and my own file system.
>> 
>> #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
>> efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile -append
>> "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
>> -nographic -no-reboot
>> 
>> I see following message while the kernel is booting:
>> 
>> [    3.873429] dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
>> [    3.884631] console [ttyAMA0] enabled
>> [    3.889783] dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
>> [    3.890646] dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
>> 
>> I think the serial ports of ttyAMA[0-2] are enabled.
>> Then I try to do serial redirection:
>> 
>> #qemu-system-arm -pidfile /tmp/qemu_0_pids/0.pid -M versatilepb -option-rom
>> efi-rtl8139.rom -initrd newinitrd -kernel vmlinuz-2.6.32-5-versatile -append
>> "root=/dev/sda1 console=ttyAMA0" -hda new.qcow2 -drive file=fat:rw:./data
>> -nographic -no-reboot *-serial stdio -serial pty*
>>
>> However, I get error message:
>> QEMU 2.2.0 monitor - type 'help' for more information
>> *(qemu) qemu-system-arm: -serial stdio: cannot use stdio by multiple character
>> devices*
>> 
>> It's weired to me. I don't think there is another one other than qemu itself
>> holding the stdio. 

You can connect multiple users to a character device in multiplexing
mode.  Quoting the fine manual:

    A character device may be used in multiplexing mode by multiple
    front-ends.  The key sequence of @key{Control-a} and @key{c} will
    rotate the input focus between attached front-ends. Specify
    @option{mux=on} to enable this mode.

> I think the conflict is that when you specify -nographic, the QEMU monitor
> uses stdio. I find it necessary to add "-monitor none" to all of my
> command lines.

I use -nodefault.  One stone, many annoying birds.

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

end of thread, other threads:[~2015-03-13  7:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-11  1:12 [Qemu-devel] Dummy question for setting up a serial connection between host and guest Alex Sun
2015-03-12 16:33 ` Christopher Covington
2015-03-12 22:19   ` Alex Sun
2015-03-13  7:40   ` Markus Armbruster

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).