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
+5 -4
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);
+19 -12
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(
+8 -5
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);