-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal handler for SIGBUS, SIGSEGV #1070
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
537c3d8
vmm: fix test_signal_handler
e277be1
vmm: rename sigsys_handler to signal_handler
8aefa72
vmm/sys_util: refactor signal handling
65dc516
sys_util: generic register_signal_handler
f533bf1
vmm: handle SIGBUS & SIGSEGV
95f5d7e
documentation & doctests for signal handling utils
1f722e2
tests: update licenses test
0bf17d8
tests: add integ test for SIGBUS/SIGSEGV handling
333869b
changelog: add note on new signal handler
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Tests scenarios for Firecracker signal handling.""" | ||
|
||
import os | ||
from signal import SIGBUS, SIGSEGV | ||
from time import sleep | ||
|
||
import pytest | ||
|
||
import host_tools.logging as log_tools | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"signum", | ||
[SIGBUS, SIGSEGV] | ||
) | ||
def test_sigbus_sigsegv(test_microvm_with_api, signum): | ||
"""Test signal handling for `SIGBUS` and `SIGSEGV`.""" | ||
test_microvm = test_microvm_with_api | ||
test_microvm.spawn() | ||
|
||
# We don't need to monitor the memory for this test. | ||
test_microvm.memory_events_queue = None | ||
|
||
test_microvm.basic_config() | ||
|
||
# Configure logging. | ||
log_fifo_path = os.path.join(test_microvm.path, 'log_fifo') | ||
metrics_fifo_path = os.path.join(test_microvm.path, 'metrics_fifo') | ||
log_fifo = log_tools.Fifo(log_fifo_path) | ||
metrics_fifo = log_tools.Fifo(metrics_fifo_path) | ||
|
||
response = test_microvm.logger.put( | ||
log_fifo=test_microvm.create_jailed_resource(log_fifo.path), | ||
metrics_fifo=test_microvm.create_jailed_resource(metrics_fifo.path), | ||
level='Error', | ||
show_level=False, | ||
show_log_origin=False | ||
) | ||
assert test_microvm.api_session.is_status_no_content(response.status_code) | ||
|
||
test_microvm.start() | ||
firecracker_pid = int(test_microvm.jailer_clone_pid) | ||
|
||
sleep(0.5) | ||
os.kill(firecracker_pid, signum) | ||
|
||
msg = 'Shutting down VM after intercepting signal {}'.format(signum) | ||
lines = log_fifo.sequential_reader(5) | ||
msg_found = False | ||
for line in lines: | ||
if msg in line: | ||
msg_found = True | ||
break | ||
assert msg_found |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