QEMU virtio/virtconsole devices explained

Viewed 874

Let's take this example (I spent several hours to make it work):

qemu-system-x86_64 ... \
-kernel $HOME/devel/vmlinuz-5.11.0-22-generic            \
-drive ...                                               \
-append 'earlyprintk=hvc0 console=hvc0 root=/dev/sda rw' \ (0)
-device virtio-serial-pci,id=virtio-serial0              \ (1)
-chardev stdio,id=charconsole0                           \ (2)
-device virtconsole,chardev=charconsole0,id=console0       (3)

What do those options do? My understanding is that

  • (2) tells qemu to create host end-point of tty/console and "binds" it to qemu's stdio.
  • (3) tells qemu what devices should be exposed to the guest, and also specifies that charconsole0 should be used as the other end, which is effectively qemu's stdio.
    • But what is virtconsole?
    • What is the difference between virtconsole and virtserialport or virtio-serial-pci?
  • What does (1) do? Where does its name: virtio-serial-pci come from?
  • How do I know that virtconsole device in the guest will be identified with the name hvc0 (so that I could specify it in (0))?
1 Answers

virtconsole is really just a specialised virtio-serial link. Each -device specifies a new device so in your example you have two virtio-serial devices. The virtio-serial-pci device behaves exactly like virtio-serial except it is on the PCI bus rather than the MMIO bus.

Related