protos: add arch = x86 guards around CPUID helpers

The CPUID-related KVM structs are only available on x86; don't try to
compile the helper functions that use these structs on other platforms.

This is slightly nonsensical, since plugin is already only compiled on a
few specific x86 platforms, but it allows the unit tests to build on
other platforms (e.g. when using `cargo test --all-features`).

BUG=chromium:1112839
TEST=FEATURES=test emerge-kevin crosvm

Change-Id: I413ac757f27c987133bdb265f203f0d6eb3a0b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2347077
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2020-08-10 16:14:44 -07:00 committed by Commit Bot
parent 482874c248
commit 1972b6855a

View file

@ -5,6 +5,7 @@
pub use crate::generated::plugin::*;
/// Converts protobuf representation of CpuId data into KVM format.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn cpuid_proto_to_kvm(entry: &CpuidEntry) -> kvm_sys::kvm_cpuid_entry2 {
// Safe: C structures are expected to be zero-initialized.
let mut e: kvm_sys::kvm_cpuid_entry2 = unsafe { std::mem::zeroed() };
@ -22,6 +23,7 @@ pub fn cpuid_proto_to_kvm(entry: &CpuidEntry) -> kvm_sys::kvm_cpuid_entry2 {
}
/// Converts KVM representation of CpuId data into protobuf format.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn cpuid_kvm_to_proto(entry: &kvm_sys::kvm_cpuid_entry2) -> CpuidEntry {
let mut e = CpuidEntry::new();
e.function = entry.function;