@@ -63,29 +63,20 @@ pub enum ResourcesError {
63
63
64
64
/// Used for configuring a vmm from one single json passed to the Firecracker process.
65
65
#[ derive( Debug , Default , PartialEq , Eq , Deserialize , Serialize ) ]
66
+ #[ serde( rename_all = "kebab-case" ) ]
66
67
pub struct VmmConfig {
67
- #[ serde( rename = "balloon" ) ]
68
- balloon_device : Option < BalloonDeviceConfig > ,
69
- #[ serde( rename = "drives" ) ]
70
- block_devices : Vec < BlockDeviceConfig > ,
71
- #[ serde( rename = "boot-source" ) ]
68
+ balloon : Option < BalloonDeviceConfig > ,
69
+ drives : Vec < BlockDeviceConfig > ,
72
70
boot_source : BootSourceConfig ,
73
- #[ serde( rename = "cpu-config" ) ]
74
71
cpu_config : Option < PathBuf > ,
75
- #[ serde( rename = "logger" ) ]
76
72
logger : Option < crate :: logger:: LoggerConfig > ,
77
- #[ serde( rename = "machine-config" ) ]
78
73
machine_config : Option < MachineConfig > ,
79
- #[ serde( rename = "metrics" ) ]
80
74
metrics : Option < MetricsConfig > ,
81
- #[ serde( rename = "mmds-config" ) ]
82
75
mmds_config : Option < MmdsConfig > ,
83
- #[ serde( rename = "network-interfaces" , default ) ]
84
- net_devices : Vec < NetworkInterfaceConfig > ,
85
- #[ serde( rename = "vsock" ) ]
86
- vsock_device : Option < VsockDeviceConfig > ,
87
- #[ serde( rename = "entropy" ) ]
88
- entropy_device : Option < EntropyDeviceConfig > ,
76
+ #[ serde( default ) ]
77
+ network_interfaces : Vec < NetworkInterfaceConfig > ,
78
+ vsock : Option < VsockDeviceConfig > ,
79
+ entropy : Option < EntropyDeviceConfig > ,
89
80
}
90
81
91
82
/// A data structure that encapsulates the device configurations
@@ -152,19 +143,19 @@ impl VmResources {
152
143
153
144
resources. build_boot_source ( vmm_config. boot_source ) ?;
154
145
155
- for drive_config in vmm_config. block_devices . into_iter ( ) {
146
+ for drive_config in vmm_config. drives . into_iter ( ) {
156
147
resources. set_block_device ( drive_config) ?;
157
148
}
158
149
159
- for net_config in vmm_config. net_devices . into_iter ( ) {
150
+ for net_config in vmm_config. network_interfaces . into_iter ( ) {
160
151
resources. build_net_device ( net_config) ?;
161
152
}
162
153
163
- if let Some ( vsock_config) = vmm_config. vsock_device {
154
+ if let Some ( vsock_config) = vmm_config. vsock {
164
155
resources. set_vsock_device ( vsock_config) ?;
165
156
}
166
157
167
- if let Some ( balloon_config) = vmm_config. balloon_device {
158
+ if let Some ( balloon_config) = vmm_config. balloon {
168
159
resources. set_balloon_device ( balloon_config) ?;
169
160
}
170
161
@@ -180,7 +171,7 @@ impl VmResources {
180
171
resources. set_mmds_config ( mmds_config, & instance_info. id ) ?;
181
172
}
182
173
183
- if let Some ( entropy_device_config) = vmm_config. entropy_device {
174
+ if let Some ( entropy_device_config) = vmm_config. entropy {
184
175
resources. build_entropy_device ( entropy_device_config) ?;
185
176
}
186
177
@@ -484,17 +475,17 @@ impl VmResources {
484
475
impl From < & VmResources > for VmmConfig {
485
476
fn from ( resources : & VmResources ) -> Self {
486
477
VmmConfig {
487
- balloon_device : resources. balloon . get_config ( ) . ok ( ) ,
488
- block_devices : resources. block . configs ( ) ,
478
+ balloon : resources. balloon . get_config ( ) . ok ( ) ,
479
+ drives : resources. block . configs ( ) ,
489
480
boot_source : resources. boot_source . config . clone ( ) ,
490
481
cpu_config : None ,
491
482
logger : None ,
492
483
machine_config : Some ( resources. machine_config . clone ( ) ) ,
493
484
metrics : None ,
494
485
mmds_config : resources. mmds_config ( ) ,
495
- net_devices : resources. net_builder . configs ( ) ,
496
- vsock_device : resources. vsock . config ( ) ,
497
- entropy_device : resources. entropy . config ( ) ,
486
+ network_interfaces : resources. net_builder . configs ( ) ,
487
+ vsock : resources. vsock . config ( ) ,
488
+ entropy : resources. entropy . config ( ) ,
498
489
}
499
490
}
500
491
}
0 commit comments