Skip to content

Commit b1c6fc4

Browse files
committed
Make it possible to disable execution timeouts
This ensures that setting an execution timeout of 0 disables execution timeouts entirely. This is temporary, as we intend to remove the wall-clock timeout feature from Hyperlight entirely in the near future.
1 parent 44e6654 commit b1c6fc4

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,20 @@ impl HypervisorHandler {
622622
// from the handler thread, as the thread may be paused by gdb.
623623
// In this case, we will wait indefinitely for a message from the handler thread.
624624
// Note: This applies to all the running sandboxes, not just the one being debugged.
625-
#[cfg(gdb)]
626-
let response = self.communication_channels.from_handler_rx.recv();
627625
#[cfg(not(gdb))]
628-
let response = self
629-
.communication_channels
630-
.from_handler_rx
631-
.recv_timeout(self.execution_variables.get_timeout()?);
626+
let timeout = self.execution_variables.get_timeout()?;
627+
#[cfg(gdb)]
628+
let timeout = Duration::ZERO;
629+
let response = if timeout.is_zero() {
630+
self.communication_channels
631+
.from_handler_rx
632+
.recv()
633+
.map_err(Into::into)
634+
} else {
635+
self.communication_channels
636+
.from_handler_rx
637+
.recv_timeout(timeout)
638+
};
632639

633640
match response {
634641
Ok(msg) => match msg {

src/hyperlight_host/src/sandbox/config.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,25 @@ impl SandboxConfiguration {
295295
self.kernel_stack_size = max(kernel_stack_size, Self::MIN_KERNEL_STACK_SIZE);
296296
}
297297

298-
/// Set the maximum execution time of a guest function execution. If set to 0, the max_execution_time
299-
/// will be set to the default value of DEFAULT_MAX_EXECUTION_TIME if the guest execution does not complete within the time specified
300-
/// then the execution will be cancelled, the minimum value is MIN_MAX_EXECUTION_TIME
298+
/// Set the maximum execution time of a guest function
299+
/// execution. If set to 0, the maximum execution time will be
300+
/// unlimited. If the guest execution does not complete within the
301+
/// time specified, then the execution will be cancelled. The
302+
/// minimum value is MIN_MAX_EXECUTION_TIME
301303
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
302304
pub fn set_max_execution_time(&mut self, max_execution_time: Duration) {
303-
match max_execution_time.as_millis() {
304-
0 => self.max_execution_time = Self::DEFAULT_MAX_EXECUTION_TIME,
305-
1.. => {
306-
self.max_execution_time = min(
307-
Self::MAX_MAX_EXECUTION_TIME.into(),
308-
max(
309-
max_execution_time.as_millis(),
310-
Self::MIN_MAX_EXECUTION_TIME.into(),
311-
),
312-
) as u16
313-
}
314-
}
305+
match max_execution_time.as_millis() {
306+
0 => self.max_execution_time = 0,
307+
1.. => {
308+
self.max_execution_time = min(
309+
Self::MAX_MAX_EXECUTION_TIME.into(),
310+
max(
311+
max_execution_time.as_millis(),
312+
Self::MIN_MAX_EXECUTION_TIME.into(),
313+
),
314+
) as u16
315+
}
316+
}
315317
}
316318

317319
/// Set the maximum time to wait for guest execution calculation. If set to 0, the maximum cancellation time

0 commit comments

Comments
 (0)