@@ -63,29 +63,20 @@ pub enum ResourcesError {
6363
6464/// Used for configuring a vmm from one single json passed to the Firecracker process.
6565#[ derive( Debug , Default , PartialEq , Eq , Deserialize , Serialize ) ]
66+ #[ serde( rename_all = "kebab-case" ) ]
6667pub 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 > ,
7270 boot_source : BootSourceConfig ,
73- #[ serde( rename = "cpu-config" ) ]
7471 cpu_config : Option < PathBuf > ,
75- #[ serde( rename = "logger" ) ]
7672 logger : Option < crate :: logger:: LoggerConfig > ,
77- #[ serde( rename = "machine-config" ) ]
7873 machine_config : Option < MachineConfig > ,
79- #[ serde( rename = "metrics" ) ]
8074 metrics : Option < MetricsConfig > ,
81- #[ serde( rename = "mmds-config" ) ]
8275 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 > ,
8980}
9081
9182/// A data structure that encapsulates the device configurations
@@ -152,19 +143,19 @@ impl VmResources {
152143
153144 resources. build_boot_source ( vmm_config. boot_source ) ?;
154145
155- for drive_config in vmm_config. block_devices . into_iter ( ) {
146+ for drive_config in vmm_config. drives . into_iter ( ) {
156147 resources. set_block_device ( drive_config) ?;
157148 }
158149
159- for net_config in vmm_config. net_devices . into_iter ( ) {
150+ for net_config in vmm_config. network_interfaces . into_iter ( ) {
160151 resources. build_net_device ( net_config) ?;
161152 }
162153
163- if let Some ( vsock_config) = vmm_config. vsock_device {
154+ if let Some ( vsock_config) = vmm_config. vsock {
164155 resources. set_vsock_device ( vsock_config) ?;
165156 }
166157
167- if let Some ( balloon_config) = vmm_config. balloon_device {
158+ if let Some ( balloon_config) = vmm_config. balloon {
168159 resources. set_balloon_device ( balloon_config) ?;
169160 }
170161
@@ -180,7 +171,7 @@ impl VmResources {
180171 resources. set_mmds_config ( mmds_config, & instance_info. id ) ?;
181172 }
182173
183- if let Some ( entropy_device_config) = vmm_config. entropy_device {
174+ if let Some ( entropy_device_config) = vmm_config. entropy {
184175 resources. build_entropy_device ( entropy_device_config) ?;
185176 }
186177
@@ -484,17 +475,17 @@ impl VmResources {
484475impl From < & VmResources > for VmmConfig {
485476 fn from ( resources : & VmResources ) -> Self {
486477 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 ( ) ,
489480 boot_source : resources. boot_source . config . clone ( ) ,
490481 cpu_config : None ,
491482 logger : None ,
492483 machine_config : Some ( resources. machine_config . clone ( ) ) ,
493484 metrics : None ,
494485 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 ( ) ,
498489 }
499490 }
500491}
0 commit comments