Skip to main content

ConsoleBuilder

Struct ConsoleBuilder 

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

Builder for console/output configuration.

§Example

VmBuilder::new()
    .console(|c| c.output("/tmp/vm.log"));

With the gpu and snd features:

VmBuilder::new()
    .console(|c| {
        c.output("/tmp/vm.log")
            .sound(true)
            .gpu_virgl_flags(0x1)
            .gpu_shm_size(1 << 28)
    });

Implementations§

Source§

impl ConsoleBuilder

Source

pub fn new() -> Self

Create a new console builder.

Source

pub fn output(self, path: impl AsRef<Path>) -> Self

Set the path to send console output.

Source

pub fn port(self, name: &str, input_fd: RawFd, output_fd: RawFd) -> Self

Add a bidirectional I/O port to the console device.

Creates a named port accessible in the guest via /sys/class/virtio-ports/<name>. The host reads from input_fd and writes to output_fd. Pass the same FD for both when using a bidirectional socket.

Source

pub fn port_tty(self, name: &str, tty_fd: RawFd) -> Self

Add a TTY port to the console device.

Creates a named port accessible in the guest via /sys/class/virtio-ports/<name>. The tty_fd must be a valid terminal file descriptor. Terminal raw mode is configured automatically.

Source

pub fn disable_implicit(self) -> Self

Disable the implicit console device.

By default libkrun creates an implicit console that reads from STDIN_FILENO. Call this to suppress that console when using only explicit ports.

Source

pub fn custom(self, name: &str, backend: Box<dyn ConsolePortBackend>) -> Self

Add a custom console port backend.

The backend provides bidirectional byte I/O without file descriptors on the data path, matching the pattern of NetBuilder::custom() and FsBuilder::custom().

§Example
VmBuilder::new()
    .console(|c| c.custom("agent", Box::new(my_backend)))

Trait Implementations§

Source§

impl Default for ConsoleBuilder

Source§

fn default() -> ConsoleBuilder

Returns the “default value” for a type. 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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V