Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 29 additions & 37 deletions nvx-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -923,18 +923,12 @@ host namespace policy or skips the identity assertions.

### `nvx::host::artifacts`

`Artifacts` (also `nvx::Artifacts`): the OpenVMM executable, guest kernel, and
Alpine initramfs, from a release, a repository checkout, the environment, or a
directory next to the executable. Artifacts located in a release or checkout
keep its `ArtifactDir`, and `Artifacts::runtime_identity` reads their
`RuntimeIdentity` from its install metadata; artifacts named by path have none.

`ArtifactDir` and `Guest`: every artifact of the guests that `nvx.py` runs, the
OpenVMM executable, the kernel, the Alpine, Ubuntu, and Azure Linux initramfs
images and their package manifests, and the Ubuntu distro layer and its
manifest, in a checkout's `build/` and `openvmm/target/release/` or a release's
`guest/` and `bin/`, checked in the order and with the messages of `nvx.py`.
`ArtifactPaths` lists them all and serializes as JSON.
`guest/` and `bin/`, checked with the messages of `nvx.py`. `ArtifactPaths`
lists them all and serializes as JSON.

`ArtifactDir::runtime_identity` reads the `RuntimeIdentity` of the OpenVMM
executable, kernel, and Alpine initramfs from the install metadata, a release's
Expand Down Expand Up @@ -1107,20 +1101,13 @@ distro layer, the targets of `nvx-rs run` shares, and the managed exec
environment; see [Sandbox input contract](#sandbox-input-contract).

`distro`: the `DistroBinding` of a distro layer, an EROFS layer or a GPT disk,
which explicit verification makes or a staging caller imports, and its check
from metadata alone, which returns the layer open; see
[Distro bindings](#distro-bindings).
which explicit verification makes, and its check from metadata alone, which
returns the layer open; see [Distro bindings](#distro-bindings).

`scratch`: the `ScratchBinding` of a scratch image, its identity, kind, and
length, and its check from metadata alone, which claims the image for one
sandbox at a time and returns it open.

`CheckedDistro::geometry` and `CheckedScratch::geometry` read, through the
checked files, the `BlockGeometry` that OpenVMM presents for them: their length,
a nonzero multiple of 512 bytes, logical blocks of 512 bytes, and physical
blocks of the I/O block size of their filesystem on Linux, and of 4096 bytes on
Windows.

### `nvx::guest`

The programs that run in Linux guests; see [Guest binaries](#guest-binaries).
Expand Down Expand Up @@ -1695,17 +1682,15 @@ manifest, or to the manifest's absence, to the revision and result of the
distro policy, `DISTRO_POLICY_REVISION`, and to the layer's format and the
identity that the guest expects of it: the UUID of an EROFS layer, or the disk
GUID of a GPT disk, which `SandboxLayer::gpt` names. It comes from explicit
verification, or from `DistroBinding::import`, which a staging caller that
verified the layer itself calls to bind it without hashing it again. `check`
fails for a binding of another version, layer, format, or policy revision, a verdict
that rejects the layer, a layer whose identity, kind, length, or times changed,
and a manifest that appeared, disappeared, or changed. A binding of a layer
without a manifest holds only while nothing is at the manifest's path: unlike
verification, which finds a manifest as `Path.exists` does, `check` and
`import` refuse a path whose lookup fails for another reason than a missing
file. A missing or stale binding fails: no runtime operation registers,
verifies, or hashes a layer on its own. Hashing belongs where layers are built,
installed, or staged, and to diagnostics.
verification. `check` fails for a binding of another version, layer, format,
or policy revision, a verdict that rejects the layer, a layer whose identity,
kind, length, or times changed, and a manifest that appeared, disappeared, or
changed. A binding of a layer without a manifest holds only while nothing is at
the manifest's path: unlike verification, which finds a manifest as
`Path.exists` does, `check` refuses a path whose lookup fails for another
reason than a missing file. A missing or stale binding fails: no runtime
operation registers, verifies, or hashes a layer on its own. Hashing belongs
where layers are built, installed, or staged, and to diagnostics.

On Linux, a seal holds `st_dev`, `st_ino`, the file type, `st_size`, and
`st_mtime` and `st_ctime` with their nanoseconds; on Windows, the volume serial
Expand Down Expand Up @@ -2542,21 +2527,28 @@ restores one, and finds one again after its caller restarts.
use std::path::Path;
use std::time::{Duration, Instant};

use nvx::Hypervisor;
use nvx::activation::{MachineIdMode, View};
use nvx::host::config::{Boot, ConsoleAttachment, RootConfig, VmConfig};
use nvx::host::runtime::{LaunchOptions, Runtime};
use nvx::host::runtime::{ArtifactIdentity, LaunchOptions, Runtime, RuntimeIdentity};
use nvx::host::vm::{self, VmDir};
use nvx::{Artifacts, Hypervisor};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Locates OpenVMM, the guest kernel, and the Alpine initramfs, with the identity that the
// install metadata of their release or checkout gives them.
let artifacts = Artifacts::discover()?;
// The caller locates OpenVMM, the guest kernel, and the Alpine initramfs, and identifies each
// by the SHA-256 digest that its install metadata records, such as the `SHA256SUMS` of an NVX
// release: here, from the command line.
let arguments: Vec<String> = std::env::args().skip(1).collect();
let [openvmm, kernel, initramfs, openvmm_sha256, kernel_sha256, initramfs_sha256] =
<[String; 6]>::try_from(arguments).map_err(|_| "expected three paths and three digests")?;
let runtime = Runtime {
identity: artifacts.runtime_identity()?,
openvmm: artifacts.openvmm,
kernel: artifacts.kernel,
initramfs: artifacts.initrd,
identity: RuntimeIdentity::new(
ArtifactIdentity::sha256(&openvmm_sha256)?,
ArtifactIdentity::sha256(&kernel_sha256)?,
ArtifactIdentity::sha256(&initramfs_sha256)?,
),
openvmm: openvmm.into(),
kernel: kernel.into(),
initramfs: initramfs.into(),
hypervisor: Hypervisor::from_env_or_default()?,
cpu_profile: None,
windows_breakaway: false,
Expand Down
58 changes: 0 additions & 58 deletions nvx-rs/public-api/linux.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
mod nvx
struct nvx::Artifacts
const nvx::Artifacts::BESIDE_EXE_DIR
const nvx::Artifacts::ENV_DIR
const nvx::Artifacts::ENV_INITRD
const nvx::Artifacts::ENV_KERNEL
const nvx::Artifacts::ENV_OPENVMM
method nvx::Artifacts::artifact_dir
method nvx::Artifacts::discover
method nvx::Artifacts::from_dir
method nvx::Artifacts::from_release_dir
method nvx::Artifacts::from_repo_layout
field nvx::Artifacts::initrd
field nvx::Artifacts::kernel
method nvx::Artifacts::new
field nvx::Artifacts::openvmm
method nvx::Artifacts::probe
method nvx::Artifacts::runtime_identity
struct nvx::Error
method nvx::Error::code
method nvx::Error::exited
Expand Down Expand Up @@ -1624,33 +1607,14 @@ method nvx::host::artifacts::ArtifactDir::release
method nvx::host::artifacts::ArtifactDir::repository
method nvx::host::artifacts::ArtifactDir::require_initramfs
method nvx::host::artifacts::ArtifactDir::require_kernel
method nvx::host::artifacts::ArtifactDir::require_openvmm
method nvx::host::artifacts::ArtifactDir::root
method nvx::host::artifacts::ArtifactDir::runtime_identity
method nvx::host::artifacts::ArtifactDir::sandbox_artifacts
struct nvx::host::artifacts::ArtifactPaths
field nvx::host::artifacts::ArtifactPaths::guests
field nvx::host::artifacts::ArtifactPaths::kernel
field nvx::host::artifacts::ArtifactPaths::layout
field nvx::host::artifacts::ArtifactPaths::openvmm
field nvx::host::artifacts::ArtifactPaths::root
struct nvx::host::artifacts::Artifacts
const nvx::host::artifacts::Artifacts::BESIDE_EXE_DIR
const nvx::host::artifacts::Artifacts::ENV_DIR
const nvx::host::artifacts::Artifacts::ENV_INITRD
const nvx::host::artifacts::Artifacts::ENV_KERNEL
const nvx::host::artifacts::Artifacts::ENV_OPENVMM
method nvx::host::artifacts::Artifacts::artifact_dir
method nvx::host::artifacts::Artifacts::discover
method nvx::host::artifacts::Artifacts::from_dir
method nvx::host::artifacts::Artifacts::from_release_dir
method nvx::host::artifacts::Artifacts::from_repo_layout
field nvx::host::artifacts::Artifacts::initrd
field nvx::host::artifacts::Artifacts::kernel
method nvx::host::artifacts::Artifacts::new
field nvx::host::artifacts::Artifacts::openvmm
method nvx::host::artifacts::Artifacts::probe
method nvx::host::artifacts::Artifacts::runtime_identity
const nvx::host::artifacts::CHECKSUMS_NAME
const nvx::host::artifacts::DISTRO_MANIFEST_SUFFIX
enum nvx::host::artifacts::Guest
Expand All @@ -1662,7 +1626,6 @@ method nvx::host::artifacts::Guest::default_memory_mib
method nvx::host::artifacts::Guest::distribution
method nvx::host::artifacts::Guest::distro_layer_name
method nvx::host::artifacts::Guest::distro_manifest_name
method nvx::host::artifacts::Guest::from_name
method nvx::host::artifacts::Guest::initramfs_name
method nvx::host::artifacts::Guest::name
method nvx::host::artifacts::Guest::package_manifest_name
Expand All @@ -1683,7 +1646,6 @@ const nvx::host::artifacts::MANIFEST_NAME
const nvx::host::artifacts::OPENVMM_PROVENANCE_NAME
const nvx::host::artifacts::PACKAGE_MANIFEST_SUFFIX
fn nvx::host::artifacts::absolute
fn nvx::host::artifacts::check_manifest
fn nvx::host::artifacts::openvmm_executable
mod nvx::host::cli (hidden)
fn nvx::host::cli::main (hidden)
Expand Down Expand Up @@ -2163,19 +2125,9 @@ method nvx::host::sandbox::SandboxMount::with_kind
mod nvx::host::sandbox::distro
const nvx::host::sandbox::distro::BINDING_VERSION
struct nvx::host::sandbox::distro::CheckedDistro
method nvx::host::sandbox::distro::CheckedDistro::file
method nvx::host::sandbox::distro::CheckedDistro::geometry
method nvx::host::sandbox::distro::CheckedDistro::into_file
method nvx::host::sandbox::distro::CheckedDistro::path
const nvx::host::sandbox::distro::DISTRO_POLICY_REVISION
struct nvx::host::sandbox::distro::DistroBinding
method nvx::host::sandbox::distro::DistroBinding::check
method nvx::host::sandbox::distro::DistroBinding::format
method nvx::host::sandbox::distro::DistroBinding::identity
method nvx::host::sandbox::distro::DistroBinding::image
method nvx::host::sandbox::distro::DistroBinding::import
method nvx::host::sandbox::distro::DistroBinding::manifest
method nvx::host::sandbox::distro::DistroBinding::policy
method nvx::host::sandbox::distro::DistroBinding::verify
enum nvx::host::sandbox::distro::DistroFormat
variant nvx::host::sandbox::distro::DistroFormat::Erofs
Expand Down Expand Up @@ -2305,18 +2257,10 @@ mod nvx::host::sandbox::scratch
const nvx::host::sandbox::scratch::CLAIM_RELEASE_WAIT
struct nvx::host::sandbox::scratch::CheckedScratch
method nvx::host::sandbox::scratch::CheckedScratch::file
method nvx::host::sandbox::scratch::CheckedScratch::geometry
method nvx::host::sandbox::scratch::CheckedScratch::into_file
method nvx::host::sandbox::scratch::CheckedScratch::path
const nvx::host::sandbox::scratch::SCRATCH_BINDING_VERSION
struct nvx::host::sandbox::scratch::ScratchBinding
method nvx::host::sandbox::scratch::ScratchBinding::bind
method nvx::host::sandbox::scratch::ScratchBinding::check
method nvx::host::sandbox::scratch::ScratchBinding::device
method nvx::host::sandbox::scratch::ScratchBinding::file_id
method nvx::host::sandbox::scratch::ScratchBinding::kind
method nvx::host::sandbox::scratch::ScratchBinding::length
method nvx::host::sandbox::scratch::ScratchBinding::scheme
mod nvx::host::seal
enum nvx::host::seal::FileKind
variant nvx::host::seal::FileKind::Block
Expand All @@ -2327,12 +2271,10 @@ variant nvx::host::seal::FileKind::Other
variant nvx::host::seal::FileKind::Regular
variant nvx::host::seal::FileKind::Socket
struct nvx::host::seal::FileSeal
method nvx::host::seal::FileSeal::changed
method nvx::host::seal::FileSeal::device
method nvx::host::seal::FileSeal::file_id
method nvx::host::seal::FileSeal::kind
method nvx::host::seal::FileSeal::length
method nvx::host::seal::FileSeal::modified
method nvx::host::seal::FileSeal::of
method nvx::host::seal::FileSeal::scheme
const nvx::host::seal::SEAL_VERSION
Expand Down
58 changes: 0 additions & 58 deletions nvx-rs/public-api/windows.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
mod nvx
struct nvx::Artifacts
const nvx::Artifacts::BESIDE_EXE_DIR
const nvx::Artifacts::ENV_DIR
const nvx::Artifacts::ENV_INITRD
const nvx::Artifacts::ENV_KERNEL
const nvx::Artifacts::ENV_OPENVMM
method nvx::Artifacts::artifact_dir
method nvx::Artifacts::discover
method nvx::Artifacts::from_dir
method nvx::Artifacts::from_release_dir
method nvx::Artifacts::from_repo_layout
field nvx::Artifacts::initrd
field nvx::Artifacts::kernel
method nvx::Artifacts::new
field nvx::Artifacts::openvmm
method nvx::Artifacts::probe
method nvx::Artifacts::runtime_identity
struct nvx::Error
method nvx::Error::code
method nvx::Error::exited
Expand Down Expand Up @@ -352,33 +335,14 @@ method nvx::host::artifacts::ArtifactDir::release
method nvx::host::artifacts::ArtifactDir::repository
method nvx::host::artifacts::ArtifactDir::require_initramfs
method nvx::host::artifacts::ArtifactDir::require_kernel
method nvx::host::artifacts::ArtifactDir::require_openvmm
method nvx::host::artifacts::ArtifactDir::root
method nvx::host::artifacts::ArtifactDir::runtime_identity
method nvx::host::artifacts::ArtifactDir::sandbox_artifacts
struct nvx::host::artifacts::ArtifactPaths
field nvx::host::artifacts::ArtifactPaths::guests
field nvx::host::artifacts::ArtifactPaths::kernel
field nvx::host::artifacts::ArtifactPaths::layout
field nvx::host::artifacts::ArtifactPaths::openvmm
field nvx::host::artifacts::ArtifactPaths::root
struct nvx::host::artifacts::Artifacts
const nvx::host::artifacts::Artifacts::BESIDE_EXE_DIR
const nvx::host::artifacts::Artifacts::ENV_DIR
const nvx::host::artifacts::Artifacts::ENV_INITRD
const nvx::host::artifacts::Artifacts::ENV_KERNEL
const nvx::host::artifacts::Artifacts::ENV_OPENVMM
method nvx::host::artifacts::Artifacts::artifact_dir
method nvx::host::artifacts::Artifacts::discover
method nvx::host::artifacts::Artifacts::from_dir
method nvx::host::artifacts::Artifacts::from_release_dir
method nvx::host::artifacts::Artifacts::from_repo_layout
field nvx::host::artifacts::Artifacts::initrd
field nvx::host::artifacts::Artifacts::kernel
method nvx::host::artifacts::Artifacts::new
field nvx::host::artifacts::Artifacts::openvmm
method nvx::host::artifacts::Artifacts::probe
method nvx::host::artifacts::Artifacts::runtime_identity
const nvx::host::artifacts::CHECKSUMS_NAME
const nvx::host::artifacts::DISTRO_MANIFEST_SUFFIX
enum nvx::host::artifacts::Guest
Expand All @@ -390,7 +354,6 @@ method nvx::host::artifacts::Guest::default_memory_mib
method nvx::host::artifacts::Guest::distribution
method nvx::host::artifacts::Guest::distro_layer_name
method nvx::host::artifacts::Guest::distro_manifest_name
method nvx::host::artifacts::Guest::from_name
method nvx::host::artifacts::Guest::initramfs_name
method nvx::host::artifacts::Guest::name
method nvx::host::artifacts::Guest::package_manifest_name
Expand All @@ -411,7 +374,6 @@ const nvx::host::artifacts::MANIFEST_NAME
const nvx::host::artifacts::OPENVMM_PROVENANCE_NAME
const nvx::host::artifacts::PACKAGE_MANIFEST_SUFFIX
fn nvx::host::artifacts::absolute
fn nvx::host::artifacts::check_manifest
fn nvx::host::artifacts::openvmm_executable
mod nvx::host::cli (hidden)
fn nvx::host::cli::main (hidden)
Expand Down Expand Up @@ -891,19 +853,9 @@ method nvx::host::sandbox::SandboxMount::with_kind
mod nvx::host::sandbox::distro
const nvx::host::sandbox::distro::BINDING_VERSION
struct nvx::host::sandbox::distro::CheckedDistro
method nvx::host::sandbox::distro::CheckedDistro::file
method nvx::host::sandbox::distro::CheckedDistro::geometry
method nvx::host::sandbox::distro::CheckedDistro::into_file
method nvx::host::sandbox::distro::CheckedDistro::path
const nvx::host::sandbox::distro::DISTRO_POLICY_REVISION
struct nvx::host::sandbox::distro::DistroBinding
method nvx::host::sandbox::distro::DistroBinding::check
method nvx::host::sandbox::distro::DistroBinding::format
method nvx::host::sandbox::distro::DistroBinding::identity
method nvx::host::sandbox::distro::DistroBinding::image
method nvx::host::sandbox::distro::DistroBinding::import
method nvx::host::sandbox::distro::DistroBinding::manifest
method nvx::host::sandbox::distro::DistroBinding::policy
method nvx::host::sandbox::distro::DistroBinding::verify
enum nvx::host::sandbox::distro::DistroFormat
variant nvx::host::sandbox::distro::DistroFormat::Erofs
Expand Down Expand Up @@ -1032,19 +984,11 @@ fn nvx::host::sandbox::require_file
mod nvx::host::sandbox::scratch
const nvx::host::sandbox::scratch::CLAIM_RELEASE_WAIT
struct nvx::host::sandbox::scratch::CheckedScratch
method nvx::host::sandbox::scratch::CheckedScratch::file
method nvx::host::sandbox::scratch::CheckedScratch::geometry
method nvx::host::sandbox::scratch::CheckedScratch::into_file
method nvx::host::sandbox::scratch::CheckedScratch::path
const nvx::host::sandbox::scratch::SCRATCH_BINDING_VERSION
struct nvx::host::sandbox::scratch::ScratchBinding
method nvx::host::sandbox::scratch::ScratchBinding::bind
method nvx::host::sandbox::scratch::ScratchBinding::check
method nvx::host::sandbox::scratch::ScratchBinding::device
method nvx::host::sandbox::scratch::ScratchBinding::file_id
method nvx::host::sandbox::scratch::ScratchBinding::kind
method nvx::host::sandbox::scratch::ScratchBinding::length
method nvx::host::sandbox::scratch::ScratchBinding::scheme
mod nvx::host::seal
enum nvx::host::seal::FileKind
variant nvx::host::seal::FileKind::Block
Expand All @@ -1055,12 +999,10 @@ variant nvx::host::seal::FileKind::Other
variant nvx::host::seal::FileKind::Regular
variant nvx::host::seal::FileKind::Socket
struct nvx::host::seal::FileSeal
method nvx::host::seal::FileSeal::changed
method nvx::host::seal::FileSeal::device
method nvx::host::seal::FileSeal::file_id
method nvx::host::seal::FileSeal::kind
method nvx::host::seal::FileSeal::length
method nvx::host::seal::FileSeal::modified
method nvx::host::seal::FileSeal::of
method nvx::host::seal::FileSeal::scheme
const nvx::host::seal::SEAL_VERSION
Expand Down
Loading
Loading