@@ -46,7 +46,7 @@ def id(self):
4646 """Computes a unique id for this test instance"""
4747 return "all_dev" if self .all_devices else f"{ self .vcpus } vcpu_{ self .mem } mb"
4848
49- def boot_vm (self , microvm_factory , guest_kernel , rootfs ) -> Microvm :
49+ def boot_vm (self , microvm_factory , guest_kernel , rootfs , secret_free ) -> Microvm :
5050 """Creates the initial snapshot that will be loaded repeatedly to sample latencies"""
5151 vm = microvm_factory .build (
5252 guest_kernel ,
@@ -60,6 +60,7 @@ def boot_vm(self, microvm_factory, guest_kernel, rootfs) -> Microvm:
6060 mem_size_mib = self .mem ,
6161 rootfs_io_engine = "Sync" ,
6262 huge_pages = self .huge_pages ,
63+ secret_free = secret_free ,
6364 )
6465
6566 for _ in range (self .nets ):
@@ -98,7 +99,11 @@ def boot_vm(self, microvm_factory, guest_kernel, rootfs) -> Microvm:
9899 ids = lambda x : x .id ,
99100)
100101def test_restore_latency (
101- microvm_factory , rootfs , guest_kernel_linux_5_10 , test_setup , metrics
102+ microvm_factory ,
103+ rootfs ,
104+ guest_kernel_linux_5_10 ,
105+ test_setup ,
106+ metrics ,
102107):
103108 """
104109 Restores snapshots with vcpu/memory configuration, roughly scaling according to mem = (vcpus - 1) * 2048MB,
@@ -116,7 +121,9 @@ def test_restore_latency(
116121 "huge pages with secret hiding kernels on ARM are currently failing"
117122 )
118123
119- vm = test_setup .boot_vm (microvm_factory , guest_kernel_linux_5_10 , rootfs )
124+ vm = test_setup .boot_vm (
125+ microvm_factory , guest_kernel_linux_5_10 , rootfs , False
126+ )
120127
121128 metrics .set_dimensions (
122129 {
@@ -159,6 +166,7 @@ def test_post_restore_latency(
159166 metrics ,
160167 uffd_handler ,
161168 huge_pages ,
169+ secret_free ,
162170):
163171 """Collects latency metric of post-restore memory accesses done inside the guest"""
164172 if huge_pages != HugePagesConfig .NONE and uffd_handler is None :
@@ -173,8 +181,13 @@ def test_post_restore_latency(
173181 "huge pages with secret hiding kernels on ARM are currently failing"
174182 )
175183
184+ if secret_free and uffd_handler is None :
185+ pytest .skip ("Restoring from a file is not compatible with Secret Freedom" )
186+
176187 test_setup = SnapshotRestoreTest (mem = 1024 , vcpus = 2 , huge_pages = huge_pages )
177- vm = test_setup .boot_vm (microvm_factory , guest_kernel_linux_5_10 , rootfs )
188+ vm = test_setup .boot_vm (
189+ microvm_factory , guest_kernel_linux_5_10 , rootfs , secret_free
190+ )
178191
179192 metrics .set_dimensions (
180193 {
@@ -226,6 +239,7 @@ def test_population_latency(
226239 huge_pages ,
227240 vcpus ,
228241 mem ,
242+ secret_free ,
229243):
230244 """Collects population latency metrics (e.g. how long it takes UFFD handler to fault in all memory)"""
231245 if (
@@ -238,7 +252,9 @@ def test_population_latency(
238252 )
239253
240254 test_setup = SnapshotRestoreTest (mem = mem , vcpus = vcpus , huge_pages = huge_pages )
241- vm = test_setup .boot_vm (microvm_factory , guest_kernel_linux_5_10 , rootfs )
255+ vm = test_setup .boot_vm (
256+ microvm_factory , guest_kernel_linux_5_10 , rootfs , secret_free
257+ )
242258
243259 metrics .set_dimensions (
244260 {
@@ -281,16 +297,13 @@ def test_population_latency(
281297
282298
283299def test_snapshot_create_latency (
284- microvm_factory ,
285- guest_kernel_linux_5_10 ,
286- rootfs ,
287- metrics ,
300+ microvm_factory , guest_kernel_linux_5_10 , rootfs , metrics , secret_free
288301):
289302 """Measure the latency of creating a Full snapshot"""
290303
291304 vm = microvm_factory .build (guest_kernel_linux_5_10 , rootfs , monitor_memory = False )
292305 vm .spawn ()
293- vm .basic_config (vcpu_count = 2 , mem_size_mib = 512 )
306+ vm .basic_config (vcpu_count = 2 , mem_size_mib = 512 , secret_free = secret_free )
294307 vm .start ()
295308 vm .pin_threads (0 )
296309
0 commit comments