mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
arch, pci: rename vm_fd to vm
The type is now hypervisor::Vm. Switch from KVM specific name vm_fd to a
generic name just like 8186a8eee6
("vmm: interrupt: Rename vm_fd").
No functional change.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
8be80aca80
commit
e5552a53d8
@ -65,15 +65,14 @@ pub struct EntryPoint {
|
|||||||
pub fn configure_vcpu(
|
pub fn configure_vcpu(
|
||||||
fd: &Arc<dyn hypervisor::Vcpu>,
|
fd: &Arc<dyn hypervisor::Vcpu>,
|
||||||
id: u8,
|
id: u8,
|
||||||
vm_fd: &Arc<dyn hypervisor::Vm>,
|
vm: &Arc<dyn hypervisor::Vm>,
|
||||||
kernel_entry_point: Option<EntryPoint>,
|
kernel_entry_point: Option<EntryPoint>,
|
||||||
vm_memory: &GuestMemoryAtomic<GuestMemoryMmap>,
|
vm_memory: &GuestMemoryAtomic<GuestMemoryMmap>,
|
||||||
) -> super::Result<u64> {
|
) -> super::Result<u64> {
|
||||||
let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
|
let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
|
||||||
|
|
||||||
// This reads back the kernel's preferred target type.
|
// This reads back the kernel's preferred target type.
|
||||||
vm_fd
|
vm.get_preferred_target(&mut kvi)
|
||||||
.get_preferred_target(&mut kvi)
|
|
||||||
.map_err(Error::VcpuArmPreferredTarget)?;
|
.map_err(Error::VcpuArmPreferredTarget)?;
|
||||||
// We already checked that the capability is supported.
|
// We already checked that the capability is supported.
|
||||||
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2;
|
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2;
|
||||||
@ -138,7 +137,7 @@ pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, Region
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn configure_system<T: DeviceInfoForFDT + Clone + Debug>(
|
pub fn configure_system<T: DeviceInfoForFDT + Clone + Debug>(
|
||||||
vm_fd: &Arc<dyn hypervisor::Vm>,
|
vm: &Arc<dyn hypervisor::Vm>,
|
||||||
guest_mem: &GuestMemoryMmap,
|
guest_mem: &GuestMemoryMmap,
|
||||||
cmdline_cstring: &CStr,
|
cmdline_cstring: &CStr,
|
||||||
vcpu_count: u64,
|
vcpu_count: u64,
|
||||||
@ -146,7 +145,7 @@ pub fn configure_system<T: DeviceInfoForFDT + Clone + Debug>(
|
|||||||
device_info: &HashMap<(DeviceType, String), T>,
|
device_info: &HashMap<(DeviceType, String), T>,
|
||||||
initrd: &Option<super::InitramfsConfig>,
|
initrd: &Option<super::InitramfsConfig>,
|
||||||
) -> super::Result<()> {
|
) -> super::Result<()> {
|
||||||
let gic_device = gic::create_gic(vm_fd, vcpu_count).map_err(Error::SetupGIC)?;
|
let gic_device = gic::create_gic(vm, vcpu_count).map_err(Error::SetupGIC)?;
|
||||||
|
|
||||||
let dtb = fdt::create_fdt(
|
let dtb = fdt::create_fdt(
|
||||||
guest_mem,
|
guest_mem,
|
||||||
|
@ -280,7 +280,7 @@ impl VfioPciConfig {
|
|||||||
/// The VMM creates a VfioDevice, then assigns it to a VfioPciDevice,
|
/// The VMM creates a VfioDevice, then assigns it to a VfioPciDevice,
|
||||||
/// which then gets added to the PCI bus.
|
/// which then gets added to the PCI bus.
|
||||||
pub struct VfioPciDevice {
|
pub struct VfioPciDevice {
|
||||||
vm_fd: Arc<dyn hypervisor::Vm>,
|
vm: Arc<dyn hypervisor::Vm>,
|
||||||
device: Arc<VfioDevice>,
|
device: Arc<VfioDevice>,
|
||||||
vfio_pci_configuration: VfioPciConfig,
|
vfio_pci_configuration: VfioPciConfig,
|
||||||
configuration: PciConfiguration,
|
configuration: PciConfiguration,
|
||||||
@ -292,7 +292,7 @@ pub struct VfioPciDevice {
|
|||||||
impl VfioPciDevice {
|
impl VfioPciDevice {
|
||||||
/// Constructs a new Vfio Pci device for the given Vfio device
|
/// Constructs a new Vfio Pci device for the given Vfio device
|
||||||
pub fn new(
|
pub fn new(
|
||||||
vm_fd: &Arc<dyn hypervisor::Vm>,
|
vm: &Arc<dyn hypervisor::Vm>,
|
||||||
device: VfioDevice,
|
device: VfioDevice,
|
||||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||||
mem: GuestMemoryAtomic<GuestMemoryMmap>,
|
mem: GuestMemoryAtomic<GuestMemoryMmap>,
|
||||||
@ -316,7 +316,7 @@ impl VfioPciDevice {
|
|||||||
let vfio_pci_configuration = VfioPciConfig::new(Arc::clone(&device));
|
let vfio_pci_configuration = VfioPciConfig::new(Arc::clone(&device));
|
||||||
|
|
||||||
let mut vfio_pci_device = VfioPciDevice {
|
let mut vfio_pci_device = VfioPciDevice {
|
||||||
vm_fd: vm_fd.clone(),
|
vm: vm.clone(),
|
||||||
device,
|
device,
|
||||||
configuration,
|
configuration,
|
||||||
vfio_pci_configuration,
|
vfio_pci_configuration,
|
||||||
@ -597,7 +597,7 @@ impl VfioPciDevice {
|
|||||||
flags: 0,
|
flags: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = self.vm_fd.set_user_memory_region(kvm_region) {
|
if let Err(e) = self.vm.set_user_memory_region(kvm_region) {
|
||||||
error!(
|
error!(
|
||||||
"Could not remove the userspace memory region from KVM: {}",
|
"Could not remove the userspace memory region from KVM: {}",
|
||||||
e
|
e
|
||||||
@ -1025,7 +1025,7 @@ impl PciDevice for VfioPciDevice {
|
|||||||
flags: 0,
|
flags: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.vm_fd
|
self.vm
|
||||||
.set_user_memory_region(old_mem_region)
|
.set_user_memory_region(old_mem_region)
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ impl PciDevice for VfioPciDevice {
|
|||||||
flags: 0,
|
flags: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.vm_fd
|
self.vm
|
||||||
.set_user_memory_region(new_mem_region)
|
.set_user_memory_region(new_mem_region)
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user