diff options
author | Zach Reizner <zachr@google.com> | 2017-08-30 17:07:01 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-01 12:39:18 -0700 |
commit | 3cbded2c51574bfdefe8d26a9c6ff235c7330b59 (patch) | |
tree | 6e891f47d965e42c47c254094b17b6813ca8dd09 /kvm/src/lib.rs | |
parent | 86fb9567b588a11ed1f7ed2e3223c25fad07cc6f (diff) | |
download | crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.gz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.bz2 crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.lz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.xz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.zst crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.zip |
fix armv7a and aarch64 build errors and warnings
BUG=None TEST=cargo build --target=armv7a-cros-linux-gnueabi && cargo build --target=aarch64-cros-linux-gnu Change-Id: I954c152f3c8086e24c4809dd5aabb5043fdd63af Reviewed-on: https://chromium-review.googlesource.com/644408 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'kvm/src/lib.rs')
-rw-r--r-- | kvm/src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index f2a45db..4681a7c 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -11,7 +11,6 @@ extern crate sys_util; mod cap; use std::fs::File; -use std::mem; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::os::raw::*; @@ -22,6 +21,7 @@ use libc::{open, O_RDWR, EINVAL, ENOSPC, ENOENT}; use kvm_sys::*; use sys_util::{GuestAddress, GuestMemory, MemoryMapping, EventFd, Error, Result}; +#[allow(unused_imports)] use sys_util::{ioctl, ioctl_with_val, ioctl_with_ref, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_mut_ptr}; @@ -659,15 +659,19 @@ impl AsRawFd for Vcpu { /// Wrapper for kvm_cpuid2 which has a zero length array at the end. /// Hides the zero length array behind a bounds check. +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub struct CpuId { bytes: Vec<u8>, // Actually accessed as a kvm_cpuid2 struct. allocated_len: usize, // Number of kvm_cpuid_entry2 structs at the end of kvm_cpuid2. } +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] impl CpuId { pub fn new(array_len: usize) -> CpuId { - let vec_size_bytes = mem::size_of::<kvm_cpuid2>() + - (array_len * mem::size_of::<kvm_cpuid_entry2>()); + use std::mem::size_of; + + let vec_size_bytes = size_of::<kvm_cpuid2>() + + (array_len * size_of::<kvm_cpuid_entry2>()); let bytes: Vec<u8> = vec![0; vec_size_bytes]; let kvm_cpuid: &mut kvm_cpuid2 = unsafe { // We have ensured in new that there is enough space for the structure so this |