diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b2d7b244d32..4040ec773e8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ - Fixed a bug that ignored the `--show-log-origin` option, preventing it from printing the source code file of the log messages. +- [#4178](https://github.com/firecracker-microvm/firecracker/pull/4178): + Fixed a bug reporting a non-zero exit code on successful shutdown when + starting Firecracker with `--no-api`. ## [1.5.0] @@ -68,7 +71,7 @@ restore times for medium to large microVMs with many devices attached. - Changed the dump feature of `cpu-template-helper` tool not to enumerate program counter (PC) on ARM because it is determined by the given kernel image and - it is useless in the custom CPU template context. + it is useless in the custom CPU templase eth0 here we could later consider this file as a good reference for getting started guide to start Firecracker with network.te context. - The ability to create snapshots for an older version of Firecracker is now deprecated. As a result, the `version` body field in `PUT` on `/snapshot/create` request in deprecated. diff --git a/src/firecracker/src/main.rs b/src/firecracker/src/main.rs index 8c62461c2f31..af8c92ee7f0d 100644 --- a/src/firecracker/src/main.rs +++ b/src/firecracker/src/main.rs @@ -83,6 +83,7 @@ impl From for ExitCode { MainError::InvalidLogLevel(_) => FcExitCode::BadConfiguration, MainError::RunWithApi(ApiServerError::MicroVMStoppedWithoutError(code)) => code, MainError::RunWithApi(ApiServerError::MicroVMStoppedWithError(code)) => code, + MainError::RunWithoutApiError(RunWithoutApiError::Shutdown(code)) => code, _ => FcExitCode::GenericError, }; diff --git a/tests/integration_tests/functional/test_cmd_line_start.py b/tests/integration_tests/functional/test_cmd_line_start.py index 3c2a3750a763..f06d4a226780 100644 --- a/tests/integration_tests/functional/test_cmd_line_start.py +++ b/tests/integration_tests/functional/test_cmd_line_start.py @@ -7,6 +7,7 @@ import platform import re import shutil +import time from pathlib import Path import pytest @@ -156,6 +157,27 @@ def test_config_start_no_api(uvm_plain, vm_config_file): ) +@pytest.mark.parametrize("vm_config_file", ["framework/vm_config_network.json"]) +def test_config_start_no_api_exit(uvm_plain, vm_config_file): + """ + Test microvm exit when API server is disabled. + """ + test_microvm = uvm_plain + _configure_vm_from_json(test_microvm, vm_config_file) + _configure_network_interface(test_microvm) + test_microvm.jailer.extra_args.update({"no-api": None}) + + test_microvm.spawn() # Start Firecracker and MicroVM + time.sleep(3) # Wait for startup + test_microvm.ssh.run("reboot") # Exit + time.sleep(3) # Wait for shutdown + + # Check error log + test_microvm.check_log_message( + "RunWithoutApiError error: MicroVMStopped without an error: Ok" + ) + + @pytest.mark.parametrize( "vm_config_file", [