1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use crate::error::OciSpecError;
use derive_builder::Builder;
use getset::{Getters, Setters};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(
    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
    default,
    pattern = "owned",
    setter(into, strip_option),
    build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// VM contains information for virtual-machine-based containers.
pub struct VM {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    /// Hypervisor specifies hypervisor-related configuration for
    /// virtual-machine-based containers.
    hypervisor: Option<VMHypervisor>,

    /// Kernel specifies kernel-related configuration for
    /// virtual-machine-based containers.
    kernel: VMKernel,

    #[serde(default, skip_serializing_if = "Option::is_none")]
    /// Image specifies guest image related configuration for
    /// virtual-machine-based containers.
    image: Option<VMImage>,
}

#[derive(
    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
    default,
    pattern = "owned",
    setter(into, strip_option),
    build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// VMHypervisor contains information about the hypervisor to use for a
/// virtual machine.
pub struct VMHypervisor {
    /// Path is the host path to the hypervisor used to manage the virtual
    /// machine.
    path: PathBuf,

    #[serde(default, skip_serializing_if = "Option::is_none")]
    /// Parameters specifies parameters to pass to the hypervisor.
    parameters: Option<Vec<String>>,
}

#[derive(
    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
    default,
    pattern = "owned",
    setter(into, strip_option),
    build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// VMKernel contains information about the kernel to use for a virtual
/// machine.
pub struct VMKernel {
    /// Path is the host path to the kernel used to boot the virtual
    /// machine.
    path: PathBuf,

    #[serde(default, skip_serializing_if = "Option::is_none")]
    /// Parameters specifies parameters to pass to the kernel.
    parameters: Option<Vec<String>>,

    #[serde(default, skip_serializing_if = "Option::is_none")]
    /// InitRD is the host path to an initial ramdisk to be used by the
    /// kernel.
    initrd: Option<String>,
}

#[derive(
    Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
    default,
    pattern = "owned",
    setter(into, strip_option),
    build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// VMImage contains information about the virtual machine root image.
pub struct VMImage {
    /// Path is the host path to the root image that the VM kernel would
    /// boot into.
    path: PathBuf,

    /// Format is the root image format type (e.g. "qcow2", "raw", "vhd",
    /// etc).
    format: String,
}