Skip to main content

VirtioConsole

Struct VirtioConsole 

Source
pub struct VirtioConsole { /* private fields */ }
Expand description

VirtIO console device.

Implementations§

Source§

impl VirtioConsole

Source

pub const FEATURE_SIZE: u64

Feature: Console size.

Source

pub const FEATURE_MULTIPORT: u64

Feature: Multiport.

Source

pub const FEATURE_EMERG_WRITE: u64

Feature: Emergency write.

Source

pub const FEATURE_VERSION_1: u64

VirtIO 1.0 feature.

Source

pub fn new(config: ConsoleConfig) -> Self

Creates a new console device.

Source

pub fn with_stdio() -> Self

Creates a console with standard I/O.

Source

pub fn set_io(&mut self, io: Arc<Mutex<dyn ConsoleIo>>)

Sets the console I/O handler.

Source

pub fn queue_input(&mut self, data: &[u8]) -> Result<()>

Queues input data to be read by the guest.

§Errors

Returns an error if the console is not active.

Source

pub fn read_output(&mut self) -> Vec<u8>

Reads output data written by the guest.

Source

pub fn process_tx_queue(&mut self, memory: &[u8]) -> Result<Vec<(u16, u32)>>

Processes the transmit queue.

§Errors

Returns an error if processing fails.

Source

pub fn rx_available(&self) -> usize

Gets the number of bytes available for RX.

Source

pub fn process_rx_queue( &mut self, memory: &mut [u8], queue_config: &QueueConfig, ) -> Result<bool>

Injects pending host input (queued via queue_input) into the guest RX queue (queue 0), advancing the used ring.

Descriptors are read directly from guest memory — the HV path drives the queue from QueueConfig rather than the internal VirtQueue. Returns true if at least one descriptor was filled, in which case the caller must raise an INT_VRING interrupt so the guest services the input.

§Errors

Returns an error if a queue address lies below the guest RAM base.

Trait Implementations§

Source§

impl Drop for VirtioConsole

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl VirtioDevice for VirtioConsole

Source§

fn device_id(&self) -> VirtioDeviceId

Returns the device type ID.
Source§

fn features(&self) -> u64

Returns the device features.
Source§

fn ack_features(&mut self, features: u64)

Acknowledges features from the driver.
Source§

fn read_config(&self, offset: u64, data: &mut [u8])

Reads from the device configuration space.
Source§

fn write_config(&mut self, offset: u64, data: &[u8])

Writes to the device configuration space.
Source§

fn activate(&mut self) -> Result<()>

Activates the device.
Source§

fn reset(&mut self)

Resets the device.
Source§

fn process_queue( &mut self, queue_idx: u16, memory: &mut [u8], queue_config: &QueueConfig, ) -> Result<Vec<(u16, u32)>>

Processes pending buffers in the specified queue. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more