oci_spec/runtime/
vm.rs

1use crate::error::OciSpecError;
2use derive_builder::Builder;
3use getset::{Getters, Setters};
4use serde::{Deserialize, Serialize};
5use std::path::PathBuf;
6
7#[derive(
8    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
9)]
10#[builder(
11    default,
12    pattern = "owned",
13    setter(into, strip_option),
14    build_fn(error = "OciSpecError")
15)]
16#[getset(get = "pub", set = "pub")]
17/// VM contains information for virtual-machine-based containers.
18pub struct VM {
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    /// Hypervisor specifies hypervisor-related configuration for
21    /// virtual-machine-based containers.
22    hypervisor: Option<VMHypervisor>,
23
24    /// Kernel specifies kernel-related configuration for
25    /// virtual-machine-based containers.
26    kernel: VMKernel,
27
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    /// Image specifies guest image related configuration for
30    /// virtual-machine-based containers.
31    image: Option<VMImage>,
32}
33
34#[derive(
35    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
36)]
37#[builder(
38    default,
39    pattern = "owned",
40    setter(into, strip_option),
41    build_fn(error = "OciSpecError")
42)]
43#[getset(get = "pub", set = "pub")]
44/// VMHypervisor contains information about the hypervisor to use for a
45/// virtual machine.
46pub struct VMHypervisor {
47    /// Path is the host path to the hypervisor used to manage the virtual
48    /// machine.
49    path: PathBuf,
50
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    /// Parameters specifies parameters to pass to the hypervisor.
53    parameters: Option<Vec<String>>,
54}
55
56#[derive(
57    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
58)]
59#[builder(
60    default,
61    pattern = "owned",
62    setter(into, strip_option),
63    build_fn(error = "OciSpecError")
64)]
65#[getset(get = "pub", set = "pub")]
66/// VMKernel contains information about the kernel to use for a virtual
67/// machine.
68pub struct VMKernel {
69    /// Path is the host path to the kernel used to boot the virtual
70    /// machine.
71    path: PathBuf,
72
73    #[serde(default, skip_serializing_if = "Option::is_none")]
74    /// Parameters specifies parameters to pass to the kernel.
75    parameters: Option<Vec<String>>,
76
77    #[serde(default, skip_serializing_if = "Option::is_none")]
78    /// InitRD is the host path to an initial ramdisk to be used by the
79    /// kernel.
80    initrd: Option<String>,
81}
82
83#[derive(
84    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
85)]
86#[builder(
87    default,
88    pattern = "owned",
89    setter(into, strip_option),
90    build_fn(error = "OciSpecError")
91)]
92#[getset(get = "pub", set = "pub")]
93/// VMImage contains information about the virtual machine root image.
94pub struct VMImage {
95    /// Path is the host path to the root image that the VM kernel would
96    /// boot into.
97    path: PathBuf,
98
99    /// Format is the root image format type (e.g. "qcow2", "raw", "vhd",
100    /// etc).
101    format: String,
102}