Skip to content

Commit

Permalink
fix: Move argument passing up
Browse files Browse the repository at this point in the history
Moves argument passing before logging `Running Firecracker` and other
code that may not be required if certain arguments are passed causing
the process to exit early.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
  • Loading branch information
Jonathan Woollett-Light authored and JonathanWoollett-Light committed Oct 6, 2023
1 parent 3d07747 commit fa4b299
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,6 @@ fn main() -> ExitCode {
fn main_exec() -> Result<(), MainError> {
// Initialize the logger.
LOGGER.init().map_err(MainError::SetLogger)?;
info!("Running Firecracker v{FIRECRACKER_VERSION}");

register_signal_handlers().map_err(MainError::RegisterSignalHandlers)?;

#[cfg(target_arch = "aarch64")]
enable_ssbd_mitigation();

if let Err(err) = resize_fdtable() {
match err {
// These errors are non-critical: In the worst case we have worse snapshot restore
// performance.
ResizeFdTableError::GetRlimit | ResizeFdTableError::Dup2(_) => {
debug!("Failed to resize fdtable: {err}")
}
// This error means that we now have a random file descriptor lying around, abort to be
// cautious.
ResizeFdTableError::Close(_) => return Err(MainError::ResizeFdtable(err)),
}
}

// We need this so that we can reset terminal to canonical mode if panic occurs.
let stdin = io::stdin();
Expand Down Expand Up @@ -281,6 +262,26 @@ fn main_exec() -> Result<(), MainError> {
return Ok(());
}

info!("Running Firecracker v{FIRECRACKER_VERSION}");

register_signal_handlers().map_err(MainError::RegisterSignalHandlers)?;

#[cfg(target_arch = "aarch64")]
enable_ssbd_mitigation();

if let Err(err) = resize_fdtable() {
match err {
// These errors are non-critical: In the worst case we have worse snapshot restore
// performance.
ResizeFdTableError::GetRlimit | ResizeFdTableError::Dup2(_) => {
debug!("Failed to resize fdtable: {err}")
}
// This error means that we now have a random file descriptor lying around, abort to be
// cautious.
ResizeFdTableError::Close(_) => return Err(MainError::ResizeFdtable(err)),
}
}

// Display warnings for any used deprecated parameters.
// Currently unused since there are no deprecated parameters. Uncomment the line when
// deprecating one.
Expand Down

0 comments on commit fa4b299

Please sign in to comment.