@@ -68,7 +68,7 @@ fn interrupt_host_call() {
6868 assert ! ( sandbox. poisoned( ) ) ;
6969
7070 // Restore from snapshot to clear poison
71- sandbox. restore ( & snapshot) . unwrap ( ) ;
71+ sandbox. restore ( snapshot. clone ( ) ) . unwrap ( ) ;
7272 assert ! ( !sandbox. poisoned( ) ) ;
7373
7474 thread. join ( ) . unwrap ( ) ;
@@ -98,7 +98,7 @@ fn interrupt_in_progress_guest_call() {
9898 assert ! ( sbox1. poisoned( ) ) ;
9999
100100 // Restore from snapshot to clear poison
101- sbox1. restore ( & snapshot) . unwrap ( ) ;
101+ sbox1. restore ( snapshot. clone ( ) ) . unwrap ( ) ;
102102 assert ! ( !sbox1. poisoned( ) ) ;
103103
104104 barrier. wait ( ) ;
@@ -191,7 +191,7 @@ fn interrupt_same_thread() {
191191 _ => panic ! ( "Unexpected return" ) ,
192192 } ;
193193 if sbox2. poisoned ( ) {
194- sbox2. restore ( & snapshot2) . unwrap ( ) ;
194+ sbox2. restore ( snapshot2. clone ( ) ) . unwrap ( ) ;
195195 }
196196 sbox3
197197 . call :: < String > ( "Echo" , "hello" . to_string ( ) )
@@ -238,7 +238,7 @@ fn interrupt_same_thread_no_barrier() {
238238 _ => panic ! ( "Unexpected return" ) ,
239239 } ;
240240 if sbox2. poisoned ( ) {
241- sbox2. restore ( & snapshot2) . unwrap ( ) ;
241+ sbox2. restore ( snapshot2. clone ( ) ) . unwrap ( ) ;
242242 }
243243 sbox3
244244 . call :: < String > ( "Echo" , "hello" . to_string ( ) )
@@ -267,7 +267,7 @@ fn interrupt_moved_sandbox() {
267267 let res = sbox1. call :: < i32 > ( "Spin" , ( ) ) . unwrap_err ( ) ;
268268 assert ! ( matches!( res, HyperlightError :: ExecutionCanceledByHost ( ) ) ) ;
269269 assert ! ( sbox1. poisoned( ) ) ;
270- sbox1. restore ( & snapshot1) . unwrap ( ) ;
270+ sbox1. restore ( snapshot1. clone ( ) ) . unwrap ( ) ;
271271 assert ! ( !sbox1. poisoned( ) ) ;
272272 } ) ;
273273
@@ -327,7 +327,7 @@ fn interrupt_custom_signal_no_and_retry_delay() {
327327 assert ! ( sbox1. poisoned( ) ) ;
328328 // immediately reenter another guest function call after having being cancelled,
329329 // so that the vcpu is running again before the interruptor-thread has a chance to see that the vcpu is not running
330- sbox1. restore ( & snapshot1) . unwrap ( ) ;
330+ sbox1. restore ( snapshot1. clone ( ) ) . unwrap ( ) ;
331331 assert ! ( !sbox1. poisoned( ) ) ;
332332 }
333333 thread. join ( ) . expect ( "Thread should finish" ) ;
@@ -906,7 +906,7 @@ fn interrupt_random_kill_stress_test() {
906906 // Wrapper to hold a sandbox and its snapshot together
907907 struct SandboxWithSnapshot {
908908 sandbox : MultiUseSandbox ,
909- snapshot : Snapshot ,
909+ snapshot : Arc < Snapshot > ,
910910 }
911911
912912 use std:: collections:: VecDeque ;
@@ -1128,7 +1128,10 @@ fn interrupt_random_kill_stress_test() {
11281128 assert ! ( sandbox_wrapper. sandbox. poisoned( ) ) ;
11291129
11301130 // Try to restore the snapshot
1131- if let Err ( e) = sandbox_wrapper. sandbox . restore ( & sandbox_wrapper. snapshot ) {
1131+ if let Err ( e) = sandbox_wrapper
1132+ . sandbox
1133+ . restore ( sandbox_wrapper. snapshot . clone ( ) )
1134+ {
11321135 error ! (
11331136 "CRITICAL: Thread {} iteration {}: Failed to restore snapshot: {:?}" ,
11341137 thread_id, iteration, e
@@ -1442,7 +1445,7 @@ fn interrupt_infinite_loop_stress_test() {
14421445 }
14431446
14441447 // Restore the sandbox for the next iteration
1445- sandbox. restore ( & snapshot) . unwrap ( ) ;
1448+ sandbox. restore ( snapshot. clone ( ) ) . unwrap ( ) ;
14461449 }
14471450 } ) ) ;
14481451 }
0 commit comments