diff --git a/src/firecracker/src/main.rs b/src/firecracker/src/main.rs index 5b237b02bae..cf95ff1f995 100644 --- a/src/firecracker/src/main.rs +++ b/src/firecracker/src/main.rs @@ -144,6 +144,7 @@ fn main_exec() -> Result<(), MainError> { .arg( Argument::new("id") .takes_value(true) + .default_value(vmm::logger::DEFAULT_INSTANCE_ID) .help("MicroVM unique identifier."), ) .arg( @@ -262,8 +263,6 @@ fn main_exec() -> Result<(), MainError> { return Ok(()); } - info!("Running Firecracker v{FIRECRACKER_VERSION}"); - register_signal_handlers().map_err(MainError::RegisterSignalHandlers)?; #[cfg(target_arch = "aarch64")] @@ -298,11 +297,9 @@ fn main_exec() -> Result<(), MainError> { app_name: "Firecracker".to_string(), }; - let id = arguments - .single_value("id") - .map(|s| s.as_str()) - .unwrap_or(vmm::logger::DEFAULT_INSTANCE_ID); + let id = arguments.single_value("id").map(|s| s.as_str()).unwrap(); vmm::logger::INSTANCE_ID.set(String::from(id)).unwrap(); + info!("Running Firecracker v{FIRECRACKER_VERSION}"); // Apply the logger configuration. let log_path = arguments.single_value("log-path").map(PathBuf::from); diff --git a/tests/integration_tests/functional/test_cmd_line_parameters.py b/tests/integration_tests/functional/test_cmd_line_parameters.py index 4b3bcb00703..55985ddea0f 100644 --- a/tests/integration_tests/functional/test_cmd_line_parameters.py +++ b/tests/integration_tests/functional/test_cmd_line_parameters.py @@ -3,6 +3,7 @@ """Tests that ensure the correctness of the command line parameters.""" import platform +import subprocess from pathlib import Path import pytest @@ -130,3 +131,18 @@ def test_cli_metrics_if_resume_no_metrics(uvm_plain, microvm_factory): # Then: the old metrics configuration does not exist metrics2 = Path(uvm2.jailer.chroot_path()) / metrics_path.name assert not metrics2.exists() + + +def test_cli_no_params(): + """ + Test running firecracker with no parameters should work + """ + + fc_binary, _ = get_firecracker_binaries() + process = subprocess.Popen(fc_binary) + try: + process.communicate(timeout=3) + assert process.returncode is None + except subprocess.TimeoutExpired: + # The good case + process.kill()