misc: vmm: drop extern crate, use modern rust

This commit is part of a series of similar commits.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster 2025-09-05 09:21:43 +02:00 committed by Rob Bradford
parent 2157f1a1f2
commit 67fc9d990e
17 changed files with 35 additions and 12 deletions

View file

@ -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};

View file

@ -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;

View file

@ -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::<Vec<_>>();
log::debug!(
debug!(
"Attaching network FDs received via UNIX domain socket to device: id={:?}, fds={new_fds:?}",
cfg.id()
);

View file

@ -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,
};

View file

@ -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;

View file

@ -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,
};

View file

@ -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;

View file

@ -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)?;

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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(())