From a5dc93df5b96728226bd3fcbc4298e6fb54f146d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 13 Mar 2020 22:21:00 +0000 Subject: move MemoryParams to devices --- arch/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/src/lib.rs b/arch/src/lib.rs index db31a9d..8f957a8 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -20,8 +20,8 @@ use acpi_tables::sdt::SDT; use devices::split_irqchip_common::GsiRelay; use devices::virtio::VirtioDevice; use devices::{ - Bus, BusDevice, BusError, JailedDevice, PciAddress, PciDevice, PciDeviceError, PciInterruptPin, - PciRoot, + Bus, BusDevice, BusError, JailedDevice, MemoryParams, PciAddress, PciDevice, PciDeviceError, + PciInterruptPin, PciRoot, }; use io_jail::Minijail; use kvm::{IoeventAddress, Kvm, Vcpu, Vm}; @@ -61,6 +61,17 @@ pub struct VmComponents { pub acpi_sdts: Vec, } +impl VmComponents { + pub fn memory_params(&self) -> MemoryParams { + MemoryParams { + size: self.memory_size, + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + has_bios: matches!(self.vm_image, VmImage::Bios(_)), + } + } +} + /// Holds the elements needed to run a Linux VM. Created by `build_vm`. pub struct RunnableLinuxVm { pub vm: Vm, @@ -116,6 +127,7 @@ pub trait LinuxArch { where F: FnOnce( &GuestMemory, + Self::MemoryParams, &mut Vm, &mut SystemAllocator, &EventFd, -- cgit 1.4.1