misc: Further improve imports styling

By introducing `imports_granularity="Module"` format strategy,
effectively groups imports from the same module into one line or block,
improving maintainability and readability.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2024-09-29 15:22:27 +00:00 committed by Rob Bradford
parent 9013d8b4ca
commit 61e57e1cb1
99 changed files with 358 additions and 513 deletions

View File

@ -1,2 +1,4 @@
edition = "2021" edition = "2021"
group_imports="StdExternalCrate" group_imports="StdExternalCrate"
imports_granularity="Module"

View File

@ -6,15 +6,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file. // found in the THIRD-PARTY file.
use std::cmp;
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt::Debug; use std::fmt::Debug;
use std::fs;
use std::path::Path; use std::path::Path;
use std::result;
use std::str;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{cmp, fs, result, str};
use byteorder::{BigEndian, ByteOrder}; use byteorder::{BigEndian, ByteOrder};
use hypervisor::arch::aarch64::gic::Vgic; use hypervisor::arch::aarch64::gic::Vgic;
@ -22,9 +19,7 @@ use thiserror::Error;
use vm_fdt::{FdtWriter, FdtWriterResult}; use vm_fdt::{FdtWriter, FdtWriterResult};
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion}; use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion};
use super::super::DeviceType; use super::super::{DeviceType, GuestMemoryMmap, InitramfsConfig};
use super::super::GuestMemoryMmap;
use super::super::InitramfsConfig;
use super::layout::{ use super::layout::{
IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE, MEM_PCI_IO_START, IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE, MEM_PCI_IO_START,
PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT,

View File

@ -11,9 +11,8 @@
extern crate log; extern crate log;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::fmt;
use std::result;
use std::sync::Arc; use std::sync::Arc;
use std::{fmt, result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error; use thiserror::Error;

View File

@ -27,9 +27,7 @@ use vm_memory::{
GuestMemoryRegion, GuestUsize, GuestMemoryRegion, GuestUsize,
}; };
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, InitramfsConfig, RegionType};
use crate::InitramfsConfig;
use crate::RegionType;
mod smbios; mod smbios;
use std::arch::x86_64; use std::arch::x86_64;
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]

View File

@ -5,9 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file. // found in the LICENSE-BSD-3-Clause file.
use std::mem; use std::{mem, result, slice};
use std::result;
use std::slice;
use libc::c_uchar; use libc::c_uchar;
use thiserror::Error; use thiserror::Error;
@ -306,9 +304,8 @@ pub fn setup_mptable(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use vm_memory::{ use vm_memory::bitmap::BitmapSlice;
bitmap::BitmapSlice, GuestUsize, VolatileMemoryError, VolatileSlice, WriteVolatile, use vm_memory::{GuestUsize, VolatileMemoryError, VolatileSlice, WriteVolatile};
};
use super::*; use super::*;
use crate::layout::MPTABLE_START; use crate::layout::MPTABLE_START;

View File

@ -6,14 +6,11 @@
// //
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::mem; use std::{mem, result, slice};
use std::result;
use std::slice;
use thiserror::Error; use thiserror::Error;
use uuid::Uuid; use uuid::Uuid;
use vm_memory::ByteValued; use vm_memory::{Address, ByteValued, Bytes, GuestAddress};
use vm_memory::{Address, Bytes, GuestAddress};
use crate::layout::SMBIOS_START; use crate::layout::SMBIOS_START;
use crate::GuestMemoryMmap; use crate::GuestMemoryMmap;

View File

@ -31,7 +31,6 @@ pub mod vhdx;
pub mod vhdx_sync; pub mod vhdx_sync;
use std::alloc::{alloc_zeroed, dealloc, Layout}; use std::alloc::{alloc_zeroed, dealloc, Layout};
use std::cmp;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::fmt::Debug; use std::fmt::Debug;
use std::fs::File; use std::fs::File;
@ -39,10 +38,9 @@ use std::io::{self, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write};
use std::os::linux::fs::MetadataExt; use std::os::linux::fs::MetadataExt;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::Path; use std::path::Path;
use std::result; use std::sync::{Arc, MutexGuard};
use std::sync::Arc;
use std::sync::MutexGuard;
use std::time::Instant; use std::time::Instant;
use std::{cmp, result};
#[cfg(feature = "io_uring")] #[cfg(feature = "io_uring")]
use io_uring::{opcode, IoUring, Probe}; use io_uring::{opcode, IoUring, Probe};
@ -52,14 +50,13 @@ use smallvec::SmallVec;
use thiserror::Error; use thiserror::Error;
use virtio_bindings::virtio_blk::*; use virtio_bindings::virtio_blk::*;
use virtio_queue::DescriptorChain; use virtio_queue::DescriptorChain;
use vm_memory::bitmap::Bitmap;
use vm_memory::{ use vm_memory::{
bitmap::Bitmap, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryLoadGuard,
GuestMemoryLoadGuard,
}; };
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::aio;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::{ioctl_io_nr, ioctl_ioc_nr}; use vmm_sys_util::{aio, ioctl_io_nr, ioctl_ioc_nr};
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult}; use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult};
use crate::fixed_vhd::FixedVhd; use crate::fixed_vhd::FixedVhd;

View File

@ -19,17 +19,14 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use libc::{EINVAL, ENOSPC, ENOTSUP}; use libc::{EINVAL, ENOSPC, ENOTSUP};
use remain::sorted; use remain::sorted;
use thiserror::Error; use thiserror::Error;
use vmm_sys_util::{ use vmm_sys_util::file_traits::{FileSetLen, FileSync};
file_traits::FileSetLen, file_traits::FileSync, seek_hole::SeekHole, write_zeroes::PunchHole, use vmm_sys_util::seek_hole::SeekHole;
write_zeroes::WriteZeroesAt, use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
};
use crate::qcow::qcow_raw_file::QcowRawFile;
pub use crate::qcow::raw_file::RawFile; pub use crate::qcow::raw_file::RawFile;
use crate::qcow::{ use crate::qcow::refcount::RefCount;
qcow_raw_file::QcowRawFile, use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
refcount::RefCount,
vec_cache::{CacheMap, Cacheable, VecCache},
};
use crate::BlockBackend; use crate::BlockBackend;
/// Nesting depth limit for disk formats that can open other disk files. /// Nesting depth limit for disk formats that can open other disk files.

View File

@ -15,7 +15,8 @@ use std::os::unix::io::{AsRawFd, RawFd};
use std::slice; use std::slice;
use libc::c_void; use libc::c_void;
use vmm_sys_util::{seek_hole::SeekHole, write_zeroes::PunchHole, write_zeroes::WriteZeroesAt}; use vmm_sys_util::seek_hole::SeekHole;
use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
use crate::BlockBackend; use crate::BlockBackend;

View File

