Re: linux shell comes out to qemu-monitor when I enter anything. (I have two uarts)

2022-07-21 Thread Peter Maydell
On Thu, 21 Jul 2022 at 03:46, Jakob Bohm  wrote:
> It would be a lot more helpful if your error message was explicit about
> which items were conflicting rather than demanding the full configuration
> from people affected.  And don't fall for the temptation of printing out a
> list of potential reasons in the fixed error text, actually print the
> actual data triggering your error case.

Yes, I agree. QEMU's command line handling and error messages
often leave a lot to be desired. Unfortunately it's often difficult
to produce good error messages, because by the time execution gets
down to the point where you notice the problem it's a long way
removed from the user's command line options. In this case, the
stdio chardev is a self-contained object which can easily determine
if another instance of it has already been created, but it doesn't
know anything about what that other instance was or what the
code creating that other instance was doing (or even about what
the code creating this instance is doing, though at least in that
case there's the opportunity for propagating an error up to the
caller).

-- PMM



Re: linux shell comes out to qemu-monitor when I enter anything. (I have two uarts)

2022-07-20 Thread Jakob Bohm

On 2022-07-20 14:35, Peter Maydell wrote:

On Wed, 20 Jul 2022 at 13:14, Chan Kim  wrote:

Hi, Peter Maydell,

Thank you for the advice.
So I uncommented the stdio_in_use guard, and used this option
(because the second uart will be used)

-chardev null,mux=off,id=char0 -serial chardev:char0 -chardev 
stdio,mux=off,id=char1 -serial chardev:char1

And it gives me :
qemu-system-aarch64: cannot use stdio by multiple character devices

That isn't a full QEMU command line. Either something else on your
command line is also using 'stdio', or you've passed an option
that implicitly says "use stdio" (maybe -nographic ?), or you have
code in your device model that's hardwiring use of the stdio chardev.


-- PMM



It would be a lot more helpful if your error message was explicit about
which items were conflicting rather than demanding the full configuration
from people affected.  And don't fall for the temptation of printing out a
list of potential reasons in the fixed error text, actually print the 
actual data

triggering your error case.


Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded




Re: linux shell comes out to qemu-monitor when I enter anything. (I have two uarts)

2022-07-20 Thread Peter Maydell
On Wed, 20 Jul 2022 at 13:14, Chan Kim  wrote:
>
> Hi, Peter Maydell,
>
> Thank you for the advice.
> So I uncommented the stdio_in_use guard, and used this option
> (because the second uart will be used)
>
> -chardev null,mux=off,id=char0 -serial chardev:char0 -chardev 
> stdio,mux=off,id=char1 -serial chardev:char1
>
> And it gives me :
> qemu-system-aarch64: cannot use stdio by multiple character devices

That isn't a full QEMU command line. Either something else on your
command line is also using 'stdio', or you've passed an option
that implicitly says "use stdio" (maybe -nographic ?), or you have
code in your device model that's hardwiring use of the stdio chardev.


-- PMM



RE: linux shell comes out to qemu-monitor when I enter anything. (I have two uarts)

2022-07-20 Thread Chan Kim
Hi, Peter Maydell,

Thank you for the advice.
So I uncommented the stdio_in_use guard, and used this option
(because the second uart will be used)

-chardev null,mux=off,id=char0 -serial chardev:char0 -chardev 
stdio,mux=off,id=char1 -serial chardev:char1

And it gives me :
qemu-system-aarch64: cannot use stdio by multiple character devices

I tried setting mux=on or removing '-serial chardev:char0'. But the message is 
the same.
The only way I  can suppress the error seems to be removing the 'stdio_in_use' 
guard.
I don't know how to 'not connect anything' to my first UART.
Can you give me more specific option?

p.s. : by the way I'm running from u-boot-spl (using -kernel elf at 0x400) 
which jumps to loaded linux(by -device loader option at 0x8020)
with dtb at 0x8000 (also using -device loader option). 
I think in this case only my loaded dtb is used and the qemu-generated fdt is 
not used at all, is this correct?

Best regards,
Chan Kim

>-Original Message-
>From: Peter Maydell 
>Sent: Wednesday, July 20, 2022 7:44 PM
>To: Chan Kim 
>Cc: qemu-discuss 
>Subject: Re: linux shell comes out to qemu-monitor when I enter anything.
>(I have two uarts)
>
>On Wed, 20 Jul 2022 at 11:27, Chan Kim  wrote:
>>
>> Hello qemu experts,
>>
>> In my virtual machine I have two uart and I want to use the
>> input/output in my host machine.
>> For that I commented out these lines in qemu_chr_open_stdio function
>> in chardev/char-stdio.c. (qemu-6.2.0)
>>
>> /*
>> if (stdio_in_use) {
>> error_setg(errp, "cannot use stdio by multiple character devices");
>> return;
>> }
>> */
>
>Don't do that, there is a reason why that guard is there.
>If you want multiple chardevs connecting to stdio you need to multiplex
>them (otherwise, which one should input from the terminal go to?).
>
>> And used this option for stdio.
>>
>> -chardev stdio,mux=on,id=char0 -serial chardev:char0 -serial
>> chardev:char0
>>
>> And two serial ports are generated and is multiplexed into stdio backend.
>> Actually in the software on the virtual machine, the first uart is
>> never written and only the second uart is written to. But the dtb
>> contains two uarts so I had to generate two frontends anyway.
>
>If you don't care about one of the UARTs, then just don't connect a chardev
>to it (or equivalently, connect an instance of the 'null' chardev, which
>throws away anything sent to it).
>
>-- PMM







Re: linux shell comes out to qemu-monitor when I enter anything. (I have two uarts)

2022-07-20 Thread Peter Maydell
On Wed, 20 Jul 2022 at 11:27, Chan Kim  wrote:
>
> Hello qemu experts,
>
> In my virtual machine I have two uart and I want to use the input/output in
> my host machine.
> For that I commented out these lines in qemu_chr_open_stdio function in
> chardev/char-stdio.c. (qemu-6.2.0)
>
> /*
> if (stdio_in_use) {
> error_setg(errp, "cannot use stdio by multiple character devices");
> return;
> }
> */

Don't do that, there is a reason why that guard is there.
If you want multiple chardevs connecting to stdio you need to
multiplex them (otherwise, which one should input from the
terminal go to?).

> And used this option for stdio.
>
> -chardev stdio,mux=on,id=char0 -serial chardev:char0 -serial chardev:char0
>
> And two serial ports are generated and is multiplexed into stdio backend.
> Actually in the software on the virtual machine, the first uart is never
> written and only the second uart is written to. But the dtb contains two
> uarts so I had to generate two frontends anyway.

If you don't care about one of the UARTs, then just don't connect
a chardev to it (or equivalently, connect an instance of the
'null' chardev, which throws away anything sent to it).

-- PMM