diff --git a/virtio-devices/src/balloon.rs b/virtio-devices/src/balloon.rs index dfb81d0a9..ca690ff3f 100644 --- a/virtio-devices/src/balloon.rs +++ b/virtio-devices/src/balloon.rs @@ -22,6 +22,8 @@ use std::sync::atomic::AtomicBool; use std::sync::{Arc, Barrier}; use anyhow::anyhow; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index 73f87f566..37488a82a 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -23,6 +23,8 @@ use block::fcntl::{LockError, LockGranularity, LockType, get_lock_state}; use block::{ ExecuteAsync, ExecuteError, Request, RequestType, VirtioBlockConfig, build_serial, fcntl, }; +use event_monitor::event; +use log::{debug, error, info, warn}; use rate_limiter::TokenType; use rate_limiter::group::{RateLimiterGroup, RateLimiterGroupHandle}; use seccompiler::SeccompAction; @@ -795,7 +797,7 @@ impl Block { false => LockType::Write, }; let granularity = self.lock_granularity(); - log::debug!( + debug!( "Attempting to acquire {lock_type:?} lock for disk image: id={},path={},granularity={granularity:?}", self.id, self.disk_path.display() @@ -806,9 +808,9 @@ impl Block { // Don't propagate the error to the outside, as it is not useful at all. Instead, // we try to log additional help to the user. if let Ok(current_lock) = current_lock { - log::error!("Can't get {lock_type:?} lock for {} as there is already a {current_lock:?} lock", self.disk_path.display()); + error!("Can't get {lock_type:?} lock for {} as there is already a {current_lock:?} lock", self.disk_path.display()); } else { - log::error!("Can't get {lock_type:?} lock for {}, but also can't determine the current lock state", self.disk_path.display()); + error!("Can't get {lock_type:?} lock for {}, but also can't determine the current lock state", self.disk_path.display()); } Error::LockDiskImage { path: self.disk_path.clone(), @@ -816,7 +818,7 @@ impl Block { lock_type, } })?; - log::info!( + info!( "Acquired {lock_type:?} lock for disk image id={},path={}", self.id, self.disk_path.display() diff --git a/virtio-devices/src/console.rs b/virtio-devices/src/console.rs index eeeeb5053..a036a5461 100644 --- a/virtio-devices/src/console.rs +++ b/virtio-devices/src/console.rs @@ -10,7 +10,9 @@ use std::sync::{Arc, Barrier, Mutex}; use std::{cmp, io, result}; use anyhow::anyhow; +use event_monitor::event; use libc::{EFD_NONBLOCK, TIOCGWINSZ}; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use serial_buffer::SerialBuffer; diff --git a/virtio-devices/src/device.rs b/virtio-devices/src/device.rs index cd9a8fea7..f0ed28f51 100644 --- a/virtio-devices/src/device.rs +++ b/virtio-devices/src/device.rs @@ -14,6 +14,7 @@ use std::sync::{Arc, Barrier}; use std::thread; use libc::EFD_NONBLOCK; +use log::{error, info, warn}; use virtio_queue::Queue; use vm_device::UserspaceMapping; use vm_memory::{GuestAddress, GuestMemoryAtomic}; diff --git a/virtio-devices/src/epoll_helper.rs b/virtio-devices/src/epoll_helper.rs index 5c0b3a57c..c20c1190a 100644 --- a/virtio-devices/src/epoll_helper.rs +++ b/virtio-devices/src/epoll_helper.rs @@ -14,6 +14,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Barrier}; use std::thread; +use log::info; use thiserror::Error; use vmm_sys_util::eventfd::EventFd; diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index e89665e51..1318e575f 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -10,6 +10,8 @@ use std::sync::{Arc, Barrier, Mutex, RwLock}; use std::{io, result}; use anyhow::anyhow; +use event_monitor::event; +use log::{debug, error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/virtio-devices/src/lib.rs b/virtio-devices/src/lib.rs index fad2d987f..da4f1c91b 100644 --- a/virtio-devices/src/lib.rs +++ b/virtio-devices/src/lib.rs @@ -10,11 +10,6 @@ //! Implements virtio devices, queues, and transport mechanisms. -#[macro_use] -extern crate event_monitor; -#[macro_use] -extern crate log; - use std::io; use serde::{Deserialize, Serialize}; diff --git a/virtio-devices/src/mem.rs b/virtio-devices/src/mem.rs index eda263c0f..3890928a5 100644 --- a/virtio-devices/src/mem.rs +++ b/virtio-devices/src/mem.rs @@ -22,6 +22,8 @@ use std::sync::{Arc, Barrier, Mutex, mpsc}; use std::{io, result}; use anyhow::anyhow; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index f0e98da3b..71faf8549 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -15,6 +15,8 @@ use std::sync::{Arc, Barrier}; use std::{result, thread}; use anyhow::anyhow; +use event_monitor::event; +use log::{debug, error, info}; #[cfg(not(fuzzing))] use net_util::virtio_features_to_tap_offload; use net_util::{ diff --git a/virtio-devices/src/pmem.rs b/virtio-devices/src/pmem.rs index ff8ad296b..da3722e25 100644 --- a/virtio-devices/src/pmem.rs +++ b/virtio-devices/src/pmem.rs @@ -14,6 +14,8 @@ use std::sync::{Arc, Barrier}; use std::{io, result}; use anyhow::anyhow; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/virtio-devices/src/rng.rs b/virtio-devices/src/rng.rs index c1d5ce9e1..aff511b0a 100644 --- a/virtio-devices/src/rng.rs +++ b/virtio-devices/src/rng.rs @@ -11,6 +11,8 @@ use std::sync::{Arc, Barrier}; use std::{io, result}; use anyhow::anyhow; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/virtio-devices/src/thread_helper.rs b/virtio-devices/src/thread_helper.rs index 735aebbf5..343e7c167 100644 --- a/virtio-devices/src/thread_helper.rs +++ b/virtio-devices/src/thread_helper.rs @@ -6,6 +6,7 @@ use std::panic::AssertUnwindSafe; use std::thread::{self, JoinHandle}; +use log::error; use seccompiler::{SeccompAction, apply_filter}; use vmm_sys_util::eventfd::EventFd; diff --git a/virtio-devices/src/transport/pci_common_config.rs b/virtio-devices/src/transport/pci_common_config.rs index 363c621eb..1a576ad5a 100644 --- a/virtio-devices/src/transport/pci_common_config.rs +++ b/virtio-devices/src/transport/pci_common_config.rs @@ -10,6 +10,7 @@ use std::sync::atomic::{AtomicU16, Ordering}; use std::sync::{Arc, Mutex}; use byteorder::{ByteOrder, LittleEndian}; +use log::{debug, error, warn}; use serde::{Deserialize, Serialize}; use virtio_queue::{Queue, QueueT}; use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable}; diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index ca60c2c06..0e1eb2cce 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -15,6 +15,7 @@ use std::sync::{Arc, Barrier, Mutex}; use anyhow::anyhow; use libc::EFD_NONBLOCK; +use log::{error, info}; use pci::{ BarReprogrammingParams, MsixCap, MsixConfig, PciBarConfiguration, PciBarRegionType, PciCapability, PciCapabilityId, PciClassCode, PciConfiguration, PciDevice, PciDeviceError, diff --git a/virtio-devices/src/vdpa.rs b/virtio-devices/src/vdpa.rs index 7c38e2f30..867cf21cc 100644 --- a/virtio-devices/src/vdpa.rs +++ b/virtio-devices/src/vdpa.rs @@ -9,6 +9,8 @@ use std::sync::{Arc, Mutex}; use std::{io, result}; use anyhow::anyhow; +use event_monitor::event; +use log::{debug, error, info}; use serde::{Deserialize, Serialize}; use thiserror::Error; use vhost::vdpa::{VhostVdpa, VhostVdpaIovaRange}; diff --git a/virtio-devices/src/vhost_user/blk.rs b/virtio-devices/src/vhost_user/blk.rs index 2c32e0b85..10bc87408 100644 --- a/virtio-devices/src/vhost_user/blk.rs +++ b/virtio-devices/src/vhost_user/blk.rs @@ -6,6 +6,8 @@ use std::sync::{Arc, Barrier, Mutex}; use std::{mem, result, thread}; use block::VirtioBlockConfig; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use vhost::vhost_user::message::{ diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index b8d728920..726d88367 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -5,6 +5,8 @@ use std::sync::atomic::AtomicBool; use std::sync::{Arc, Barrier, Mutex}; use std::{result, thread}; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use serde_with::{Bytes, serde_as}; diff --git a/virtio-devices/src/vhost_user/mod.rs b/virtio-devices/src/vhost_user/mod.rs index 1db305421..764b0d1c0 100644 --- a/virtio-devices/src/vhost_user/mod.rs +++ b/virtio-devices/src/vhost_user/mod.rs @@ -8,6 +8,7 @@ use std::sync::atomic::AtomicBool; use std::sync::{Arc, Barrier, Mutex}; use anyhow::anyhow; +use log::error; use serde::{Deserialize, Serialize}; use thiserror::Error; use vhost::Error as VhostError; diff --git a/virtio-devices/src/vhost_user/net.rs b/virtio-devices/src/vhost_user/net.rs index fef399e89..fb79d52d8 100644 --- a/virtio-devices/src/vhost_user/net.rs +++ b/virtio-devices/src/vhost_user/net.rs @@ -5,6 +5,8 @@ use std::sync::atomic::AtomicBool; use std::sync::{Arc, Barrier, Mutex}; use std::{result, thread}; +use event_monitor::event; +use log::{error, info}; use net_util::{CtrlQueue, MacAddr, VirtioNetConfig, build_net_config_space}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; diff --git a/virtio-devices/src/vhost_user/vu_common_ctrl.rs b/virtio-devices/src/vhost_user/vu_common_ctrl.rs index 5f81bc247..76a792c87 100644 --- a/virtio-devices/src/vhost_user/vu_common_ctrl.rs +++ b/virtio-devices/src/vhost_user/vu_common_ctrl.rs @@ -10,6 +10,7 @@ use std::sync::atomic::Ordering; use std::thread::sleep; use std::time::{Duration, Instant}; +use log::{error, info}; use vhost::vhost_kern::vhost_binding::{VHOST_F_LOG_ALL, VHOST_VRING_F_LOG}; use vhost::vhost_user::message::{ VhostUserHeaderFlag, VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures, diff --git a/virtio-devices/src/vsock/csm/connection.rs b/virtio-devices/src/vsock/csm/connection.rs index 3b87194da..fe89365e3 100644 --- a/virtio-devices/src/vsock/csm/connection.rs +++ b/virtio-devices/src/vsock/csm/connection.rs @@ -85,6 +85,8 @@ use std::num::Wrapping; use std::os::unix::io::{AsRawFd, RawFd}; use std::time::{Duration, Instant}; +use log::{debug, error, info, warn}; + use super::super::defs::uapi; use super::super::packet::VsockPacket; use super::super::{Result as VsockResult, VsockChannel, VsockEpollListener, VsockError}; diff --git a/virtio-devices/src/vsock/device.rs b/virtio-devices/src/vsock/device.rs index 38b834a43..63cfb3a67 100644 --- a/virtio-devices/src/vsock/device.rs +++ b/virtio-devices/src/vsock/device.rs @@ -16,6 +16,8 @@ use std::{io, result}; use anyhow::anyhow; use byteorder::{ByteOrder, LittleEndian}; +use event_monitor::event; +use log::{debug, error, info, warn}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use virtio_queue::{Queue, QueueOwnedT, QueueT}; diff --git a/virtio-devices/src/vsock/unix/muxer.rs b/virtio-devices/src/vsock/unix/muxer.rs index 6d91c6657..ee2264476 100644 --- a/virtio-devices/src/vsock/unix/muxer.rs +++ b/virtio-devices/src/vsock/unix/muxer.rs @@ -45,6 +45,8 @@ use std::io::{self, ErrorKind, Read}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::net::{UnixListener, UnixStream}; +use log::{debug, error, info, warn}; + use super::super::csm::ConnState; use super::super::defs::uapi; use super::super::packet::VsockPacket; diff --git a/virtio-devices/src/watchdog.rs b/virtio-devices/src/watchdog.rs index 124d586f8..2f76cae37 100644 --- a/virtio-devices/src/watchdog.rs +++ b/virtio-devices/src/watchdog.rs @@ -14,6 +14,8 @@ use std::sync::{Arc, Barrier, Mutex}; use std::time::Instant; use anyhow::anyhow; +use event_monitor::event; +use log::{error, info}; use seccompiler::SeccompAction; use serde::{Deserialize, Serialize}; use thiserror::Error;