mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
hypervisor: Make vm module private
And thus only export what is necessary through a `pub use`. This is consistent with some of the other modules and makes it easier to understand what the external interface of the hypervisor crate is. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
8e1ba99e8d
commit
d3f66f8702
@ -40,7 +40,7 @@ pub mod mshv;
|
|||||||
pub mod hypervisor;
|
pub mod hypervisor;
|
||||||
|
|
||||||
/// Vm related module
|
/// Vm related module
|
||||||
pub mod vm;
|
mod vm;
|
||||||
|
|
||||||
/// CPU related module
|
/// CPU related module
|
||||||
mod cpu;
|
mod cpu;
|
||||||
@ -48,16 +48,19 @@ mod cpu;
|
|||||||
/// Device related module
|
/// Device related module
|
||||||
mod device;
|
mod device;
|
||||||
|
|
||||||
pub use crate::hypervisor::{Hypervisor, HypervisorError};
|
|
||||||
pub use cpu::{HypervisorCpuError, Vcpu, VmExit};
|
pub use cpu::{HypervisorCpuError, Vcpu, VmExit};
|
||||||
pub use device::{Device, HypervisorDeviceError};
|
pub use device::{Device, HypervisorDeviceError};
|
||||||
|
pub use hypervisor::{Hypervisor, HypervisorError};
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
pub use kvm::TdxCapabilities;
|
pub use kvm::TdxCapabilities;
|
||||||
#[cfg(feature = "kvm")]
|
#[cfg(feature = "kvm")]
|
||||||
pub use kvm::*;
|
pub use kvm::*;
|
||||||
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
|
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
|
||||||
pub use mshv::*;
|
pub use mshv::*;
|
||||||
pub use vm::{DataMatch, HypervisorVmError, Vm};
|
pub use vm::{
|
||||||
|
DataMatch, HypervisorVmError, InterruptSourceConfig, LegacyIrqSourceConfig, MsiIrqSourceConfig,
|
||||||
|
Vm, VmOps,
|
||||||
|
};
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
//! * The virtual device backend requests the interrupt manager to create an interrupt group
|
//! * The virtual device backend requests the interrupt manager to create an interrupt group
|
||||||
//! according to guest configuration information
|
//! according to guest configuration information
|
||||||
|
|
||||||
pub use hypervisor::vm::{InterruptSourceConfig, LegacyIrqSourceConfig, MsiIrqSourceConfig};
|
pub use hypervisor::{InterruptSourceConfig, LegacyIrqSourceConfig, MsiIrqSourceConfig};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ use hypervisor::kvm::kvm_bindings;
|
|||||||
use hypervisor::x86_64::{SpecialRegisters, StandardRegisters};
|
use hypervisor::x86_64::{SpecialRegisters, StandardRegisters};
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use hypervisor::CpuId;
|
use hypervisor::CpuId;
|
||||||
use hypervisor::{vm::VmOps, CpuState, HypervisorCpuError, VmExit};
|
use hypervisor::{CpuState, HypervisorCpuError, VmExit, VmOps};
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
use hypervisor::{TdxExitDetails, TdxExitStatus};
|
use hypervisor::{TdxExitDetails, TdxExitStatus};
|
||||||
use libc::{c_void, siginfo_t};
|
use libc::{c_void, siginfo_t};
|
||||||
|
@ -53,7 +53,7 @@ use devices::legacy::Serial;
|
|||||||
use devices::{
|
use devices::{
|
||||||
interrupt_controller, interrupt_controller::InterruptController, AcpiNotificationFlags,
|
interrupt_controller, interrupt_controller::InterruptController, AcpiNotificationFlags,
|
||||||
};
|
};
|
||||||
use hypervisor::{DeviceFd, IoEventAddress};
|
use hypervisor::{DeviceFd, HypervisorVmError, IoEventAddress};
|
||||||
use libc::{
|
use libc::{
|
||||||
cfmakeraw, isatty, tcgetattr, tcsetattr, termios, MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED,
|
cfmakeraw, isatty, tcgetattr, tcsetattr, termios, MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED,
|
||||||
O_TMPFILE, PROT_READ, PROT_WRITE, TCSANOW,
|
O_TMPFILE, PROT_READ, PROT_WRITE, TCSANOW,
|
||||||
@ -468,7 +468,7 @@ pub enum DeviceManagerError {
|
|||||||
InvalidIommuHotplug,
|
InvalidIommuHotplug,
|
||||||
|
|
||||||
/// Failed to create UEFI flash
|
/// Failed to create UEFI flash
|
||||||
CreateUefiFlash(hypervisor::vm::HypervisorVmError),
|
CreateUefiFlash(HypervisorVmError),
|
||||||
|
|
||||||
/// Invalid identifier as it is not unique.
|
/// Invalid identifier as it is not unique.
|
||||||
IdentifierNotUnique(String),
|
IdentifierNotUnique(String),
|
||||||
|
@ -49,7 +49,7 @@ use devices::interrupt_controller::{self, InterruptController};
|
|||||||
use devices::AcpiNotificationFlags;
|
use devices::AcpiNotificationFlags;
|
||||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||||
use gdbstub_arch::x86::reg::X86_64CoreRegs;
|
use gdbstub_arch::x86::reg::X86_64CoreRegs;
|
||||||
use hypervisor::vm::{HypervisorVmError, VmOps};
|
use hypervisor::{HypervisorVmError, VmOps};
|
||||||
use linux_loader::cmdline::Cmdline;
|
use linux_loader::cmdline::Cmdline;
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use linux_loader::loader::elf::PvhBootCapability::PvhEntryPresent;
|
use linux_loader::loader::elf::PvhBootCapability::PvhEntryPresent;
|
||||||
@ -353,28 +353,28 @@ struct VmOpsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VmOps for VmOpsHandler {
|
impl VmOps for VmOpsHandler {
|
||||||
fn guest_mem_write(&self, gpa: u64, buf: &[u8]) -> hypervisor::vm::Result<usize> {
|
fn guest_mem_write(&self, gpa: u64, buf: &[u8]) -> result::Result<usize, HypervisorVmError> {
|
||||||
self.memory
|
self.memory
|
||||||
.memory()
|
.memory()
|
||||||
.write(buf, GuestAddress(gpa))
|
.write(buf, GuestAddress(gpa))
|
||||||
.map_err(|e| HypervisorVmError::GuestMemWrite(e.into()))
|
.map_err(|e| HypervisorVmError::GuestMemWrite(e.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guest_mem_read(&self, gpa: u64, buf: &mut [u8]) -> hypervisor::vm::Result<usize> {
|
fn guest_mem_read(&self, gpa: u64, buf: &mut [u8]) -> result::Result<usize, HypervisorVmError> {
|
||||||
self.memory
|
self.memory
|
||||||
.memory()
|
.memory()
|
||||||
.read(buf, GuestAddress(gpa))
|
.read(buf, GuestAddress(gpa))
|
||||||
.map_err(|e| HypervisorVmError::GuestMemRead(e.into()))
|
.map_err(|e| HypervisorVmError::GuestMemRead(e.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mmio_read(&self, gpa: u64, data: &mut [u8]) -> hypervisor::vm::Result<()> {
|
fn mmio_read(&self, gpa: u64, data: &mut [u8]) -> result::Result<(), HypervisorVmError> {
|
||||||
if let Err(vm_device::BusError::MissingAddressRange) = self.mmio_bus.read(gpa, data) {
|
if let Err(vm_device::BusError::MissingAddressRange) = self.mmio_bus.read(gpa, data) {
|
||||||
warn!("Guest MMIO read to unregistered address 0x{:x}", gpa);
|
warn!("Guest MMIO read to unregistered address 0x{:x}", gpa);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mmio_write(&self, gpa: u64, data: &[u8]) -> hypervisor::vm::Result<()> {
|
fn mmio_write(&self, gpa: u64, data: &[u8]) -> result::Result<(), HypervisorVmError> {
|
||||||
match self.mmio_bus.write(gpa, data) {
|
match self.mmio_bus.write(gpa, data) {
|
||||||
Err(vm_device::BusError::MissingAddressRange) => {
|
Err(vm_device::BusError::MissingAddressRange) => {
|
||||||
warn!("Guest MMIO write to unregistered address 0x{:x}", gpa);
|
warn!("Guest MMIO write to unregistered address 0x{:x}", gpa);
|
||||||
@ -390,7 +390,7 @@ impl VmOps for VmOpsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn pio_read(&self, port: u64, data: &mut [u8]) -> hypervisor::vm::Result<()> {
|
fn pio_read(&self, port: u64, data: &mut [u8]) -> result::Result<(), HypervisorVmError> {
|
||||||
use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE};
|
use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE};
|
||||||
|
|
||||||
if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) {
|
if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) {
|
||||||
@ -409,7 +409,7 @@ impl VmOps for VmOpsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn pio_write(&self, port: u64, data: &[u8]) -> hypervisor::vm::Result<()> {
|
fn pio_write(&self, port: u64, data: &[u8]) -> result::Result<(), HypervisorVmError> {
|
||||||
use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE};
|
use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE};
|
||||||
|
|
||||||
if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) {
|
if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) {
|
||||||
|
Loading…
Reference in New Issue
Block a user