@@ -46,7 +46,7 @@ def id(self):
46
46
"""Computes a unique id for this test instance"""
47
47
return "all_dev" if self .all_devices else f"{ self .vcpus } vcpu_{ self .mem } mb"
48
48
49
- def boot_vm (self , microvm_factory , guest_kernel , rootfs ) -> Microvm :
49
+ def boot_vm (self , microvm_factory , guest_kernel , rootfs , secret_free ) -> Microvm :
50
50
"""Creates the initial snapshot that will be loaded repeatedly to sample latencies"""
51
51
vm = microvm_factory .build (
52
52
guest_kernel ,
@@ -60,6 +60,7 @@ def boot_vm(self, microvm_factory, guest_kernel, rootfs) -> Microvm:
60
60
mem_size_mib = self .mem ,
61
61
rootfs_io_engine = "Sync" ,
62
62
huge_pages = self .huge_pages ,
63
+ secret_free = secret_free ,
63
64
)
64
65
65
66
for _ in range (self .nets ):
@@ -98,7 +99,11 @@ def boot_vm(self, microvm_factory, guest_kernel, rootfs) -> Microvm:
98
99
ids = lambda x : x .id ,
99
100
)
100
101
def 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 ,
102
107
):
103
108
"""
104
109
Restores snapshots with vcpu/memory configuration, roughly scaling according to mem = (vcpus - 1) * 2048MB,
@@ -116,7 +121,7 @@ def test_restore_latency(
116
121
"huge pages with secret hiding kernels on ARM are currently failing"
117
122
)
118
123
119
- vm = test_setup .boot_vm (microvm_factory , guest_kernel_linux_5_10 , rootfs )
124
+ vm = test_setup .boot_vm (microvm_factory , guest_kernel_linux_5_10 , rootfs , False )
120
125
121
126
metrics .set_dimensions (
122
127
{
@@ -159,6 +164,7 @@ def test_post_restore_latency(
159
164
metrics ,
160
165
uffd_handler ,
161
166
huge_pages ,
167
+ secret_free ,
162
168
):
163
169
"""Collects latency metric of post-restore memory accesses done inside the guest"""
164
170
if huge_pages != HugePagesConfig .NONE and uffd_handler is None :
@@ -173,8 +179,16 @@ def test_post_restore_latency(
173
179
"huge pages with secret hiding kernels on ARM are currently failing"
174
180
)
175
181
182
+ if secret_free and uffd_handler is None :
183
+ pytest .skip ("Restoring from a file is not compatible with Secret Freedom" )
184
+
185
+ if secret_free and huge_pages != HugePagesConfig .NONE :
186
+ pytest .skip ("Huge pages are not supported with Secret Freedom yet" )
187
+
176
188
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 )
189
+ vm = test_setup .boot_vm (
190
+ microvm_factory , guest_kernel_linux_5_10 , rootfs , secret_free
191
+ )
178
192
179
193
metrics .set_dimensions (
180
194
{
@@ -226,6 +240,7 @@ def test_population_latency(
226
240
huge_pages ,
227
241
vcpus ,
228
242
mem ,
243
+ secret_free ,
229
244
):
230
245
"""Collects population latency metrics (e.g. how long it takes UFFD handler to fault in all memory)"""
231
246
if (
@@ -237,8 +252,13 @@ def test_population_latency(
237
252
"huge pages with secret hiding kernels on ARM are currently failing"
238
253
)
239
254
255
+ if secret_free and huge_pages != HugePagesConfig .NONE :
256
+ pytest .skip ("Huge pages are not supported with Secret Freedom yet" )
257
+
240
258
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 )
259
+ vm = test_setup .boot_vm (
260
+ microvm_factory , guest_kernel_linux_5_10 , rootfs , secret_free
261
+ )
242
262
243
263
metrics .set_dimensions (
244
264
{
@@ -287,15 +307,20 @@ def test_snapshot_create_latency(
287
307
rootfs ,
288
308
metrics ,
289
309
snapshot_type ,
310
+ secret_free ,
290
311
):
291
312
"""Measure the latency of creating a Full snapshot"""
292
313
314
+ if secret_free and snapshot_type == SnapshotType .DIFF :
315
+ pytest .skip ("secret freedom and diff snapshots are mutually exclusive" )
316
+
293
317
vm = microvm_factory .build (guest_kernel_linux_5_10 , rootfs , monitor_memory = False )
294
318
vm .spawn ()
295
319
vm .basic_config (
296
320
vcpu_count = 2 ,
297
321
mem_size_mib = 512 ,
298
322
track_dirty_pages = snapshot_type == SnapshotType .DIFF ,
323
+ secret_free = secret_free ,
299
324
)
300
325
vm .start ()
301
326
vm .pin_threads (0 )
0 commit comments