pub struct Process {
    started: bool,
    plugin_pid: pid_t,
    request_sockets: Vec<UnixDatagram>,
    objects: HashMap<u32, PluginObject>,
    shared_vcpu_state: Arc<RwLock<SharedVcpuState>>,
    per_vcpu_states: Vec<Arc<Mutex<PerVcpuState>>>,
    kill_evt: Event,
    vcpu_pipes: Vec<VcpuPipe>,
    request_buffer: Vec<u8>,
    response_buffer: Vec<u8>,
}
Expand description

Creates, owns, and handles messages from a plugin process.

A plugin process has control over a single VM and a fixed number of VCPUs via a set of pipes & unix domain socket connections and a protocol defined in protos::plugin. The plugin process is run in an unprivileged manner as a child process spawned via a path to a arbitrary executable.

Fields§

§started: bool§plugin_pid: pid_t§request_sockets: Vec<UnixDatagram>§objects: HashMap<u32, PluginObject>§shared_vcpu_state: Arc<RwLock<SharedVcpuState>>§per_vcpu_states: Vec<Arc<Mutex<PerVcpuState>>>§kill_evt: Event§vcpu_pipes: Vec<VcpuPipe>§request_buffer: Vec<u8>§response_buffer: Vec<u8>

Implementations§

Creates a new plugin process for the given number of vcpus and VM.

This will immediately spawn the plugin process and wait for the child to signal that it is ready to start. This call may block indefinitely.

Set the jail argument to spawn the plugin process within the preconfigured jail. Due to an API limitation in libminijail necessitating that this function set an environment variable, this function is not thread-safe.

Arguments:

  • cpu_count: number of vcpus
  • cmd: path to plugin executable
  • args: arguments to plugin executable
  • jail: jail to launch plugin in. If None plugin will just be spawned as a child
  • stderr: File to redirect stderr of plugin process to

Creates a VCPU plugin connection object, used by a VCPU run loop to communicate with the plugin process.

While each invocation of create_vcpu with the given cpu_id will return a unique PluginVcpu object, the underlying resources are shared by each PluginVcpu resulting from the same cpu_id.

Returns if the plugin process indicated the VM was ready to start.

Returns the process ID of the plugin process.

Returns a slice of each socket that should be polled.

If any socket in this slice becomes readable, handle_socket should be called with the index of that socket. If any socket becomes closed, its index should be passed to drop_sockets.

Drops the each socket identified by its index in the slice returned by sockets.

The given socket_idxs slice will be modified in an arbitrary way for efficient removal of the sockets from internal data structures.

Gently requests that the plugin process exit cleanly, and ends handling of all VCPU connections.

The plugin process can ignore the given signal, and so some timeout should be used before forcefully terminating the process.

Any blocked VCPU connections will get interrupted so that the VCPU threads can exit cleanly. Any subsequent attempt to use the VCPU connections will fail.

Waits without blocking for the plugin process to exit and returns the status.

Handles a request on a readable socket identified by its index in the slice returned by sockets.

The vm is used to service request that affect the VM. The vcpu_handles slice is used to interrupt a VCPU thread currently running in the VM if the socket request it.

Trait Implementations§

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.