pub struct Session { /* private fields */ }Expand description
A booted VM and everything that must outlive its dispatch queue.
Implementations§
Source§impl Session
impl Session
Sourcepub fn start(config: &Config) -> Result<Session, Error>
pub fn start(config: &Config) -> Result<Session, Error>
Build the VZ config, create the VM on its own serial queue, install
the delegate / vsock listener / timeout, and call start. Returns
once the VM has been asked to start; the boot proceeds on the VM’s
queue (a libdispatch worker thread) and the terminal event is observed
via Session::wait.
Snapshot configs are rejected here — those still go through
[crate::vz::snapshot] from crate::run.
Sourcepub fn vsock_port(&self) -> Option<u32>
pub fn vsock_port(&self) -> Option<u32>
The resolved vsock host port (None if vsock is disabled). Stable
for the session’s lifetime — read it for banners/logging instead of
re-resolving, which would re-randomize an Auto port.
Sourcepub fn wait(&self) -> SessionEnd
pub fn wait(&self) -> SessionEnd
Block until the session ends, then return how it ended. Safe to call after the end was already recorded (returns immediately). Does not pump any run loop — the VM runs on its own dispatch queue.
Sourcepub fn stop(&self)
pub fn stop(&self)
Request a graceful force-stop of the guest. The stop completes on the
VM’s queue and records SessionEnd::Stopped, unblocking a concurrent
Session::wait. No-op if the session has already ended.
Sourcepub fn request(
&self,
action: &Action,
) -> Result<(ResponseHeader, Vec<u8>), Error>
pub fn request( &self, action: &Action, ) -> Result<(ResponseHeader, Vec<u8>), Error>
Send a desktop Action to the in-guest agent and block for its
response (a ResponseHeader plus an optional binary payload, e.g.
a PNG for Action::Screenshot). See SessionClient::request.
Sourcepub fn client(&self) -> SessionClient
pub fn client(&self) -> SessionClient
Extract a Send client for issuing desktop requests from another
thread (the daemon hands these to its async request handlers). Shares
the agent connection with the Session; the fd is closed once the
last holder drops.
Sourcepub fn stop_handle(&self) -> StopHandle
pub fn stop_handle(&self) -> StopHandle
Extract a Send handle for stopping the session from another thread.
Stopping unblocks the thread that owns the Session in
Session::wait, which then tears the VM down by dropping it.