@ -9,10 +9,8 @@ use std::io;
use libc::EINVAL; use libc::EINVAL;
use thiserror::Error; use thiserror::Error;
use crate::qcow::{ use crate::qcow::qcow_raw_file::QcowRawFile;
qcow_raw_file::QcowRawFile, use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
vec_cache::{CacheMap, Cacheable, VecCache},
};
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {

View File

@ -11,12 +11,10 @@ use remain::sorted;
use thiserror::Error; use thiserror::Error;
use uuid::Uuid; use uuid::Uuid;
use crate::vhdx::{ use crate::vhdx::vhdx_bat::{BatEntry, VhdxBatError};
vhdx_bat::{BatEntry, VhdxBatError}, use crate::vhdx::vhdx_header::{RegionInfo, RegionTableEntry, VhdxHeader, VhdxHeaderError};
vhdx_header::{RegionInfo, RegionTableEntry, VhdxHeader, VhdxHeaderError}, use crate::vhdx::vhdx_io::VhdxIoError;
vhdx_io::VhdxIoError, use crate::vhdx::vhdx_metadata::{DiskSpec, VhdxMetadataError};
vhdx_metadata::{DiskSpec, VhdxMetadataError},
};
use crate::BlockBackend; use crate::BlockBackend;
macro_rules! div_round_up { macro_rules! div_round_up {

View File

@ -10,7 +10,8 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use remain::sorted; use remain::sorted;
use thiserror::Error; use thiserror::Error;
use crate::vhdx::{vhdx_header::RegionTableEntry, vhdx_metadata::DiskSpec}; use crate::vhdx::vhdx_header::RegionTableEntry;
use crate::vhdx::vhdx_metadata::DiskSpec;
// Payload BAT Entry States // Payload BAT Entry States
pub const PAYLOAD_BLOCK_NOT_PRESENT: u64 = 0; pub const PAYLOAD_BLOCK_NOT_PRESENT: u64 = 0;

View File

@ -8,10 +8,8 @@ use std::io::{self, Read, Seek, SeekFrom, Write};
use remain::sorted; use remain::sorted;
use thiserror::Error; use thiserror::Error;
use crate::vhdx::{ use crate::vhdx::vhdx_bat::{self, BatEntry, VhdxBatError};
vhdx_bat::{self, BatEntry, VhdxBatError}, use crate::vhdx::vhdx_metadata::{self, DiskSpec};
vhdx_metadata::{self, DiskSpec},
};
const SECTOR_SIZE: u64 = 512; const SECTOR_SIZE: u64 = 512;

View File

@ -9,10 +9,8 @@ use std::sync::{Arc, Mutex};
use anyhow::anyhow; use anyhow::anyhow;
use arch::layout; use arch::layout;
use hypervisor::{ use hypervisor::arch::aarch64::gic::{Vgic, VgicConfig};
arch::aarch64::gic::{Vgic, VgicConfig}, use hypervisor::{CpuState, GicState};
CpuState, GicState,
};
use vm_device::interrupt::{ use vm_device::interrupt::{
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup, InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
LegacyIrqSourceConfig, MsiIrqGroupConfig, LegacyIrqSourceConfig, MsiIrqGroupConfig,

View File

@ -2,8 +2,7 @@
// //
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::io; use std::{io, result};
use std::result;
use thiserror::Error; use thiserror::Error;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -5,10 +5,9 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::cmp::min; use std::cmp::min;
use std::mem;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::thread; use std::{mem, thread};
// https://github.com/rust-lang/libc/issues/1848 // https://github.com/rust-lang/libc/issues/1848
#[cfg_attr(target_env = "musl", allow(deprecated))] #[cfg_attr(target_env = "musl", allow(deprecated))]

View File

@ -7,9 +7,8 @@
//! This module implements an ARM PrimeCell General Purpose Input/Output(PL061) to support gracefully poweroff microvm from external. //! This module implements an ARM PrimeCell General Purpose Input/Output(PL061) to support gracefully poweroff microvm from external.
//! //!
use std::io;
use std::result;
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::{io, result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error; use thiserror::Error;

View File

@ -4,10 +4,8 @@
// //
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::sync::{ use std::sync::atomic::{AtomicBool, Ordering};
atomic::{AtomicBool, Ordering}, use std::sync::{Arc, Barrier};
Arc, Barrier,
};
use std::thread; use std::thread;
use vm_device::BusDevice; use vm_device::BusDevice;

View File

@ -3,12 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::{ use std::collections::HashMap;
collections::HashMap, use std::ffi::CString;
ffi::CString, use std::sync::{Arc, Barrier, Mutex, RwLock};
io, result, use std::{io, result};
sync::{Arc, Barrier, Mutex, RwLock},
};
use num_enum::TryFromPrimitive; use num_enum::TryFromPrimitive;
use pci::{ use pci::{
@ -16,11 +14,13 @@ use pci::{
PciClassCode, PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciSubclass, PciClassCode, PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciSubclass,
}; };
use thiserror::Error; use thiserror::Error;
use vm_allocator::{page_size::get_page_size, AddressAllocator, SystemAllocator}; use vm_allocator::page_size::get_page_size;
use vm_allocator::{AddressAllocator, SystemAllocator};
use vm_device::{BusDeviceSync, Resource}; use vm_device::{BusDeviceSync, Resource};
use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{ use vm_memory::{
bitmap::AtomicBitmap, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
GuestMemoryAtomic, GuestMemoryError, GuestMemoryMmap, Le32, Le64, GuestMemoryError, GuestMemoryMmap, Le32, Le64,
}; };
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};

View File

@ -11,7 +11,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -9,19 +9,20 @@
#![no_main] #![no_main]
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::ffi;
use std::fs::File; use std::fs::File;
use std::io;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use std::{ffi, io};
use block::{async_io::DiskFile, raw_sync::RawFileDiskSync}; use block::async_io::DiskFile;
use block::raw_sync::RawFileDiskSync;
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{Block, VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{Block, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -13,7 +13,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -12,9 +12,10 @@ use libfuzzer_sys::fuzz_target;
use micro_http::Request; use micro_http::Request;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use vm_migration::MigratableError; use vm_migration::MigratableError;
use vmm::api::http::*;
use vmm::api::{ use vmm::api::{
http::*, ApiRequest, RequestHandler, VmInfoResponse, VmReceiveMigrationData, ApiRequest, RequestHandler, VmInfoResponse, VmReceiveMigrationData, VmSendMigrationData,
VmSendMigrationData, VmmPingResponse, VmmPingResponse,
}; };
use vmm::config::RestoreConfig; use vmm::config::RestoreConfig;
use vmm::vm::{Error as VmError, VmState}; use vmm::vm::{Error as VmError, VmState};

View File

@ -11,7 +11,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -8,15 +8,15 @@
#![no_main] #![no_main]
use std::ffi;
use std::fs::File; use std::fs::File;
use std::io;
use std::io::{Seek, SeekFrom, Write}; use std::io::{Seek, SeekFrom, Write};
use std::os::unix::io::{FromRawFd, RawFd}; use std::os::unix::io::{FromRawFd, RawFd};
use std::{ffi, io};
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use linux_loader::loader::KernelLoader; use linux_loader::loader::KernelLoader;
use vm_memory::{bitmap::AtomicBitmap, GuestAddress}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::GuestAddress;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -9,7 +9,8 @@
#![no_main] #![no_main]
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use vm_memory::{bitmap::AtomicBitmap, GuestAddress}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::GuestAddress;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -11,7 +11,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{BlocksState, Mem, VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{BlocksState, Mem, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -13,7 +13,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm::EpollContext; use vmm::EpollContext;
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};

View File

@ -4,19 +4,19 @@
#![no_main] #![no_main]
use std::ffi;
use std::fs::File; use std::fs::File;
use std::io;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc; use std::sync::Arc;
use std::{ffi, io};
use libc::{MAP_NORESERVE, MAP_PRIVATE, PROT_READ, PROT_WRITE}; use libc::{MAP_NORESERVE, MAP_PRIVATE, PROT_READ, PROT_WRITE};
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{Pmem, UserspaceMapping, VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{Pmem, UserspaceMapping, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::bitmap::AtomicBitmap;
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic, MmapRegion}; use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic, MmapRegion};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -11,7 +11,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -11,7 +11,8 @@ use libfuzzer_sys::fuzz_target;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType}; use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{bitmap::AtomicBitmap, Bytes, GuestAddress, GuestMemoryAtomic}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -17,9 +17,7 @@ use crate::aarch64::{RegList, VcpuInit};
use crate::arch::x86::{CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters}; use crate::arch::x86::{CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters};
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
use crate::kvm::{TdxExitDetails, TdxExitStatus}; use crate::kvm::{TdxExitDetails, TdxExitStatus};
use crate::CpuState; use crate::{CpuState, MpState, StandardRegisters};
use crate::MpState;
use crate::StandardRegisters;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
#[derive(Copy, Clone, Default)] #[derive(Copy, Clone, Default)]

View File

@ -11,8 +11,7 @@ use crate::kvm::kvm_bindings::{
KVM_REG_ARM64_SYSREG_OP0_MASK, KVM_REG_ARM64_SYSREG_OP0_SHIFT, KVM_REG_ARM64_SYSREG_OP2_MASK, KVM_REG_ARM64_SYSREG_OP0_MASK, KVM_REG_ARM64_SYSREG_OP0_SHIFT, KVM_REG_ARM64_SYSREG_OP2_MASK,
KVM_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_SIZE_U64, KVM_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_SIZE_U64,
}; };
use crate::kvm::Register; use crate::kvm::{Register, VcpuKvmState};
use crate::kvm::VcpuKvmState;
use crate::CpuState; use crate::CpuState;
// Relevant redistributor registers that we want to save/restore. // Relevant redistributor registers that we want to save/restore.

View File

@ -15,8 +15,8 @@ use kvm_bindings::{
KVM_REG_SIZE_MASK, KVM_REG_SIZE_U32, KVM_REG_SIZE_U64, KVM_REG_SIZE_MASK, KVM_REG_SIZE_U32, KVM_REG_SIZE_U64,
}; };
pub use kvm_bindings::{kvm_one_reg as Register, kvm_vcpu_init as VcpuInit, RegList}; pub use kvm_bindings::{kvm_one_reg as Register, kvm_vcpu_init as VcpuInit, RegList};
pub use kvm_ioctls::{Cap, Kvm};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub use {kvm_ioctls::Cap, kvm_ioctls::Kvm};
use crate::kvm::{KvmError, KvmResult}; use crate::kvm::{KvmError, KvmResult};

View File

@ -19,8 +19,7 @@ use std::os::unix::io::RawFd;
use std::result; use std::result;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex; use std::sync::{Arc, Mutex, RwLock};
use std::sync::{Arc, RwLock};
use kvm_ioctls::{NoDatamatch, VcpuFd, VmFd}; use kvm_ioctls::{NoDatamatch, VcpuFd, VmFd};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
@ -34,13 +33,10 @@ pub use crate::aarch64::{
}; };
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use crate::arch::aarch64::gic::{Vgic, VgicConfig}; use crate::arch::aarch64::gic::{Vgic, VgicConfig};
use crate::cpu;
use crate::hypervisor;
use crate::vec_with_array_field;
use crate::vm::{self, InterruptSourceConfig, VmOps}; use crate::vm::{self, InterruptSourceConfig, VmOps};
use crate::HypervisorType;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use crate::{arm64_core_reg_id, offset_of}; use crate::{arm64_core_reg_id, offset_of};
use crate::{cpu, hypervisor, vec_with_array_field, HypervisorType};
// x86_64 dependencies // x86_64 dependencies
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
pub mod x86_64; pub mod x86_64;
@ -62,9 +58,8 @@ use crate::arch::x86::{
}; };
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use crate::ClockData; use crate::ClockData;
use crate::StandardRegisters;
use crate::{ use crate::{
CpuState, IoEventAddress, IrqRoutingEntry, MpState, UserMemoryRegion, CpuState, IoEventAddress, IrqRoutingEntry, MpState, StandardRegisters, UserMemoryRegion,
USER_MEMORY_REGION_LOG_DIRTY, USER_MEMORY_REGION_READ, USER_MEMORY_REGION_WRITE, USER_MEMORY_REGION_LOG_DIRTY, USER_MEMORY_REGION_READ, USER_MEMORY_REGION_WRITE,
}; };
// aarch64 dependencies // aarch64 dependencies
@ -73,7 +68,6 @@ pub mod aarch64;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use std::mem; use std::mem;
pub use kvm_bindings;
pub use kvm_bindings::{ pub use kvm_bindings::{
kvm_clock_data, kvm_create_device, kvm_device_type_KVM_DEV_TYPE_VFIO, kvm_guest_debug, kvm_clock_data, kvm_create_device, kvm_device_type_KVM_DEV_TYPE_VFIO, kvm_guest_debug,
kvm_irq_routing, kvm_irq_routing_entry, kvm_mp_state, kvm_userspace_memory_region, kvm_irq_routing, kvm_irq_routing_entry, kvm_mp_state, kvm_userspace_memory_region,
@ -89,12 +83,12 @@ use kvm_bindings::{
}; };
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
use kvm_bindings::{kvm_run__bindgen_ty_1, KVMIO}; use kvm_bindings::{kvm_run__bindgen_ty_1, KVMIO};
pub use kvm_ioctls;
pub use kvm_ioctls::{Cap, Kvm}; pub use kvm_ioctls::{Cap, Kvm};
use thiserror::Error; use thiserror::Error;
use vfio_ioctls::VfioDeviceFd; use vfio_ioctls::VfioDeviceFd;
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
use vmm_sys_util::{ioctl::ioctl_with_val, ioctl_ioc_nr, ioctl_iowr_nr}; use vmm_sys_util::{ioctl::ioctl_with_val, ioctl_ioc_nr, ioctl_iowr_nr};
pub use {kvm_bindings, kvm_ioctls};
/// ///
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms /// Export generically-named wrappers of kvm-bindings for Unix-based platforms
/// ///

View File

@ -15,12 +15,9 @@ use vm::DataMatch;
use crate::arch::emulator::PlatformEmulator; use crate::arch::emulator::PlatformEmulator;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use crate::arch::x86::emulator::Emulator; use crate::arch::x86::emulator::Emulator;
use crate::cpu;
use crate::hypervisor;
use crate::mshv::emulator::MshvEmulatorContext; use crate::mshv::emulator::MshvEmulatorContext;
use crate::vec_with_array_field;
use crate::vm::{self, InterruptSourceConfig, VmOps}; use crate::vm::{self, InterruptSourceConfig, VmOps};
use crate::HypervisorType; use crate::{cpu, hypervisor, vec_with_array_field, HypervisorType};
#[cfg(feature = "sev_snp")] #[cfg(feature = "sev_snp")]
mod snp_constants; mod snp_constants;
// x86_64 dependencies // x86_64 dependencies

View File

@ -29,8 +29,7 @@ use crate::arch::x86::CpuIdEntry;
use crate::cpu::Vcpu; use crate::cpu::Vcpu;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use crate::ClockData; use crate::ClockData;
use crate::UserMemoryRegion; use crate::{IoEventAddress, IrqRoutingEntry, UserMemoryRegion};
use crate::{IoEventAddress, IrqRoutingEntry};
/// ///
/// I/O events data matches (32 or 64 bits). /// I/O events data matches (32 or 64 bits).

View File

@ -16,8 +16,7 @@ use virtio_queue::{Queue, QueueT};
use vm_memory::{ByteValued, Bytes, GuestMemoryError}; use vm_memory::{ByteValued, Bytes, GuestMemoryError};
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, Tap};
use crate::Tap;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {

View File

@ -26,7 +26,8 @@ use virtio_bindings::virtio_net::{
VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_TSO4,
VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_F_MAC, VIRTIO_NET_F_MQ, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_F_MAC, VIRTIO_NET_F_MQ,
}; };
use vm_memory::{bitmap::AtomicBitmap, ByteValued}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::ByteValued;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -5,9 +5,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file. // found in the THIRD-PARTY file.
use std::fmt;
use std::io;
use std::str::FromStr; use std::str::FromStr;
use std::{fmt, io};
use serde::de::{Deserialize, Deserializer, Error}; use serde::de::{Deserialize, Deserializer, Error};
use serde::ser::{Serialize, Serializer}; use serde::ser::{Serialize, Serializer};

View File

@ -424,10 +424,9 @@ impl AsRawFd for Tap {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use std::str;
use std::sync::{mpsc, Mutex}; use std::sync::{mpsc, Mutex};
use std::thread;
use std::time::Duration; use std::time::Duration;
use std::{str, thread};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use pnet::packet::ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket}; use pnet::packet::ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket};

View File

@ -3,13 +3,11 @@
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
// //
use std::io;
use std::result;
use std::sync::Arc; use std::sync::Arc;
use std::{io, result};
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use serde::Deserialize; use serde::{Deserialize, Serialize};
use serde::Serialize;
use vm_device::interrupt::{ use vm_device::interrupt::{
InterruptIndex, InterruptSourceConfig, InterruptSourceGroup, MsiIrqSourceConfig, InterruptIndex, InterruptSourceConfig, InterruptSourceGroup, MsiIrqSourceConfig,
}; };

View File

@ -25,8 +25,10 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use crate::vfio::{UserMemoryRegion, Vfio, VfioCommon, VfioError, VFIO_COMMON_ID}; use crate::vfio::{UserMemoryRegion, Vfio, VfioCommon, VfioError, VFIO_COMMON_ID};
use crate::{BarReprogrammingParams, PciBarConfiguration, VfioPciError}; use crate::{
use crate::{PciBdf, PciDevice, PciDeviceError, PciSubclass}; BarReprogrammingParams, PciBarConfiguration, PciBdf, PciDevice, PciDeviceError, PciSubclass,
VfioPciError,
};
pub struct VfioUserPciDevice { pub struct VfioUserPciDevice {
id: String, id: String,

View File

@ -8,13 +8,11 @@ extern crate test_infra;
mod performance_tests; mod performance_tests;
use std::{ use std::process::Command;
env, fmt, use std::sync::mpsc::channel;
process::Command, use std::sync::Arc;
sync::{mpsc::channel, Arc}, use std::time::Duration;
thread, use std::{env, fmt, thread};
time::Duration,
};
use clap::{Arg, ArgAction, Command as ClapCommand}; use clap::{Arg, ArgAction, Command as ClapCommand};
use performance_tests::*; use performance_tests::*;

View File

@ -5,13 +5,11 @@
// Performance tests // Performance tests
use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use std::thread;
use std::time::Duration; use std::time::Duration;
use std::{fs, thread};
use test_infra::Error as InfraError; use test_infra::{Error as InfraError, *};
use test_infra::*;
use crate::{mean, PerformanceTestControl}; use crate::{mean, PerformanceTestControl};

View File

@ -6,11 +6,9 @@
use core::panic::AssertUnwindSafe; use core::panic::AssertUnwindSafe;
use std::fs::File; use std::fs::File;
use std::io;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::result;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread; use std::{io, result, thread};
use thiserror::Error; use thiserror::Error;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
@ -300,12 +298,15 @@ impl Drop for RateLimiterGroup {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use std::{os::fd::AsRawFd, thread, time::Duration}; use std::os::fd::AsRawFd;
use std::thread;
use std::time::Duration;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::RateLimiterGroupHandle; use super::RateLimiterGroupHandle;
use crate::{group::RateLimiterGroup, TokenBucket, TokenType, REFILL_TIMER_INTERVAL_MS}; use crate::group::RateLimiterGroup;
use crate::{TokenBucket, TokenType, REFILL_TIMER_INTERVAL_MS};
impl RateLimiterGroupHandle { impl RateLimiterGroupHandle {
pub fn bandwidth(&self) -> Option<TokenBucket> { pub fn bandwidth(&self) -> Option<TokenBucket> {

View File

@ -520,8 +520,7 @@ impl Default for RateLimiter {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use std::fmt; use std::{fmt, thread};
use std::thread;
use super::*; use super::*;

View File

@ -3,14 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::{ use std::collections::VecDeque;
collections::VecDeque, use std::io::Write;
io::Write, use std::sync::atomic::{AtomicBool, Ordering};
sync::{ use std::sync::Arc;
atomic::{AtomicBool, Ordering},
Arc,
},
};
const MAX_BUFFER_SIZE: usize = 1 << 20; const MAX_BUFFER_SIZE: usize = 1 << 20;

View File

@ -3,16 +3,15 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::fmt;
use std::io::Read; use std::io::Read;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
use std::process; use std::{fmt, process};
use api_client::simple_api_command; use api_client::{
use api_client::simple_api_command_with_fds; simple_api_command, simple_api_command_with_fds, simple_api_full_command,
use api_client::simple_api_full_command; Error as ApiClientError,
use api_client::Error as ApiClientError; };
use clap::{Arg, ArgAction, ArgMatches, Command}; use clap::{Arg, ArgAction, ArgMatches, Command};
use option_parser::{ByteSized, ByteSizedParseError}; use option_parser::{ByteSized, ByteSizedParseError};
#[cfg(feature = "dbus_api")] #[cfg(feature = "dbus_api")]

View File

@ -5,22 +5,18 @@
#![allow(clippy::undocumented_unsafe_blocks)] #![allow(clippy::undocumented_unsafe_blocks)]
use std::env;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fmt::Display; use std::fmt::Display;
use std::io;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::net::TcpListener; use std::net::{TcpListener, TcpStream};
use std::net::TcpStream;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
use std::os::unix::io::{AsRawFd, FromRawFd}; use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::Path; use std::path::Path;
use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::str::FromStr; use std::str::FromStr;
use std::sync::Mutex; use std::sync::Mutex;
use std::thread;
use std::time::Duration; use std::time::Duration;
use std::{fmt, fs}; use std::{env, fmt, fs, io, thread};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde_json::Value; use serde_json::Value;

View File

@ -11,24 +11,19 @@
extern crate test_infra; extern crate test_infra;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs; use std::io::{BufRead, Read, Seek, Write};
use std::io;
use std::io::BufRead;
use std::io::Read;
use std::io::Seek;
use std::io::Write;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{Child, Command, Stdio}; use std::process::{Child, Command, Stdio};
use std::string::String; use std::string::String;
use std::sync::mpsc;
use std::sync::mpsc::Receiver; use std::sync::mpsc::Receiver;
use std::sync::Mutex; use std::sync::{mpsc, Mutex};
use std::thread; use std::{fs, io, thread};
use net_util::MacAddr; use net_util::MacAddr;
use test_infra::*; use test_infra::*;
use vmm_sys_util::{tempdir::TempDir, tempfile::TempFile}; use vmm_sys_util::tempdir::TempDir;
use vmm_sys_util::tempfile::TempFile;
use wait_timeout::ChildExt; use wait_timeout::ChildExt;
// Constant taken from the VMM crate. // Constant taken from the VMM crate.
@ -2347,7 +2342,8 @@ fn make_guest_panic(guest: &Guest) {
} }
mod common_parallel { mod common_parallel {
use std::{fs::OpenOptions, io::SeekFrom}; use std::fs::OpenOptions;
use std::io::SeekFrom;
use crate::*; use crate::*;

View File

@ -8,13 +8,14 @@ use std::path::Path;
use std::{mem, ptr}; use std::{mem, ptr};
use anyhow::anyhow; use anyhow::anyhow;
use libc::c_void; use libc::{c_void, sockaddr_storage, socklen_t};
use libc::{sockaddr_storage, socklen_t};
use thiserror::Error; use thiserror::Error;
use crate::socket::SocketDev; use crate::socket::SocketDev;
use crate::{Commands, MemberType, Ptm, PtmCap, PtmEst, PtmInit, PtmResult, PtmSetBufferSize}; use crate::{
use crate::{TPM_CRB_BUFFER_MAX, TPM_SUCCESS}; Commands, MemberType, Ptm, PtmCap, PtmEst, PtmInit, PtmResult, PtmSetBufferSize,
TPM_CRB_BUFFER_MAX, TPM_SUCCESS,
};
const TPM_REQ_HDR_SIZE: usize = 10; const TPM_REQ_HDR_SIZE: usize = 10;

View File

@ -8,41 +8,32 @@
// //
// SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause) // SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause)
use std::fs::File; use std::fs::{File, OpenOptions};
use std::fs::OpenOptions; use std::io::{Read, Seek, SeekFrom, Write};
use std::io::Read; use std::ops::{Deref, DerefMut};
use std::io::{Seek, SeekFrom, Write};
use std::ops::Deref;
use std::ops::DerefMut;
use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::OpenOptionsExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::process;
use std::result;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, RwLock, RwLockWriteGuard}; use std::sync::{Arc, Mutex, RwLock, RwLockWriteGuard};
use std::time::Instant; use std::time::Instant;
use std::{convert, error, fmt, io}; use std::{convert, error, fmt, io, process, result};
use block::{ use block::qcow::{self, ImageType, QcowFile};
build_serial, use block::{build_serial, Request, VirtioBlockConfig};
qcow::{self, ImageType, QcowFile},
Request, VirtioBlockConfig,
};
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use log::*; use log::*;
use option_parser::{OptionParser, OptionParserError, Toggle}; use option_parser::{OptionParser, OptionParserError, Toggle};
use vhost::vhost_user::message::*; use vhost::vhost_user::message::*;
use vhost::vhost_user::Listener; use vhost::vhost_user::Listener;
use vhost_user_backend::{ use vhost_user_backend::bitmap::BitmapMmapRegion;
bitmap::BitmapMmapRegion, VhostUserBackendMut, VhostUserDaemon, VringRwLock, VringState, VringT, use vhost_user_backend::{VhostUserBackendMut, VhostUserDaemon, VringRwLock, VringState, VringT};
};
use virtio_bindings::virtio_blk::*; use virtio_bindings::virtio_blk::*;
use virtio_bindings::virtio_config::VIRTIO_F_VERSION_1; use virtio_bindings::virtio_config::VIRTIO_F_VERSION_1;
use virtio_bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use virtio_queue::QueueT; use virtio_queue::QueueT;
use vm_memory::GuestAddressSpace; use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_memory::{ByteValued, Bytes, GuestMemoryAtomic}; use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::{epoll::EventSet, eventfd::EventFd}; use vmm_sys_util::eventfd::EventFd;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<BitmapMmapRegion>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<BitmapMmapRegion>;

View File

@ -6,30 +6,27 @@
// //
// SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause) // SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause)
use std::fmt;
use std::io;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use std::ops::Deref; use std::ops::Deref;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::process;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::{fmt, io, process};
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use log::*; use log::*;
use net_util::{ use net_util::{
open_tap, MacAddr, NetCounters, NetQueuePair, OpenTapError, RxVirtio, Tap, TxVirtio, open_tap, MacAddr, NetCounters, NetQueuePair, OpenTapError, RxVirtio, Tap, TxVirtio,
}; };
use option_parser::Toggle; use option_parser::{OptionParser, OptionParserError, Toggle};
use option_parser::{OptionParser, OptionParserError};
use vhost::vhost_user::message::*; use vhost::vhost_user::message::*;
use vhost::vhost_user::Listener; use vhost::vhost_user::Listener;
use vhost_user_backend::bitmap::BitmapMmapRegion; use vhost_user_backend::bitmap::BitmapMmapRegion;
use vhost_user_backend::{VhostUserBackendMut, VhostUserDaemon, VringRwLock, VringT}; use vhost_user_backend::{VhostUserBackendMut, VhostUserDaemon, VringRwLock, VringT};
use virtio_bindings::virtio_config::{VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_F_VERSION_1}; use virtio_bindings::virtio_config::{VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_F_VERSION_1};
use virtio_bindings::virtio_net::*; use virtio_bindings::virtio_net::*;
use vm_memory::GuestAddressSpace; use vm_memory::{GuestAddressSpace, GuestMemoryAtomic};
use vm_memory::GuestMemoryAtomic; use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::{epoll::EventSet, eventfd::EventFd}; use vmm_sys_util::eventfd::EventFd;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<BitmapMmapRegion>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<BitmapMmapRegion>;

View File

@ -18,7 +18,8 @@ use std::io::{self, Write};
use std::mem::size_of; use std::mem::size_of;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::result; use std::result;
use std::sync::{atomic::AtomicBool, Arc, Barrier}; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier};
use anyhow::anyhow; use anyhow::anyhow;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -33,11 +34,12 @@ use vm_memory::{
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;
use crate::{ use crate::{
seccomp_filters::Thread, thread_helper::spawn_virtio_thread, ActivateResult, EpollHelper, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, GuestMemoryMmap,
EpollHelperError, EpollHelperHandler, GuestMemoryMmap, VirtioCommon, VirtioDevice, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType,
VirtioDeviceType, VirtioInterrupt, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
VIRTIO_F_VERSION_1,
}; };
const QUEUE_SIZE: u16 = 128; const QUEUE_SIZE: u16 = 128;

View File

@ -8,23 +8,18 @@
// //
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::collections::BTreeMap; use std::collections::{BTreeMap, HashMap, VecDeque};
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io;
use std::num::Wrapping; use std::num::Wrapping;
use std::ops::Deref; use std::ops::Deref;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::PathBuf; use std::path::PathBuf;
use std::result;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use block::{ use block::async_io::{AsyncIo, AsyncIoError, DiskFile};
async_io::AsyncIo, async_io::AsyncIoError, async_io::DiskFile, build_serial, Request, use block::{build_serial, Request, RequestType, VirtioBlockConfig};
RequestType, VirtioBlockConfig,
};
use rate_limiter::group::{RateLimiterGroup, RateLimiterGroupHandle}; use rate_limiter::group::{RateLimiterGroup, RateLimiterGroupHandle};
use rate_limiter::TokenType; use rate_limiter::TokenType;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -39,15 +34,14 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::AccessPlatform; use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
VirtioDevice, VirtioDeviceType, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST, Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType,
EPOLL_HELPER_EVENT_LAST,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, VirtioInterrupt};
use crate::VirtioInterrupt;
const SECTOR_SHIFT: u8 = 9; const SECTOR_SHIFT: u8 = 9;
pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT; pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT;

View File

@ -1,15 +1,13 @@
// Copyright 2019 Intel Corporation. All Rights Reserved. // Copyright 2019 Intel Corporation. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::cmp;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::fs::File; use std::fs::File;
use std::io;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::result;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::{cmp, io, result};
use anyhow::anyhow; use anyhow::anyhow;
use libc::{EFD_NONBLOCK, TIOCGWINSZ}; use libc::{EFD_NONBLOCK, TIOCGWINSZ};
@ -23,16 +21,14 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, VirtioDevice, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
VirtioDeviceType, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IOMMU_PLATFORM, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, VirtioInterrupt};
use crate::VirtioInterrupt;
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;
const NUM_QUEUES: usize = 2; const NUM_QUEUES: usize = 2;

View File

@ -9,18 +9,15 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::io::Write; use std::io::Write;
use std::num::Wrapping; use std::num::Wrapping;
use std::sync::{ use std::sync::atomic::{AtomicBool, Ordering};
atomic::{AtomicBool, Ordering}, use std::sync::{Arc, Barrier};
Arc, Barrier,
};
use std::thread; use std::thread;
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use virtio_queue::Queue; use virtio_queue::Queue;
use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestUsize}; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestUsize};
use vm_migration::{MigratableError, Pausable}; use vm_migration::{MigratableError, Pausable};
use vm_virtio::AccessPlatform; use vm_virtio::{AccessPlatform, VirtioDeviceType};
use vm_virtio::VirtioDeviceType;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use crate::{ use crate::{

View File

@ -3,13 +3,12 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io;
use std::mem::size_of; use std::mem::size_of;
use std::ops::Bound::Included; use std::ops::Bound::Included;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::result;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier, Mutex, RwLock}; use std::sync::{Arc, Barrier, Mutex, RwLock};
use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -25,15 +24,13 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::AccessPlatform; use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, VirtioDevice, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{DmaRemapping, GuestMemoryMmap, VirtioInterrupt, VirtioInterruptType};
use crate::{DmaRemapping, VirtioInterrupt, VirtioInterruptType};
/// Queues sizes /// Queues sizes
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;

View File

@ -39,7 +39,8 @@ pub mod vhost_user;
pub mod vsock; pub mod vsock;
pub mod watchdog; pub mod watchdog;
use vm_memory::{bitmap::AtomicBitmap, GuestAddress, GuestMemory}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{GuestAddress, GuestMemory};
use vm_virtio::VirtioDeviceType; use vm_virtio::VirtioDeviceType;
pub use self::balloon::Balloon; pub use self::balloon::Balloon;

View File

@ -15,13 +15,11 @@
// limitations under the License. // limitations under the License.
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io;
use std::mem::size_of; use std::mem::size_of;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::mpsc; use std::sync::{mpsc, Arc, Barrier, Mutex};
use std::sync::{Arc, Barrier, Mutex}; use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -37,15 +35,14 @@ use vm_migration::protocol::MemoryRangeTable;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::{GuestMemoryMmap, GuestRegionMmap}; use crate::{GuestMemoryMmap, GuestRegionMmap, VirtioInterrupt, VirtioInterruptType};
use crate::{VirtioInterrupt, VirtioInterruptType};
const QUEUE_SIZE: u16 = 128; const QUEUE_SIZE: u16 = 128;
const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE]; const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE];

View File

@ -10,18 +10,16 @@ use std::net::Ipv4Addr;
use std::num::Wrapping; use std::num::Wrapping;
use std::ops::Deref; use std::ops::Deref;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::result;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::thread; use std::{result, thread};
use anyhow::anyhow; use anyhow::anyhow;
#[cfg(not(fuzzing))] #[cfg(not(fuzzing))]
use net_util::virtio_features_to_tap_offload; use net_util::virtio_features_to_tap_offload;
use net_util::CtrlQueue;
use net_util::{ use net_util::{
build_net_config_space, build_net_config_space_with_mq, open_tap, MacAddr, NetCounters, build_net_config_space, build_net_config_space_with_mq, open_tap, CtrlQueue, MacAddr,
NetQueuePair, OpenTapError, RxVirtio, Tap, TapError, TxVirtio, VirtioNetConfig, NetCounters, NetQueuePair, OpenTapError, RxVirtio, Tap, TapError, TxVirtio, VirtioNetConfig,
}; };
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -35,16 +33,14 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::AccessPlatform; use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
RateLimiterConfig, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType, Error as DeviceError, RateLimiterConfig, VirtioCommon, VirtioDevice, VirtioDeviceType,
EPOLL_HELPER_EVENT_LAST, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, VirtioInterrupt};
use crate::VirtioInterrupt;
/// Control queue /// Control queue
// Event available on the control queue. // Event available on the control queue.

View File

@ -7,12 +7,11 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::fs::File; use std::fs::File;
use std::io;
use std::mem::size_of; use std::mem::size_of;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -27,16 +26,14 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
UserspaceMapping, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, Error as DeviceError, UserspaceMapping, VirtioCommon, VirtioDevice, VirtioDeviceType,
VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::{GuestMemoryMmap, MmapRegion}; use crate::{GuestMemoryMmap, MmapRegion, VirtioInterrupt, VirtioInterruptType};
use crate::{VirtioInterrupt, VirtioInterruptType};
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;
const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE]; const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE];

View File

@ -5,11 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use std::fs::File; use std::fs::File;
use std::io;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier}; use std::sync::{Arc, Barrier};
use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -21,16 +20,14 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IOMMU_PLATFORM, Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, VirtioInterrupt, VirtioInterruptType};
use crate::{VirtioInterrupt, VirtioInterruptType};
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;
const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE]; const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE];

