From e5552a53d86cccc3593c5aad55f100af34a53127 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Mon, 13 Jul 2020 13:04:58 +0000 Subject: [PATCH] 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 8186a8eee68f ("vmm: interrupt: Rename vm_fd"). No functional change. Signed-off-by: Wei Liu --- arch/src/aarch64/mod.rs | 9 ++++----- pci/src/vfio.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/src/aarch64/mod.rs b/arch/src/aarch64/mod.rs index 584360424..6509d6871 100644 --- a/arch/src/aarch64/mod.rs +++ b/arch/src/aarch64/mod.rs @@ -65,15 +65,14 @@ pub struct EntryPoint { pub fn configure_vcpu( fd: &Arc, id: u8, - vm_fd: &Arc, + vm: &Arc, kernel_entry_point: Option, vm_memory: &GuestMemoryAtomic, ) -> super::Result { let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); // This reads back the kernel's preferred target type. - vm_fd - .get_preferred_target(&mut kvi) + vm.get_preferred_target(&mut kvi) .map_err(Error::VcpuArmPreferredTarget)?; // We already checked that the capability is supported. 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(unused_variables)] pub fn configure_system( - vm_fd: &Arc, + vm: &Arc, guest_mem: &GuestMemoryMmap, cmdline_cstring: &CStr, vcpu_count: u64, @@ -146,7 +145,7 @@ pub fn configure_system( device_info: &HashMap<(DeviceType, String), T>, initrd: &Option, ) -> 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( guest_mem, diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index a43e66378..3d2cd9842 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -280,7 +280,7 @@ impl VfioPciConfig { /// The VMM creates a VfioDevice, then assigns it to a VfioPciDevice, /// which then gets added to the PCI bus. pub struct VfioPciDevice { - vm_fd: Arc, + vm: Arc, device: Arc, vfio_pci_configuration: VfioPciConfig, configuration: PciConfiguration, @@ -292,7 +292,7 @@ pub struct VfioPciDevice { impl VfioPciDevice { /// Constructs a new Vfio Pci device for the given Vfio device pub fn new( - vm_fd: &Arc, + vm: &Arc, device: VfioDevice, interrupt_manager: &Arc>, mem: GuestMemoryAtomic, @@ -316,7 +316,7 @@ impl VfioPciDevice { let vfio_pci_configuration = VfioPciConfig::new(Arc::clone(&device)); let mut vfio_pci_device = VfioPciDevice { - vm_fd: vm_fd.clone(), + vm: vm.clone(), device, configuration, vfio_pci_configuration, @@ -597,7 +597,7 @@ impl VfioPciDevice { 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!( "Could not remove the userspace memory region from KVM: {}", e @@ -1025,7 +1025,7 @@ impl PciDevice for VfioPciDevice { flags: 0, }; - self.vm_fd + self.vm .set_user_memory_region(old_mem_region) .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; @@ -1038,7 +1038,7 @@ impl PciDevice for VfioPciDevice { flags: 0, }; - self.vm_fd + self.vm .set_user_memory_region(new_mem_region) .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; }