qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to use multiple uart in a virtual machine?


From: Chan Kim
Subject: RE: How to use multiple uart in a virtual machine?
Date: Thu, 17 Mar 2022 15:34:37 +0900

Hello all,

 

I found this : https://unix.stackexchange.com/questions/479085/can-qemu-m-virt-on-arm-aarch64-have-multiple-serial-ttys-like-such-as-pl011-t (answer from LastRitter)

I followed as he showed (added one more uart, added acpi tables too) and used the following option

   -chardev stdio,mux=on,id=char0 -serial chardev:char0 -serial chardev:char0

But it gave me the same error. (qemu-system-aarch64: cannot use stdio by multiple character devices)

So I used debugger and found out when I give above option, By the “-chardev stdio,mux=on,id=char0” option, a chardev is made with backend=stdio and the chardev is open for use.

And the another default chardev named “compat_monitor0” is made and open (seemingly from default option). And when this new chardev is opened, the above error is generated.

This function qemu_chr_open_stdio opens the Chardev. ( qemu-6.2.0 chardev/char-stdio.c)

 

static void qemu_chr_open_stdio(Chardev *chr,

                                ChardevBackend *backend,

                                bool *be_opened,

                                Error **errp)

{

    ChardevStdio *opts = backend->u.stdio.data;

    struct sigaction act;

 

    if (is_daemonized()) {

        error_setg(errp, "cannot use stdio with -daemonize");

        return;

    }

 

if (stdio_in_use) {

        error_setg(errp, "cannot use stdio by multiple character devices");

        return;

    }

 

    stdio_in_use = true;

    old_fd0_flags = fcntl(0, F_GETFL);

    tcgetattr(0, &oldtty);

    qemu_set_nonblock(0);

                    .... (continued)

 

So I tried commenting out the above “if (stdio_in_use)” check and then the booting procedure passed the enumeration of the device and reading the uart device.

(earlier exception occurred because the second uart device was not there)

The code above seems to tell the stdio cannot be used twice as backend of a chardev, even though I set ‘mux=on’ for the chardev char0 above.

Is this a bug in qemu-6.2.0 or am I missing something?

Please help me identify what is wrong.

Thank you!

 

Chan Kim

 

From: Chan Kim <ckim@etri.re.kr>
Sent: Wednesday, March 16, 2022 5:32 PM
To: 'qemu-discuss' <qemu-discuss@nongnu.org>
Subject: How to use multiple uart in a virtual machine?

 

Hello all,

 

After checking character device option for qemu invocation, https://www.qemu.org/docs/master/system/invocation.html#hxtool-6

I tried to add another uart for a modified arm64 virt machine (named ab21q).

So I added second uart like this  (in hw/arm/ab21q.c which is modified from hw/arm/virt.c,  using qemu-6.2.0)

create_uart(vms, AB21Q_UART, sysmem, serial_hd(0));

create_uart(vms, AB21Q_UART1, sysmem, serial_hd(1)); // second uart

    // AB21Q_UART and AB21Q_UART1 have their own address space and irq number

I added the command option

-chardev stdio,mux=on,id=char0 -serial chardev:char0 -serial chardev:char0

But qemu gives this error :

qemu-system-aarch64: cannot use stdio by multiple character devices

(BTW, Im running from u-boot program for starting linux)

How can I add second uart and make the second uart output to appear in the stdio also?

Any comment or help will be much appreciated.

Thank you!

 

Chan Kim

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]