diff --git a/hypervisor/src/arch/x86/emulator/instructions/mod.rs b/hypervisor/src/arch/x86/emulator/instructions/mod.rs index 99d797c0b..1f4665bce 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mod.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mod.rs @@ -4,6 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // +use anyhow::anyhow; use iced_x86::*; use crate::arch::emulator::{EmulationError, PlatformEmulator, PlatformError}; diff --git a/hypervisor/src/arch/x86/emulator/instructions/movs.rs b/hypervisor/src/arch/x86/emulator/instructions/movs.rs index 5642e04f4..a4831481b 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/movs.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/movs.rs @@ -10,6 +10,8 @@ // MOVS - Move Data from String to String // +use anyhow::anyhow; + use crate::arch::x86::emulator::instructions::*; use crate::arch::x86::regs::DF; diff --git a/hypervisor/src/arch/x86/emulator/instructions/stos.rs b/hypervisor/src/arch/x86/emulator/instructions/stos.rs index 38233eea4..c830126fb 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/stos.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/stos.rs @@ -10,6 +10,8 @@ // STOS - Store String // +use anyhow::anyhow; + use crate::arch::x86::emulator::instructions::*; use crate::arch::x86::regs::DF; diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 591a5e42b..3de545e47 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -4,8 +4,9 @@ // SPDX-License-Identifier: Apache-2.0 // -use anyhow::Context; +use anyhow::{Context, anyhow}; use iced_x86::*; +use log::debug; use crate::StandardRegisters; use crate::arch::emulator::{EmulationError, EmulationResult, PlatformEmulator, PlatformError}; diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 763eaa455..23a1632c1 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -12,7 +12,7 @@ use thiserror::Error; #[cfg(not(target_arch = "riscv64"))] -use vm_memory::GuestAddress; +use {anyhow::anyhow, vm_memory::GuestAddress}; #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] use crate::RegList; diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 6a1b31607..0ecf9a48d 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -25,7 +25,10 @@ use std::sync::Mutex; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, RwLock}; +use anyhow::anyhow; use kvm_ioctls::{NoDatamatch, VcpuFd, VmFd}; +#[cfg(target_arch = "x86_64")] +use log::warn; use vmm_sys_util::eventfd::EventFd; #[cfg(target_arch = "aarch64")] diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index 607166968..1899d282b 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -21,12 +21,6 @@ //! - riscv64 (experimental) //! -#[macro_use] -extern crate anyhow; -#[allow(unused_imports)] -#[macro_use] -extern crate log; - /// Architecture specific definitions #[macro_use] pub mod arch; @@ -53,6 +47,7 @@ mod device; use std::sync::Arc; +use anyhow::anyhow; use concat_idents::concat_idents; #[cfg(target_arch = "x86_64")] pub use cpu::CpuVendor; diff --git a/hypervisor/src/mshv/aarch64/emulator.rs b/hypervisor/src/mshv/aarch64/emulator.rs index a97659840..d71b50cf8 100644 --- a/hypervisor/src/mshv/aarch64/emulator.rs +++ b/hypervisor/src/mshv/aarch64/emulator.rs @@ -3,6 +3,8 @@ // Copyright © 2025, Microsoft Corporation // +use anyhow::anyhow; + use crate::arch::aarch64::regs::{EsrEl2, ExceptionClass, IssDataAbort}; use crate::arch::emulator::PlatformError; use crate::cpu::Vcpu; diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 3ca3d846f..719456720 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -9,8 +9,8 @@ use std::collections::HashMap; use std::num::NonZeroUsize; use std::sync::{Arc, RwLock}; -#[cfg(feature = "sev_snp")] -use arc_swap::ArcSwap; +use anyhow::anyhow; +use log::{debug, warn}; use mshv_bindings::*; #[cfg(target_arch = "x86_64")] use mshv_ioctls::InterruptRequest; @@ -19,6 +19,8 @@ use vfio_ioctls::VfioDeviceFd; use vm::DataMatch; #[cfg(feature = "sev_snp")] use vm_memory::bitmap::AtomicBitmap; +#[cfg(feature = "sev_snp")] +use {arc_swap::ArcSwap, log::info}; #[cfg(target_arch = "aarch64")] use crate::arch::aarch64::regs::{ @@ -271,7 +273,6 @@ impl hypervisor::Hypervisor for MshvHypervisor { /// # Examples /// /// ``` - /// # extern crate hypervisor; /// use hypervisor::mshv::MshvHypervisor; /// use hypervisor::mshv::MshvVm; /// use hypervisor::HypervisorVmConfig; @@ -1700,7 +1701,6 @@ impl MshvVm { /// # Examples /// /// ``` -/// extern crate hypervisor; /// use hypervisor::mshv::MshvHypervisor; /// use hypervisor::HypervisorVmConfig; /// use std::sync::Arc; diff --git a/hypervisor/src/mshv/x86_64/emulator.rs b/hypervisor/src/mshv/x86_64/emulator.rs index 80d2a2eda..3000cdf59 100644 --- a/hypervisor/src/mshv/x86_64/emulator.rs +++ b/hypervisor/src/mshv/x86_64/emulator.rs @@ -3,7 +3,9 @@ // Copyright © 2024, Microsoft Corporation // +use anyhow::anyhow; use iced_x86::Register; +use log::debug; use mshv_bindings::*; use crate::arch::emulator::{PlatformEmulator, PlatformError};