View File

@ -4,9 +4,10 @@
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use seccompiler::SeccompCmpOp::Eq;
use seccompiler::{ use seccompiler::{
BpfProgram, Error, SeccompAction, SeccompCmpArgLen as ArgLen, SeccompCmpOp::Eq, BpfProgram, Error, SeccompAction, SeccompCmpArgLen as ArgLen, SeccompCondition as Cond,
SeccompCondition as Cond, SeccompFilter, SeccompRule, SeccompFilter, SeccompRule,
}; };
pub enum Thread { pub enum Thread {

View File

@ -3,19 +3,15 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::{ use std::panic::AssertUnwindSafe;
panic::AssertUnwindSafe, use std::thread::{self, JoinHandle};
thread::{self, JoinHandle},
};
use seccompiler::{apply_filter, SeccompAction}; use seccompiler::{apply_filter, SeccompAction};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use crate::{ use crate::epoll_helper::EpollHelperError;
epoll_helper::EpollHelperError, use crate::seccomp_filters::{get_seccomp_filter, Thread};
seccomp_filters::{get_seccomp_filter, Thread}, use crate::ActivateError;
ActivateError,
};
pub(crate) fn spawn_virtio_thread<F>( pub(crate) fn spawn_virtio_thread<F>(
name: &str, name: &str,

View File

@ -410,8 +410,7 @@ mod tests {
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::*; use super::*;
use crate::GuestMemoryMmap; use crate::{ActivateResult, GuestMemoryMmap, VirtioInterrupt};
use crate::{ActivateResult, VirtioInterrupt};
struct DummyDevice(u32); struct DummyDevice(u32);
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;

View File

@ -36,11 +36,10 @@ use vmm_sys_util::eventfd::EventFd;
use super::pci_common_config::VirtioPciCommonConfigState; use super::pci_common_config::VirtioPciCommonConfigState;
use crate::transport::{VirtioPciCommonConfig, VirtioTransport, VIRTIO_PCI_COMMON_CONFIG_ID}; use crate::transport::{VirtioPciCommonConfig, VirtioTransport, VIRTIO_PCI_COMMON_CONFIG_ID};
use crate::GuestMemoryMmap;
use crate::{ use crate::{
ActivateResult, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType, ActivateResult, GuestMemoryMmap, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED, DEVICE_FEATURES_OK, VirtioInterruptType, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED,
DEVICE_INIT, DEVICE_FEATURES_OK, DEVICE_INIT,
}; };
/// Vector value used to disable MSI for a queue. /// Vector value used to disable MSI for a queue.

View File

@ -3,24 +3,19 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::{ use std::collections::BTreeMap;
collections::BTreeMap, use std::sync::atomic::{AtomicBool, Ordering};
io, result, use std::sync::{Arc, Mutex};
sync::{ use std::{io, result};
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
};
use anyhow::anyhow; use anyhow::anyhow;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error; use thiserror::Error;
use vhost::{ use vhost::vdpa::{VhostVdpa, VhostVdpaIovaRange};
vdpa::{VhostVdpa, VhostVdpaIovaRange}, use vhost::vhost_kern::vdpa::VhostKernVdpa;
vhost_kern::VhostKernFeatures, use vhost::vhost_kern::vhost_binding::VHOST_BACKEND_F_SUSPEND;
vhost_kern::{vdpa::VhostKernVdpa, vhost_binding::VHOST_BACKEND_F_SUSPEND}, use vhost::vhost_kern::VhostKernFeatures;
VhostBackend, VringConfigData, use vhost::{VhostBackend, VringConfigData};
};
use virtio_queue::{Descriptor, Queue, QueueT}; use virtio_queue::{Descriptor, Queue, QueueT};
use vm_device::dma_mapping::ExternalDmaMapping; use vm_device::dma_mapping::ExternalDmaMapping;
use vm_memory::{GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic}; use vm_memory::{GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};

View File

@ -1,11 +1,9 @@
// Copyright 2019 Intel Corporation. All Rights Reserved. // Copyright 2019 Intel Corporation. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::mem;
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::thread; use std::{mem, result, thread};
use block::VirtioBlockConfig; use block::VirtioBlockConfig;
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -22,10 +20,8 @@ use virtio_bindings::virtio_blk::{
}; };
use virtio_queue::Queue; use virtio_queue::Queue;
use vm_memory::{ByteValued, GuestMemoryAtomic}; use vm_memory::{ByteValued, GuestMemoryAtomic};
use vm_migration::{ use vm_migration::protocol::MemoryRangeTable;
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
Transportable,
};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::super::{ActivateResult, VirtioCommon, VirtioDevice, VirtioDeviceType}; use super::super::{ActivateResult, VirtioCommon, VirtioDevice, VirtioDeviceType};
@ -34,8 +30,7 @@ use super::{Error, Result, DEFAULT_VIRTIO_FEATURES};
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::VhostUserCommon; use crate::vhost_user::VhostUserCommon;
use crate::{GuestMemoryMmap, GuestRegionMmap}; use crate::{GuestMemoryMmap, GuestRegionMmap, VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM};
use crate::{VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM};
const DEFAULT_QUEUE_NUMBER: usize = 1; const DEFAULT_QUEUE_NUMBER: usize = 1;

View File

@ -1,10 +1,9 @@
// Copyright 2019 Intel Corporation. All Rights Reserved. // Copyright 2019 Intel Corporation. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::thread; use std::{result, thread};
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -13,10 +12,8 @@ use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatu
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler}; use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
use virtio_queue::Queue; use virtio_queue::Queue;
use vm_memory::{ByteValued, GuestMemoryAtomic}; use vm_memory::{ByteValued, GuestMemoryAtomic};
use vm_migration::{ use vm_migration::protocol::MemoryRangeTable;
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
Transportable,
};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::vu_common_ctrl::VhostUserHandle; use super::vu_common_ctrl::VhostUserHandle;
@ -25,10 +22,10 @@ use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::VhostUserCommon; use crate::vhost_user::VhostUserCommon;
use crate::{ use crate::{
ActivateResult, UserspaceMapping, VirtioCommon, VirtioDevice, VirtioDeviceType, ActivateResult, GuestMemoryMmap, GuestRegionMmap, MmapRegion, UserspaceMapping, VirtioCommon,
VirtioInterrupt, VirtioSharedMemoryList, VIRTIO_F_IOMMU_PLATFORM, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList,
VIRTIO_F_IOMMU_PLATFORM,
}; };
use crate::{GuestMemoryMmap, GuestRegionMmap, MmapRegion};
const NUM_QUEUE_OFFSET: usize = 1; const NUM_QUEUE_OFFSET: usize = 1;
const DEFAULT_QUEUE_NUMBER: usize = 2; const DEFAULT_QUEUE_NUMBER: usize = 2;

View File

@ -4,7 +4,8 @@
use std::io; use std::io;
use std::ops::Deref; use std::ops::Deref;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::sync::{atomic::AtomicBool, Arc, Barrier, Mutex}; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, Mutex};
use anyhow::anyhow; use anyhow::anyhow;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -14,13 +15,11 @@ use vhost::vhost_user::message::{
}; };
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontendReqHandler}; use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontendReqHandler};
use vhost::Error as VhostError; use vhost::Error as VhostError;
use virtio_queue::Error as QueueError; use virtio_queue::{Error as QueueError, Queue};
use virtio_queue::Queue; use vm_memory::mmap::MmapRegionError;
use vm_memory::{ use vm_memory::{Address, Error as MmapError, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};
mmap::MmapRegionError, Address, Error as MmapError, GuestAddressSpace, GuestMemory, use vm_migration::protocol::MemoryRangeTable;
GuestMemoryAtomic, use vm_migration::{MigratableError, Snapshot};
};
use vm_migration::{protocol::MemoryRangeTable, MigratableError, Snapshot};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use vu_common_ctrl::VhostUserHandle; use vu_common_ctrl::VhostUserHandle;

