Skip to content

vmm: fix test_epoll_stdin_event#1406

Merged
alxiord merged 1 commit intofirecracker-microvm:masterfrom
dianpopa:little_fixes_4
Nov 22, 2019
Merged

vmm: fix test_epoll_stdin_event#1406
alxiord merged 1 commit intofirecracker-microvm:masterfrom
dianpopa:little_fixes_4

Conversation

@dianpopa
Copy link
Copy Markdown
Contributor

Reason for This PR

Fixes #1381

Description of Changes

This unit tests makes sure that calling
epoll_ctl_add on STDIN_FILENO succeeds.
However, if the unit tests are run through
ssh without a pseudo terminal, adding STDIN_FILENO
would return EPERM. Adjust unit test to not panic
in case of EPERM.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

[Author TODO: Meet these criteria. Where there are two options, keep one.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided.
  • The description of changes is clear and encompassing.
  • No docs need to be updated as part of this PR.
  • Code-level documentation for touched code is included in this PR.
  • No API changes are included in this PR.
  • The changes in this PR have no user impact.
  • No new unsafe code has been added.

@dianpopa dianpopa self-assigned this Nov 15, 2019
Copy link
Copy Markdown
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

sandreim
sandreim previously approved these changes Nov 20, 2019
Comment thread vmm/src/lib.rs Outdated
Comment on lines +2271 to +2270
// If this unit test is run without a terminal attached (i.e ssh without pseudo terminal,
// request, jailer with `--deamonize` flag on) EPOLL_CTL_ADD would return EPERM
// on STDIN_FILENO.
// Here we are testing that if we receive EPERM, we are no longer asserting
// against `epoll_context.dispatch_table[epoll_context.stdin_index as usize]` holding any value.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering these restrictions, is this test ever going to be run by the CI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the test is run by the CI both on x86_64 and aarch64.
The x86_64 hits the first branch of the match (i.e Ok) while aarch64 hits the EPERM branch.
The other solution to this problem would be to run the tests with ssh -t (which allocates a pseudo terminal by force) but i did not choose that path because it contravenes with the --daemonize flag where we want firecracker to redirect all three standard I/O file descriptors to dev/null.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a new one, it is also described at https://github.com/firecracker-microvm/firecracker/blob/master/vmm/src/lib.rs#L211.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. My worry was that this test can silently fail and hide away problems with our code.

alxiord
alxiord previously approved these changes Nov 21, 2019
Comment thread vmm/src/lib.rs Outdated
Copy link
Copy Markdown
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leverage let istty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0; in order to fix this ?

Or maybe libc::ttyname(libc::STDIN_FILENO as i32);

@dianpopa dianpopa dismissed stale reviews from alxiord and sandreim via 7a4019a November 22, 2019 12:25
@dianpopa dianpopa force-pushed the little_fixes_4 branch 2 times, most recently from 7a4019a to d5c0346 Compare November 22, 2019 12:59
Comment thread vmm/src/lib.rs Outdated
This unit tests makes sure that calling
epoll_ctl_add on STDIN_FILENO succeeds.
However, if the unit tests are run through
ssh without a pseudo terminal, adding STDIN_FILENO
would return EPERM. Adjust unit test to not panic
in case of EPERM.

Signed-off-by: Diana Popa <[email protected]>
@alxiord alxiord merged commit 2879087 into firecracker-microvm:master Nov 22, 2019
@dianpopa dianpopa deleted the little_fixes_4 branch January 3, 2020 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_epoll_stdin_event fails on a1.metal when running without a tty

6 participants