@@ -18,9 +18,7 @@ use vmm::rpc_interface::{
18
18
use vmm:: seccomp:: get_empty_filters;
19
19
use vmm:: snapshot:: Snapshot ;
20
20
use 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} ;
24
22
use vmm:: vmm_config:: balloon:: BalloonDeviceConfig ;
25
23
use vmm:: vmm_config:: boot_source:: BootSourceConfig ;
26
24
use vmm:: vmm_config:: drive:: BlockDeviceConfig ;
@@ -66,13 +64,12 @@ fn test_build_and_boot_microvm() {
66
64
assert_eq ! ( format!( "{:?}" , vmm_ret. err( ) ) , "Some(MissingKernelConfig)" ) ;
67
65
}
68
66
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
+ }
76
73
}
77
74
78
75
#[ allow( unused_mut, unused_variables) ]
@@ -96,10 +93,12 @@ fn check_build_microvm(vmm: Arc<Mutex<Vmm>>, mut evmgr: EventManager) {
96
93
97
94
#[ test]
98
95
fn 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
+ }
103
102
}
104
103
105
104
fn pause_resume_microvm ( vmm : Arc < Mutex < Vmm > > ) {
@@ -118,13 +117,14 @@ fn pause_resume_microvm(vmm: Arc<Mutex<Vmm>>) {
118
117
119
118
#[ test]
120
119
fn 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) ;
123
124
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
+ }
128
128
}
129
129
130
130
#[ test]
@@ -195,11 +195,21 @@ fn test_disallow_dump_cpu_config_without_pausing() {
195
195
vmm. lock ( ) . unwrap ( ) . stop ( FcExitCode :: Ok ) ;
196
196
}
197
197
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 ) {
199
203
let snapshot_file = TempFile :: new ( ) . unwrap ( ) ;
200
204
let memory_file = TempFile :: new ( ) . unwrap ( ) ;
201
205
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
+ ) ;
203
213
let resources = VmResources {
204
214
machine_config : MachineConfig {
205
215
mem_size_mib : 1 ,
@@ -303,14 +313,19 @@ fn verify_load_snapshot(snapshot_file: TempFile, memory_file: TempFile) {
303
313
304
314
#[ test]
305
315
fn 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
+ }
314
329
}
315
330
}
316
331
@@ -338,15 +353,15 @@ fn check_snapshot(mut microvm_state: MicrovmState) {
338
353
339
354
fn get_microvm_state_from_snapshot ( pci_enabled : bool ) -> MicrovmState {
340
355
// 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 ) ;
342
357
343
358
// Deserialize the microVM state.
344
359
snapshot_file. as_file ( ) . seek ( SeekFrom :: Start ( 0 ) ) . unwrap ( ) ;
345
360
Snapshot :: load ( & mut snapshot_file. as_file ( ) ) . unwrap ( ) . data
346
361
}
347
362
348
363
fn 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 ) ;
350
365
351
366
let mut event_manager = EventManager :: new ( ) . unwrap ( ) ;
352
367
let empty_seccomp_filters = get_empty_filters ( ) ;
0 commit comments