Merge pull request #1472 from jodh-intel/unbreak-agent-ctl

agent-ctl: Unbreak build
This commit is contained in:
James O. D. Hunt 2021-03-08 10:32:22 +00:00 committed by GitHub
commit 83d5a49941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 256 additions and 311 deletions

View File

@ -66,3 +66,6 @@ jobs:
- name: Run agent unit tests
run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/src/agent && make check
- name: Build agent-ctl tool (must be buildable against current agent)
run: |
cd ${GOPATH}/src/github.com/kata-containers/kata-containers/tools/agent-ctl && make

View File

@ -30,7 +30,7 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -76,7 +76,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -140,19 +140,19 @@ dependencies = [
[[package]]
name = "bytes"
version = "0.5.6"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "caps"
version = "0.3.4"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf6a638a1f7f409f1e545ff0036b8aa5541692c775dd36b48b75bbde50d83d1c"
checksum = "d092fbb6657fb1f98a7da70c14335ac97e5a9477e1a8156d4bbf19a3a7aece51"
dependencies = [
"errno",
"error-chain",
"libc",
"thiserror",
]
[[package]]
@ -267,7 +267,7 @@ checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
dependencies = [
"libc",
"redox_users",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -284,7 +284,7 @@ checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371"
dependencies = [
"errno-dragonfly",
"libc",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -297,15 +297,6 @@ dependencies = [
"libc",
]
[[package]]
name = "error-chain"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd"
dependencies = [
"version_check",
]
[[package]]
name = "failure"
version = "0.1.8"
@ -321,28 +312,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.3.8"
@ -501,7 +470,7 @@ dependencies = [
"futures-core",
"inotify-sys",
"libc",
"tokio 1.0.1",
"tokio",
]
[[package]]
@ -562,16 +531,6 @@ dependencies = [
"ttrpc",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -626,25 +585,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow 0.2.2",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]]
name = "mio"
version = "0.7.7"
@ -653,44 +593,9 @@ checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7"
dependencies = [
"libc",
"log",
"miow 0.3.6",
"miow",
"ntapi",
"winapi 0.3.8",
]
[[package]]
name = "mio-named-pipes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
dependencies = [
"log",
"mio 0.6.23",
"miow 0.3.6",
"winapi 0.3.8",
]
[[package]]
name = "mio-uds"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
dependencies = [
"iovec",
"libc",
"mio 0.6.23",
]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
"winapi",
]
[[package]]
@ -700,7 +605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"socket2",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -709,17 +614,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04b9f127583ed176e163fb9ec6f3e793b87e21deedd5734a69386a18a0151"
[[package]]
name = "net2"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.8",
]
[[package]]
name = "nix"
version = "0.16.1"
@ -758,6 +652,18 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
dependencies = [
"bitflags",
"cc",
"cfg-if 1.0.0",
"libc",
]
[[package]]
name = "nom"
version = "2.2.1"
@ -770,7 +676,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2"
dependencies = [
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -792,16 +698,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "object"
version = "0.21.1"
@ -872,12 +768,6 @@ dependencies = [
"syn 1.0.58",
]
[[package]]
name = "pin-project-lite"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
[[package]]
name = "pin-project-lite"
version = "0.2.1"
@ -1135,7 +1025,16 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi 0.3.8",
"winapi",
]
[[package]]
name = "rlimit"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e7148757b4951f04391d2b301b2e3597d504c4d2434212d542b73c1a6b3f847"
dependencies = [
"libc",
]
[[package]]
@ -1178,7 +1077,6 @@ dependencies = [
"inotify",
"lazy_static",
"libc",
"mio 0.6.23",
"nix 0.17.0",
"oci",
"path-absolutize",
@ -1186,6 +1084,7 @@ dependencies = [
"protobuf",
"protocols",
"regex",
"rlimit",
"scan_fmt",
"scopeguard",
"serde",
@ -1194,7 +1093,7 @@ dependencies = [
"slog",
"slog-scope",
"tempfile",
"tokio 0.2.24",
"tokio",
]
[[package]]
@ -1334,7 +1233,7 @@ checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [
"cfg-if 1.0.0",
"libc",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -1382,7 +1281,7 @@ dependencies = [
"rand",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.8",
"winapi",
]
[[package]]
@ -1430,49 +1329,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
"libc",
"winapi 0.3.8",
"winapi",
]
[[package]]
name = "tokio"
version = "0.2.24"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48"
dependencies = [
"bytes 0.5.6",
"fnv",
"futures-core",
"lazy_static",
"libc",
"memchr",
"mio 0.6.23",
"mio-named-pipes",
"mio-uds",
"num_cpus",
"pin-project-lite 0.1.11",
"signal-hook-registry",
"slab",
"tokio-macros",
"winapi 0.3.8",
]
[[package]]
name = "tokio"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d258221f566b6c803c7b4714abadc080172b272090cdc5e244a6d4dd13c3a6bd"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
dependencies = [
"autocfg",
"bytes 1.0.1",
"libc",
"mio 0.7.7",
"pin-project-lite 0.2.1",
"memchr",
"mio",
"once_cell",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "0.2.6"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a"
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
@ -1481,25 +1363,22 @@ dependencies = [
[[package]]
name = "tokio-vsock"
version = "0.2.2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "547a35667d4d842422da7f5528612321770f2f640e7fd5df0431de7b717fb2b4"
checksum = "70c401a3d0e82328c6fa900e9e2c4152737a4caa304558b762f0154a8b306456"
dependencies = [
"bytes 0.4.12",
"futures",
"iovec",
"libc",
"mio 0.6.23",
"nix 0.17.0",
"tokio 0.2.24",
"tokio",
"vsock",
]
[[package]]
name = "ttrpc"
version = "0.4.14"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc512242eee1f113eadd48087dd97cbf807ccae4820006e7a890044044399c51"
checksum = "ff9ad10daac7027ac1e4c46326abc301349ab9b4006e931e9f7cb0feeb9a2096"
dependencies = [
"async-trait",
"byteorder",
@ -1510,15 +1389,15 @@ dependencies = [
"protobuf",
"protobuf-codegen-pure",
"thiserror",
"tokio 0.2.24",
"tokio",
"tokio-vsock",
]
[[package]]
name = "ttrpc-codegen"
version = "0.1.2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e8844d7a8351fa833bea811f826401bec020b233e60a7c0a8f313f764ce5a5"
checksum = "809eda4e459820237104e4b61d6b41bbe6c9e1ce6adf4057955e6e6722a90408"
dependencies = [
"protobuf",
"protobuf-codegen",
@ -1528,9 +1407,9 @@ dependencies = [
[[package]]
name = "ttrpc-compiler"
version = "0.3.2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d290e64bdb994926d102f2983cc6550ece0778c8430253dc2de4e71cbf5285d9"
checksum = "8c2f2ce8c9a6e9422d0714bc8058b705d503fc9d028e69fae2236050c4721d75"
dependencies = [
"derive-new",
"prost",
@ -1571,12 +1450,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "void"
version = "1.0.2"
@ -1585,12 +1458,12 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "vsock"
version = "0.2.1"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dba063357047c0f2216c7c653879ea4e5e198d0c3cde7efa37ebfd9039b48491"
checksum = "50e2ef09834e1d203d24556512c0e58e66de203440bd9d74c30a33f7240091c6"
dependencies = [
"libc",
"nix 0.17.0",
"nix 0.19.1",
]
[[package]]
@ -1609,12 +1482,6 @@ dependencies = [
"libc",
]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.8"
@ -1625,12 +1492,6 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
@ -1642,13 +1503,3 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]

View File

@ -29,7 +29,7 @@ protobuf = "2.14.0"
nix = "0.17.0"
libc = "0.2.69"
# XXX: Must be the same as the version used by the agent
ttrpc = { version = "0.4.14" }
ttrpc = { version = "0.5.0" }
# For parsing timeouts
humantime = "2.0.0"

View File

@ -13,7 +13,7 @@ clean:
test:
install:
install:
check:

View File

@ -22,6 +22,15 @@ use std::os::unix::net::UnixStream;
use std::thread::sleep;
use std::time::Duration;
use ttrpc;
use ttrpc::context::Context;
// Hack until the actual Context type supports this.
fn clone_context(ctx: &Context) -> Context {
Context {
metadata: ctx.metadata.clone(),
timeout_nano: ctx.timeout_nano,
}
}
// Agent command handler type
//
@ -32,7 +41,7 @@ use ttrpc;
// - 'options' can be read and written to, allowing commands to pass state to
// each other via well-known option names.
type AgentCmdFp = fn(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
health: &HealthClient,
options: &mut Options,
@ -40,7 +49,7 @@ type AgentCmdFp = fn(
) -> Result<()>;
// Builtin command handler type
type BuiltinCmdFp = fn(cfg: &Config, options: &mut Options, args: &str) -> (Result<()>, bool);
type BuiltinCmdFp = fn(args: &str) -> (Result<()>, bool);
enum ServiceType {
Agent,
@ -521,6 +530,8 @@ pub fn client(cfg: &Config, commands: Vec<&str>) -> Result<()> {
let mut options = Options::new();
let ttrpc_ctx = ttrpc::context::with_timeout(cfg.timeout_nano);
// Special-case loading the OCI config file so it is accessible
// to all commands.
let oci_spec_json = utils::get_oci_spec_json(cfg)?;
@ -533,7 +544,7 @@ pub fn client(cfg: &Config, commands: Vec<&str>) -> Result<()> {
"server-address" => cfg.server_address.to_string());
if cfg.interactive {
return interactive_client_loop(&cfg, &mut options, &client, &health);
return interactive_client_loop(&cfg, &mut options, &client, &health, &ttrpc_ctx);
}
let mut repeat_count = 1;
@ -544,8 +555,15 @@ pub fn client(cfg: &Config, commands: Vec<&str>) -> Result<()> {
continue;
}
let (result, shutdown) =
handle_cmd(&cfg, &client, &health, repeat_count, &mut options, &cmd);
let (result, shutdown) = handle_cmd(
&cfg,
&client,
&health,
&ttrpc_ctx,
repeat_count,
&mut options,
&cmd,
);
if result.is_err() {
return result;
}
@ -566,6 +584,7 @@ fn handle_cmd(
cfg: &Config,
client: &AgentServiceClient,
health: &HealthClient,
ctx: &Context,
repeat_count: i64,
options: &mut Options,
cmdline: &str,
@ -609,9 +628,9 @@ fn handle_cmd(
info!(sl!(), "Run command {:} ({})", cmd, count_msg);
if first.is_lowercase() {
result = handle_builtin_cmd(cfg, options, cmd, &args);
result = handle_builtin_cmd(cmd, &args);
} else {
result = handle_agent_cmd(cfg, client, health, options, cmd, &args);
result = handle_agent_cmd(ctx, client, health, options, cmd, &args);
}
if result.0.is_err() {
@ -645,24 +664,19 @@ fn handle_cmd(
}
}
fn handle_builtin_cmd(
cfg: &Config,
options: &mut Options,
cmd: &str,
args: &str,
) -> (Result<()>, bool) {
fn handle_builtin_cmd(cmd: &str, args: &str) -> (Result<()>, bool) {
let f = match get_builtin_cmd_func(&cmd) {
Ok(fp) => fp,
Err(e) => return (Err(e), false),
};
f(cfg, options, &args)
f(&args)
}
// Execute the ttRPC specified by the first field of "line". Return a result
// along with a bool which if set means the client should shutdown.
fn handle_agent_cmd(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
health: &HealthClient,
options: &mut Options,
@ -674,7 +688,7 @@ fn handle_agent_cmd(
Err(e) => return (Err(e), false),
};
let result = f(cfg, client, health, options, &args);
let result = f(ctx, client, health, options, &args);
if result.is_err() {
return (result, false);
}
@ -689,8 +703,9 @@ fn interactive_client_loop(
options: &mut Options,
client: &AgentServiceClient,
health: &HealthClient,
ctx: &Context,
) -> Result<()> {
let result = builtin_cmd_list(cfg, options, "");
let result = builtin_cmd_list("");
if result.0.is_err() {
return result.0;
}
@ -710,7 +725,8 @@ fn interactive_client_loop(
continue;
}
let (result, shutdown) = handle_cmd(cfg, client, health, repeat_count, options, &cmdline);
let (result, shutdown) =
handle_cmd(cfg, client, health, ctx, repeat_count, options, &cmdline);
if result.is_err() {
return result;
}
@ -744,7 +760,7 @@ fn readline(prompt: &str) -> std::result::Result<String, String> {
}
fn agent_cmd_health_check(
cfg: &Config,
ctx: &Context,
_client: &AgentServiceClient,
health: &HealthClient,
_options: &mut Options,
@ -752,13 +768,15 @@ fn agent_cmd_health_check(
) -> Result<()> {
let mut req = CheckRequest::default();
let ctx = clone_context(ctx);
// value unused
req.set_service("".to_string());
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = health
.check(&req, cfg.timeout_nano)
.check(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -768,7 +786,7 @@ fn agent_cmd_health_check(
}
fn agent_cmd_health_version(
cfg: &Config,
ctx: &Context,
_client: &AgentServiceClient,
health: &HealthClient,
_options: &mut Options,
@ -777,13 +795,15 @@ fn agent_cmd_health_version(
// XXX: Yes, the API is actually broken!
let mut req = CheckRequest::default();
let ctx = clone_context(ctx);
// value unused
req.set_service("".to_string());
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = health
.version(&req, cfg.timeout_nano)
.version(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -793,7 +813,7 @@ fn agent_cmd_health_version(
}
fn agent_cmd_sandbox_create(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -801,13 +821,15 @@ fn agent_cmd_sandbox_create(
) -> Result<()> {
let mut req = CreateSandboxRequest::default();
let ctx = clone_context(ctx);
let sid = utils::get_option("sid", options, args);
req.set_sandbox_id(sid);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.create_sandbox(&req, cfg.timeout_nano)
.create_sandbox(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -817,7 +839,7 @@ fn agent_cmd_sandbox_create(
}
fn agent_cmd_sandbox_destroy(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -825,10 +847,12 @@ fn agent_cmd_sandbox_destroy(
) -> Result<()> {
let req = DestroySandboxRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.destroy_sandbox(&req, cfg.timeout_nano)
.destroy_sandbox(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -838,7 +862,7 @@ fn agent_cmd_sandbox_destroy(
}
fn agent_cmd_container_create(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -846,6 +870,8 @@ fn agent_cmd_container_create(
) -> Result<()> {
let mut req = CreateContainerRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -860,7 +886,7 @@ fn agent_cmd_container_create(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.create_container(&req, cfg.timeout_nano)
.create_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -870,7 +896,7 @@ fn agent_cmd_container_create(
}
fn agent_cmd_container_remove(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -880,12 +906,14 @@ fn agent_cmd_container_remove(
let cid = utils::get_option("cid", options, args);
let ctx = clone_context(ctx);
req.set_container_id(cid);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.remove_container(&req, cfg.timeout_nano)
.remove_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -895,7 +923,7 @@ fn agent_cmd_container_remove(
}
fn agent_cmd_container_exec(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -903,17 +931,24 @@ fn agent_cmd_container_exec(
) -> Result<()> {
let mut req = ExecProcessRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
let grpc_spec = utils::get_grpc_spec(options, &cid).map_err(|e| anyhow!(e))?;
let bundle_dir = options
.get("bundle-dir")
.ok_or("BUG: bundle-dir missing")
.map_err(|e| anyhow!(e))?;
let process = grpc_spec
.Process
.into_option()
.ok_or(format!(
"failed to get process from OCI spec: {}",
cfg.bundle_dir
bundle_dir,
))
.map_err(|e| anyhow!(e))?;
@ -924,7 +959,7 @@ fn agent_cmd_container_exec(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.exec_process(&req, cfg.timeout_nano)
.exec_process(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -934,7 +969,7 @@ fn agent_cmd_container_exec(
}
fn agent_cmd_container_stats(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -942,6 +977,8 @@ fn agent_cmd_container_stats(
) -> Result<()> {
let mut req = StatsContainerRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
req.set_container_id(cid);
@ -949,7 +986,7 @@ fn agent_cmd_container_stats(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.stats_container(&req, cfg.timeout_nano)
.stats_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -959,7 +996,7 @@ fn agent_cmd_container_stats(
}
fn agent_cmd_container_pause(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -967,6 +1004,8 @@ fn agent_cmd_container_pause(
) -> Result<()> {
let mut req = PauseContainerRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
req.set_container_id(cid);
@ -974,7 +1013,7 @@ fn agent_cmd_container_pause(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.pause_container(&req, cfg.timeout_nano)
.pause_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -984,7 +1023,7 @@ fn agent_cmd_container_pause(
}
fn agent_cmd_container_resume(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -994,12 +1033,14 @@ fn agent_cmd_container_resume(
let cid = utils::get_option("cid", options, args);
let ctx = clone_context(ctx);
req.set_container_id(cid);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.resume_container(&req, cfg.timeout_nano)
.resume_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1009,7 +1050,7 @@ fn agent_cmd_container_resume(
}
fn agent_cmd_container_start(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1017,6 +1058,8 @@ fn agent_cmd_container_start(
) -> Result<()> {
let mut req = StartContainerRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
req.set_container_id(cid);
@ -1024,7 +1067,7 @@ fn agent_cmd_container_start(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.start_container(&req, cfg.timeout_nano)
.start_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1034,7 +1077,7 @@ fn agent_cmd_container_start(
}
fn agent_cmd_sandbox_get_guest_details(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1042,12 +1085,14 @@ fn agent_cmd_sandbox_get_guest_details(
) -> Result<()> {
let mut req = GuestDetailsRequest::default();
let ctx = clone_context(ctx);
req.set_mem_block_size(true);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.get_guest_details(&req, cfg.timeout_nano)
.get_guest_details(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1057,7 +1102,7 @@ fn agent_cmd_sandbox_get_guest_details(
}
fn agent_cmd_container_list_processes(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1065,6 +1110,8 @@ fn agent_cmd_container_list_processes(
) -> Result<()> {
let mut req = ListProcessesRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let mut list_format = utils::get_option("format", options, args);
@ -1079,7 +1126,7 @@ fn agent_cmd_container_list_processes(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.list_processes(&req, cfg.timeout_nano)
.list_processes(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1089,7 +1136,7 @@ fn agent_cmd_container_list_processes(
}
fn agent_cmd_container_wait_process(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1097,6 +1144,8 @@ fn agent_cmd_container_wait_process(
) -> Result<()> {
let mut req = WaitProcessRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1106,7 +1155,7 @@ fn agent_cmd_container_wait_process(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.wait_process(&req, cfg.timeout_nano)
.wait_process(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1116,7 +1165,7 @@ fn agent_cmd_container_wait_process(
}
fn agent_cmd_container_signal_process(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1124,6 +1173,8 @@ fn agent_cmd_container_signal_process(
) -> Result<()> {
let mut req = SignalProcessRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1143,7 +1194,7 @@ fn agent_cmd_container_signal_process(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.signal_process(&req, cfg.timeout_nano)
.signal_process(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1153,7 +1204,7 @@ fn agent_cmd_container_signal_process(
}
fn agent_cmd_sandbox_tracing_start(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1161,10 +1212,12 @@ fn agent_cmd_sandbox_tracing_start(
) -> Result<()> {
let req = StartTracingRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.start_tracing(&req, cfg.timeout_nano)
.start_tracing(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1174,7 +1227,7 @@ fn agent_cmd_sandbox_tracing_start(
}
fn agent_cmd_sandbox_tracing_stop(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1182,10 +1235,12 @@ fn agent_cmd_sandbox_tracing_stop(
) -> Result<()> {
let req = StopTracingRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.stop_tracing(&req, cfg.timeout_nano)
.stop_tracing(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1195,7 +1250,7 @@ fn agent_cmd_sandbox_tracing_stop(
}
fn agent_cmd_sandbox_update_interface(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1203,9 +1258,11 @@ fn agent_cmd_sandbox_update_interface(
) -> Result<()> {
let req = UpdateInterfaceRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.update_interface(&req, cfg.timeout_nano)
.update_interface(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
// FIXME: Implement 'UpdateInterface' fully.
@ -1218,7 +1275,7 @@ fn agent_cmd_sandbox_update_interface(
}
fn agent_cmd_sandbox_update_routes(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1226,10 +1283,12 @@ fn agent_cmd_sandbox_update_routes(
) -> Result<()> {
let req = UpdateRoutesRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.update_routes(&req, cfg.timeout_nano)
.update_routes(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
// FIXME: Implement 'UpdateRoutes' fully.
@ -1242,7 +1301,7 @@ fn agent_cmd_sandbox_update_routes(
}
fn agent_cmd_sandbox_list_interfaces(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1250,10 +1309,12 @@ fn agent_cmd_sandbox_list_interfaces(
) -> Result<()> {
let req = ListInterfacesRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.list_interfaces(&req, cfg.timeout_nano)
.list_interfaces(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1263,7 +1324,7 @@ fn agent_cmd_sandbox_list_interfaces(
}
fn agent_cmd_sandbox_list_routes(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1271,10 +1332,12 @@ fn agent_cmd_sandbox_list_routes(
) -> Result<()> {
let req = ListRoutesRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.list_routes(&req, cfg.timeout_nano)
.list_routes(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1284,7 +1347,7 @@ fn agent_cmd_sandbox_list_routes(
}
fn agent_cmd_container_tty_win_resize(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1292,6 +1355,8 @@ fn agent_cmd_container_tty_win_resize(
) -> Result<()> {
let mut req = TtyWinResizeRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1320,7 +1385,7 @@ fn agent_cmd_container_tty_win_resize(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.tty_win_resize(&req, cfg.timeout_nano)
.tty_win_resize(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1330,7 +1395,7 @@ fn agent_cmd_container_tty_win_resize(
}
fn agent_cmd_container_close_stdin(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1338,6 +1403,8 @@ fn agent_cmd_container_close_stdin(
) -> Result<()> {
let mut req = CloseStdinRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1347,7 +1414,7 @@ fn agent_cmd_container_close_stdin(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.close_stdin(&req, cfg.timeout_nano)
.close_stdin(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1357,7 +1424,7 @@ fn agent_cmd_container_close_stdin(
}
fn agent_cmd_container_read_stdout(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1365,6 +1432,8 @@ fn agent_cmd_container_read_stdout(
) -> Result<()> {
let mut req = ReadStreamRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1383,7 +1452,7 @@ fn agent_cmd_container_read_stdout(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.read_stdout(&req, cfg.timeout_nano)
.read_stdout(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1393,7 +1462,7 @@ fn agent_cmd_container_read_stdout(
}
fn agent_cmd_container_read_stderr(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1401,6 +1470,8 @@ fn agent_cmd_container_read_stderr(
) -> Result<()> {
let mut req = ReadStreamRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1419,7 +1490,7 @@ fn agent_cmd_container_read_stderr(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.read_stderr(&req, cfg.timeout_nano)
.read_stderr(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1429,7 +1500,7 @@ fn agent_cmd_container_read_stderr(
}
fn agent_cmd_container_write_stdin(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1437,6 +1508,8 @@ fn agent_cmd_container_write_stdin(
) -> Result<()> {
let mut req = WriteStreamRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
let exec_id = utils::get_option("exec_id", options, args);
@ -1450,7 +1523,7 @@ fn agent_cmd_container_write_stdin(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.write_stdin(&req, cfg.timeout_nano)
.write_stdin(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1460,7 +1533,7 @@ fn agent_cmd_container_write_stdin(
}
fn agent_cmd_sandbox_get_metrics(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1468,10 +1541,12 @@ fn agent_cmd_sandbox_get_metrics(
) -> Result<()> {
let req = GetMetricsRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.get_metrics(&req, cfg.timeout_nano)
.get_metrics(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1481,7 +1556,7 @@ fn agent_cmd_sandbox_get_metrics(
}
fn agent_cmd_sandbox_get_oom_event(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1489,10 +1564,12 @@ fn agent_cmd_sandbox_get_oom_event(
) -> Result<()> {
let req = GetOOMEventRequest::default();
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.get_oom_event(&req, cfg.timeout_nano)
.get_oom_event(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1502,7 +1579,7 @@ fn agent_cmd_sandbox_get_oom_event(
}
fn agent_cmd_sandbox_copy_file(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1510,6 +1587,8 @@ fn agent_cmd_sandbox_copy_file(
) -> Result<()> {
let mut req = CopyFileRequest::default();
let ctx = clone_context(ctx);
let path = utils::get_option("path", options, args);
if path != "" {
req.set_path(path);
@ -1582,7 +1661,7 @@ fn agent_cmd_sandbox_copy_file(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.copy_file(&req, cfg.timeout_nano)
.copy_file(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1592,7 +1671,7 @@ fn agent_cmd_sandbox_copy_file(
}
fn agent_cmd_sandbox_reseed_random_dev(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1600,6 +1679,8 @@ fn agent_cmd_sandbox_reseed_random_dev(
) -> Result<()> {
let mut req = ReseedRandomDevRequest::default();
let ctx = clone_context(ctx);
let str_data = utils::get_option("data", options, args);
let data = utils::str_to_bytes(&str_data)?;
@ -1608,7 +1689,7 @@ fn agent_cmd_sandbox_reseed_random_dev(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.reseed_random_dev(&req, cfg.timeout_nano)
.reseed_random_dev(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1618,7 +1699,7 @@ fn agent_cmd_sandbox_reseed_random_dev(
}
fn agent_cmd_sandbox_online_cpu_mem(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1626,6 +1707,8 @@ fn agent_cmd_sandbox_online_cpu_mem(
) -> Result<()> {
let mut req = OnlineCPUMemRequest::default();
let ctx = clone_context(ctx);
let wait_str = utils::get_option("wait", options, args);
if wait_str != "" {
@ -1659,7 +1742,7 @@ fn agent_cmd_sandbox_online_cpu_mem(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.online_cpu_mem(&req, cfg.timeout_nano)
.online_cpu_mem(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1669,7 +1752,7 @@ fn agent_cmd_sandbox_online_cpu_mem(
}
fn agent_cmd_sandbox_set_guest_date_time(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1677,6 +1760,8 @@ fn agent_cmd_sandbox_set_guest_date_time(
) -> Result<()> {
let mut req = SetGuestDateTimeRequest::default();
let ctx = clone_context(ctx);
let secs_str = utils::get_option("sec", options, args);
if secs_str != "" {
@ -1700,7 +1785,7 @@ fn agent_cmd_sandbox_set_guest_date_time(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.set_guest_date_time(&req, cfg.timeout_nano)
.set_guest_date_time(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1710,7 +1795,7 @@ fn agent_cmd_sandbox_set_guest_date_time(
}
fn agent_cmd_sandbox_add_arp_neighbors(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
@ -1718,13 +1803,15 @@ fn agent_cmd_sandbox_add_arp_neighbors(
) -> Result<()> {
let req = AddARPNeighborsRequest::default();
let ctx = clone_context(ctx);
// FIXME: Implement fully.
eprintln!("FIXME: 'AddARPNeighbors' not fully implemented");
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.add_arp_neighbors(&req, cfg.timeout_nano)
.add_arp_neighbors(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1734,7 +1821,7 @@ fn agent_cmd_sandbox_add_arp_neighbors(
}
fn agent_cmd_sandbox_update_container(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1742,6 +1829,8 @@ fn agent_cmd_sandbox_update_container(
) -> Result<()> {
let mut req = UpdateContainerRequest::default();
let ctx = clone_context(ctx);
let cid = utils::get_option("cid", options, args);
req.set_container_id(cid);
@ -1752,7 +1841,7 @@ fn agent_cmd_sandbox_update_container(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.update_container(&req, cfg.timeout_nano)
.update_container(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1762,7 +1851,7 @@ fn agent_cmd_sandbox_update_container(
}
fn agent_cmd_sandbox_mem_hotplug_by_probe(
cfg: &Config,
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
options: &mut Options,
@ -1770,6 +1859,8 @@ fn agent_cmd_sandbox_mem_hotplug_by_probe(
) -> Result<()> {
let mut req = MemHotplugByProbeRequest::default();
let ctx = clone_context(ctx);
// Expected to be a comma separated list of hex addresses
let addr_list = utils::get_option("memHotplugProbeAddr", options, args);
@ -1796,7 +1887,7 @@ fn agent_cmd_sandbox_mem_hotplug_by_probe(
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.mem_hotplug_by_probe(&req, cfg.timeout_nano)
.mem_hotplug_by_probe(ctx, &req)
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
@ -1806,7 +1897,7 @@ fn agent_cmd_sandbox_mem_hotplug_by_probe(
}
#[inline]
fn builtin_cmd_repeat(_cfg: &Config, _options: &mut Options, _args: &str) -> (Result<()>, bool) {
fn builtin_cmd_repeat(_args: &str) -> (Result<()>, bool) {
// XXX: NOP implementation. Due to the way repeat has to work, providing a
// handler like this is "too late" to be useful. However, a handler
// is required as "repeat" is a valid command.
@ -1818,7 +1909,7 @@ fn builtin_cmd_repeat(_cfg: &Config, _options: &mut Options, _args: &str) -> (Re
(Ok(()), false)
}
fn builtin_cmd_sleep(_cfg: &Config, _options: &mut Options, args: &str) -> (Result<()>, bool) {
fn builtin_cmd_sleep(args: &str) -> (Result<()>, bool) {
let ns = match utils::human_time_to_ns(args) {
Ok(t) => t,
Err(e) => return (Err(e), false),
@ -1829,17 +1920,17 @@ fn builtin_cmd_sleep(_cfg: &Config, _options: &mut Options, args: &str) -> (Resu
(Ok(()), false)
}
fn builtin_cmd_echo(_cfg: &Config, _options: &mut Options, args: &str) -> (Result<()>, bool) {
fn builtin_cmd_echo(args: &str) -> (Result<()>, bool) {
println!("{}", args);
(Ok(()), false)
}
fn builtin_cmd_quit(_cfg: &Config, _options: &mut Options, _args: &str) -> (Result<()>, bool) {
fn builtin_cmd_quit(_args: &str) -> (Result<()>, bool) {
(Ok(()), true)
}
fn builtin_cmd_list(_cfg: &Config, _options: &mut Options, _args: &str) -> (Result<()>, bool) {
fn builtin_cmd_list(_args: &str) -> (Result<()>, bool) {
let cmds = get_all_cmd_details();
cmds.iter().for_each(|n| println!(" - {}", n));