Skip to content

Commit 880670f

Browse files
committed
fix: upstream post-rebase fixes
1 parent bb95413 commit 880670f

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/devices/src/virtio/fs/kinds.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
use std::{ffi::CStr, io, path::PathBuf, time::Duration};
3+
use std::{ffi::CStr, io, path::PathBuf, sync::{atomic::AtomicI32, Arc}, time::Duration};
44

55
#[cfg(target_os = "macos")]
66
use crossbeam_channel::Sender;
@@ -596,13 +596,14 @@ impl FileSystem for FsImpl {
596596
arg: u64,
597597
in_size: u32,
598598
out_size: u32,
599+
exit_code: &Arc<AtomicI32>,
599600
) -> io::Result<Vec<u8>> {
600601
match self {
601602
FsImpl::Passthrough(fs) => {
602-
fs.ioctl(ctx, inode, handle, flags, cmd, arg, in_size, out_size)
603+
fs.ioctl(ctx, inode, handle, flags, cmd, arg, in_size, out_size, exit_code)
603604
}
604605
FsImpl::Overlayfs(fs) => {
605-
fs.ioctl(ctx, inode, handle, flags, cmd, arg, in_size, out_size)
606+
fs.ioctl(ctx, inode, handle, flags, cmd, arg, in_size, out_size, exit_code)
606607
}
607608
}
608609
}

src/devices/src/virtio/fs/linux/overlayfs.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ use std::{
1010
},
1111
path::PathBuf,
1212
sync::{
13-
atomic::{AtomicBool, AtomicU64, Ordering},
13+
atomic::{AtomicBool, AtomicI32, AtomicU64, Ordering},
1414
Arc, LazyLock, RwLock,
1515
},
1616
time::Duration,
1717
};
1818

1919
use caps::{has_cap, CapSet, Capability};
2020
use intaglio::{cstr::SymbolTable, Symbol};
21-
use nix::request_code_read;
21+
use nix::{request_code_none, request_code_read};
2222

2323
use crate::virtio::{
2424
bindings,
@@ -2283,7 +2283,7 @@ impl OverlayFs {
22832283
}
22842284
}
22852285
};
2286-
2286+
22872287
if res < 0 {
22882288
return Err(io::Error::last_os_error());
22892289
}
@@ -2631,9 +2631,12 @@ impl OverlayFs {
26312631
inode: Inode,
26322632
handle: Handle,
26332633
cmd: u32,
2634+
arg: u64,
26342635
out_size: u32,
2636+
exit_code: &Arc<AtomicI32>,
26352637
) -> io::Result<Vec<u8>> {
26362638
const VIRTIO_IOC_MAGIC: u8 = b'v';
2639+
26372640
const VIRTIO_IOC_TYPE_EXPORT_FD: u8 = 1;
26382641
const VIRTIO_IOC_EXPORT_FD_SIZE: usize = 2 * mem::size_of::<u64>();
26392642
const VIRTIO_IOC_EXPORT_FD_REQ: u32 = request_code_read!(
@@ -2642,6 +2645,10 @@ impl OverlayFs {
26422645
VIRTIO_IOC_EXPORT_FD_SIZE
26432646
) as u32;
26442647

2648+
const VIRTIO_IOC_TYPE_EXIT_CODE: u8 = 2;
2649+
const VIRTIO_IOC_EXIT_CODE_REQ: u32 =
2650+
request_code_none!(VIRTIO_IOC_MAGIC, VIRTIO_IOC_TYPE_EXIT_CODE) as u32;
2651+
26452652
match cmd {
26462653
VIRTIO_IOC_EXPORT_FD_REQ => {
26472654
if out_size as usize != VIRTIO_IOC_EXPORT_FD_SIZE {
@@ -2672,6 +2679,10 @@ impl OverlayFs {
26722679
ret.extend_from_slice(&handle.to_ne_bytes());
26732680
Ok(ret)
26742681
}
2682+
VIRTIO_IOC_EXIT_CODE_REQ => {
2683+
exit_code.store(arg as i32, Ordering::SeqCst);
2684+
Ok(Vec::new())
2685+
}
26752686
_ => Err(io::Error::from_raw_os_error(libc::EOPNOTSUPP)),
26762687
}
26772688
}
@@ -3349,11 +3360,12 @@ impl FileSystem for OverlayFs {
33493360
handle: Self::Handle,
33503361
_flags: u32,
33513362
cmd: u32,
3352-
_arg: u64,
3363+
arg: u64,
33533364
_in_size: u32,
33543365
out_size: u32,
3366+
exit_code: &Arc<AtomicI32>,
33553367
) -> io::Result<Vec<u8>> {
3356-
self.do_ioctl(inode, handle, cmd, out_size)
3368+
self.do_ioctl(inode, handle, cmd, arg, out_size, exit_code)
33573369
}
33583370
}
33593371

src/libkrun/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::ffi::CStr;
99
#[cfg(target_os = "linux")]
1010
use std::ffi::CString;
1111
use std::fs::File;
12+
use std::net::Ipv4Addr;
1213
#[cfg(target_os = "linux")]
1314
use std::os::fd::AsRawFd;
1415
use std::os::fd::{FromRawFd, RawFd};

0 commit comments

Comments
 (0)