Skip to content

Commit aa18f7d

Browse files
author
Jonathan Woollett-Light
committed
fix: Pass through no-API shutdown exit code
Without passing through the exit code a non-zero exit code was returned on a successful no-API shutdown. Signed-off-by: Jonathan Woollett-Light <[email protected]>
1 parent e71046f commit aa18f7d

File tree

4 files changed

+101
-32
lines changed

4 files changed

+101
-32
lines changed

src/firecracker/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl From<MainError> for ExitCode {
8383
MainError::InvalidLogLevel(_) => FcExitCode::BadConfiguration,
8484
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithoutError(code)) => code,
8585
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithError(code)) => code,
86+
MainError::RunWithoutApiError(RunWithoutApiError::Shutdown(code)) => code,
8687
_ => FcExitCode::GenericError,
8788
};
8889

tests/framework/vm_config.json

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
{
2-
"boot-source": {
3-
"kernel_image_path": "vmlinux.bin",
4-
"boot_args": "console=ttyS0 reboot=k panic=1 pci=off",
5-
"initrd_path": null
6-
},
7-
"drives": [
8-
{
9-
"drive_id": "rootfs",
10-
"path_on_host": "bionic.rootfs.ext4",
11-
"is_root_device": true,
12-
"partuuid": null,
13-
"is_read_only": false,
14-
"cache_type": "Unsafe",
15-
"io_engine": "Sync",
16-
"rate_limiter": null
17-
}
18-
],
19-
"machine-config": {
20-
"vcpu_count": 2,
21-
"mem_size_mib": 1024,
22-
"smt": false,
23-
"track_dirty_pages": false
24-
},
25-
"cpu-config": null,
26-
"balloon": null,
27-
"network-interfaces": [],
28-
"vsock": null,
29-
"logger": null,
30-
"metrics": null,
31-
"mmds-config": null,
32-
"entropy": null
33-
}
2+
"boot-source": {
3+
"kernel_image_path": "vmlinux.bin",
4+
"boot_args": "console=ttyS0 reboot=k panic=1 pci=off",
5+
"initrd_path": null
6+
},
7+
"drives": [
8+
{
9+
"drive_id": "rootfs",
10+
"path_on_host": "bionic.rootfs.ext4",
11+
"is_root_device": true,
12+
"partuuid": null,
13+
"is_read_only": false,
14+
"cache_type": "Unsafe",
15+
"io_engine": "Sync",
16+
"rate_limiter": null
17+
}
18+
],
19+
"machine-config": {
20+
"vcpu_count": 2,
21+
"mem_size_mib": 1024,
22+
"smt": false,
23+
"track_dirty_pages": false
24+
},
25+
"cpu-config": null,
26+
"balloon": null,
27+
"network-interfaces": [],
28+
"vsock": null,
29+
"logger": null,
30+
"metrics": null,
31+
"mmds-config": null,
32+
"entropy": null
33+
}
34+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"boot-source": {
3+
"kernel_image_path": "vmlinux.bin",
4+
"boot_args": "console=ttyS0 reboot=k panic=1 pci=off",
5+
"initrd_path": null
6+
},
7+
"drives": [
8+
{
9+
"drive_id": "rootfs",
10+
"path_on_host": "bionic.rootfs.ext4",
11+
"is_root_device": true,
12+
"partuuid": null,
13+
"is_read_only": false,
14+
"cache_type": "Unsafe",
15+
"io_engine": "Sync",
16+
"rate_limiter": null
17+
}
18+
],
19+
"machine-config": {
20+
"vcpu_count": 2,
21+
"mem_size_mib": 1024,
22+
"smt": false,
23+
"track_dirty_pages": false
24+
},
25+
"cpu-config": null,
26+
"balloon": null,
27+
"network-interfaces": [
28+
{
29+
"iface_id": "1",
30+
"host_dev_name": "tap0",
31+
"guest_mac": "06:00:c0:a8:00:02",
32+
"rx_rate_limiter": null,
33+
"tx_rate_limiter": null
34+
}
35+
],
36+
"vsock": null,
37+
"logger": null,
38+
"metrics": null,
39+
"mmds-config": null,
40+
"entropy": null
41+
}
42+

tests/integration_tests/functional/test_cmd_line_start.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88
import re
99
import shutil
10+
import time
1011
from pathlib import Path
1112

1213
import pytest
@@ -156,6 +157,30 @@ def test_config_start_no_api(uvm_plain, vm_config_file):
156157
)
157158

158159

160+
@pytest.mark.parametrize("vm_config_file", ["framework/vm_config_network.json"])
161+
def test_config_start_no_api_exit(uvm_plain, vm_config_file):
162+
"""
163+
Test microvm exit when API server is disabled.
164+
"""
165+
test_microvm = uvm_plain
166+
_configure_vm_from_json(test_microvm, vm_config_file)
167+
_configure_network_interface(test_microvm)
168+
test_microvm.jailer.extra_args.update({"no-api": None})
169+
170+
test_microvm.spawn() # Start Firecracker and MicroVM
171+
172+
time.sleep(3)
173+
174+
test_microvm.ssh.run("reboot") # Exit
175+
176+
time.sleep(3)
177+
178+
# Check error log
179+
test_microvm.check_log_message(
180+
"RunWithoutApiError error: MicroVMStopped without an error: Ok"
181+
)
182+
183+
159184
@pytest.mark.parametrize(
160185
"vm_config_file",
161186
[

0 commit comments

Comments
 (0)