vm-virtio: Add virtio console device for single port operation

The virtio console device is a console for the communication between
the host and guest userspace. It has two parts: the device and the
driver. The console device is implemented here as a virtio-pci device
to the guest. On the other side, the guest OS expected to have a
character device driver which provides an interface to the userspace
applications.

The console device can have multiple ports where each port has one
transmit queue and one receive queue. The current implementation only
supports one port. For data IO communication, one or more empty
buffers are placed in the receive queue for incoming data, and
outgoing characters are placed in the transmit queue. Details spec
can be found from the following link.

https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.pdf#e7

Apart from the console, for the communication between guest and host,
the Cloud Hypervisor has a legacy serial device implemented. However,
the implementation of a console device lets us be independent of legacy
pin-based interrupts without losing the logs and access to the VM.

Signed-off-by: A K M Fazla Mehrab <fazla.mehrab.akm@intel.com>
This commit is contained in:
fazlamehrab
2019-07-22 11:50:56 -07:00
committed by Rob Bradford
parent f98a69f42e
commit 577d44c8eb
3 changed files with 535 additions and 70 deletions

View File

@@ -20,6 +20,7 @@ use std::fmt;
use std::io;
mod block;
mod console;
mod device;
pub mod fs;
pub mod net;
@@ -30,6 +31,7 @@ mod rng;
pub mod transport;
pub use self::block::*;
pub use self::console::*;
pub use self::device::*;
pub use self::fs::*;
pub use self::net::*;
@@ -55,6 +57,7 @@ const VIRTIO_F_VERSION_1_BITMASK: u64 = 1 << VIRTIO_F_VERSION_1;
enum VirtioDeviceType {
TYPE_NET = 1,
TYPE_BLOCK = 2,
TYPE_CONSOLE = 3,
TYPE_RNG = 4,
TYPE_BALLOON = 5,
TYPE_9P = 9,