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 committed Oct 5, 2023
1 parent d6e6140 commit d0e7b52
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)?;

Check warning on line 106 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L106

Added line #L106 was not covered by tests
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}");

Check warning on line 265 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L265

Added line #L265 was not covered by tests

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

Check warning on line 267 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L267

Added line #L267 was not covered by tests

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

Check warning on line 270 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L270

Added line #L270 was not covered by tests

if let Err(err) = resize_fdtable() {
match err {

Check warning on line 273 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L272-L273

Added lines #L272 - L273 were not covered by tests
// 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}")

Check warning on line 277 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L277

Added line #L277 was not covered by tests
}
// This error means that we now have a random file descriptor lying around, abort to be
// cautious.
ResizeFdTableError::Close(_) => return Err(MainError::ResizeFdtable(err)),

Check warning on line 281 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L281

Added line #L281 was not covered by tests
}
}

Check warning on line 283 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L283

Added line #L283 was not covered by tests

// 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 d0e7b52

Please sign in to comment.