mbox series

[0/1] virtio: add driver for virtio_console devices

Message ID 20230606132540.3362711-1-paul.liu@linaro.org
Headers show
Series virtio: add driver for virtio_console devices | expand

Message

Ying-Chun Liu (PaulLiu) June 6, 2023, 1:25 p.m. UTC
This is an implementation of single-character virtio-console. Part of the
patch is based on barebox implementations.

To test the patch, we can build qemu_arm64_defconfig target. Enable
CONFIG_VIRTIO_CONSOLE. And run qemu-system-aarch64 with
 -device virtio-serial-pci,id=virtio-serial0 \
 -chardev file,id=charconsole0,path=/tmp/serialconsolelog \
 -device virtconsole,chardev=charconsole0,id=console0 \

When in U-boot console, type "dm tree" and we should be able to see the
virtio-console device.

A. Cody Schuffelen (1):
  virtio: add driver for virtio_console devices

 drivers/virtio/Kconfig          |   8 ++
 drivers/virtio/Makefile         |   1 +
 drivers/virtio/virtio-uclass.c  |   1 +
 drivers/virtio/virtio_console.c | 158 ++++++++++++++++++++++++++++++++
 include/virtio.h                |   2 +
 5 files changed, 170 insertions(+)
 create mode 100644 drivers/virtio/virtio_console.c

Comments

Bin Meng June 9, 2023, 9:27 a.m. UTC | #1
Hi,

On Tue, Jun 6, 2023 at 9:26 PM Ying-Chun Liu (PaulLiu)
<paulliu@debian.org> wrote:
>
> This is an implementation of single-character virtio-console. Part of the
> patch is based on barebox implementations.
>
> To test the patch, we can build qemu_arm64_defconfig target. Enable
> CONFIG_VIRTIO_CONSOLE. And run qemu-system-aarch64 with
>  -device virtio-serial-pci,id=virtio-serial0 \
>  -chardev file,id=charconsole0,path=/tmp/serialconsolelog \
>  -device virtconsole,chardev=charconsole0,id=console0 \
>

With this command, it still uses the on-board UART but not
virtio-console. Would you please post test instructions on using
virtio-console as the U-Boot serial console? Thanks!

> When in U-boot console, type "dm tree" and we should be able to see the
> virtio-console device.
>
> A. Cody Schuffelen (1):
>   virtio: add driver for virtio_console devices
>
>  drivers/virtio/Kconfig          |   8 ++
>  drivers/virtio/Makefile         |   1 +
>  drivers/virtio/virtio-uclass.c  |   1 +
>  drivers/virtio/virtio_console.c | 158 ++++++++++++++++++++++++++++++++
>  include/virtio.h                |   2 +
>  5 files changed, 170 insertions(+)
>  create mode 100644 drivers/virtio/virtio_console.c
>
> --

Regards,
Bin
Paul Liu June 13, 2023, 5:36 p.m. UTC | #2
On 2023/6/9 17:27, Bin Meng wrote:
> Hi,
> 
> On Tue, Jun 6, 2023 at 9:26 PM Ying-Chun Liu (PaulLiu)
> <paulliu@debian.org> wrote:
>>
>> This is an implementation of single-character virtio-console. Part of the
>> patch is based on barebox implementations.
>>
>> To test the patch, we can build qemu_arm64_defconfig target. Enable
>> CONFIG_VIRTIO_CONSOLE. And run qemu-system-aarch64 with
>>   -device virtio-serial-pci,id=virtio-serial0 \
>>   -chardev file,id=charconsole0,path=/tmp/serialconsolelog \
>>   -device virtconsole,chardev=charconsole0,id=console0 \
>>
> 
> With this command, it still uses the on-board UART but not
> virtio-console. Would you please post test instructions on using
> virtio-console as the U-Boot serial console? Thanks!
> 

Hi Bin,

