Skip to content

Commit 022e1f3

Browse files
committed
Fix merge errors from rebasing
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent e0fb924 commit 022e1f3

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl MultiUseSandbox {
245245
/// if result.is_err() {
246246
/// if sandbox.poisoned() {
247247
/// // Restore from snapshot to clear poison
248-
/// sandbox.restore(&snapshot)?;
248+
/// sandbox.restore(snapshot.clone())?;
249249
/// assert!(!sandbox.poisoned());
250250
///
251251
/// // Sandbox is now usable again
@@ -429,7 +429,7 @@ impl MultiUseSandbox {
429429
///
430430
/// if sandbox.poisoned() {
431431
/// eprintln!("Sandbox was poisoned, restoring from snapshot");
432-
/// sandbox.restore(&snapshot)?;
432+
/// sandbox.restore(snapshot.clone())?;
433433
/// }
434434
/// }
435435
/// # Ok(())
@@ -856,7 +856,7 @@ mod tests {
856856
assert!(matches!(res, HyperlightError::PoisonedSandbox));
857857

858858
// restore to non-poisoned snapshot should work and clear poison
859-
sbox.restore(&snapshot).unwrap();
859+
sbox.restore(snapshot.clone()).unwrap();
860860
assert!(!sbox.poisoned());
861861

862862
// guest calls should work again after restore
@@ -874,7 +874,7 @@ mod tests {
874874
assert!(sbox.poisoned());
875875

876876
// restore to non-poisoned snapshot should work again
877-
sbox.restore(&snapshot).unwrap();
877+
sbox.restore(snapshot.clone()).unwrap();
878878
assert!(!sbox.poisoned());
879879

880880
// guest calls should work again
@@ -1243,12 +1243,12 @@ mod tests {
12431243
assert_eq!(sbox.vm.get_mapped_regions().count(), 1);
12441244

12451245
// 4. Restore to snapshot 1 (should unmap the region)
1246-
sbox.restore(snapshot1).unwrap();
1247-
assert_eq!(sbox.vm.get_mapped_regions().len(), 0);
1246+
sbox.restore(snapshot1.clone()).unwrap();
1247+
assert_eq!(sbox.vm.get_mapped_regions().count(), 0);
12481248

12491249
// 5. Restore forward to snapshot 2 (should remap the region)
1250-
sbox.restore(snapshot2).unwrap();
1251-
assert_eq!(sbox.vm.get_mapped_regions().len(), 1);
1250+
sbox.restore(snapshot2.clone()).unwrap();
1251+
assert_eq!(sbox.vm.get_mapped_regions().count(), 1);
12521252

12531253
// Verify the region is the same
12541254
let mut restored_regions = sbox.vm.get_mapped_regions();

src/hyperlight_host/tests/integration_test.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/hyperlight_host/tests/sandbox_host_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ fn host_function_error() -> Result<()> {
365365
);
366366
// C guest panics in rust guest lib when host function returns error, which will poison the sandbox
367367
if init_sandbox.poisoned() {
368-
init_sandbox.restore(&snapshot)?;
368+
init_sandbox.restore(snapshot.clone())?;
369369
}
370370
}
371371
}

0 commit comments

Comments
 (0)