Skip to content

Commit 5be5f6f

Browse files
Merge #375
375: [PLAT-421] Improve error handling r=Pagten a=raoulstrackx Co-authored-by: Raoul Strackx <[email protected]>
2 parents 73a31d9 + 3cf7191 commit 5be5f6f

File tree

7 files changed

+257
-208
lines changed

7 files changed

+257
-208
lines changed

Cargo.lock

Lines changed: 33 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fortanix-vme/ci-fortanixvme.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function setup_environment {
2929
function start_runner {
3030
pushd fortanix-vme-runner
3131
cargo +${toolchain_version} --locked build
32-
cargo +${toolchain_version} --locked run &
32+
log=$(mktemp /tmp/ci-fortanixvme.log.XXXXX)
33+
RUST_LOG=debug cargo +${toolchain_version} --locked run 2> ${log} &
3334

3435
if [[ -v AWS_VM ]]; then
3536
ssh ubuntu@${AWS_VM} 'mkdir -p /home/ubuntu/ci-fortanixvme'

fortanix-vme/fortanix-vme-abi/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-all
1212
compiler_builtins = { version = "0.1.0", optional = true }
1313
# Avoid using patch section due to https://github.com/rust-lang/cargo/issues/10031
1414
serde = { git = "https://github.com/fortanix/serde.git", branch = "master", default-features = false, features = ["derive", "alloc"] }
15+
vsock = { version = "0.2.4", optional = true }
1516

1617
[features]
17-
std = ["serde/std"]
18+
std = ["serde/std", "vsock"]
1819
default = ["std"]
1920
docs = []
2021
rustc-dep-of-std = ["core", "alloc", "compiler_builtins/rustc-dep-of-std", "serde/rustc-dep-of-std"]

fortanix-vme/fortanix-vme-abi/src/lib.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ extern crate std;
77
use alloc::string::String;
88
use serde::{Deserialize, Serialize};
99
#[cfg(feature="std")]
10-
use std::net::SocketAddr;
10+
use {
11+
std::io,
12+
std::net::SocketAddr,
13+
vsock::Error as VsockError,
14+
};
1115

1216
pub const SERVER_PORT: u32 = 10000;
1317

@@ -108,6 +112,33 @@ pub enum Response {
108112
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
109113
pub enum Error {
110114
ConnectionNotFound,
115+
SystemError(i32),
116+
Unknown,
117+
VsockError,
118+
}
119+
120+
#[cfg(feature="std")]
121+
impl From<io::Error> for Error {
122+
fn from(error: io::Error) -> Error {
123+
if let Some(errno) = error.raw_os_error() {
124+
Error::SystemError(errno)
125+
} else {
126+
Error::Unknown
127+
}
128+
}
129+
}
130+
131+
#[cfg(feature="std")]
132+
impl From<VsockError> for Error {
133+
fn from(error: VsockError) -> Error {
134+
match error {
135+
VsockError::EntropyError => Error::VsockError,
136+
VsockError::SystemError(errno) => Error::SystemError(errno),
137+
VsockError::WrongAddressType => Error::VsockError,
138+
VsockError::ZeroDurationTimeout => Error::VsockError,
139+
VsockError::ReservedPort => Error::VsockError,
140+
}
141+
}
111142
}
112143

113144
#[cfg(test)]

fortanix-vme/fortanix-vme-runner/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ edition = "2018"
55
authors = ["Fortanix, Inc."]
66

77
[dependencies]
8+
env_logger = "0.8.4"
89
fnv = "1.0.7"
910
fortanix-vme-abi = { path = "../fortanix-vme-abi", features = ["std"] }
11+
log = "0.4.14"
1012
nix = "0.22.1"
1113
serde = { version = "1.0", features = ["derive"] }
1214
serde_cbor = { version = "0.11" }

0 commit comments

Comments
 (0)