Skip to content

runtime adapter: turn the host program's exit statuses into an enum #906

Open

Description

Follow-up to #875, from its review. It waits for #875 to merge.

Summary

runtime-adapter-host reports how a command ended through its exit status, which its module documentation, tests/runtime-adapter/README.md, and its tests rely on. The statuses are defined in four ways, across two files:

Status Meaning Definition
0 the command did what it was asked ExitCode::SUCCESS
1 the command failed, after a diagnostic on standard error ExitCode::FAILURE
2 a usage error the literal ExitCode::from(2) in main
3 reattach finds the VM mismatched MISMATCHED
4 the guest reported that a stage of the root failed, and the VM ended with the stage's status and a complete teardown ROOT_FAILED
5 the step hook ended a launch hook::HOOK_EXIT, through std::process::exit
6 the guest failed a mapping of the table, and the VM stopped gracefully, with success and a complete teardown TABLE_FAILED

Nothing ties them together: a new status could take a number that another one already has, a reader has to collect them from the binary's constants, main, and the hook module, and the tests repeat the numbers, as tests/vm_layered.rs does with a ROOT_FAILED of its own.

Proposal

  • Add an enum of the host program's exit statuses, for example HostExit, with a variant for each status above and its number in one place, such as a #[repr(u8)] enum with impl From<HostExit> for std::process::ExitCode.
  • Make the commands return it, in place of the ExitCodes that they build from constants and literals, and make the step hook exit with its value for status 5.
  • Define it in the adapter's library, beside the step hook, so that the tests name the statuses instead of repeating their numbers.

Requirements

  • Keep each status's number and meaning: the scenarios and the VM suites check them.
  • Keep the binary's module documentation and tests/runtime-adapter/README.md in step with the enum.

Validation

The runtime adapter's protocol-only and host-only checks in check-nvx-rs, on Linux and Windows, and its VM suites, vm_layered, vm_restart, and vm_steps, which CI runs on KVM, MSHV, and WHP.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions