Skip to main content

openvmm_defs/
worker.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Mesh worker definitions for the VM worker.
5
6use crate::config::Config;
7use crate::rpc::VmRpc;
8use hypervisor_resources::HypervisorKind;
9use mesh::MeshPayload;
10use mesh::payload::message::ProtobufMessage;
11use mesh_worker::WorkerId;
12use vm_resource::Resource;
13use vmm_core_defs::HaltReason;
14
15/// File descriptor (Unix) or handle (Windows) for file-backed guest RAM.
16#[cfg(unix)]
17pub type SharedMemoryFd = std::os::fd::OwnedFd;
18/// File descriptor (Unix) or handle (Windows) for file-backed guest RAM.
19#[cfg(windows)]
20pub type SharedMemoryFd = std::os::windows::io::OwnedHandle;
21
22pub const VM_WORKER: WorkerId<VmWorkerParameters> = WorkerId::new("VmWorker");
23
24/// Launch parameters for the VM worker.
25#[derive(MeshPayload)]
26pub struct VmWorkerParameters {
27    /// The hypervisor to use.
28    pub hypervisor: Resource<HypervisorKind>,
29    /// The initial configuration.
30    pub cfg: Config,
31    /// The saved state.
32    pub saved_state: Option<ProtobufMessage>,
33    /// File-backed guest RAM handle. When set, guest memory uses this
34    /// fd/handle instead of allocating anonymous memory.
35    pub shared_memory: Option<SharedMemoryFd>,
36    /// The VM RPC channel.
37    pub rpc: mesh::Receiver<VmRpc>,
38    /// The notification channel.
39    pub notify: mesh::Sender<HaltReason>,
40}