@@ -84,7 +84,7 @@ impl TryFrom<&Request> for ParsedRequest {
8484 ( Method :: Get , "balloon" , None ) => parse_get_balloon ( path_tokens) ,
8585 ( Method :: Get , "version" , None ) => parse_get_version ( ) ,
8686 ( Method :: Get , "vm" , None ) if path_tokens. next ( ) == Some ( "config" ) => {
87- Ok ( ParsedRequest :: new_sync ( VmmAction :: GetFullVmConfig ) )
87+ Ok ( ParsedRequest :: new_sync ( VmmAction :: GetFullVmSpec ) )
8888 }
8989 ( Method :: Get , "machine-config" , None ) => parse_get_machine_config ( ) ,
9090 ( Method :: Get , "mmds" , None ) => parse_get_mmds ( ) ,
@@ -179,12 +179,12 @@ impl ParsedRequest {
179179 info ! ( "The request was executed successfully. Status code: 204 No Content." ) ;
180180 Response :: new ( Version :: Http11 , StatusCode :: NoContent )
181181 }
182- VmmData :: MachineConfiguration ( machine_config ) => {
183- Self :: success_response_with_data ( machine_config )
182+ VmmData :: MachineSpec ( machine_spec ) => {
183+ Self :: success_response_with_data ( machine_spec )
184184 }
185185 VmmData :: MmdsValue ( value) => Self :: success_response_with_mmds_value ( value) ,
186- VmmData :: BalloonConfig ( balloon_config ) => {
187- Self :: success_response_with_data ( balloon_config )
186+ VmmData :: BalloonSpec ( balloon_spec ) => {
187+ Self :: success_response_with_data ( balloon_spec )
188188 }
189189 VmmData :: BalloonStats ( stats) => Self :: success_response_with_data ( stats) ,
190190 VmmData :: VirtioMemStatus ( data) => Self :: success_response_with_data ( data) ,
@@ -195,7 +195,7 @@ impl ParsedRequest {
195195 VmmData :: VmmVersion ( version) => Self :: success_response_with_data (
196196 & serde_json:: json!( { "firecracker_version" : version. as_str( ) } ) ,
197197 ) ,
198- VmmData :: FullVmConfig ( config ) => Self :: success_response_with_data ( config ) ,
198+ VmmData :: FullVmSpec ( vmm_spec ) => Self :: success_response_with_data ( vmm_spec ) ,
199199 } ,
200200 Err ( vmm_action_error) => {
201201 let mut response = match vmm_action_error {
@@ -223,8 +223,19 @@ impl ParsedRequest {
223223 }
224224
225225 /// Helper function to avoid boiler-plate code.
226- pub ( crate ) fn new_sync ( vmm_action : VmmAction ) -> ParsedRequest {
227- ParsedRequest :: new ( RequestAction :: Sync ( Box :: new ( vmm_action) ) )
226+ pub ( crate ) fn new_sync < T > ( vmm_action : T ) -> ParsedRequest
227+ where
228+ T : Into < VmmAction > ,
229+ {
230+ ParsedRequest :: new ( RequestAction :: Sync ( Box :: new ( vmm_action. into ( ) ) ) )
231+ }
232+
233+ pub ( crate ) fn new_stateless < F , A > ( entrypoint : F , args : A ) -> ParsedRequest
234+ where
235+ F : FnOnce ( A ) -> VmmAction ,
236+ A : vmm:: vmm_config:: StatelessArgs ,
237+ {
238+ ParsedRequest :: new_sync ( vmm:: vmm_config:: VmmActionPayload :: new ( entrypoint, args) )
228239 }
229240}
230241
@@ -342,11 +353,11 @@ pub mod tests {
342353 use vmm:: builder:: StartMicrovmError ;
343354 use vmm:: cpu_config:: templates:: test_utils:: build_test_template;
344355 use vmm:: devices:: virtio:: balloon:: device:: HintingStatus ;
345- use vmm:: resources:: VmmConfig ;
356+ use vmm:: resources:: VmmSpec ;
346357 use vmm:: rpc_interface:: VmmActionError ;
347- use vmm:: vmm_config:: balloon:: { BalloonDeviceConfig , BalloonStats } ;
358+ use vmm:: vmm_config:: balloon:: { BalloonDeviceSpec , BalloonStats } ;
348359 use vmm:: vmm_config:: instance_info:: InstanceInfo ;
349- use vmm:: vmm_config:: machine_config:: MachineConfig ;
360+ use vmm:: vmm_config:: machine_config:: MachineSpec ;
350361
351362 use super :: * ;
352363
@@ -581,8 +592,8 @@ pub mod tests {
581592 let data = Ok ( vmm_data) ;
582593 let mut buf = Cursor :: new ( vec ! [ 0 ] ) ;
583594 let expected_response = match data. as_ref ( ) . unwrap ( ) {
584- VmmData :: BalloonConfig ( cfg ) => {
585- http_response ( & serde_json:: to_string ( cfg ) . unwrap ( ) , 200 )
595+ VmmData :: BalloonSpec ( spec ) => {
596+ http_response ( & serde_json:: to_string ( spec ) . unwrap ( ) , 200 )
586597 }
587598 VmmData :: BalloonStats ( stats) => {
588599 http_response ( & serde_json:: to_string ( stats) . unwrap ( ) , 200 )
@@ -594,11 +605,11 @@ pub mod tests {
594605 http_response ( & serde_json:: to_string ( status) . unwrap ( ) , 200 )
595606 }
596607 VmmData :: Empty => http_response ( "" , 204 ) ,
597- VmmData :: FullVmConfig ( cfg ) => {
598- http_response ( & serde_json:: to_string ( cfg ) . unwrap ( ) , 200 )
608+ VmmData :: FullVmSpec ( spec ) => {
609+ http_response ( & serde_json:: to_string ( spec ) . unwrap ( ) , 200 )
599610 }
600- VmmData :: MachineConfiguration ( cfg ) => {
601- http_response ( & serde_json:: to_string ( cfg ) . unwrap ( ) , 200 )
611+ VmmData :: MachineSpec ( spec ) => {
612+ http_response ( & serde_json:: to_string ( spec ) . unwrap ( ) , 200 )
602613 }
603614 VmmData :: MmdsValue ( value) => {
604615 http_response ( & serde_json:: to_string ( value) . unwrap ( ) , 200 )
@@ -616,7 +627,7 @@ pub mod tests {
616627 assert_eq ! ( buf. into_inner( ) , expected_response. as_bytes( ) ) ;
617628 } ;
618629
619- verify_ok_response_with ( VmmData :: BalloonConfig ( BalloonDeviceConfig :: default ( ) ) ) ;
630+ verify_ok_response_with ( VmmData :: BalloonSpec ( BalloonDeviceSpec :: default ( ) ) ) ;
620631 verify_ok_response_with ( VmmData :: BalloonStats ( BalloonStats {
621632 swap_in : Some ( 1 ) ,
622633 swap_out : Some ( 1 ) ,
@@ -626,8 +637,8 @@ pub mod tests {
626637 ..Default :: default ( )
627638 } ) ) ;
628639 verify_ok_response_with ( VmmData :: Empty ) ;
629- verify_ok_response_with ( VmmData :: FullVmConfig ( VmmConfig :: default ( ) ) ) ;
630- verify_ok_response_with ( VmmData :: MachineConfiguration ( MachineConfig :: default ( ) ) ) ;
640+ verify_ok_response_with ( VmmData :: FullVmSpec ( VmmSpec :: default ( ) ) ) ;
641+ verify_ok_response_with ( VmmData :: MachineSpec ( MachineSpec :: default ( ) ) ) ;
631642 verify_ok_response_with ( VmmData :: MmdsValue ( serde_json:: from_str ( "{}" ) . unwrap ( ) ) ) ;
632643 verify_ok_response_with ( VmmData :: InstanceInformation ( InstanceInfo :: default ( ) ) ) ;
633644 verify_ok_response_with ( VmmData :: VmmVersion ( String :: default ( ) ) ) ;
0 commit comments