cargo: Bump the kvm and vmm-sys-util crates

Since the kvm crates now depend on vmm-sys-util, the bump must be
atomic.
The kvm-bindings and ioctls 0.2.0 and 0.4.0 crates come with a few API
changes, one of them being the use of a kvm_ioctls specific error type.
Porting our code to that type makes for a fairly large diff stat.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-11-29 16:36:33 +01:00 committed by Rob Bradford
parent ca97385da5
commit 0f21781fbe
21 changed files with 112 additions and 127 deletions

59
Cargo.lock generated
View File

@ -35,8 +35,8 @@ dependencies = [
"acpi_tables 0.1.0",
"arch_gen 0.1.0",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.3.0 (git+https://github.com/rust-vmm/kvm-ioctls)",
"kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"linux-loader 0.1.0 (git+https://github.com/rust-vmm/linux-loader)",
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -188,7 +188,7 @@ dependencies = [
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vm-virtio 0.1.0",
"vmm 0.1.0",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -228,13 +228,13 @@ version = "0.1.0"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"epoll 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.3.0 (git+https://github.com/rust-vmm/kvm-ioctls)",
"kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -330,17 +330,20 @@ dependencies = [
[[package]]
name = "kvm-bindings"
version = "0.1.1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kvm-ioctls"
version = "0.3.0"
source = "git+https://github.com/rust-vmm/kvm-ioctls#681745a7776d60e390bcf62eefd48531a5f8ec47"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -418,7 +421,7 @@ dependencies = [
name = "net_gen"
version = "0.1.0"
dependencies = [
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -432,7 +435,7 @@ dependencies = [
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -457,7 +460,7 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"vm-allocator 0.1.0",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -568,7 +571,7 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"remain 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -966,8 +969,8 @@ version = "0.0.1"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"devices 0.1.0",
"kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.3.0 (git+https://github.com/rust-vmm/kvm-ioctls)",
"kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pci 0.1.0",
@ -975,7 +978,7 @@ dependencies = [
"vm-allocator 0.1.0",
"vm-device 0.1.0",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -994,7 +997,7 @@ dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1006,7 +1009,7 @@ dependencies = [
"vhost_rs 0.1.0",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vm-virtio 0.1.0",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1070,7 +1073,7 @@ dependencies = [
"vm-allocator 0.1.0",
"vm-device 0.1.0",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1081,8 +1084,8 @@ dependencies = [
"arch 0.1.0",
"devices 0.1.0",
"epoll 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.3.0 (git+https://github.com/rust-vmm/kvm-ioctls)",
"kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvm-ioctls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"linux-loader 0.1.0 (git+https://github.com/rust-vmm/linux-loader)",
@ -1099,7 +1102,7 @@ dependencies = [
"vm-allocator 0.1.0",
"vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)",
"vm-virtio 0.1.0",
"vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1112,7 +1115,7 @@ dependencies = [
[[package]]
name = "vmm-sys-util"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1196,8 +1199,8 @@ dependencies = [
"checksum ipnetwork 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3d862c86f7867f19b693ec86765e0252d82e53d4240b9b629815675a0714ad1"
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum kvm-bindings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c223e8703d2eb76d990c5f58e29c85b0f6f50e24b823babde927948e7c71fc03"
"checksum kvm-ioctls 0.3.0 (git+https://github.com/rust-vmm/kvm-ioctls)" = "<none>"
"checksum kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d381156ad52005b4655a9421401f02b80f9f049e653496e3ea6639a83fc12453"
"checksum kvm-ioctls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8a59db3c7098cc87f140eb7a4317decda01dd42e7979b1d4d789bd6f6c599a"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
"checksum libssh2-sys 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5fcd5a428a31cbbfe059812d74f4b6cd3b9b7426c2bdaec56993c5365da1c328"
@ -1271,7 +1274,7 @@ dependencies = [
"checksum virtio-bindings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff512178285488516ed85f15b5d0113a7cdb89e9e8a760b269ae4f02b84bd6b"
"checksum vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)" = "<none>"
"checksum vmm-sys-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46996f56aeae31fbc0532ae57a944e00089302f03b18c10c76eebfd9249f4a6c"
"checksum vmm-sys-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b75440f66b299f66acf005431d5f13be6e6a8d02b4dcaa83be5144e88762d010"
"checksum vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebb6ba7ba5653b69bfd3fab8c8c363945c0d3f616a6a1592e12122c3be4724e"
"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"

View File

@ -20,7 +20,7 @@ virtio-bindings = "0.1.0"
vmm = { path = "vmm" }
vm-device = { path = "vm-device" }
vm-memory = { git = "https://github.com/rust-vmm/vm-memory" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
vm-virtio = { path = "vm-virtio" }
[dev-dependencies]

View File

@ -8,8 +8,8 @@ default = []
[dependencies]
byteorder = "1.3.2"
kvm-bindings = "0.1.1"
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm-ioctls", branch = "master" }
kvm-bindings = "0.2.0"
kvm-ioctls = "0.4.0"
libc = "0.2.60"
acpi_tables = { path = "../acpi_tables", optional = true }

View File

@ -5,7 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file.
use std::io::{self, Cursor};
use std::io::Cursor;
use std::mem;
use std::result;
@ -16,8 +16,8 @@ use kvm_ioctls;
#[derive(Debug)]
pub enum Error {
GetLapic(io::Error),
SetLapic(io::Error),
GetLapic(kvm_ioctls::Error),
SetLapic(kvm_ioctls::Error),
}
pub type Result<T> = result::Result<T, Error>;

View File

@ -5,11 +5,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file.
use std::{io, mem, result};
use std::{mem, result};
use super::gdt::{gdt_entry, kvm_segment_from_gdt};
use arch_gen::x86::msr_index;
use kvm_bindings::{kvm_fpu, kvm_msr_entry, kvm_msrs, kvm_regs, kvm_sregs};
use kvm_bindings::{kvm_fpu, kvm_msr_entry, kvm_regs, kvm_sregs, Msrs};
use kvm_ioctls::VcpuFd;
use layout::{BOOT_GDT_START, BOOT_IDT_START, PDE_START, PDPTE_START, PML4_START};
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryMmap};
@ -21,15 +21,15 @@ const MTRR_MEM_TYPE_WB: u64 = 0x6;
#[derive(Debug)]
pub enum Error {
/// Failed to get SREGs for this CPU.
GetStatusRegisters(io::Error),
GetStatusRegisters(kvm_ioctls::Error),
/// Failed to set base registers for this CPU.
SetBaseRegisters(io::Error),
SetBaseRegisters(kvm_ioctls::Error),
/// Failed to configure the FPU.
SetFPURegisters(io::Error),
SetFPURegisters(kvm_ioctls::Error),
/// Setting up MSRs failed.
SetModelSpecificRegisters(io::Error),
SetModelSpecificRegisters(kvm_ioctls::Error),
/// Failed to set SREGs for this CPU.
SetStatusRegisters(io::Error),
SetStatusRegisters(kvm_ioctls::Error),
/// Writing the GDT to RAM failed.
WriteGDT,
/// Writing the IDT to RAM failed.
@ -65,25 +65,7 @@ pub fn setup_fpu(vcpu: &VcpuFd) -> Result<()> {
///
/// * `vcpu` - Structure for the VCPU that holds the VCPU's fd.
pub fn setup_msrs(vcpu: &VcpuFd) -> Result<()> {
let entry_vec = create_msr_entries();
let vec_size_bytes =
mem::size_of::<kvm_msrs>() + (entry_vec.len() * mem::size_of::<kvm_msr_entry>());
let vec: Vec<u8> = Vec::with_capacity(vec_size_bytes);
let msrs: &mut kvm_msrs = unsafe {
// Converting the vector's memory to a struct is unsafe. Carefully using the read-only
// vector to size and set the members ensures no out-of-bounds errors below.
&mut *(vec.as_ptr() as *mut kvm_msrs)
};
unsafe {
// Mapping the unsized array to a slice is unsafe because the length isn't known.
// Providing the length used to create the struct guarantees the entire slice is valid.
let entries: &mut [kvm_msr_entry] = msrs.entries.as_mut_slice(entry_vec.len());
entries.copy_from_slice(&entry_vec);
}
msrs.nmsrs = entry_vec.len() as u32;
vcpu.set_msrs(msrs)
vcpu.set_msrs(&create_msr_entries())
.map_err(Error::SetModelSpecificRegisters)?;
Ok(())
@ -213,7 +195,7 @@ fn setup_page_tables(mem: &GuestMemoryMmap, sregs: &mut kvm_sregs) -> Result<()>
Ok(())
}
fn create_msr_entries() -> Vec<kvm_msr_entry> {
fn create_msr_entries() -> Msrs {
let mut entries = Vec::<kvm_msr_entry>::new();
entries.push(kvm_msr_entry {
@ -274,7 +256,7 @@ fn create_msr_entries() -> Vec<kvm_msr_entry> {
..Default::default()
});
entries
Msrs::from_entries(&entries)
}
#[cfg(test)]
@ -379,24 +361,11 @@ mod tests {
// This test will check against the last MSR entry configured (the tenth one).
// See create_msr_entries for details.
let test_kvm_msrs_entry = [kvm_msr_entry {
let mut msrs = Msrs::from_entries(&[kvm_msr_entry {
index: msr_index::MSR_IA32_MISC_ENABLE,
..Default::default()
}];
let vec_size_bytes = mem::size_of::<kvm_msrs>() + mem::size_of::<kvm_msr_entry>();
let vec: Vec<u8> = Vec::with_capacity(vec_size_bytes);
let mut msrs: &mut kvm_msrs = unsafe {
// Converting the vector's memory to a struct is unsafe. Carefully using the read-only
// vector to size and set the members ensures no out-of-bounds errors below.
&mut *(vec.as_ptr() as *mut kvm_msrs)
};
}]);
unsafe {
let entries: &mut [kvm_msr_entry] = msrs.entries.as_mut_slice(1);
entries.copy_from_slice(&test_kvm_msrs_entry);
}
msrs.nmsrs = 1;
// get_msrs returns the number of msrs that it succeed in reading. We only want to read 1
// in this test case scenario.
let read_msrs = vcpu.get_msrs(&mut msrs).unwrap();
@ -406,9 +375,7 @@ mod tests {
// tenth one (i.e the one with index msr_index::MSR_IA32_MISC_ENABLE has the data we
// expect.
let entry_vec = create_msr_entries();
unsafe {
assert_eq!(entry_vec[9], msrs.entries.as_slice(1)[0]);
}
assert_eq!(entry_vec.as_slice()[9], msrs.as_slice()[0]);
}
#[test]

View File

@ -6,12 +6,12 @@ authors = ["The Chromium OS Authors"]
[dependencies]
byteorder = "1.3.2"
epoll = ">=4.0.1"
kvm-bindings = "0.1.1"
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm-ioctls", branch = "master" }
kvm-bindings = "0.2.0"
kvm-ioctls = "0.4.0"
libc = "0.2.60"
log = "0.4.8"
vm-memory = { git = "https://github.com/rust-vmm/vm-memory" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -13,14 +13,14 @@ use crate::BusDevice;
use byteorder::{ByteOrder, LittleEndian};
use kvm_bindings::kvm_msi;
use kvm_ioctls::VmFd;
use std::result;
use std::sync::Arc;
use std::{io, result};
use vm_memory::GuestAddress;
#[derive(Debug)]
pub enum Error {
/// Failed to send an interrupt.
InterruptFailed(io::Error),
InterruptFailed(kvm_ioctls::Error),
/// Invalid destination mode.
InvalidDestinationMode,
/// Invalid trigger mode.

View File

@ -4,4 +4,4 @@ version = "0.1.0"
authors = ["The Chromium OS Authors"]
[dependencies]
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"

View File

@ -7,7 +7,7 @@ authors = ["The Chromium OS Authors"]
libc = "0.2.60"
rand = "0.7.0"
serde = "1.0.98"
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
net_gen = { path = "../net_gen" }

View File

@ -11,4 +11,4 @@ devices = { path = "../devices" }
libc = "0.2.60"
log = "0.4.8"
vm-memory = { git = "https://github.com/rust-vmm/vm-memory" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"

View File

@ -13,7 +13,7 @@ byteorder = "1.3.2"
libc = "0.2.60"
log = "0.4.8"
remain = "0.1.3"
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -6,15 +6,15 @@ authors = ["The Cloud Hypervisor Authors"]
[dependencies]
byteorder = "1.3.2"
devices = { path = "../devices" }
kvm-bindings = "0.1.1"
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm-ioctls", branch = "master" }
kvm-bindings = "0.2.0"
kvm-ioctls = "0.4.0"
libc = "0.2.60"
log = "0.4.8"
pci = { path = "../pci" }
vfio-bindings = "0.1.0"
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dependencies.vm-memory]
git = "https://github.com/rust-vmm/vm-memory"

View File

@ -38,7 +38,7 @@ pub enum VfioError {
UnsetContainer,
ContainerSetIOMMU,
GroupGetDeviceFD,
KvmSetDeviceAttr(io::Error),
KvmSetDeviceAttr(kvm_ioctls::Error),
VfioDeviceGetInfo,
VfioDeviceGetRegionInfo,
InvalidPath,
@ -268,7 +268,7 @@ impl VfioGroup {
.map_err(VfioError::KvmSetDeviceAttr)
}
fn kvm_device_del_group(&self) -> std::result::Result<(), io::Error> {
fn kvm_device_del_group(&self) -> std::result::Result<(), kvm_ioctls::Error> {
let group_fd = self.as_raw_fd();
let group_fd_ptr = &group_fd as *const i32;
let dev_attr = kvm_bindings::kvm_device_attr {

View File

@ -34,10 +34,10 @@ use vmm_sys_util::eventfd::EventFd;
pub enum VfioPciError {
AllocateGsi,
EventFd(io::Error),
IrqFd(io::Error),
IrqFd(kvm_ioctls::Error),
NewVfioPciDevice,
MapRegionGuest(io::Error),
SetGsiRouting(io::Error),
MapRegionGuest(kvm_ioctls::Error),
SetGsiRouting(kvm_ioctls::Error),
}
pub type Result<T> = std::result::Result<T, VfioPciError>;
@ -1047,7 +1047,9 @@ impl PciDevice for VfioPciDevice {
};
// Safe because the guest regions are guaranteed not to overlap.
unsafe {
self.vm_fd.set_user_memory_region(old_mem_region)?;
self.vm_fd
.set_user_memory_region(old_mem_region)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))?;
}
// Insert new region to KVM
@ -1060,7 +1062,9 @@ impl PciDevice for VfioPciDevice {
};
// Safe because the guest regions are guaranteed not to overlap.
unsafe {
self.vm_fd.set_user_memory_region(new_mem_region)?;
self.vm_fd
.set_user_memory_region(new_mem_region)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))?;
}
}
}

View File

@ -15,7 +15,7 @@ vhost-user-slave = []
[dependencies]
bitflags = "1.1.0"
libc = "0.2.60"
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dependencies.vm-memory]
git = "https://github.com/rust-vmm/vm-memory"

View File

@ -14,7 +14,7 @@ epoll = ">=4.0.1"
libc = "0.2.66"
vm-memory = { git = "https://github.com/rust-vmm/vm-memory" }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dependencies.vhost_rs]
path = "../vhost_rs"

View File

@ -22,7 +22,7 @@ tempfile = "3.1.0"
virtio-bindings = { git = "https://github.com/rust-vmm/virtio-bindings", version = "0.1", features = ["virtio-v5_0_0"]}
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
[dependencies.vhost_rs]
path = "../vhost_rs"

View File

@ -16,8 +16,8 @@ acpi_tables = { path = "../acpi_tables", optional = true }
arch = { path = "../arch" }
devices = { path = "../devices" }
epoll = ">=4.0.1"
kvm-bindings = "0.1.1"
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm-ioctls", branch = "master" }
kvm-bindings = "0.2.0"
kvm-ioctls = "0.4.0"
lazy_static = "1.4.0"
libc = "0.2.62"
log = "0.4.8"
@ -31,7 +31,7 @@ serde_json = ">=1.0.9"
vfio = { path = "../vfio", optional = true }
vm-allocator = { path = "../vm-allocator" }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.1.1"
vmm-sys-util = ">=0.2.1"
signal-hook = "0.1.10"
[dependencies.linux-loader]

View File

@ -20,6 +20,7 @@ use libc::{c_void, siginfo_t};
use crate::device_manager::DeviceManager;
use devices::{ioapic, BusDevice};
use kvm_bindings::CpuId;
use kvm_ioctls::*;
use vm_memory::{Address, GuestAddress, GuestMemoryMmap};
@ -74,10 +75,10 @@ impl fmt::Display for DebugIoPortRange {
#[derive(Debug)]
pub enum Error {
/// Cannot open the VCPU file descriptor.
VcpuFd(io::Error),
VcpuFd(kvm_ioctls::Error),
/// Cannot run the VCPUs.
VcpuRun(io::Error),
VcpuRun(kvm_ioctls::Error),
/// Cannot spawn a new vCPU thread.
VcpuSpawn(io::Error),
@ -95,7 +96,7 @@ pub enum Error {
FPUConfiguration(arch::x86_64::regs::Error),
/// The call to KVM_SET_CPUID2 failed.
SetSupportedCpusFailed(io::Error),
SetSupportedCpusFailed(kvm_ioctls::Error),
#[cfg(target_arch = "x86_64")]
/// Cannot set the local interruption due to bad configuration.
@ -309,7 +310,7 @@ impl Vcpu {
}
},
Err(ref e) => match e.raw_os_error().unwrap() {
Err(ref e) => match e.errno() {
libc::EAGAIN | libc::EINTR => Ok(true),
_ => {
error!("VCPU {:?} error {:?}", self.id, e);

View File

@ -112,14 +112,14 @@ pub enum DeviceManagerError {
AllocateIrq,
/// Cannot configure the IRQ.
Irq(io::Error),
Irq(kvm_ioctls::Error),
/// Cannot allocate PCI BARs
#[cfg(feature = "pci_support")]
AllocateBars(pci::PciDeviceError),
/// Cannot register ioevent.
RegisterIoevent(io::Error),
RegisterIoevent(kvm_ioctls::Error),
/// Cannot create virtio device
VirtioDevice(vmm_sys_util::errno::Error),
@ -159,7 +159,7 @@ pub enum DeviceManagerError {
VfioMapRegion(VfioPciError),
/// Failed to create the KVM device.
CreateKvmDevice(io::Error),
CreateKvmDevice(kvm_ioctls::Error),
/// Failed to memory map.
Mmap(io::Error),
@ -366,11 +366,15 @@ impl DeviceRelocation for AddressManager {
if bar_addr == new_base {
for (event, addr) in virtio_pci_dev.ioeventfds(old_base) {
let io_addr = IoEventAddress::Mmio(addr);
self.vm_fd.unregister_ioevent(event, &io_addr)?;
self.vm_fd
.unregister_ioevent(event, &io_addr)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))?;
}
for (event, addr) in virtio_pci_dev.ioeventfds(new_base) {
let io_addr = IoEventAddress::Mmio(addr);
self.vm_fd.register_ioevent(event, &io_addr, NoDatamatch)?;
self.vm_fd
.register_ioevent(event, &io_addr, NoDatamatch)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))?;
}
}
}
@ -1365,13 +1369,16 @@ impl DeviceManager {
pad: [0u8; 12],
};
return vm_fd_clone.signal_msi(msi_queue).map(|ret| {
if ret > 0 {
debug!("MSI message successfully delivered");
} else if ret == 0 {
warn!("failed to deliver MSI message, blocked by guest");
}
});
return vm_fd_clone
.signal_msi(msi_queue)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))
.map(|ret| {
if ret > 0 {
debug!("MSI message successfully delivered");
} else if ret == 0 {
warn!("failed to deliver MSI message, blocked by guest");
}
});
}
Err(std::io::Error::new(

View File

@ -70,10 +70,10 @@ pub enum Error {
VmFd(io::Error),
/// Cannot create the KVM instance
VmCreate(io::Error),
VmCreate(kvm_ioctls::Error),
/// Cannot set the VM up
VmSetup(io::Error),
VmSetup(kvm_ioctls::Error),
/// Cannot open the kernel image
KernelFile(io::Error),
@ -129,7 +129,7 @@ pub enum Error {
ThreadCleanup,
/// Failed to create a new KVM instance
KvmNew(io::Error),
KvmNew(kvm_ioctls::Error),
/// VM is not created
VmNotCreated,
@ -301,7 +301,10 @@ impl Vm {
};
// Safe because the guest regions are guaranteed not to overlap.
unsafe { fd.set_user_memory_region(mem_region) }?;
unsafe {
fd.set_user_memory_region(mem_region)
.map_err(|e| io::Error::from_raw_os_error(e.errno()))
}?;
// Mark the pages as mergeable if explicitly asked for.
if config.memory.mergeable {
@ -393,7 +396,7 @@ impl Vm {
// Supported CPUID
let mut cpuid = kvm
.get_supported_cpuid(MAX_KVM_CPUID_ENTRIES)
.get_supported_cpuid(kvm_bindings::KVM_MAX_CPUID_ENTRIES)
.map_err(Error::VmSetup)?;
cpu::CpuidPatch::patch_cpuid(&mut cpuid, cpuid_patches);