Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
755 changes: 287 additions & 468 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ efi = []

[dependencies]
libc = ">=0.2.39"
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vmm-sys-util = ">= 0.14"
vm-memory = { version = "0.17", features = ["backend-mmap"] }
vmm-sys-util = "0.14"

arch_gen = { path = "../arch_gen" }
smbios = { path = "../smbios" }
utils = { path = "../utils" }

[target.'cfg(target_os = "linux")'.dependencies]
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-ioctls = ">=0.21"
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"
tdx = { version = "0.1.0", optional = true }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions src/cpuid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2021"
tdx = []

[dependencies]
vmm-sys-util = ">= 0.14"
vmm-sys-util = "0.14"

[target.'cfg(target_os = "linux")'.dependencies]
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-ioctls = ">=0.21"
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"
8 changes: 4 additions & 4 deletions src/devices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pw = { package = "pipewire", version = "0.8.0", optional = true }
rand = "0.9.2"
thiserror = { version = "2.0", optional = true }
virtio-bindings = "0.2.0"
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vm-memory = { version = "0.17", features = ["backend-mmap"] }
zerocopy = { version = "0.8.26", optional = true, features = ["derive"] }
krun_display = { path = "../krun_display", optional = true, features = ["bindgen_clang_runtime"] }
krun_input = { path = "../krun_input", features = ["bindgen_clang_runtime"], optional = true }
Expand All @@ -39,7 +39,7 @@ arch = { path = "../arch" }
utils = { path = "../utils" }
polly = { path = "../polly" }
rutabaga_gfx = { path = "../rutabaga_gfx", features = ["virgl_renderer", "virgl_renderer_next"], optional = true }
imago = { version = "0.2.1", features = ["sync-wrappers", "vm-memory"] }
imago = { version = "0.2.2", features = ["sync-wrappers", "vm-memory"] }

[target.'cfg(target_os = "macos")'.dependencies]
hvf = { path = "../hvf" }
Expand All @@ -48,8 +48,8 @@ lru = ">=0.9"
[target.'cfg(target_os = "linux")'.dependencies]
rutabaga_gfx = { path = "../rutabaga_gfx", features = ["x"], optional = true }
caps = "0.5.5"
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-ioctls = ">=0.21"
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"

[target.'cfg(any(target_arch = "aarch64", target_arch = "riscv64"))'.dependencies]
vm-fdt = ">= 0.2.0"
29 changes: 14 additions & 15 deletions src/devices/src/virtio/console/process_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::{io, thread};

use vm_memory::{GuestMemory, GuestMemoryError, GuestMemoryMmap, GuestMemoryRegion};
use vm_memory::{GuestMemory, GuestMemoryError, GuestMemoryMmap};

