Skip to content

Commit fdc0da7

Browse files
authored
chore(deps): upgrade youki, nix, and related crates (#598)
1 parent 8cddbe5 commit fdc0da7

10 files changed

Lines changed: 204 additions & 195 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fancy-regex = "0.14.0"
3131
futures-util = "0.3.28"
3232
heck = "0.5.0"
3333
lazy_static = "1.4.0"
34-
nix = "0.28.0"
34+
nix = "0.29.0"
3535
proc-macro2 = "1.0"
3636
proto = { path = "./proto" }
3737
proto-reader = { path = "./crates/proto-reader" }

auraed/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ fancy-regex = { workspace = true }
3838
futures = "0.3.28"
3939
ipnetwork = "0.21.1"
4040
iter_tools = "0.24.0"
41-
libc = "0.2.169" # TODO: Nix comes with libc, can we rely on that?
4241
lazy_static = { workspace = true }
43-
libcgroups = { git = "https://github.com/containers/youki", tag = "v0.5.2", default-features = false, features = [
42+
libcgroups = { version = "0.5.7", default-features = false, features = [
4443
"v2",
4544
] }
46-
libcontainer = { git = "https://github.com/containers/youki", tag = "v0.5.2", default-features = false, features = [
45+
libcontainer = { version = "0.5.7", default-features = false, features = [
4746
"v2",
4847
] }
4948
log = "0.4.21"
5049
netlink-packet-route = "0.28.0"
51-
nix = { workspace = true, features = ["sched", "mount", "signal", "net"] }
52-
oci-spec = "0.7.1"
50+
nix = { workspace = true, features = ["sched", "mount", "signal", "net", "dir", "user", "process", "hostname"] }
51+
oci-spec = "0.8.4"
5352
once_cell = "1"
5453
procfs = "0.17.0"
5554
proto = { workspace = true }

auraed/src/cells/cell_service/cells/nested_auraed/isolation_controls.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* SPDX-License-Identifier: Apache-2.0 *
1414
\* -------------------------------------------------------------------------- */
1515

16-
use libc::c_char;
17-
use std::io::{self};
16+
use nix::libc::{c_char, setdomainname};
17+
use std::io;
1818
use std::path::PathBuf;
1919
use tracing::info;
2020

@@ -43,13 +43,12 @@ impl Isolation {
4343
// Bind mount root:root with MS_REC and MS_PRIVATE flags
4444
// We are not sharing the mounts at this point (in other words we are in a new mount namespace)
4545
nix::mount::mount(
46-
None::<&str>, // ignored
46+
None::<&str>,
4747
"/",
48-
None::<&str>, // ignored
48+
None::<&str>,
4949
nix::mount::MsFlags::MS_PRIVATE | nix::mount::MsFlags::MS_REC,
50-
None::<&str>, // ignored
51-
)
52-
.map_err(|e| io::Error::from_raw_os_error(e as i32))?;
50+
None::<&str>,
51+
)?;
5352
info!("Isolation: Mounted root dir (/) in cell");
5453
Ok(())
5554
}
@@ -62,37 +61,23 @@ impl Isolation {
6261
return Ok(());
6362
}
6463

65-
//Mount proc in the new pid and mount namespace
64+
// Mount proc in the new pid and mount namespace
6665
let target = PathBuf::from("/proc");
6766
nix::mount::mount(
6867
Some("/proc"),
6968
&target,
7069
Some("proc"),
7170
nix::mount::MsFlags::empty(),
7271
None::<&str>,
73-
)
74-
.map_err(|e| io::Error::from_raw_os_error(e as i32))?;
72+
)?;
7573

7674
// We are in a new UTS namespace so we manage hostname and domainname.
77-
// hostname and domainname both allow null bytes and are not required to be null terminated.
78-
if unsafe {
79-
#[allow(trivial_casts)]
80-
libc::sethostname(
81-
self.name.as_ptr() as *const c_char,
82-
self.name.len(),
83-
)
84-
} == -1
85-
{
86-
return Err(io::Error::last_os_error());
87-
}
75+
nix::unistd::sethostname(&self.name)?;
8876

8977
// Set domainname
9078
if unsafe {
9179
#[allow(trivial_casts)]
92-
libc::setdomainname(
93-
self.name.as_ptr() as *const c_char,
94-
self.name.len(),
95-
)
80+
setdomainname(self.name.as_ptr() as *const c_char, self.name.len())
9681
} == -1
9782
{
9883
return Err(io::Error::last_os_error());

auraed/src/cells/cell_service/cells/nested_auraed/nested_auraed.rs

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ use crate::AURAED_RUNTIME;
1818
use client::AuraeSocket;
1919
use clone3::Flags;
2020
use nix::{
21+
errno::Errno,
2122
libc::SIGCHLD,
22-
sys::signal::{Signal, Signal::SIGKILL, Signal::SIGTERM},
23+
sys::{
24+
signal::{Signal, Signal::SIGKILL, Signal::SIGTERM},
25+
wait::{WaitStatus, waitpid},
26+
},
2327
unistd::Pid,
2428
};
2529
use std::path::PathBuf;
2630
use std::{
27-
io::{self, ErrorKind},
31+
io,
2832
os::unix::process::{CommandExt, ExitStatusExt},
2933
process::{Command, ExitStatus},
3034
};
@@ -136,9 +140,7 @@ impl NestedAuraed {
136140
}
137141

138142
// Execute the clone system call and create the new process with the relevant namespaces.
139-
match unsafe { clone.call() }
140-
.map_err(|e| io::Error::from_raw_os_error(e.0))?
141-
{
143+
match unsafe { clone.call() }? {
142144
0 => {
143145
// child
144146
let command = {
@@ -187,33 +189,67 @@ impl NestedAuraed {
187189
) -> io::Result<()> {
188190
let signal = signal.into();
189191
let pid = Pid::from_raw(self.process.pid);
190-
191-
nix::sys::signal::kill(pid, signal)
192-
.map_err(|e| io::Error::from_raw_os_error(e as i32))
192+
nix::sys::signal::kill(pid, signal)?;
193+
Ok(())
193194
}
194195

195196
fn wait(&mut self) -> io::Result<ExitStatus> {
196197
let pid = Pid::from_raw(self.process.pid);
197198

198-
let mut exit_status = 0;
199-
let _child_pid = loop {
200-
let res =
201-
unsafe { libc::waitpid(pid.as_raw(), &mut exit_status, 0) };
199+
let status = loop {
200+
match waitpid(pid, None) {
201+
Ok(status) => break status,
202+
Err(Errno::EINTR) => continue,
203+
Err(e) => return Err(e.into()),
204+
}
205+
};
202206

203-
if res == -1 {
204-
let err = io::Error::last_os_error();
205-
match err.kind() {
206-
ErrorKind::Interrupted => continue,
207-
_ => break Err(err),
207+
let exit_status = match status {
208+
WaitStatus::Exited(_, code) => {
209+
trace!("Pid {pid} exited with code {code}");
210+
ExitStatus::from_raw(code << 8)
211+
}
212+
WaitStatus::Signaled(_, sig, core_dumped) => {
213+
if core_dumped {
214+
error!("Pid {pid} killed by signal {sig} (core dumped)");
215+
} else {
216+
trace!("Pid {pid} killed by signal {sig}");
208217
}
218+
ExitStatus::from_raw(sig as i32)
209219
}
210-
211-
break Ok(res);
212-
}?;
213-
214-
let exit_status = ExitStatus::from_raw(exit_status);
215-
216-
trace!("Pid {pid} exited with status {exit_status}");
220+
WaitStatus::Stopped(_, sig) => {
221+
error!("Pid {pid} unexpectedly stopped by signal {sig}");
222+
return Err(io::Error::other(format!(
223+
"process {pid} stopped by signal {sig}"
224+
)));
225+
}
226+
WaitStatus::Continued(_) => {
227+
error!("Pid {pid} unexpectedly continued");
228+
return Err(io::Error::other(format!(
229+
"process {pid} continued unexpectedly"
230+
)));
231+
}
232+
WaitStatus::PtraceEvent(_, sig, event) => {
233+
error!(
234+
"Pid {pid} unexpected ptrace event {event} (signal {sig})"
235+
);
236+
return Err(io::Error::other(format!(
237+
"unexpected ptrace event for process {pid}"
238+
)));
239+
}
240+
WaitStatus::PtraceSyscall(_) => {
241+
error!("Pid {pid} unexpected ptrace syscall-stop");
242+
return Err(io::Error::other(format!(
243+
"unexpected ptrace syscall-stop for process {pid}"
244+
)));
245+
}
246+
WaitStatus::StillAlive => {
247+
error!("Pid {pid} still alive after waitpid");
248+
return Err(io::Error::other(format!(
249+
"process {pid} still alive after waitpid"
250+
)));
251+
}
252+
};
217253

218254
Ok(exit_status)
219255
}

auraed/src/cri/runtime_service.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,6 @@
1212
* Copyright 2022 - 2024, the aurae contributors *
1313
* SPDX-License-Identifier: Apache-2.0 *
1414
\* -------------------------------------------------------------------------- */
15-
/* -------------------------------------------------------------------------- *\
16-
* Apache 2.0 License Copyright © 2022-2023 The Aurae Authors *
17-
* *
18-
* +--------------------------------------------+ *
19-
* | █████╗ ██╗ ██╗██████╗ █████╗ ███████╗ | *
20-
* | ██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝ | *
21-
* | ███████║██║ ██║██████╔╝███████║█████╗ | *
22-
* | ██╔══██║██║ ██║██╔══██╗██╔══██║██╔══╝ | *
23-
* | ██║ ██║╚██████╔╝██║ ██║██║ ██║███████╗ | *
24-
* | ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ | *
25-
* +--------------------------------------------+ *
26-
* *
27-
* Distributed Systems Runtime *
28-
* *
29-
* -------------------------------------------------------------------------- *
30-
* *
31-
* Licensed under the Apache License, Version 2.0 (the "License"); *
32-
* you may not use this file except in compliance with the License. *
33-
* You may obtain a copy of the License at *
34-
* *
35-
* http://www.apache.org/licenses/LICENSE-2.0 *
36-
* *
37-
* Unless required by applicable law or agreed to in writing, software *
38-
* distributed under the License is distributed on an "AS IS" BASIS, *
39-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
40-
* See the License for the specific language governing permissions and *
41-
* limitations under the License. *
42-
* *
43-
\* -------------------------------------------------------------------------- */
4415

4516
#[allow(unused_imports)]
4617
use crate::cri::oci::AuraeOCIBuilder;
@@ -229,7 +200,6 @@ impl runtime_service_server::RuntimeService for RuntimeService {
229200
let container_status = proto::cri::ContainerStatus {
230201
id: sandbox_id,
231202
state: state as i32,
232-
233203
..Default::default()
234204
};
235205
Ok(Response::new(PodSandboxStatusResponse {

auraed/src/init/network/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
use futures::stream::TryStreamExt;
1717
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
18-
use libc::EEXIST;
1918
use netlink_packet_route::address::AddressAttribute;
2019
use netlink_packet_route::link::LinkAttribute;
20+
use nix::libc::EEXIST;
2121
use rtnetlink::{Handle, LinkUnspec, RouteMessageBuilder};
2222
use std::collections::HashMap;
2323
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

auraed/src/init/power.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{
2323
};
2424
use tracing::{info, trace, warn};
2525

26-
use ::libc;
26+
use nix::libc;
2727

2828
pub(crate) fn syscall_reboot(action: i32) {
2929
unsafe {

auraed/src/vms/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::sync::{
1818
};
1919

2020
use hypervisor::Hypervisor;
21-
use libc::EFD_NONBLOCK;
21+
use nix::libc::EFD_NONBLOCK;
2222
use vmm::{VmmThreadHandle, api::ApiRequest};
2323
use vmm_sys_util::eventfd::EventFd;
2424

auraed/src/vms/virtual_machines.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::{collections::HashMap, net::Ipv4Addr};
1616

1717
use anyhow::anyhow;
1818
use net_util::MacAddr;
19+
use nix::libc;
1920
use tracing::error;
2021
use vmm_sys_util::{rand, signal::block_signal};
2122

0 commit comments

Comments
 (0)