pub trait GuestEngine: Send + Sync {
Show 14 methods
// Required methods
fn name(&self) -> &'static str;
fn boot(&self, spec: &GuestSpec) -> GuestOutcome;
// Provided methods
fn power_on(&self, _machine: &Machine) -> Result<(), String> { ... }
fn power_off(&self, _server: &str, _hard: bool) { ... }
fn running(&self, _server: &str) -> Option<bool> { ... }
fn eject(&self, _server: &str) { ... }
fn console(&self, _server: &str) -> Option<(String, u16)> { ... }
fn load(&self, _server: &str, _storage: &str) { ... }
fn resize_disk(&self, _storage: &str, _size_gib: u64) -> Result<(), String> { ... }
fn store_medium(&self, _storage: &str, _bytes: &[u8]) -> Result<(), String> { ... }
fn forget_server(&self, _server: &str) { ... }
fn forget_storage(&self, _storage: &str) { ... }
fn forget_all(&self) { ... }
fn evidence(&self, _server: &str) -> Option<Value> { ... }
}Expand description
The seam. boot is the one-shot question a storm asks; the lifecycle
methods below are what the estate calls when an API request changes a
server, so that behind the JSON there is a machine.
Every lifecycle method has a default that does NOTHING, and
running defaults to None (“this engine has no
machine to ask”), which is how the estate knows to keep its own state
machine. So the default engine is exactly the mock as it was, and
cargo test -p mock-upcloud needs no hypervisor.
All calls are made with the estate’s lock held and must return promptly: a soft stop SENDS the ACPI event and returns, it does not wait for the guest.
Required Methods§
Provided Methods§
Sourcefn power_on(&self, _machine: &Machine) -> Result<(), String>
fn power_on(&self, _machine: &Machine) -> Result<(), String>
Power the machine on: create any disk that does not exist yet, sized
from its storage record, grow any that is smaller, and boot. An Err is
a refusal by name, and the estate reports the server stopped — a
server whose machine never started must not read started.
Sourcefn power_off(&self, _server: &str, _hard: bool)
fn power_off(&self, _server: &str, _hard: bool)
hard: kill it now. Soft: press the ACPI power button and return.
Sourcefn running(&self, _server: &str) -> Option<bool>
fn running(&self, _server: &str) -> Option<bool>
Some(true) a machine is running for this server, Some(false) one was
started and is gone (it powered itself off, or died), None this engine
has never run one — the estate’s own state machine then stands.
Sourcefn console(&self, _server: &str) -> Option<(String, u16)>
fn console(&self, _server: &str) -> Option<(String, u16)>
Where the server’s console REALLY listens — a loopback host and port
for a real guest’s VNC. None (the default) leaves the estate’s
RFC 2606 <zone>.vnc.mock.invalid.
Sourcefn load(&self, _server: &str, _storage: &str)
fn load(&self, _server: &str, _storage: &str)
Put the medium of storage into the server’s tray (cdrom/load). A
running machine gets it live; a stopped one reads it at the next
power-on either way, because Machine::medium is built from the
device row.
Sourcefn resize_disk(&self, _storage: &str, _size_gib: u64) -> Result<(), String>
fn resize_disk(&self, _storage: &str, _size_gib: u64) -> Result<(), String>
A storage’s size record grew. The engine grows the disk only while no running machine has it open, and otherwise at the next power-on.
Sourcefn store_medium(&self, _storage: &str, _bytes: &[u8]) -> Result<(), String>
fn store_medium(&self, _storage: &str, _bytes: &[u8]) -> Result<(), String>
The bytes an upload session received, kept as that storage’s medium.
Sourcefn forget_server(&self, _server: &str)
fn forget_server(&self, _server: &str)
The server is being deleted: kill its machine and drop its records.
Sourcefn forget_storage(&self, _storage: &str)
fn forget_storage(&self, _storage: &str)
The storage is gone from the account: delete its disk and medium.
Sourcefn forget_all(&self)
fn forget_all(&self)
The whole estate is being replaced (/mock/seed): every machine and
every disk goes with it, because nothing can refer to them any more.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".