summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Staron <jstaron@google.com>2019-04-26 11:22:51 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-29 20:57:13 -0700
commitf55f75d6894fe997a619df3fc4ca6e5c9d7b79a6 (patch)
treefbf47be142bf4d51ff80043e54acb2083a1c854e
parentaff94ca6da90b92503558b6ba7aa68e1180afd87 (diff)
downloadcrosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar.gz
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar.bz2
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar.lz
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar.xz
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.tar.zst
crosvm-f55f75d6894fe997a619df3fc4ca6e5c9d7b79a6.zip
crosvm: Fix misleading field name in VmComponents struct.
Renames field memory_mb to memory_size. All usages of this
field treat it as a memory size in bytes, not megabytes.

BUG=None
TEST=cargo check
TEST=cargo check --package aarch64 --target aarch64-unknown-linux-gnu

Change-Id: I7b1aefe4f0b612d5eeb2987dc2a0fce6db0dd228
Reviewed-on: https://chromium-review.googlesource.com/1585617
Commit-Ready: Jakub StaroĊ„ <jstaron@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
-rw-r--r--aarch64/src/lib.rs6
-rw-r--r--arch/src/lib.rs2
-rw-r--r--src/linux.rs2
-rw-r--r--x86_64/src/lib.rs6
4 files changed, 8 insertions, 8 deletions
diff --git a/aarch64/src/lib.rs b/aarch64/src/lib.rs
index ac70e0d..53e2084 100644
--- a/aarch64/src/lib.rs
+++ b/aarch64/src/lib.rs
@@ -197,8 +197,8 @@ impl arch::LinuxArch for AArch64 {
         E: StdError + 'static,
     {
         let mut resources =
-            Self::get_resource_allocator(components.memory_mb, components.wayland_dmabuf);
-        let mem = Self::setup_memory(components.memory_mb)?;
+            Self::get_resource_allocator(components.memory_size, components.wayland_dmabuf);
+        let mem = Self::setup_memory(components.memory_size)?;
         let kvm = Kvm::new().map_err(Error::CreateKvm)?;
         let mut vm = Vm::new(&kvm, mem.clone()).map_err(Error::CreateVm)?;
 
@@ -263,7 +263,7 @@ impl arch::LinuxArch for AArch64 {
         let kernel_end = get_kernel_addr().offset() + kernel_size as u64;
         Self::setup_system_memory(
             &mem,
-            components.memory_mb,
+            components.memory_size,
             vcpu_count,
             &CString::new(cmdline).unwrap(),
             components.initrd_image,
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index 032170f..26967d3 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -26,7 +26,7 @@ use sys_util::{syslog, EventFd, GuestAddress, GuestMemory, GuestMemoryError};
 /// Holds the pieces needed to build a VM. Passed to `build_vm` in the `LinuxArch` trait below to
 /// create a `RunnableLinuxVm`.
 pub struct VmComponents {
-    pub memory_mb: u64,
+    pub memory_size: u64,
     pub vcpu_count: u32,
     pub vcpu_affinity: Vec<usize>,
     pub kernel_image: File,
diff --git a/src/linux.rs b/src/linux.rs
index 7733672..223b3a3 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -1123,7 +1123,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
     };
 
     let components = VmComponents {
-        memory_mb: (cfg.memory.unwrap_or(256) << 20) as u64,
+        memory_size: (cfg.memory.unwrap_or(256) << 20) as u64,
         vcpu_count: cfg.vcpu_count.unwrap_or(1),
         vcpu_affinity: cfg.vcpu_affinity.clone(),
         kernel_image: File::open(&cfg.kernel_path)
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index 84483a5..684a60f 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -304,8 +304,8 @@ impl arch::LinuxArch for X8664arch {
         E: StdError + 'static,
     {
         let mut resources =
-            Self::get_resource_allocator(components.memory_mb, components.wayland_dmabuf);
-        let mem = Self::setup_memory(components.memory_mb)?;
+            Self::get_resource_allocator(components.memory_size, components.wayland_dmabuf);
+        let mem = Self::setup_memory(components.memory_size)?;
         let kvm = Kvm::new().map_err(Error::CreateKvm)?;
         let mut vm = Self::create_vm(&kvm, split_irqchip, mem.clone())?;
 
@@ -357,7 +357,7 @@ impl arch::LinuxArch for X8664arch {
 
         Self::setup_system_memory(
             &mem,
-            components.memory_mb,
+            components.memory_size,
             vcpu_count,
             &CString::new(cmdline).unwrap(),
             components.initrd_image,