Yes. The way to test this is.
I compile U-boot for qemu_arm64_defconfig
Enable the following configs manually.
CONFIG_VIRTIO_CONSOLE=y
CONFIG_CONSOLE_MUX=y
CONFIG_SYS_CONSOLE_IS_IN_ENV=y

Now run qemu with the following commands.
qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic \
-device virtio-serial-pci,id=virtio-serial0 \
-chardev file,id=charconsole0,path=/tmp/serialconsolelog \
-device virtconsole,chardev=charconsole0,id=console0 \
-bios /tmp/uboot-qemu-clang/u-boot.bin

In U-boot prompt,
we run
1. virtio scan
2. coninfo
In coninfo, we can see there is a new console device called virtio-console#XX
Then.
3. setenv stdout pl011@9000000,virtio-console#XX
And then all the output will also be output to /tmp/serialconsolelog on host.

This is the minimum example of testing the driver.
If we want to test it more then we might need to modify the -chardev to not use a file.
For example, we can use a telnet server.
-chardev socket,id=charconsole0,host=127.0.0.1,port=10023,telnet=on,server

After set stdin and stdout to pl011@9000000,virtio-console#XX
We can use "telnet localhost 10023" to access the U-boot prompt in qemu.

Yours,
Paul
Bin Meng June 19, 2023, 4:19 a.m. UTC | #3
Hi Paul,

On Wed, Jun 14, 2023 at 1:36 AM Ying-Chun Liu (PaulLiu)
<paul.liu@linaro.org> wrote:
>
>
>
> On 2023/6/9 17:27, Bin Meng wrote:
> > Hi,
> >
> > On Tue, Jun 6, 2023 at 9:26 PM Ying-Chun Liu (PaulLiu)
> > <paulliu@debian.org> wrote:
> >>
> >> This is an implementation of single-character virtio-console. Part of the
> >> patch is based on barebox implementations.
> >>
> >> To test the patch, we can build qemu_arm64_defconfig target. Enable
> >> CONFIG_VIRTIO_CONSOLE. And run qemu-system-aarch64 with
> >>   -device virtio-serial-pci,id=virtio-serial0 \
> >>   -chardev file,id=charconsole0,path=/tmp/serialconsolelog \
> >>   -device virtconsole,chardev=charconsole0,id=console0 \
> >>
> >
> > With this command, it still uses the on-board UART but not
> > virtio-console. Would you please post test instructions on using
> > virtio-console as the U-Boot serial console? Thanks!
> >
>
> Hi Bin,
>
> Yes. The way to test this is.
> I compile U-boot for qemu_arm64_defconfig
> Enable the following configs manually.
> CONFIG_VIRTIO_CONSOLE=y
> CONFIG_CONSOLE_MUX=y
> CONFIG_SYS_CONSOLE_IS_IN_ENV=y
>
> Now run qemu with the following commands.
> qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic \
> -device virtio-serial-pci,id=virtio-serial0 \
> -chardev file,id=charconsole0,path=/tmp/serialconsolelog \
> -device virtconsole,chardev=charconsole0,id=console0 \
> -bios /tmp/uboot-qemu-clang/u-boot.bin
>
> In U-boot prompt,
> we run
> 1. virtio scan
> 2. coninfo
> In coninfo, we can see there is a new console device called virtio-console#XX
> Then.
> 3. setenv stdout pl011@9000000,virtio-console#XX
> And then all the output will also be output to /tmp/serialconsolelog on host.
>
> This is the minimum example of testing the driver.
> If we want to test it more then we might need to modify the -chardev to not use a file.
> For example, we can use a telnet server.
> -chardev socket,id=charconsole0,host=127.0.0.1,port=10023,telnet=on,server
>
> After set stdin and stdout to pl011@9000000,virtio-console#XX
> We can use "telnet localhost 10023" to access the U-boot prompt in qemu.
>

Thanks for the instructions. Is it possible to test the virtio-console
driver as the U-Boot boot console?

I suspect we need to add the DM_FLAG_PRE_RELOC flag here and there in
the virtio subsystem?

Regards,
Bin