diff --git a/vmm/src/acpi.rs b/vmm/src/acpi.rs index f748c87c5..56513a6d0 100644 --- a/vmm/src/acpi.rs +++ b/vmm/src/acpi.rs @@ -16,6 +16,7 @@ use arch::NumaNodes; #[cfg(target_arch = "aarch64")] use arch::aarch64::DeviceInfoForFdt; use bitflags::bitflags; +use log::info; use pci::PciBdf; use tracer::trace_scoped; use vm_memory::{Address, Bytes, GuestAddress, GuestMemoryRegion}; diff --git a/vmm/src/api/dbus/mod.rs b/vmm/src/api/dbus/mod.rs index 59c48f8a9..6f75fb5cd 100644 --- a/vmm/src/api/dbus/mod.rs +++ b/vmm/src/api/dbus/mod.rs @@ -10,6 +10,7 @@ use std::thread; use futures::channel::oneshot; use futures::{FutureExt, executor}; use hypervisor::HypervisorType; +use log::{error, warn}; use seccompiler::{SeccompAction, apply_filter}; use vmm_sys_util::eventfd::EventFd; use zbus::connection::Builder; diff --git a/vmm/src/api/http/http_endpoint.rs b/vmm/src/api/http/http_endpoint.rs index b25b7e9ab..be8118e0e 100644 --- a/vmm/src/api/http/http_endpoint.rs +++ b/vmm/src/api/http/http_endpoint.rs @@ -73,6 +73,8 @@ mod fds_helper { use std::fs::File; use std::os::fd::{IntoRawFd, RawFd}; + use log::{debug, error, warn}; + use crate::api::http::HttpError; /// Abstraction over configuration types received via the HTTP API that @@ -172,7 +174,7 @@ mod fds_helper { if fds_amount > 0 { let new_fds = fds.drain(..fds_amount).collect::>(); - log::debug!( + debug!( "Attaching network FDs received via UNIX domain socket to device: id={:?}, fds={new_fds:?}", cfg.id() ); diff --git a/vmm/src/api/http/mod.rs b/vmm/src/api/http/mod.rs index 456610ce9..a35c9aca0 100644 --- a/vmm/src/api/http/mod.rs +++ b/vmm/src/api/http/mod.rs @@ -15,6 +15,7 @@ use std::sync::mpsc::Sender; use std::thread; use hypervisor::HypervisorType; +use log::error; use micro_http::{ Body, HttpServer, MediaType, Method, Request, Response, ServerError, StatusCode, Version, }; diff --git a/vmm/src/api/mod.rs b/vmm/src/api/mod.rs index 4bb4d0015..96c99f3fc 100644 --- a/vmm/src/api/mod.rs +++ b/vmm/src/api/mod.rs @@ -36,6 +36,7 @@ pub mod http; use std::io; use std::sync::mpsc::{RecvError, SendError, Sender, channel}; +use log::info; use micro_http::Body; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/vmm/src/config.rs b/vmm/src/config.rs index c7ec5a07d..5c04e6083 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -11,6 +11,7 @@ use std::result; use std::str::FromStr; use clap::ArgMatches; +use log::{debug, warn}; use option_parser::{ ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, Tuple, }; diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 5d35cab91..67cd79bdb 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -58,6 +58,12 @@ use hypervisor::{CpuState, HypervisorCpuError, VmExit, VmOps}; use libc::{c_void, siginfo_t}; #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] use linux_loader::elf::Elf64_Nhdr; +#[cfg(any( + target_arch = "aarch64", + all(target_arch = "x86_64", feature = "guest_debug") +))] +use log::debug; +use log::{error, info, warn}; use seccompiler::{SeccompAction, apply_filter}; use thiserror::Error; use tracer::trace_scoped; diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 81a061aad..1883e0d7b 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -68,6 +68,7 @@ use devices::legacy::{ #[cfg(feature = "pvmemcontrol")] use devices::pvmemcontrol::{PvmemcontrolBusDevice, PvmemcontrolPciDevice}; use devices::{AcpiNotificationFlags, interrupt_controller}; +use event_monitor::event; use hypervisor::IoEventAddress; #[cfg(target_arch = "aarch64")] use hypervisor::arch::aarch64::regs::AARCH64_PMU_IRQ; @@ -75,6 +76,7 @@ use libc::{ MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED, O_TMPFILE, PROT_READ, PROT_WRITE, TCSANOW, tcsetattr, termios, }; +use log::{debug, error, info, warn}; use pci::{ DeviceRelocation, MmioRegion, PciBarRegionType, PciBdf, PciDevice, VfioDmaMapping, VfioPciDevice, VfioUserDmaMapping, VfioUserPciDevice, VfioUserPciDeviceError, @@ -2615,7 +2617,7 @@ impl DeviceManager { let (virtio_device, migratable_device) = if disk_cfg.vhost_user { if is_hotplug { - log::debug!("Acquiring image lock for vhost-user block device not supported"); + debug!("Acquiring image lock for vhost-user block device not supported"); } let socket = disk_cfg.vhost_socket.as_ref().unwrap().clone(); let vu_cfg = VhostUserConfig { @@ -2801,7 +2803,7 @@ impl DeviceManager { // state save/resume, and live-migration, locking is part of the outer control flow // to ensure proper order of (un)locking. if is_hotplug { - log::debug!("Acquiring lock for hotplugged image"); + debug!("Acquiring lock for hotplugged image"); virtio_block .try_lock_image() .map_err(DeviceManagerError::DiskLockError)?; diff --git a/vmm/src/gdb.rs b/vmm/src/gdb.rs index f97fb4625..fc24767d9 100644 --- a/vmm/src/gdb.rs +++ b/vmm/src/gdb.rs @@ -29,6 +29,7 @@ use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs; use gdbstub_arch::x86::X86_64_SSE as GdbArch; #[cfg(target_arch = "x86_64")] use gdbstub_arch::x86::reg::X86_64CoreRegs as CoreRegs; +use log::{error, info}; use thiserror::Error; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryError}; diff --git a/vmm/src/igvm/igvm_loader.rs b/vmm/src/igvm/igvm_loader.rs index 03dd4d247..e53dc698f 100644 --- a/vmm/src/igvm/igvm_loader.rs +++ b/vmm/src/igvm/igvm_loader.rs @@ -15,6 +15,9 @@ use igvm_defs::{IGVM_VHS_MEMORY_MAP_ENTRY, MemoryMapEntryType}; use igvm_defs::{ IGVM_VHS_PARAMETER, IGVM_VHS_PARAMETER_INSERT, IgvmPageDataType, IgvmPlatformType, }; +use log::debug; +#[cfg(feature = "sev_snp")] +use log::info; use mshv_bindings::*; use thiserror::Error; use zerocopy::IntoBytes; diff --git a/vmm/src/igvm/loader.rs b/vmm/src/igvm/loader.rs index 316cadb1a..a27eb9498 100644 --- a/vmm/src/igvm/loader.rs +++ b/vmm/src/igvm/loader.rs @@ -2,6 +2,7 @@ // // Copyright © 2023, Microsoft Corporation // +use log::debug; use range_map_vec::{Entry, RangeMap}; use thiserror::Error; use vm_memory::bitmap::AtomicBitmap; diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 84cf123ea..e8c07dba5 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -3,11 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#[macro_use] -extern crate event_monitor; -#[macro_use] -extern crate log; - use std::collections::HashMap; use std::fs::File; use std::io::{Read, Write, stdout}; @@ -30,8 +25,10 @@ use api::http::HttpApiHandle; #[cfg(all(feature = "kvm", target_arch = "x86_64"))] use arch::x86_64::MAX_SUPPORTED_CPUS_LEGACY; use console_devices::{ConsoleInfo, pre_create_console_devices}; +use event_monitor::event; use landlock::LandlockError; use libc::{EFD_NONBLOCK, SIGINT, SIGTERM, TCSANOW, tcsetattr, termios}; +use log::{error, info, warn}; use memory_manager::MemoryManagerSnapshotData; use pci::PciBdf; use seccompiler::{SeccompAction, apply_filter}; diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index a9efbe99a..f73790e42 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -25,6 +25,9 @@ use devices::ioapic; #[cfg(target_arch = "aarch64")] use hypervisor::HypervisorVmError; use libc::_SC_NPROCESSORS_ONLN; +#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] +use log::debug; +use log::{error, info, warn}; use serde::{Deserialize, Serialize}; use thiserror::Error; use tracer::trace_scoped; diff --git a/vmm/src/pci_segment.rs b/vmm/src/pci_segment.rs index c31a60a22..b334ddb5d 100644 --- a/vmm/src/pci_segment.rs +++ b/vmm/src/pci_segment.rs @@ -13,6 +13,7 @@ use std::sync::{Arc, Mutex}; use acpi_tables::{Aml, aml}; use arch::layout; +use log::info; use pci::{DeviceRelocation, PciBdf, PciBus, PciConfigMmio, PciRoot}; #[cfg(target_arch = "x86_64")] use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE, PciConfigIo}; diff --git a/vmm/src/serial_manager.rs b/vmm/src/serial_manager.rs index 2df1ba3ca..6fa94a0c2 100644 --- a/vmm/src/serial_manager.rs +++ b/vmm/src/serial_manager.rs @@ -19,6 +19,7 @@ use devices::legacy::Pl011; #[cfg(any(target_arch = "x86_64", target_arch = "riscv64"))] use devices::legacy::Serial; use libc::EFD_NONBLOCK; +use log::{error, info, warn}; use serial_buffer::SerialBuffer; use thiserror::Error; use vmm_sys_util::eventfd::EventFd; diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index b5bb4a70a..fdaa77802 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -39,6 +39,7 @@ use devices::AcpiNotificationFlags; use devices::interrupt_controller; #[cfg(feature = "fw_cfg")] use devices::legacy::fw_cfg::FwCfgItem; +use event_monitor::event; #[cfg(all(target_arch = "aarch64", feature = "guest_debug"))] use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs; #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] @@ -57,6 +58,7 @@ use linux_loader::loader::bzimage::BzImage; use linux_loader::loader::elf::PvhBootCapability::PvhEntryPresent; #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] use linux_loader::loader::pe::Error::InvalidImageMagicNumber; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index 70c357902..662a9b409 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::{fs, result}; +use log::{debug, warn}; use net_util::MacAddr; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -807,13 +808,11 @@ impl PayloadConfig { (Some(_firmware), Some(_kernel)) => Err(PayloadConfigError::FirmwarePlusOtherPayloads), (Some(_firmware), None) => { if self.cmdline.is_some() { - log::warn!("Ignoring cmdline parameter as firmware is provided as the payload"); + warn!("Ignoring cmdline parameter as firmware is provided as the payload"); self.cmdline = None; } if self.initramfs.is_some() { - log::warn!( - "Ignoring initramfs parameter as firmware is provided as the payload" - ); + warn!("Ignoring initramfs parameter as firmware is provided as the payload"); self.initramfs = None; } Ok(())