use crate::virtio::console::console_control::ConsoleControl;
use crate::virtio::console::port_io::PortInput;
Expand Down Expand Up @@ -89,19 +89,18 @@ fn read_to_desc(
input: &mut (dyn PortInput + Send),
eof: &mut bool,
) -> Result<usize, GuestMemoryError> {
desc.mem
.try_access(desc.len as usize, desc.addr, |_, len, addr, region| {
let mut target = region.get_slice(addr, len).unwrap();
match input.read_volatile(&mut target) {
Ok(n) => {
if n == 0 {
*eof = true
}
Ok(n)
}
// We can't return an error otherwise we would not know how many bytes were processed before WouldBlock
Err(e) if e.kind() == io::ErrorKind::WouldBlock => Ok(0),
Err(e) => Err(GuestMemoryError::IOError(e)),
let mut total = 0;
for slice in desc.mem.get_slices(desc.addr, desc.len as usize) {
let mut slice = slice?;
match input.read_volatile(&mut slice) {
Ok(0) => {
*eof = true;
break;
}
})
Ok(n) => total += n,
Err(e) if e.kind() == io::ErrorKind::WouldBlock => break,
Err(e) => return Err(GuestMemoryError::IOError(e)),
}
}
Ok(total)
}
36 changes: 19 additions & 17 deletions src/devices/src/virtio/console/process_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::{io, thread};

use vm_memory::{GuestMemory, GuestMemoryError, GuestMemoryMmap, GuestMemoryRegion};
use vm_memory::{GuestMemory, GuestMemoryError, GuestMemoryMmap};

use crate::virtio::console::port_io::PortOutput;
use crate::virtio::{DescriptorChain, InterruptTransport, Queue};
Expand Down Expand Up @@ -76,22 +76,24 @@ fn write_desc_to_output(
output: &mut (dyn PortOutput + Send),
interrupt: &InterruptTransport,
) -> Result<usize, GuestMemoryError> {
desc.mem
.try_access(desc.len as usize, desc.addr, |_, len, addr, region| {
let src = region.get_slice(addr, len).unwrap();
loop {
log::trace!("Tx {src:?}, write_volatile {len} bytes");
match output.write_volatile(&src) {
// try_access seem to handle partial write for us (we will be invoked again with an offset)
Ok(n) => break Ok(n),
// We can't return an error otherwise we would not know how many bytes were processed before WouldBlock
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {
log::trace!("Tx wait for output (would block)");
interrupt.signal_used_queue();
output.wait_until_writable();
}
Err(e) => break Err(GuestMemoryError::IOError(e)),
let mut total = 0;
for slice in desc.mem.get_slices(desc.addr, desc.len as usize) {
let slice = slice?;
loop {
log::trace!("Tx {slice:?}, write_volatile {} bytes", slice.len());
match output.write_volatile(&slice) {
Ok(n) => {
total += n;
break;
}
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {
log::trace!("Tx wait for output (would block)");
interrupt.signal_used_queue();
output.wait_until_writable();
}
Err(e) => return Err(GuestMemoryError::IOError(e)),
}
})
}
}
Ok(total)
}
2 changes: 1 addition & 1 deletion src/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vm-memory = { version = "0.17", features = ["backend-mmap"] }

utils = { path = "../utils" }
8 changes: 4 additions & 4 deletions src/libkrun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ rand = "0.9.2"
hvf = { path = "../hvf" }

[target.'cfg(target_os = "linux")'.dependencies]
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-ioctls = ">=0.21"
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"
aws-nitro = { path = "../aws_nitro", optional = true }
nitro-enclaves = { version = "0.5.0", optional = true }
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vm-memory = { version = "0.17", features = ["backend-mmap"] }

[lib]
name = "krun"
crate-type = ["cdylib"]
crate-type = ["cdylib", "lib"]
2 changes: 1 addition & 1 deletion src/rutabaga_gfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ remain = "0.2"
thiserror = "1.0.23"
zerocopy = { version = "0.8.26", features = ["derive"] }
log = "0.4"
vmm-sys-util = ">=0.14"
vmm-sys-util = "0.14"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.30.1", features = ["event", "feature", "fs", "mman", "socket", "uio", "ioctl"] }
Expand Down
2 changes: 1 addition & 1 deletion src/smbios/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vm-memory = { version = "0.17", features = ["backend-mmap"] }
4 changes: 2 additions & 2 deletions src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ bitflags = "1.2.0"
libc = ">=0.2.85"
log = "0.4.0"
nix = "0.30.1"
vmm-sys-util = ">= 0.14"
vmm-sys-util = "0.14"
crossbeam-channel = ">=0.5.15"

[target.'cfg(target_os = "linux")'.dependencies]
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }

[target.'cfg(target_os = "macos")'.dependencies]
nix = { version = "0.30.1", features = ["fs"] }
10 changes: 5 additions & 5 deletions src/vmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ aws-nitro = []
crossbeam-channel = ">=0.5.15"
flate2 = "1.0.35"
libc = ">=0.2.39"
linux-loader = { version = "0.13.0", features = ["bzimage", "elf", "pe"] }
linux-loader = { version = "0.13.2", features = ["bzimage", "elf", "pe"] }
log = "0.4.0"
nix = { version = "0.30.1", features = ["fs", "term"] }
vm-memory = { version = ">=0.13", features = ["backend-mmap"] }
vmm-sys-util = ">=0.14"
vm-memory = { version = ">=0.17.0, <0.17.2", features = ["backend-mmap"] }
vmm-sys-util = "0.14"
krun_display = { path = "../krun_display", optional = true, features = ["bindgen_clang_runtime"] }
krun_input = { path = "../krun_input", optional = true, features = ["bindgen_clang_runtime"] }

Expand All @@ -51,8 +51,8 @@ zstd = "0.13"

[target.'cfg(target_os = "linux")'.dependencies]
tdx = { version = "0.1.0", optional = true }
kvm-bindings = { version = ">=0.11", features = ["fam-wrappers"] }
kvm-ioctls = ">=0.21"
kvm-bindings = { version = "0.12", features = ["fam-wrappers"] }
kvm-ioctls = "0.22"

[target.'cfg(target_os = "macos")'.dependencies]
hvf = { path = "../hvf" }
Expand Down
12 changes: 8 additions & 4 deletions src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub enum StartMicrovmError {
/// Cannot read firmware contents from file.
FirmwareRead(io::Error),
/// Memory regions are overlapping or mmap fails.
GuestMemoryMmap(vm_memory::Error),
GuestMemoryMmap(String),
/// The BZIP2 decoder couldn't decompress the kernel.
ImageBz2Decoder(io::Error),
/// Cannot find compressed kernel in file.
Expand Down Expand Up @@ -1339,9 +1339,13 @@ fn load_payload(
guest_mem
.insert_region(Arc::new(
GuestRegionMmap::new(kernel_region, GuestAddress(kernel_guest_addr))
.map_err(StartMicrovmError::GuestMemoryMmap)?,
.ok_or_else(|| {
StartMicrovmError::GuestMemoryMmap(
"Failed to create GuestRegionMmap".to_string(),
)
})?,
))
.map_err(StartMicrovmError::GuestMemoryMmap)?,
.map_err(|e| StartMicrovmError::GuestMemoryMmap(format!("{e:?}")))?,
GuestAddress(kernel_entry_addr),
None,
None,
Expand Down Expand Up @@ -1500,7 +1504,7 @@ pub fn create_guest_memory(
arch_mem_regions.extend(shm_manager.regions());

let guest_mem = GuestMemoryMmap::from_ranges(&arch_mem_regions)
.map_err(StartMicrovmError::GuestMemoryMmap)?;
.map_err(|e| StartMicrovmError::GuestMemoryMmap(format!("{e:?}")))?;

let (guest_mem, entry_addr, initrd_config, cmdline) =
load_payload(vm_resources, guest_mem, &arch_mem_info, payload)?;
Expand Down
Loading