Skip to content

Commit f4fbdce

Browse files
committed
feat(uhyve-interface): Uhyve Interface v3 (crate uhyve-interface v0.4.0)
1 parent 8f812c6 commit f4fbdce

18 files changed

Lines changed: 597 additions & 227 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tempfile = "3.27"
6161
thiserror = "2.0.18"
6262
time = { version = "0.3", default-features = false, features = ["std"] }
6363
toml = { version = "1", default-features = false, features = ["parse", "serde"] }
64-
uhyve-interface = { version = "0.3.0", path = "uhyve-interface", features = ["std"] }
64+
uhyve-interface = { version = "0.4", path = "uhyve-interface", features = ["std"] }
6565
virtio-bindings = "~0.2.7"
6666
vm-fdt = "0.3"
6767
vm-memory = { version = "0.18", features = ["backend-mmap"] }
@@ -99,7 +99,7 @@ memory_addresses = { version = "0.4", default-features = false, features = [
9999
criterion = "0.8"
100100
home = "0.5"
101101
regex = { version = "1.12.3", default-features = false, features = ["unicode-perl"] }
102-
uhyve-interface = { version = "0.3.0", path = "uhyve-interface", features = ["std"] }
102+
uhyve-interface = { path = "uhyve-interface", features = ["std"] }
103103

104104
[profile.dist]
105105
inherits = "release"

‎src/hypercall/by_path.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use std::{
77
sync::Arc,
88
};
99

10-
use uhyve_interface::{
11-
GuestPhysAddr,
12-
v2::parameters::{FileType, *},
13-
};
10+
use uhyve_interface::{GuestPhysAddr, v2::parameters::*, v3::parameters::FileType};
1411

1512
use crate::{
1613
hypercall::translate_last_errno,
@@ -197,6 +194,7 @@ pub(super) fn open(mem: &MmapMemory, sysopen: &mut OpenParams, file_map: &mut Uh
197194
}
198195
}
199196

197+
/*
200198
/// Attempts `mkdir(host_path)` on the host, mapping the outcome to a [`MkdirResult`].
201199
fn host_mkdir(host_path_c: &CString) -> MkdirResult {
202200
// SAFETY: `host_path_c` is a valid, null-terminated C string.
@@ -238,3 +236,4 @@ pub(super) fn mkdir(mem: &MmapMemory, sysmkdir: &mut MkdirParams, file_map: &mut
238236
}
239237
};
240238
}
239+
*/

‎src/hypercall/mod.rs‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use crate::{
1414
mod by_fd;
1515
mod by_path;
1616
mod cmdval_copy;
17-
mod fstat;
18-
mod getdents;
17+
//mod fstat;
18+
//mod getdents;
1919

2020
use by_fd::{close, lseek, lseek_v1, read, read_v1, write, write_v1};
21-
use by_path::{mkdir, open, unlink};
22-
use fstat::{fstat, stat};
23-
use getdents::getdents;
21+
use by_path::{open, unlink};
22+
//use fstat::{fstat, stat};
23+
//use getdents::getdents;
2424

2525
/// `addr` is the address of the hypercall parameter in the guest's memory space. `data` is the
2626
/// parameter that was sent to that address by the guest.
@@ -95,10 +95,6 @@ pub unsafe fn address_to_hypercall_v2(
9595
HypercallAddress::SerialReadBuffer => Hypercall::SerialReadBuffer(get_data!()),
9696
HypercallAddress::SerialWriteBuffer => Hypercall::SerialWriteBuffer(get_data!()),
9797
HypercallAddress::SerialWriteByte => Hypercall::SerialWriteByte(data.as_u64() as u8),
98-
HypercallAddress::Getdents => Hypercall::Getdents(get_data!()),
99-
HypercallAddress::FileStat => Hypercall::FileStat(get_data!()),
100-
HypercallAddress::FileFstat => Hypercall::FileFstat(get_data!()),
101-
HypercallAddress::Mkdir => Hypercall::Mkdir(get_data!()),
10298
_ => return None,
10399
})
104100
}
@@ -136,12 +132,6 @@ pub fn handle_hypercall_v2<N: NetworkBackend>(
136132
v2::Hypercall::FileUnlink(sysunlink) => {
137133
unlink(&peripherals.mem, sysunlink, &mut file_mapping())
138134
}
139-
v2::Hypercall::Getdents(sysgetdents) => {
140-
getdents(&peripherals.mem, sysgetdents, &mut file_mapping())
141-
}
142-
v2::Hypercall::FileStat(sysstat) => stat(&peripherals.mem, sysstat, &file_mapping()),
143-
v2::Hypercall::FileFstat(sysfstat) => fstat(&peripherals.mem, sysfstat, &file_mapping()),
144-
v2::Hypercall::Mkdir(sysmkdir) => mkdir(&peripherals.mem, sysmkdir, &mut file_mapping()),
145135
v2::Hypercall::SerialWriteByte(buf) => peripherals
146136
.serial
147137
.output(&[buf])

‎src/isolation/fd.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
};
88

99
use nohash::NoHashHasher;
10-
use uhyve_interface::v2::parameters::FileType;
10+
use uhyve_interface::v3::parameters::FileType;
1111

1212
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1313
pub struct GuestFd(pub i32);
@@ -145,6 +145,7 @@ impl UhyveFileDescriptorLayer {
145145
self.fds.get_mut(&fd.get())
146146
}
147147

148+
#[expect(unused)]
148149
pub fn get(&self, fd: GuestFd) -> Option<&FdData> {
149150
self.fds.get(&fd.get())
150151
}

‎src/isolation/filemap/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl UhyveFileMap {
197197
/// so that the caller can create it on the host.
198198
///
199199
/// * `guest_path` - The requested guest path.
200+
#[expect(unused)]
200201
pub fn create_temporary_directory(&mut self, guest_path: &str) -> Option<CString> {
201202
let host_path = self.tempdir.path().join(Uuid::new_v4().to_string());
202203
trace!("create_temporary_directory (host_path): {host_path:#?}");

‎src/linux/fs.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#![expect(unused)]
2+
13
use std::os::fd::RawFd;
24

3-
use uhyve_interface::v2::parameters::{FileAttr, Timespec};
5+
use uhyve_interface::v3::parameters::{FileAttr, Timespec};
46

57
pub(crate) fn host_stat_to_file_attr(st: libc::stat) -> FileAttr {
68
FileAttr {

‎src/macos/fs.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use core::{
55
use std::{io, os::fd::RawFd};
66

77
use align_address::Align;
8-
use uhyve_interface::v2::parameters::{Dirent64, FileAttr, FileType, Timespec};
8+
use uhyve_interface::v3::parameters::{Dirent64, FileAttr, FileType, Timespec};
99

1010
/// MacOS file attributes have slightly different types than Linux, so we need a separate conversion function.
11+
#[allow(unused)]
1112
pub(crate) fn host_stat_to_file_attr(st: libc::stat) -> FileAttr {
1213
FileAttr {
1314
st_dev: st.st_dev as u64,
@@ -55,6 +56,7 @@ unsafe extern "C" {
5556
}
5657

5758
/// Reads host directory entries and writes Linux `dirent64` records into `buf`.
59+
#[allow(unused)]
5860
pub(crate) unsafe fn raw_getdents(host_fd: RawFd, buf: &mut [u8]) -> isize {
5961
let mut guest_off = 0usize;
6062
let mut host_buf = [0u8; 2048];

‎tests/fs-test.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ use common::{
1414
};
1515
use rand::{RngExt, distr::Alphanumeric};
1616
use tempfile::TempDir;
17-
use uhyve_interface::{v1, v2};
17+
//use uhyve_interface::{v1, v2};
1818
use uhyvelib::{
1919
UhyveVm,
2020
params::{Output, Params},
21+
/*
2122
stats::{
2223
HypercallAddresses::{V1, V2},
2324
VmExit,
2425
},
26+
*/
2527
};
2628

2729
/// Verifies successful file creation on the host OS and its contents.
@@ -432,6 +434,7 @@ fn fd_write_to_fd() {
432434
);
433435
}
434436

437+
/*
435438
/// Tests the Mkdir hypercall: the guest creates a directory inside a mapped host
436439
/// directory and populates it with files. The host then verifies the result.
437440
#[test]
@@ -500,6 +503,7 @@ fn hypercall_mkdir_unmapped_test() {
500503
3
501504
);
502505
}
506+
*/
503507

504508
#[test]
505509
fn mounts_test() {
@@ -555,6 +559,7 @@ fn lseek_test() {
555559
check_result_and_print_output(&res, 0);
556560
}
557561

562+
/*
558563
/// Tests the Getdents hypercall: opens a mapped directory and reads its entries.
559564
#[test]
560565
fn getdents_test() {
@@ -615,3 +620,4 @@ fn hypercall_fstat_test() {
615620
let res = run_vm_in_thread(bin_path, params);
616621
check_result_and_print_output(&res, 0);
617622
}
623+
*/

‎tests/test-kernels/Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)