View File

@ -1,10 +1,9 @@
// Copyright 2019 Intel Corporation. All Rights Reserved. // Copyright 2019 Intel Corporation. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::thread; use std::{result, thread};
use net_util::{build_net_config_space, CtrlQueue, MacAddr, VirtioNetConfig}; use net_util::{build_net_config_space, CtrlQueue, MacAddr, VirtioNetConfig};
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
@ -20,10 +19,8 @@ use virtio_bindings::virtio_net::{
use virtio_bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use virtio_queue::{Queue, QueueT}; use virtio_queue::{Queue, QueueT};
use vm_memory::{ByteValued, GuestMemoryAtomic}; use vm_memory::{ByteValued, GuestMemoryAtomic};
use vm_migration::{ use vm_migration::protocol::MemoryRangeTable;
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
Transportable,
};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
@ -31,10 +28,10 @@ use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::vu_common_ctrl::{VhostUserConfig, VhostUserHandle}; use crate::vhost_user::vu_common_ctrl::{VhostUserConfig, VhostUserHandle};
use crate::vhost_user::{Error, Result, VhostUserCommon}; use crate::vhost_user::{Error, Result, VhostUserCommon};
use crate::{ use crate::{
ActivateResult, NetCtrlEpollHandler, VirtioCommon, VirtioDevice, VirtioDeviceType, ActivateResult, GuestMemoryMmap, GuestRegionMmap, NetCtrlEpollHandler, VirtioCommon,
VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1,
}; };
use crate::{GuestMemoryMmap, GuestRegionMmap};
const DEFAULT_QUEUE_NUMBER: usize = 2; const DEFAULT_QUEUE_NUMBER: usize = 2;

View File

@ -88,9 +88,8 @@ use std::time::{Duration, Instant};
use super::super::defs::uapi; use super::super::defs::uapi;
use super::super::packet::VsockPacket; use super::super::packet::VsockPacket;
use super::super::{Result as VsockResult, VsockChannel, VsockEpollListener, VsockError}; use super::super::{Result as VsockResult, VsockChannel, VsockEpollListener, VsockError};
use super::defs;
use super::txbuf::TxBuf; use super::txbuf::TxBuf;
use super::{ConnState, Error, PendingRx, PendingRxSet, Result}; use super::{defs, ConnState, Error, PendingRx, PendingRxSet, Result};
/// A self-managing connection object, that handles communication between a guest-side AF_VSOCK /// A self-managing connection object, that handles communication between a guest-side AF_VSOCK
/// socket and a host-side `Read + Write + AsRawFd` stream. /// socket and a host-side `Read + Write + AsRawFd` stream.

View File

@ -5,8 +5,7 @@
use std::io::Write; use std::io::Write;
use std::num::Wrapping; use std::num::Wrapping;
use super::defs; use super::{defs, Error, Result};
use super::{Error, Result};
/// A simple ring-buffer implementation, used by vsock connections to buffer TX (guest -> host) /// A simple ring-buffer implementation, used by vsock connections to buffer TX (guest -> host)
/// data. Memory for this buffer is allocated lazily, since buffering will only be needed when /// data. Memory for this buffer is allocated lazily, since buffering will only be needed when
@ -144,9 +143,7 @@ impl TxBuf {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io::Error as IoError; use std::io::{Error as IoError, ErrorKind, Result as IoResult};
use std::io::ErrorKind;
use std::io::Result as IoResult;
use super::*; use super::*;

View File

@ -8,22 +8,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file. // found in the THIRD-PARTY file.
use std::io;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::PathBuf; use std::path::PathBuf;
use std::result;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, RwLock}; use std::sync::{Arc, Barrier, RwLock};
use std::{io, result};
use anyhow::anyhow; use anyhow::anyhow;
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use seccompiler::SeccompAction; use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use virtio_queue::Queue; use virtio_queue::{Queue, QueueOwnedT, QueueT};
use virtio_queue::QueueOwnedT; use vm_memory::{GuestAddressSpace, GuestMemoryAtomic};
use virtio_queue::QueueT;
use vm_memory::GuestAddressSpace;
use vm_memory::GuestMemoryAtomic;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vm_virtio::AccessPlatform; use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
@ -49,13 +45,12 @@ use vmm_sys_util::eventfd::EventFd;
/// ///
use super::{VsockBackend, VsockPacket}; use super::{VsockBackend, VsockPacket};
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::Error as DeviceError; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap;
use crate::VirtioInterrupt;
use crate::{ use crate::{
thread_helper::spawn_virtio_thread, ActivateResult, EpollHelper, EpollHelperError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
EpollHelperHandler, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType, GuestMemoryMmap, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_VERSION_1,
}; };
const QUEUE_SIZE: u16 = 256; const QUEUE_SIZE: u16 = 256;

View File

@ -18,8 +18,7 @@ use std::os::unix::io::RawFd;
use packet::VsockPacket; use packet::VsockPacket;
pub use self::device::Vsock; pub use self::device::Vsock;
pub use self::unix::VsockUnixBackend; pub use self::unix::{VsockUnixBackend, VsockUnixError};
pub use self::unix::VsockUnixError;
mod defs { mod defs {
@ -178,8 +177,7 @@ mod tests {
use super::*; use super::*;
use crate::device::{VirtioInterrupt, VirtioInterruptType}; use crate::device::{VirtioInterrupt, VirtioInterruptType};
use crate::epoll_helper::EpollHelperHandler; use crate::epoll_helper::EpollHelperHandler;
use crate::EpollHelper; use crate::{EpollHelper, GuestMemoryMmap};
use crate::GuestMemoryMmap;
pub struct NoopVirtioInterrupt {} pub struct NoopVirtioInterrupt {}

View File

@ -24,8 +24,7 @@ use virtio_queue::DescriptorChain;
use vm_memory::{Address, GuestMemory}; use vm_memory::{Address, GuestMemory};
use vm_virtio::{AccessPlatform, Translatable}; use vm_virtio::{AccessPlatform, Translatable};
use super::defs; use super::{defs, Result, VsockError};
use super::{Result, VsockError};
use crate::get_host_address_range; use crate::get_host_address_range;
// The vsock packet header is defined by the C struct: // The vsock packet header is defined by the C struct:

View File

@ -50,11 +50,9 @@ use super::super::packet::VsockPacket;
use super::super::{ use super::super::{
Result as VsockResult, VsockBackend, VsockChannel, VsockEpollListener, VsockError, Result as VsockResult, VsockBackend, VsockChannel, VsockEpollListener, VsockError,
}; };
use super::defs;
use super::muxer_killq::MuxerKillQ; use super::muxer_killq::MuxerKillQ;
use super::muxer_rxq::MuxerRxQ; use super::muxer_rxq::MuxerRxQ;
use super::MuxerConnection; use super::{defs, Error, MuxerConnection, Result};
use super::{Error, Result};
/// A unique identifier of a `MuxerConnection` object. Connections are stored in a hash map, /// A unique identifier of a `MuxerConnection` object. Connections are stored in a hash map,
/// keyed by a `ConnMapKey` object. /// keyed by a `ConnMapKey` object.

View File

@ -28,9 +28,8 @@
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::time::Instant; use std::time::Instant;
use super::defs;
use super::muxer::ConnMapKey; use super::muxer::ConnMapKey;
use super::MuxerConnection; use super::{defs, MuxerConnection};
/// A kill queue item, holding the connection key and the scheduled time for termination. /// A kill queue item, holding the connection key and the scheduled time for termination.
/// ///

View File

@ -19,9 +19,8 @@
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use super::super::VsockChannel; use super::super::VsockChannel;
use super::defs;
use super::muxer::{ConnMapKey, MuxerRx}; use super::muxer::{ConnMapKey, MuxerRx};
use super::MuxerConnection; use super::{defs, MuxerConnection};
/// The muxer RX queue. /// The muxer RX queue.
/// ///

View File

@ -22,15 +22,14 @@ use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use super::Error as DeviceError;
use super::{ use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, VirtioCommon, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::Thread; use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread; use crate::thread_helper::spawn_virtio_thread;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, VirtioInterrupt, VirtioInterruptType};
use crate::{VirtioInterrupt, VirtioInterruptType};
const QUEUE_SIZE: u16 = 8; const QUEUE_SIZE: u16 = 8;
const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE]; const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE];

View File

@ -13,7 +13,8 @@ pub mod testing {
use std::mem; use std::mem;
use virtio_queue::{Queue, QueueT, VirtqUsedElem}; use virtio_queue::{Queue, QueueT, VirtqUsedElem};
use vm_memory::{bitmap::AtomicBitmap, Address, Bytes, GuestAddress, GuestUsize}; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{Address, Bytes, GuestAddress, GuestUsize};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>; type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;

View File

@ -5,9 +5,11 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Instant; use std::time::Instant;
use acpi_tables::rsdp::Rsdp;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use acpi_tables::sdt::GenericAddress; use acpi_tables::sdt::GenericAddress;
use acpi_tables::{rsdp::Rsdp, sdt::Sdt, Aml}; use acpi_tables::sdt::Sdt;
use acpi_tables::Aml;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use arch::aarch64::DeviceInfoForFdt; use arch::aarch64::DeviceInfoForFdt;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]

View File

@ -26,8 +26,7 @@ use crate::api::{
VmSendMigration, VmShutdown, VmSnapshot, VmmPing, VmmShutdown, VmSendMigration, VmShutdown, VmSnapshot, VmmPing, VmmShutdown,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::{Error as VmmError, Result as VmmResult}; use crate::{Error as VmmError, NetConfig, Result as VmmResult, VmConfig};
use crate::{NetConfig, VmConfig};
pub type DBusApiShutdownChannels = (oneshot::Sender<()>, oneshot::Receiver<()>); pub type DBusApiShutdownChannels = (oneshot::Sender<()>, oneshot::Receiver<()>);

View File

@ -45,8 +45,7 @@ use vmm_sys_util::eventfd::EventFd;
#[cfg(feature = "dbus_api")] #[cfg(feature = "dbus_api")]
pub use self::dbus::start_dbus_thread; pub use self::dbus::start_dbus_thread;
pub use self::http::start_http_fd_thread; pub use self::http::{start_http_fd_thread, start_http_path_thread};
pub use self::http::start_http_path_thread;
use crate::config::{ use crate::config::{
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, UserDeviceConfig, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, UserDeviceConfig,
VdpaConfig, VmConfig, VsockConfig, VdpaConfig, VmConfig, VsockConfig,

View File

@ -4,10 +4,9 @@
// //
use std::collections::{BTreeSet, HashMap}; use std::collections::{BTreeSet, HashMap};
use std::fmt;
use std::path::PathBuf; use std::path::PathBuf;
use std::result;
use std::str::FromStr; use std::str::FromStr;
use std::{fmt, result};
use clap::ArgMatches; use clap::ArgMatches;
use option_parser::{ use option_parser::{

View File

@ -10,27 +10,16 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
// //
use std::fs::read_link; use std::fs::{read_link, File, OpenOptions};
use std::fs::File;
use std::fs::OpenOptions;
use std::io;
use std::mem::zeroed; use std::mem::zeroed;
use std::os::fd::AsRawFd; use std::os::fd::{AsRawFd, FromRawFd, RawFd};
use std::os::fd::FromRawFd;
use std::os::fd::RawFd;
use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::net::UnixListener; use std::os::unix::net::UnixListener;
use std::path::PathBuf; use std::path::PathBuf;
use std::result; use std::sync::{Arc, Mutex};
use std::sync::Arc; use std::{io, result};
use std::sync::Mutex;
use libc::cfmakeraw; use libc::{cfmakeraw, isatty, tcgetattr, tcsetattr, termios, TCSANOW};
use libc::isatty;
use libc::tcgetattr;
use libc::tcsetattr;
use libc::termios;
use libc::TCSANOW;
use thiserror::Error; use thiserror::Error;
use crate::sigwinch_listener::listen_for_sigwinch_on_tty; use crate::sigwinch_listener::listen_for_sigwinch_on_tty;

View File

@ -21,14 +21,14 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::{cmp, io, result, thread}; use std::{cmp, io, result, thread};
use acpi_tables::{aml, sdt::Sdt, Aml}; use acpi_tables::sdt::Sdt;
use acpi_tables::{aml, Aml};
use anyhow::anyhow; use anyhow::anyhow;
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))] #[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
use arch::aarch64::regs; use arch::aarch64::regs;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use arch::x86_64::get_x2apic_id; use arch::x86_64::get_x2apic_id;
use arch::EntryPoint; use arch::{EntryPoint, NumaNodes};
use arch::NumaNodes;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use devices::gic::Gic; use devices::gic::Gic;
use devices::interrupt_controller::InterruptController; use devices::interrupt_controller::InterruptController;
@ -91,8 +91,7 @@ use crate::memory_manager::MemoryManager;
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use crate::vm::physical_bits; use crate::vm::physical_bits;
use crate::GuestMemoryMmap; use crate::{GuestMemoryMmap, CPU_MANAGER_SNAPSHOT_ID};
use crate::CPU_MANAGER_SNAPSHOT_ID;
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))] #[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
/// Extract the specified bits of a 64-bit integer. /// Extract the specified bits of a 64-bit integer.
/// For example, to extrace 2 bits from offset 1 (zero based) of `6u64`, /// For example, to extrace 2 bits from offset 1 (zero based) of `6u64`,
@ -2806,8 +2805,7 @@ impl CpuElf64Writable for CpuManager {
#[cfg(all(feature = "kvm", target_arch = "x86_64"))] #[cfg(all(feature = "kvm", target_arch = "x86_64"))]
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use arch::layout::BOOT_STACK_POINTER; use arch::layout::{BOOT_STACK_POINTER, ZERO_PAGE_START};
use arch::layout::ZERO_PAGE_START;
use arch::x86_64::interrupts::*; use arch::x86_64::interrupts::*;
use arch::x86_64::regs::*; use arch::x86_64::regs::*;
use hypervisor::arch::x86::{FpuState, LapicState}; use hypervisor::arch::x86::{FpuState, LapicState};
@ -2947,7 +2945,8 @@ mod tests {
mod tests { mod tests {
use std::mem; use std::mem;
use arch::{aarch64::regs, layout}; use arch::aarch64::regs;
use arch::layout;
use hypervisor::kvm::aarch64::is_system_register; use hypervisor::kvm::aarch64::is_system_register;
use hypervisor::kvm::kvm_bindings::{ use hypervisor::kvm::kvm_bindings::{
kvm_vcpu_init, user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM64_SYSREG, KVM_REG_ARM_CORE, kvm_vcpu_init, user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM64_SYSREG, KVM_REG_ARM_CORE,

View File

@ -23,16 +23,19 @@ use std::time::Instant;
use acpi_tables::sdt::GenericAddress; use acpi_tables::sdt::GenericAddress;
use acpi_tables::{aml, Aml}; use acpi_tables::{aml, Aml};
use anyhow::anyhow; use anyhow::anyhow;
use arch::layout;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START}; use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
use arch::NumaNodes; use arch::{layout, NumaNodes};
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use arch::{DeviceType, MmioDeviceInfo}; use arch::{DeviceType, MmioDeviceInfo};
use block::async_io::DiskFile;
use block::fixed_vhd_sync::FixedVhdDiskSync;
use block::qcow_sync::QcowDiskSync;
use block::raw_async_aio::RawFileDiskAio;
use block::raw_sync::RawFileDiskSync;
use block::vhdx_sync::VhdxDiskSync;
use block::{ use block::{
async_io::DiskFile, block_aio_is_supported, block_io_uring_is_supported, detect_image_type, block_aio_is_supported, block_io_uring_is_supported, detect_image_type, qcow, vhdx, ImageType,
fixed_vhd_sync::FixedVhdDiskSync, qcow, qcow_sync::QcowDiskSync, raw_async_aio::RawFileDiskAio,
raw_sync::RawFileDiskSync, vhdx, vhdx_sync::VhdxDiskSync, ImageType,
}; };
#[cfg(feature = "io_uring")] #[cfg(feature = "io_uring")]
use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk}; use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
@ -40,15 +43,14 @@ use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
use devices::debug_console::DebugConsole; use devices::debug_console::DebugConsole;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use devices::gic; use devices::gic;
use devices::interrupt_controller::InterruptController;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use devices::ioapic; use devices::ioapic;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use devices::legacy::Pl011; use devices::legacy::Pl011;
#[cfg(feature = "pvmemcontrol")] #[cfg(feature = "pvmemcontrol")]
use devices::pvmemcontrol::{PvmemcontrolBusDevice, PvmemcontrolPciDevice}; use devices::pvmemcontrol::{PvmemcontrolBusDevice, PvmemcontrolPciDevice};
use devices::{ use devices::{interrupt_controller, AcpiNotificationFlags};
interrupt_controller, interrupt_controller::InterruptController, AcpiNotificationFlags,
};
use hypervisor::IoEventAddress; use hypervisor::IoEventAddress;
use libc::{ use libc::{
tcsetattr, termios, MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED, O_TMPFILE, PROT_READ, PROT_WRITE, tcsetattr, termios, MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED, O_TMPFILE, PROT_READ, PROT_WRITE,
@ -63,13 +65,12 @@ use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracer::trace_scoped; use tracer::trace_scoped;
use vfio_ioctls::{VfioContainer, VfioDevice, VfioDeviceFd}; use vfio_ioctls::{VfioContainer, VfioDevice, VfioDeviceFd};
use virtio_devices::transport::VirtioTransport; use virtio_devices::transport::{VirtioPciDevice, VirtioPciDeviceActivator, VirtioTransport};
use virtio_devices::transport::{VirtioPciDevice, VirtioPciDeviceActivator};
use virtio_devices::vhost_user::VhostUserConfig; use virtio_devices::vhost_user::VhostUserConfig;
use virtio_devices::{ use virtio_devices::{
AccessPlatformMapping, ActivateError, VdpaDmaMapping, VirtioMemMappingSource, AccessPlatformMapping, ActivateError, Endpoint, IommuMapping, VdpaDmaMapping,
VirtioMemMappingSource,
}; };
use virtio_devices::{Endpoint, IommuMapping};
use vm_allocator::{AddressAllocator, SystemAllocator}; use vm_allocator::{AddressAllocator, SystemAllocator};
use vm_device::dma_mapping::ExternalDmaMapping; use vm_device::dma_mapping::ExternalDmaMapping;
use vm_device::interrupt::{ use vm_device::interrupt::{
@ -77,16 +78,15 @@ use vm_device::interrupt::{
}; };
use vm_device::{Bus, BusDevice, BusDeviceSync, Resource}; use vm_device::{Bus, BusDevice, BusDeviceSync, Resource};
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
use vm_memory::GuestMemoryRegion; use vm_memory::{Address, GuestAddress, GuestMemoryRegion, GuestUsize, MmapRegion};
use vm_memory::{Address, GuestAddress, GuestUsize, MmapRegion};
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use vm_memory::{GuestAddressSpace, GuestMemory}; use vm_memory::{GuestAddressSpace, GuestMemory};
use vm_migration::protocol::MemoryRangeTable;
use vm_migration::{ use vm_migration::{
protocol::MemoryRangeTable, snapshot_from_id, state_from_id, Migratable, MigratableError, snapshot_from_id, state_from_id, Migratable, MigratableError, Pausable, Snapshot, SnapshotData,
Pausable, Snapshot, SnapshotData, Snapshottable, Transportable, Snapshottable, Transportable,
}; };
use vm_virtio::AccessPlatform; use vm_virtio::{AccessPlatform, VirtioDeviceType};
use vm_virtio::VirtioDeviceType;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use {devices::debug_console, devices::legacy::Serial}; use {devices::debug_console, devices::legacy::Serial};
@ -98,15 +98,12 @@ use crate::config::{
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo, ConsoleOutput}; use crate::console_devices::{ConsoleDeviceError, ConsoleInfo, ConsoleOutput};
use crate::cpu::{CpuManager, CPU_MANAGER_ACPI_SIZE}; use crate::cpu::{CpuManager, CPU_MANAGER_ACPI_SIZE};
use crate::device_tree::{DeviceNode, DeviceTree}; use crate::device_tree::{DeviceNode, DeviceTree};
use crate::interrupt::LegacyUserspaceInterruptManager; use crate::interrupt::{LegacyUserspaceInterruptManager, MsiInterruptManager};
use crate::interrupt::MsiInterruptManager;
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager, MEMORY_MANAGER_ACPI_SIZE}; use crate::memory_manager::{Error as MemoryManagerError, MemoryManager, MEMORY_MANAGER_ACPI_SIZE};
use crate::pci_segment::PciSegment; use crate::pci_segment::PciSegment;
use crate::serial_manager::{Error as SerialManagerError, SerialManager}; use crate::serial_manager::{Error as SerialManagerError, SerialManager};
use crate::vm_config::DEFAULT_PCI_SEGMENT_APERTURE_WEIGHT; use crate::vm_config::DEFAULT_PCI_SEGMENT_APERTURE_WEIGHT;
use crate::GuestRegionMmap; use crate::{device_node, GuestRegionMmap, PciDeviceInfo, DEVICE_MANAGER_SNAPSHOT_ID};
use crate::PciDeviceInfo;
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
const MMIO_LEN: u64 = 0x1000; const MMIO_LEN: u64 = 0x1000;

View File

@ -5,27 +5,22 @@
// //
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
use std::{os::unix::net::UnixListener, sync::mpsc}; use std::os::unix::net::UnixListener;
use std::sync::mpsc;
use gdbstub::{ use gdbstub::arch::Arch;
arch::Arch, use gdbstub::common::{Signal, Tid};
common::{Signal, Tid}, use gdbstub::conn::{Connection, ConnectionExt};
conn::{Connection, ConnectionExt}, use gdbstub::stub::{run_blocking, DisconnectReason, MultiThreadStopReason};
stub::{run_blocking, DisconnectReason, MultiThreadStopReason}, use gdbstub::target::ext::base::multithread::{
target::{ MultiThreadBase, MultiThreadResume, MultiThreadResumeOps, MultiThreadSingleStep,
ext::{ MultiThreadSingleStepOps,
base::{
multithread::{
MultiThreadBase, MultiThreadResume, MultiThreadResumeOps,
MultiThreadSingleStep, MultiThreadSingleStepOps,
},
BaseOps,
},
breakpoints::{Breakpoints, BreakpointsOps, HwBreakpoint, HwBreakpointOps},
},
Target, TargetError, TargetResult,
},
}; };
use gdbstub::target::ext::base::BaseOps;
use gdbstub::target::ext::breakpoints::{
Breakpoints, BreakpointsOps, HwBreakpoint, HwBreakpointOps,
};
use gdbstub::target::{Target, TargetError, TargetResult};
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs; use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]

View File

@ -4,13 +4,12 @@
// //
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::CString; use std::ffi::CString;
use std::io::Read; use std::io::{Read, Seek, SeekFrom};
use std::io::Seek;
use std::io::SeekFrom;
use std::mem::size_of; use std::mem::size_of;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use igvm::{snp_defs::SevVmsa, IgvmDirectiveHeader, IgvmFile, IgvmPlatformHeader, IsolationType}; use igvm::snp_defs::SevVmsa;
use igvm::{IgvmDirectiveHeader, IgvmFile, IgvmPlatformHeader, IsolationType};
use igvm_defs::{ use igvm_defs::{
IgvmPageDataType, IgvmPlatformType, IGVM_VHS_PARAMETER, IGVM_VHS_PARAMETER_INSERT, IgvmPageDataType, IgvmPlatformType, IGVM_VHS_PARAMETER, IGVM_VHS_PARAMETER_INSERT,
}; };
@ -21,9 +20,8 @@ use thiserror::Error;
use zerocopy::AsBytes; use zerocopy::AsBytes;
use crate::cpu::CpuManager; use crate::cpu::CpuManager;
use crate::igvm::{ use crate::igvm::loader::Loader;
loader::Loader, BootPageAcceptance, IgvmLoadedInfo, StartupMemoryType, HV_PAGE_SIZE, use crate::igvm::{BootPageAcceptance, IgvmLoadedInfo, StartupMemoryType, HV_PAGE_SIZE};
};
use crate::memory_manager::MemoryManager; use crate::memory_manager::MemoryManager;
#[cfg(feature = "sev_snp")] #[cfg(feature = "sev_snp")]
use crate::GuestMemoryMmap; use crate::GuestMemoryMmap;

View File

@ -10,18 +10,16 @@ extern crate log;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io;
use std::io::{stdout, Read, Write}; use std::io::{stdout, Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::net::UnixListener; use std::os::unix::net::{UnixListener, UnixStream};
use std::os::unix::net::UnixStream;
use std::panic::AssertUnwindSafe; use std::panic::AssertUnwindSafe;
use std::path::PathBuf; use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
use std::sync::mpsc::{Receiver, RecvError, SendError, Sender}; use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Instant; use std::time::Instant;
use std::{result, thread}; use std::{io, result, thread};
use anyhow::anyhow; use anyhow::anyhow;
#[cfg(feature = "dbus_api")] #[cfg(feature = "dbus_api")]
@ -40,8 +38,8 @@ use thiserror::Error;
use tracer::trace_scoped; use tracer::trace_scoped;
use vm_memory::bitmap::AtomicBitmap; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::{ReadVolatile, WriteVolatile}; use vm_memory::{ReadVolatile, WriteVolatile};
use vm_migration::{protocol::*, Migratable}; use vm_migration::protocol::*;
use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::signal::unblock_signal; use vmm_sys_util::signal::unblock_signal;
use vmm_sys_util::sock_ctrl_msg::ScmSocket; use vmm_sys_util::sock_ctrl_msg::ScmSocket;

View File

@ -12,9 +12,8 @@ use std::ops::{BitAnd, Deref, Not, Sub};
use std::os::fd::AsFd; use std::os::fd::AsFd;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::path::PathBuf; use std::path::PathBuf;
use std::result;
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use std::{ffi, thread}; use std::{ffi, result, thread};
use acpi_tables::{aml, Aml}; use acpi_tables::{aml, Aml};
use anyhow::anyhow; use anyhow::anyhow;
@ -37,14 +36,14 @@ use vm_allocator::{AddressAllocator, SystemAllocator};
use vm_device::BusDevice; use vm_device::BusDevice;
use vm_memory::bitmap::AtomicBitmap; use vm_memory::bitmap::AtomicBitmap;
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
use vm_memory::mmap::MmapRegionError;
use vm_memory::{ use vm_memory::{
mmap::MmapRegionError, Address, Error as MmapError, GuestAddress, GuestAddressSpace, Address, Error as MmapError, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
GuestMemory, GuestMemoryAtomic, GuestMemoryError, GuestMemoryRegion, GuestUsize, MmapRegion, GuestMemoryError, GuestMemoryRegion, GuestUsize, MmapRegion, ReadVolatile,
ReadVolatile,
}; };
use vm_migration::protocol::{MemoryRange, MemoryRangeTable};
use vm_migration::{ use vm_migration::{
protocol::MemoryRange, protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Migratable, MigratableError, Pausable, Snapshot, SnapshotData, Snapshottable, Transportable,
Snapshot, SnapshotData, Snapshottable, Transportable,
}; };
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
@ -55,8 +54,7 @@ use crate::coredump::{
CoredumpMemoryRegion, CoredumpMemoryRegions, DumpState, GuestDebuggableError, CoredumpMemoryRegion, CoredumpMemoryRegions, DumpState, GuestDebuggableError,
}; };
use crate::migration::url_to_path; use crate::migration::url_to_path;
use crate::MEMORY_MANAGER_SNAPSHOT_ID; use crate::{GuestMemoryMmap, GuestRegionMmap, MEMORY_MANAGER_SNAPSHOT_ID};
use crate::{GuestMemoryMmap, GuestRegionMmap};
pub const MEMORY_MANAGER_ACPI_SIZE: usize = 0x18; pub const MEMORY_MANAGER_ACPI_SIZE: usize = 0x18;

View File

@ -9,9 +9,10 @@ use std::path::PathBuf;
use anyhow::anyhow; use anyhow::anyhow;
use vm_migration::{MigratableError, Snapshot}; use vm_migration::{MigratableError, Snapshot};
use crate::config::VmConfig;
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
use crate::coredump::GuestDebuggableError; use crate::coredump::GuestDebuggableError;
use crate::{config::VmConfig, vm::VmSnapshot}; use crate::vm::VmSnapshot;
pub const SNAPSHOT_STATE_FILE: &str = "state.json"; pub const SNAPSHOT_STATE_FILE: &str = "state.json";
pub const SNAPSHOT_CONFIG_FILE: &str = "config.json"; pub const SNAPSHOT_CONFIG_FILE: &str = "config.json";

View File

@ -5,8 +5,9 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use hypervisor::HypervisorType; use hypervisor::HypervisorType;
use seccompiler::SeccompCmpOp::Eq;
use seccompiler::{ use seccompiler::{
BackendError, BpfProgram, Error, SeccompAction, SeccompCmpArgLen as ArgLen, SeccompCmpOp::Eq, BackendError, BpfProgram, Error, SeccompAction, SeccompCmpArgLen as ArgLen,
SeccompCondition as Cond, SeccompFilter, SeccompRule, SeccompCondition as Cond, SeccompFilter, SeccompRule,
}; };

View File

@ -6,8 +6,7 @@ use std::collections::BTreeSet;
use std::fs::{read_dir, File}; use std::fs::{read_dir, File};
use std::io::{self, ErrorKind, Read, Write}; use std::io::{self, ErrorKind, Read, Write};
use std::iter::once; use std::iter::once;
use std::mem::size_of; use std::mem::{size_of, MaybeUninit};
use std::mem::MaybeUninit;
use std::os::unix::prelude::*; use std::os::unix::prelude::*;
use std::process::exit; use std::process::exit;
use std::ptr::null_mut; use std::ptr::null_mut;

View File

@ -11,9 +11,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
// //
use std::cmp; use std::collections::{BTreeMap, HashMap};
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::io::{self, Seek, SeekFrom, Write}; use std::io::{self, Seek, SeekFrom, Write};
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
@ -23,18 +21,16 @@ use std::ops::Deref;
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::time::Instant; use std::time::Instant;
use std::{result, str, thread}; use std::{cmp, result, str, thread};
use anyhow::anyhow; use anyhow::anyhow;
use arch::get_host_cpu_phys_bits;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use arch::layout::{KVM_IDENTITY_MAP_START, KVM_TSS_START}; use arch::layout::{KVM_IDENTITY_MAP_START, KVM_TSS_START};
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
use arch::x86_64::tdx::TdvfSection; use arch::x86_64::tdx::TdvfSection;
use arch::EntryPoint;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use arch::PciSpaceInfo; use arch::PciSpaceInfo;
use arch::{NumaNode, NumaNodes}; use arch::{get_host_cpu_phys_bits, EntryPoint, NumaNode, NumaNodes};
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use devices::interrupt_controller; use devices::interrupt_controller;
use devices::AcpiNotificationFlags; use devices::AcpiNotificationFlags;
@ -64,25 +60,23 @@ use vm_memory::{Address, ByteValued, GuestMemoryRegion, ReadVolatile};
use vm_memory::{ use vm_memory::{
Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, WriteVolatile, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, WriteVolatile,
}; };
use vm_migration::protocol::{Request, Response}; use vm_migration::protocol::{MemoryRangeTable, Request, Response};
use vm_migration::{ use vm_migration::{
protocol::MemoryRangeTable, snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot, snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable,
Snapshottable, Transportable,
}; };
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::sock_ctrl_msg::ScmSocket; use vmm_sys_util::sock_ctrl_msg::ScmSocket;
use crate::config::{ use crate::config::{
add_to_config, DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, PmemConfig, add_to_config, DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, NumaConfig,
UserDeviceConfig, ValidationError, VdpaConfig, VmConfig, VsockConfig, PayloadConfig, PmemConfig, UserDeviceConfig, ValidationError, VdpaConfig, VmConfig,
VsockConfig,
}; };
use crate::config::{NumaConfig, PayloadConfig};
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo}; use crate::console_devices::{ConsoleDeviceError, ConsoleInfo};
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
use crate::coredump::{ use crate::coredump::{
CpuElf64Writable, DumpState, Elf64Writable, GuestDebuggable, GuestDebuggableError, NoteDescType, CpuElf64Writable, DumpState, Elf64Writable, GuestDebuggable, GuestDebuggableError, NoteDescType,
}; };
use crate::cpu;
use crate::device_manager::{DeviceManager, DeviceManagerError}; use crate::device_manager::{DeviceManager, DeviceManagerError};
use crate::device_tree::DeviceTree; use crate::device_tree::DeviceTree;
#[cfg(feature = "guest_debug")] #[cfg(feature = "guest_debug")]
@ -98,9 +92,9 @@ use crate::migration::get_vm_snapshot;
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
use crate::migration::url_to_file; use crate::migration::url_to_file;
use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE}; use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE};
use crate::GuestMemoryMmap;
use crate::{ use crate::{
PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, MEMORY_MANAGER_SNAPSHOT_ID, cpu, GuestMemoryMmap, PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID,
MEMORY_MANAGER_SNAPSHOT_ID,
}; };
/// Errors associated with VM management /// Errors associated with VM management

View File

@ -2,13 +2,16 @@
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
use std::{fs, net::Ipv4Addr, path::PathBuf, result}; use std::net::Ipv4Addr;
use std::path::PathBuf;
use std::{fs, result};
use net_util::MacAddr; use net_util::MacAddr;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use virtio_devices::RateLimiterConfig; use virtio_devices::RateLimiterConfig;
use crate::{landlock::LandlockError, Landlock}; use crate::landlock::LandlockError;
use crate::Landlock;
pub type LandlockResult<T> = result::Result<T, LandlockError>; pub type LandlockResult<T> = result::Result<T, LandlockError>;