@@ -18,9 +18,7 @@ use vmm::rpc_interface::{
1818use vmm:: seccomp:: get_empty_filters;
1919use vmm:: snapshot:: Snapshot ;
2020use vmm:: test_utils:: mock_resources:: { MockVmResources , NOISY_KERNEL_IMAGE } ;
21- use vmm:: test_utils:: {
22- create_vmm, default_vmm, default_vmm_no_boot, default_vmm_pci, default_vmm_pci_no_boot,
23- } ;
21+ use vmm:: test_utils:: { create_vmm, default_vmm, default_vmm_no_boot} ;
2422use vmm:: vmm_config:: balloon:: BalloonDeviceConfig ;
2523use vmm:: vmm_config:: boot_source:: BootSourceConfig ;
2624use vmm:: vmm_config:: drive:: BlockDeviceConfig ;
@@ -66,13 +64,12 @@ fn test_build_and_boot_microvm() {
6664 assert_eq ! ( format!( "{:?}" , vmm_ret. err( ) ) , "Some(MissingKernelConfig)" ) ;
6765 }
6866
69- // Success case.
70- let ( vmm, evmgr) = default_vmm ( None ) ;
71- check_booted_microvm ( vmm, evmgr) ;
72-
73- // microVM with PCI
74- let ( vmm, evmgr) = default_vmm_pci ( None ) ;
75- check_booted_microvm ( vmm, evmgr) ;
67+ for pci_enabled in [ false , true ] {
68+ for memory_hotplug in [ false , true ] {
69+ let ( vmm, evmgr) = create_vmm ( None , false , true , pci_enabled, memory_hotplug) ;
70+ check_booted_microvm ( vmm, evmgr) ;
71+ }
72+ }
7673}
7774
7875#[ allow( unused_mut, unused_variables) ]
@@ -96,10 +93,12 @@ fn check_build_microvm(vmm: Arc<Mutex<Vmm>>, mut evmgr: EventManager) {
9693
9794#[ test]
9895fn test_build_microvm ( ) {
99- let ( vmm, evtmgr) = default_vmm_no_boot ( None ) ;
100- check_build_microvm ( vmm, evtmgr) ;
101- let ( vmm, evtmgr) = default_vmm_pci_no_boot ( None ) ;
102- check_build_microvm ( vmm, evtmgr) ;
96+ for pci_enabled in [ false , true ] {
97+ for memory_hotplug in [ false , true ] {
98+ let ( vmm, evmgr) = create_vmm ( None , false , false , pci_enabled, memory_hotplug) ;
99+ check_build_microvm ( vmm, evmgr) ;
100+ }
101+ }
103102}
104103
105104fn pause_resume_microvm ( vmm : Arc < Mutex < Vmm > > ) {
@@ -118,13 +117,14 @@ fn pause_resume_microvm(vmm: Arc<Mutex<Vmm>>) {
118117
119118#[ test]
120119fn test_pause_resume_microvm ( ) {
121- // Tests that pausing and resuming a microVM work as expected.
122- let ( vmm, _) = default_vmm ( None ) ;
120+ for pci_enabled in [ false , true ] {
121+ for memory_hotplug in [ false , true ] {
122+ // Tests that pausing and resuming a microVM work as expected.
123+ let ( vmm, _) = create_vmm ( None , false , true , pci_enabled, memory_hotplug) ;
123124
124- pause_resume_microvm ( vmm) ;
125-
126- let ( vmm, _) = default_vmm_pci ( None ) ;
127- pause_resume_microvm ( vmm) ;
125+ pause_resume_microvm ( vmm) ;
126+ }
127+ }
128128}
129129
130130#[ test]
@@ -195,11 +195,21 @@ fn test_disallow_dump_cpu_config_without_pausing() {
195195 vmm. lock ( ) . unwrap ( ) . stop ( FcExitCode :: Ok ) ;
196196}
197197
198- fn verify_create_snapshot ( is_diff : bool , pci_enabled : bool ) -> ( TempFile , TempFile ) {
198+ fn verify_create_snapshot (
199+ is_diff : bool ,
200+ pci_enabled : bool ,
201+ memory_hotplug : bool ,
202+ ) -> ( TempFile , TempFile ) {
199203 let snapshot_file = TempFile :: new ( ) . unwrap ( ) ;
200204 let memory_file = TempFile :: new ( ) . unwrap ( ) ;
201205
202- let ( vmm, _) = create_vmm ( Some ( NOISY_KERNEL_IMAGE ) , is_diff, true , pci_enabled) ;
206+ let ( vmm, _) = create_vmm (
207+ Some ( NOISY_KERNEL_IMAGE ) ,
208+ is_diff,
209+ true ,
210+ pci_enabled,
211+ memory_hotplug,
212+ ) ;
203213 let resources = VmResources {
204214 machine_config : MachineConfig {
205215 mem_size_mib : 1 ,
@@ -303,14 +313,19 @@ fn verify_load_snapshot(snapshot_file: TempFile, memory_file: TempFile) {
303313
304314#[ test]
305315fn test_create_and_load_snapshot ( ) {
306- for ( diff_snap, pci_enabled) in [ ( false , false ) , ( false , true ) , ( true , false ) , ( true , true ) ] {
307- // Create snapshot.
308- let ( snapshot_file, memory_file) = verify_create_snapshot ( diff_snap, pci_enabled) ;
309- // Create a new microVm from snapshot. This only tests code-level logic; it verifies
310- // that a microVM can be built with no errors from given snapshot.
311- // It does _not_ verify that the guest is actually restored properly. We're using
312- // python integration tests for that.
313- verify_load_snapshot ( snapshot_file, memory_file) ;
316+ for diff_snap in [ false , true ] {
317+ for pci_enabled in [ false , true ] {
318+ for memory_hotplug in [ false , true ] {
319+ // Create snapshot.
320+ let ( snapshot_file, memory_file) =
321+ verify_create_snapshot ( diff_snap, pci_enabled, memory_hotplug) ;
322+ // Create a new microVm from snapshot. This only tests code-level logic; it verifies
323+ // that a microVM can be built with no errors from given snapshot.
324+ // It does _not_ verify that the guest is actually restored properly. We're using
325+ // python integration tests for that.
326+ verify_load_snapshot ( snapshot_file, memory_file) ;
327+ }
328+ }
314329 }
315330}
316331
@@ -338,15 +353,15 @@ fn check_snapshot(mut microvm_state: MicrovmState) {
338353
339354fn get_microvm_state_from_snapshot ( pci_enabled : bool ) -> MicrovmState {
340355 // Create a diff snapshot
341- let ( snapshot_file, _) = verify_create_snapshot ( true , pci_enabled) ;
356+ let ( snapshot_file, _) = verify_create_snapshot ( true , pci_enabled, false ) ;
342357
343358 // Deserialize the microVM state.
344359 snapshot_file. as_file ( ) . seek ( SeekFrom :: Start ( 0 ) ) . unwrap ( ) ;
345360 Snapshot :: load ( & mut snapshot_file. as_file ( ) ) . unwrap ( ) . data
346361}
347362
348363fn verify_load_snap_disallowed_after_boot_resources ( res : VmmAction , res_name : & str ) {
349- let ( snapshot_file, memory_file) = verify_create_snapshot ( false , false ) ;
364+ let ( snapshot_file, memory_file) = verify_create_snapshot ( false , false , false ) ;
350365
351366 let mut event_manager = EventManager :: new ( ) . unwrap ( ) ;
352367 let empty_seccomp_filters = get_empty_filters ( ) ;
0 commit comments