mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Adapt consistent import style formatting
Historically the Cloud Hypervisor coding style has been to ensure that all imports are ordered and placed in a single group. Unfortunately cargo fmt has no support for ensuring that all imports are in a single group so if whitespace lines were added as part of the import statements then they would only be odered correctly in the group. By adopting "group_imports="StdExternalCrate" we can enforce a style where imports are placed in at most three groups for std, external crates and the crate itself. Choosing a style enforceable by the tooling reduces the reviewer burden. Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
+9
-7
@@ -2,11 +2,9 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use crate::cpu::CpuManager;
|
||||
use crate::device_manager::DeviceManager;
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::pci_segment::PciSegment;
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use acpi_tables::sdt::GenericAddress;
|
||||
use acpi_tables::{rsdp::Rsdp, sdt::Sdt, Aml};
|
||||
@@ -17,12 +15,16 @@ use arch::DeviceType;
|
||||
use arch::NumaNodes;
|
||||
use bitflags::bitflags;
|
||||
use pci::PciBdf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use tracer::trace_scoped;
|
||||
use vm_memory::{Address, Bytes, GuestAddress, GuestMemoryRegion};
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
use crate::cpu::CpuManager;
|
||||
use crate::device_manager::DeviceManager;
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::pci_segment::PciSegment;
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap};
|
||||
|
||||
/* Values for Type in APIC sub-headers */
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub const ACPI_X2APIC_PROCESSOR: u8 = 9;
|
||||
|
||||
+14
-12
@@ -2,6 +2,20 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
use futures::channel::oneshot;
|
||||
use futures::{executor, FutureExt};
|
||||
use hypervisor::HypervisorType;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use zbus::fdo::{self, Result};
|
||||
use zbus::zvariant::Optional;
|
||||
use zbus::{interface, ConnectionBuilder};
|
||||
|
||||
use super::{ApiAction, ApiRequest};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::api::VmCoredump;
|
||||
@@ -14,18 +28,6 @@ use crate::api::{
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::{Error as VmmError, Result as VmmResult};
|
||||
use crate::{NetConfig, VmConfig};
|
||||
use futures::channel::oneshot;
|
||||
use futures::{executor, FutureExt};
|
||||
use hypervisor::HypervisorType;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use zbus::fdo::{self, Result};
|
||||
use zbus::zvariant::Optional;
|
||||
use zbus::{interface, ConnectionBuilder};
|
||||
|
||||
pub type DBusApiShutdownChannels = (oneshot::Sender<()>, oneshot::Receiver<()>);
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::IntoRawFd;
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use micro_http::{Body, Method, Request, Response, StatusCode, Version};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::api::http::{error_response, EndpointHandler, HttpError};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::api::VmCoredump;
|
||||
@@ -14,11 +21,6 @@ use crate::api::{
|
||||
VmSendMigration, VmShutdown, VmSnapshot,
|
||||
};
|
||||
use crate::config::{NetConfig, RestoreConfig};
|
||||
use micro_http::{Body, Method, Request, Response, StatusCode, Version};
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::IntoRawFd;
|
||||
use std::sync::mpsc::Sender;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
// /api/v1/vm.create handler
|
||||
pub struct VmCreate {}
|
||||
|
||||
+20
-18
@@ -3,6 +3,26 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use core::fmt;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Display;
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::{IntoRawFd, RawFd};
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
|
||||
use hypervisor::HypervisorType;
|
||||
use micro_http::{
|
||||
Body, HttpServer, MediaType, Method, Request, Response, ServerError, StatusCode, Version,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use serde_json::Error as SerdeError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use self::http_endpoint::{VmActionHandler, VmCreate, VmInfo, VmmPing, VmmShutdown};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::api::VmCoredump;
|
||||
@@ -15,24 +35,6 @@ use crate::api::{
|
||||
use crate::landlock::Landlock;
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::{Error as VmmError, Result};
|
||||
use core::fmt;
|
||||
use hypervisor::HypervisorType;
|
||||
use micro_http::{
|
||||
Body, HttpServer, MediaType, Method, Request, Response, ServerError, StatusCode, Version,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use serde_json::Error as SerdeError;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Display;
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::{IntoRawFd, RawFd};
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
pub mod http_endpoint;
|
||||
|
||||
|
||||
+10
-9
@@ -33,11 +33,20 @@
|
||||
pub mod dbus;
|
||||
pub mod http;
|
||||
|
||||
use core::fmt;
|
||||
use std::fmt::Display;
|
||||
use std::io;
|
||||
use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
||||
|
||||
use micro_http::Body;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vm_migration::MigratableError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
#[cfg(feature = "dbus_api")]
|
||||
pub use self::dbus::start_dbus_thread;
|
||||
pub use self::http::start_http_fd_thread;
|
||||
pub use self::http::start_http_path_thread;
|
||||
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, UserDeviceConfig,
|
||||
VdpaConfig, VmConfig, VsockConfig,
|
||||
@@ -45,14 +54,6 @@ use crate::config::{
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use crate::Error as VmmError;
|
||||
use core::fmt;
|
||||
use micro_http::Body;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
use std::io;
|
||||
use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
||||
use vm_migration::MigratableError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
/// API errors are sent back from the VMM API server through the ApiResponse.
|
||||
#[derive(Debug)]
|
||||
|
||||
+13
-9
@@ -3,21 +3,23 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use crate::landlock::LandlockAccess;
|
||||
pub use crate::vm_config::*;
|
||||
use clap::ArgMatches;
|
||||
use option_parser::{
|
||||
ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, Tuple,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::ArgMatches;
|
||||
use option_parser::{
|
||||
ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, Tuple,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use virtio_devices::{RateLimiterConfig, TokenBucketConfig};
|
||||
|
||||
use crate::landlock::LandlockAccess;
|
||||
pub use crate::vm_config::*;
|
||||
|
||||
const MAX_NUM_PCI_SEGMENTS: u16 = 96;
|
||||
|
||||
/// Errors associated with VM configuration parameters.
|
||||
@@ -3104,12 +3106,14 @@ impl Drop for VmConfig {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use net_util::MacAddr;
|
||||
use std::fs::File;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
use net_util::MacAddr;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_cpu_parsing() -> Result<()> {
|
||||
assert_eq!(CpusConfig::parse("")?, CpusConfig::default());
|
||||
|
||||
@@ -10,15 +10,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::sigwinch_listener::listen_for_sigwinch_on_tty;
|
||||
use crate::vm_config::ConsoleOutputMode;
|
||||
use crate::Vmm;
|
||||
use libc::cfmakeraw;
|
||||
use libc::isatty;
|
||||
use libc::tcgetattr;
|
||||
use libc::tcsetattr;
|
||||
use libc::termios;
|
||||
use libc::TCSANOW;
|
||||
use std::fs::read_link;
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
@@ -33,8 +24,19 @@ use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use libc::cfmakeraw;
|
||||
use libc::isatty;
|
||||
use libc::tcgetattr;
|
||||
use libc::tcsetattr;
|
||||
use libc::termios;
|
||||
use libc::TCSANOW;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::sigwinch_listener::listen_for_sigwinch_on_tty;
|
||||
use crate::vm_config::ConsoleOutputMode;
|
||||
use crate::Vmm;
|
||||
|
||||
const TIOCSPTLCK: libc::c_int = 0x4004_5431;
|
||||
const TIOCGPTPEER: libc::c_int = 0x5441;
|
||||
|
||||
|
||||
+3
-2
@@ -3,11 +3,12 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use hypervisor::arch::x86::{DescriptorTable, SegmentRegister};
|
||||
use linux_loader::elf;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use vm_memory::ByteValued;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
+28
-25
@@ -11,22 +11,16 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::config::CpusConfig;
|
||||
use std::collections::BTreeMap;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CpuElf64Writable, CpuSegment, CpuState as DumpCpusState, DumpState, Elf64Writable,
|
||||
GuestDebuggableError, NoteDescType, X86_64ElfPrStatus, X86_64UserRegs, COREDUMP_NAME_SIZE,
|
||||
NT_PRSTATUS,
|
||||
};
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{get_raw_tid, Debuggable, DebuggableError};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::vm::physical_bits;
|
||||
use crate::GuestMemoryMmap;
|
||||
use crate::CPU_MANAGER_SNAPSHOT_ID;
|
||||
use std::io::Write;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::mem::size_of;
|
||||
use std::os::unix::thread::JoinHandleExt;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use std::{cmp, io, result, thread};
|
||||
|
||||
use acpi_tables::{aml, sdt::Sdt, Aml};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
@@ -67,15 +61,6 @@ use libc::{c_void, siginfo_t};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use linux_loader::elf::Elf64_Nhdr;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use std::collections::BTreeMap;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::io::Write;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::mem::size_of;
|
||||
use std::os::unix::thread::JoinHandleExt;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use std::{cmp, io, result, thread};
|
||||
use thiserror::Error;
|
||||
use tracer::trace_scoped;
|
||||
use vm_device::BusDevice;
|
||||
@@ -91,6 +76,23 @@ use vm_migration::{
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
use crate::config::CpusConfig;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CpuElf64Writable, CpuSegment, CpuState as DumpCpusState, DumpState, Elf64Writable,
|
||||
GuestDebuggableError, NoteDescType, X86_64ElfPrStatus, X86_64UserRegs, COREDUMP_NAME_SIZE,
|
||||
NT_PRSTATUS,
|
||||
};
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{get_raw_tid, Debuggable, DebuggableError};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::vm::physical_bits;
|
||||
use crate::GuestMemoryMmap;
|
||||
use crate::CPU_MANAGER_SNAPSHOT_ID;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
/// Extract the specified bits of a 64-bit integer.
|
||||
/// For example, to extrace 2 bits from offset 1 (zero based) of `6u64`,
|
||||
@@ -2943,6 +2945,8 @@ mod tests {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::mem;
|
||||
|
||||
use arch::{aarch64::regs, layout};
|
||||
use hypervisor::kvm::aarch64::is_system_register;
|
||||
use hypervisor::kvm::kvm_bindings::{
|
||||
@@ -2950,7 +2954,6 @@ mod tests {
|
||||
KVM_REG_SIZE_U64,
|
||||
};
|
||||
use hypervisor::{arm64_core_reg_id, offset_of};
|
||||
use std::mem;
|
||||
|
||||
#[test]
|
||||
fn test_setup_regs() {
|
||||
|
||||
+28
-26
@@ -9,22 +9,17 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::config::{
|
||||
ConsoleOutputMode, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig,
|
||||
VdpaConfig, VhostMode, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo, ConsoleOutput};
|
||||
use crate::cpu::{CpuManager, CPU_MANAGER_ACPI_SIZE};
|
||||
use crate::device_tree::{DeviceNode, DeviceTree};
|
||||
use crate::interrupt::LegacyUserspaceInterruptManager;
|
||||
use crate::interrupt::MsiInterruptManager;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager, MEMORY_MANAGER_ACPI_SIZE};
|
||||
use crate::pci_segment::PciSegment;
|
||||
use crate::serial_manager::{Error as SerialManagerError, SerialManager};
|
||||
use crate::vm_config::DEFAULT_PCI_SEGMENT_APERTURE_WEIGHT;
|
||||
use crate::GuestRegionMmap;
|
||||
use crate::PciDeviceInfo;
|
||||
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, stdout, IsTerminal, Seek, SeekFrom};
|
||||
use std::num::Wrapping;
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
|
||||
use acpi_tables::sdt::GenericAddress;
|
||||
use acpi_tables::{aml, Aml};
|
||||
use anyhow::anyhow;
|
||||
@@ -66,16 +61,6 @@ use pci::{
|
||||
use rate_limiter::group::RateLimiterGroup;
|
||||
use seccompiler::SeccompAction;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, stdout, IsTerminal, Seek, SeekFrom};
|
||||
use std::num::Wrapping;
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use tracer::trace_scoped;
|
||||
use vfio_ioctls::{VfioContainer, VfioDevice, VfioDeviceFd};
|
||||
use virtio_devices::transport::VirtioTransport;
|
||||
@@ -106,6 +91,23 @@ use vmm_sys_util::eventfd::EventFd;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use {devices::debug_console, devices::legacy::Serial};
|
||||
|
||||
use crate::config::{
|
||||
ConsoleOutputMode, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig,
|
||||
VdpaConfig, VhostMode, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo, ConsoleOutput};
|
||||
use crate::cpu::{CpuManager, CPU_MANAGER_ACPI_SIZE};
|
||||
use crate::device_tree::{DeviceNode, DeviceTree};
|
||||
use crate::interrupt::LegacyUserspaceInterruptManager;
|
||||
use crate::interrupt::MsiInterruptManager;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager, MEMORY_MANAGER_ACPI_SIZE};
|
||||
use crate::pci_segment::PciSegment;
|
||||
use crate::serial_manager::{Error as SerialManagerError, SerialManager};
|
||||
use crate::vm_config::DEFAULT_PCI_SEGMENT_APERTURE_WEIGHT;
|
||||
use crate::GuestRegionMmap;
|
||||
use crate::PciDeviceInfo;
|
||||
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
const MMIO_LEN: u64 = 0x1000;
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::device_manager::PciDeviceHandle;
|
||||
use pci::PciBdf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use pci::PciBdf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vm_device::Resource;
|
||||
use vm_migration::Migratable;
|
||||
|
||||
use crate::device_manager::PciDeviceHandle;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct DeviceNode {
|
||||
pub id: String,
|
||||
|
||||
+4
-2
@@ -5,7 +5,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
use crate::GuestMemoryMmap;
|
||||
use std::{os::unix::net::UnixListener, sync::mpsc};
|
||||
|
||||
use gdbstub::{
|
||||
arch::Arch,
|
||||
common::{Signal, Tid},
|
||||
@@ -33,9 +34,10 @@ use gdbstub_arch::aarch64::AArch64 as GdbArch;
|
||||
use gdbstub_arch::x86::reg::X86_64CoreRegs as CoreRegs;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use gdbstub_arch::x86::X86_64_SSE as GdbArch;
|
||||
use std::{os::unix::net::UnixListener, sync::mpsc};
|
||||
use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryError};
|
||||
|
||||
use crate::GuestMemoryMmap;
|
||||
|
||||
type ArchUsize = u64;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
+15
-15
@@ -2,18 +2,6 @@
|
||||
//
|
||||
// Copyright © 2023, Microsoft Corporation
|
||||
//
|
||||
use crate::cpu::CpuManager;
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
use crate::igvm::{
|
||||
loader::Loader, BootPageAcceptance, IgvmLoadedInfo, StartupMemoryType, HV_PAGE_SIZE,
|
||||
};
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use igvm::{snp_defs::SevVmsa, IgvmDirectiveHeader, IgvmFile, IgvmPlatformHeader, IsolationType};
|
||||
use igvm_defs::{
|
||||
IgvmPageDataType, IgvmPlatformType, IGVM_VHS_PARAMETER, IGVM_VHS_PARAMETER_INSERT,
|
||||
};
|
||||
use mshv_bindings::*;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::CString;
|
||||
use std::io::Read;
|
||||
@@ -21,12 +9,24 @@ use std::io::Seek;
|
||||
use std::io::SeekFrom;
|
||||
use std::mem::size_of;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "sev_snp")]
|
||||
use crate::GuestMemoryMmap;
|
||||
use igvm::{snp_defs::SevVmsa, IgvmDirectiveHeader, IgvmFile, IgvmPlatformHeader, IsolationType};
|
||||
use igvm_defs::{
|
||||
IgvmPageDataType, IgvmPlatformType, IGVM_VHS_PARAMETER, IGVM_VHS_PARAMETER_INSERT,
|
||||
};
|
||||
#[cfg(feature = "sev_snp")]
|
||||
use igvm_defs::{MemoryMapEntryType, IGVM_VHS_MEMORY_MAP_ENTRY};
|
||||
use mshv_bindings::*;
|
||||
use thiserror::Error;
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
use crate::cpu::CpuManager;
|
||||
use crate::igvm::{
|
||||
loader::Loader, BootPageAcceptance, IgvmLoadedInfo, StartupMemoryType, HV_PAGE_SIZE,
|
||||
};
|
||||
use crate::memory_manager::MemoryManager;
|
||||
#[cfg(feature = "sev_snp")]
|
||||
use crate::GuestMemoryMmap;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
//
|
||||
// Copyright © 2023, Microsoft Corporation
|
||||
//
|
||||
use crate::igvm::{BootPageAcceptance, StartupMemoryType, HV_PAGE_SIZE};
|
||||
use range_map_vec::{Entry, RangeMap};
|
||||
use thiserror::Error;
|
||||
use vm_memory::bitmap::AtomicBitmap;
|
||||
@@ -11,6 +10,8 @@ use vm_memory::{
|
||||
GuestMemoryRegion,
|
||||
};
|
||||
|
||||
use crate::igvm::{BootPageAcceptance, StartupMemoryType, HV_PAGE_SIZE};
|
||||
|
||||
/// Structure to hold the guest memory info/layout to check
|
||||
/// the if the memory is accepted within the layout.
|
||||
/// Adds up the total bytes written to the guest memory
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use devices::interrupt_controller::InterruptController;
|
||||
use hypervisor::IrqRoutingEntry;
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use devices::interrupt_controller::InterruptController;
|
||||
use hypervisor::IrqRoutingEntry;
|
||||
use vm_allocator::SystemAllocator;
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
||||
|
||||
+4
-3
@@ -2,15 +2,16 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::io::Error as IoError;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(test)]
|
||||
use landlock::make_bitflags;
|
||||
use landlock::{
|
||||
path_beneath_rules, Access, AccessFs, BitFlags, Ruleset, RulesetAttr, RulesetCreated,
|
||||
RulesetCreatedAttr, RulesetError, ABI,
|
||||
};
|
||||
use std::convert::TryFrom;
|
||||
use std::io::Error as IoError;
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
||||
+42
-39
@@ -8,6 +8,44 @@ extern crate event_monitor;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::{stdout, Read, Write};
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use std::{result, thread};
|
||||
|
||||
use anyhow::anyhow;
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use api::dbus::{DBusApiOptions, DBusApiShutdownChannels};
|
||||
use api::http::HttpApiHandle;
|
||||
use console_devices::{pre_create_console_devices, ConsoleInfo};
|
||||
use landlock::LandlockError;
|
||||
use libc::{tcsetattr, termios, EFD_NONBLOCK, SIGINT, SIGTERM, TCSANOW};
|
||||
use memory_manager::MemoryManagerSnapshotData;
|
||||
use pci::PciBdf;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use serde::ser::{SerializeStruct, Serializer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use signal_hook::iterator::{Handle, Signals};
|
||||
use thiserror::Error;
|
||||
use tracer::trace_scoped;
|
||||
use vm_memory::bitmap::AtomicBitmap;
|
||||
use vm_memory::{ReadVolatile, WriteVolatile};
|
||||
use vm_migration::{protocol::*, Migratable};
|
||||
use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::unblock_signal;
|
||||
use vmm_sys_util::sock_ctrl_msg::ScmSocket;
|
||||
|
||||
use crate::api::{
|
||||
ApiRequest, ApiResponse, RequestHandler, VmInfoResponse, VmReceiveMigrationData,
|
||||
VmSendMigrationData, VmmPingResponse,
|
||||
@@ -25,42 +63,6 @@ use crate::migration::get_vm_snapshot;
|
||||
use crate::migration::{recv_vm_config, recv_vm_state};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::vm::{Error as VmError, Vm, VmState};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use api::dbus::{DBusApiOptions, DBusApiShutdownChannels};
|
||||
use api::http::HttpApiHandle;
|
||||
use console_devices::{pre_create_console_devices, ConsoleInfo};
|
||||
use landlock::LandlockError;
|
||||
use libc::{tcsetattr, termios, EFD_NONBLOCK, SIGINT, SIGTERM, TCSANOW};
|
||||
use memory_manager::MemoryManagerSnapshotData;
|
||||
use pci::PciBdf;
|
||||
use seccompiler::{apply_filter, SeccompAction};
|
||||
use serde::ser::{SerializeStruct, Serializer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use signal_hook::iterator::{Handle, Signals};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::{stdout, Read, Write};
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||
use std::os::unix::net::UnixListener;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use std::{result, thread};
|
||||
use thiserror::Error;
|
||||
use tracer::trace_scoped;
|
||||
use vm_memory::bitmap::AtomicBitmap;
|
||||
use vm_memory::{ReadVolatile, WriteVolatile};
|
||||
use vm_migration::{protocol::*, Migratable};
|
||||
use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::unblock_signal;
|
||||
use vmm_sys_util::sock_ctrl_msg::ScmSocket;
|
||||
|
||||
mod acpi;
|
||||
pub mod api;
|
||||
@@ -2143,14 +2145,15 @@ const DEVICE_MANAGER_SNAPSHOT_ID: &str = "device-manager";
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_tests {
|
||||
use super::*;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::DebugConsoleConfig;
|
||||
use config::{
|
||||
ConsoleConfig, ConsoleOutputMode, CpusConfig, HotplugMethod, MemoryConfig, PayloadConfig,
|
||||
RngConfig,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::DebugConsoleConfig;
|
||||
|
||||
fn create_dummy_vmm() -> Vmm {
|
||||
Vmm::new(
|
||||
VmmVersionInfo::new("dummy", "dummy"),
|
||||
|
||||
+25
-23
@@ -2,29 +2,6 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::SgxEpcConfig;
|
||||
use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CoredumpMemoryRegion, CoredumpMemoryRegions, DumpState, GuestDebuggableError,
|
||||
};
|
||||
use crate::migration::url_to_path;
|
||||
use crate::MEMORY_MANAGER_SNAPSHOT_ID;
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap};
|
||||
use acpi_tables::{aml, Aml};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use arch::x86_64::{SgxEpcRegion, SgxEpcSection};
|
||||
use arch::RegionType;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use devices::ioapic;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use hypervisor::HypervisorVmError;
|
||||
use libc::_SC_NPROCESSORS_ONLN;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use libc::{MAP_NORESERVE, MAP_POPULATE, MAP_SHARED, PROT_READ, PROT_WRITE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
@@ -38,6 +15,20 @@ use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use std::{ffi, thread};
|
||||
|
||||
use acpi_tables::{aml, Aml};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use arch::x86_64::{SgxEpcRegion, SgxEpcSection};
|
||||
use arch::RegionType;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use devices::ioapic;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use hypervisor::HypervisorVmError;
|
||||
use libc::_SC_NPROCESSORS_ONLN;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use libc::{MAP_NORESERVE, MAP_POPULATE, MAP_SHARED, PROT_READ, PROT_WRITE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracer::trace_scoped;
|
||||
use virtio_devices::BlocksState;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -56,6 +47,17 @@ use vm_migration::{
|
||||
Snapshot, SnapshotData, Snapshottable, Transportable,
|
||||
};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::SgxEpcConfig;
|
||||
use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CoredumpMemoryRegion, CoredumpMemoryRegions, DumpState, GuestDebuggableError,
|
||||
};
|
||||
use crate::migration::url_to_path;
|
||||
use crate::MEMORY_MANAGER_SNAPSHOT_ID;
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap};
|
||||
|
||||
pub const MEMORY_MANAGER_ACPI_SIZE: usize = 0x18;
|
||||
|
||||
const DEFAULT_MEMORY_ZONE: &str = "mem0";
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::GuestDebuggableError;
|
||||
use crate::{config::VmConfig, vm::VmSnapshot};
|
||||
use anyhow::anyhow;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use vm_migration::{MigratableError, Snapshot};
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::GuestDebuggableError;
|
||||
use crate::{config::VmConfig, vm::VmSnapshot};
|
||||
|
||||
pub const SNAPSHOT_STATE_FILE: &str = "state.json";
|
||||
pub const SNAPSHOT_CONFIG_FILE: &str = "config.json";
|
||||
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::device_manager::{AddressManager, DeviceManagerError, DeviceManagerResult};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use acpi_tables::{aml, Aml};
|
||||
use arch::layout;
|
||||
use pci::{DeviceRelocation, PciBdf, PciBus, PciConfigMmio, PciRoot};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use pci::{PciConfigIo, PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use uuid::Uuid;
|
||||
use vm_allocator::AddressAllocator;
|
||||
use vm_device::BusDeviceSync;
|
||||
|
||||
use crate::device_manager::{AddressManager, DeviceManagerError, DeviceManagerResult};
|
||||
|
||||
pub(crate) struct PciSegment {
|
||||
pub(crate) id: u16,
|
||||
pub(crate) pci_bus: Arc<Mutex<PciBus>>,
|
||||
|
||||
@@ -148,12 +148,11 @@ mod kvm {
|
||||
pub const KVM_NMI: u64 = 0xae9a;
|
||||
}
|
||||
|
||||
#[cfg(feature = "kvm")]
|
||||
use kvm::*;
|
||||
|
||||
// MSHV IOCTL code. This is unstable until the kernel code has been declared stable.
|
||||
#[cfg(feature = "mshv")]
|
||||
use hypervisor::mshv::mshv_ioctls::*;
|
||||
#[cfg(feature = "kvm")]
|
||||
use kvm::*;
|
||||
|
||||
#[cfg(feature = "mshv")]
|
||||
fn create_vmm_ioctl_seccomp_rule_common_mshv() -> Result<Vec<SeccompRule>, BackendError> {
|
||||
|
||||
@@ -3,13 +3,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use crate::console_devices::ConsoleOutput;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use devices::legacy::Pl011;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use devices::legacy::Serial;
|
||||
use libc::EFD_NONBLOCK;
|
||||
use serial_buffer::SerialBuffer;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::net::Shutdown;
|
||||
@@ -20,9 +13,18 @@ use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{io, result, thread};
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use devices::legacy::Pl011;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use devices::legacy::Serial;
|
||||
use libc::EFD_NONBLOCK;
|
||||
use serial_buffer::SerialBuffer;
|
||||
use thiserror::Error;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::console_devices::ConsoleOutput;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
/// Cannot clone File.
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
// Copyright 2021, 2023 Alyssa Ross <hi@alyssa.is>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::clone3::{clone3, clone_args, CLONE_CLEAR_SIGHAND};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use arch::_NSIG;
|
||||
use hypervisor::HypervisorType;
|
||||
use libc::{
|
||||
c_int, c_void, close, fork, getpgrp, ioctl, pipe2, poll, pollfd, setsid, sigemptyset,
|
||||
siginfo_t, signal, sigprocmask, syscall, tcgetpgrp, tcsetpgrp, SYS_close_range, EINVAL, ENOSYS,
|
||||
ENOTTY, O_CLOEXEC, POLLERR, SIGCHLD, SIGWINCH, SIG_DFL, SIG_SETMASK, STDERR_FILENO, TIOCSCTTY,
|
||||
};
|
||||
use seccompiler::{apply_filter, BpfProgram, SeccompAction};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fs::{read_dir, File};
|
||||
@@ -21,8 +11,20 @@ use std::mem::MaybeUninit;
|
||||
use std::os::unix::prelude::*;
|
||||
use std::process::exit;
|
||||
use std::ptr::null_mut;
|
||||
|
||||
use arch::_NSIG;
|
||||
use hypervisor::HypervisorType;
|
||||
use libc::{
|
||||
c_int, c_void, close, fork, getpgrp, ioctl, pipe2, poll, pollfd, setsid, sigemptyset,
|
||||
siginfo_t, signal, sigprocmask, syscall, tcgetpgrp, tcsetpgrp, SYS_close_range, EINVAL, ENOSYS,
|
||||
ENOTTY, O_CLOEXEC, POLLERR, SIGCHLD, SIGWINCH, SIG_DFL, SIG_SETMASK, STDERR_FILENO, TIOCSCTTY,
|
||||
};
|
||||
use seccompiler::{apply_filter, BpfProgram, SeccompAction};
|
||||
use vmm_sys_util::signal::register_signal_handler;
|
||||
|
||||
use crate::clone3::{clone3, clone_args, CLONE_CLEAR_SIGHAND};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
|
||||
thread_local! {
|
||||
// The tty file descriptor is stored in a global variable so it
|
||||
// can be accessed by a signal handler.
|
||||
|
||||
+46
-43
@@ -11,36 +11,20 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::config::{
|
||||
add_to_config, DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, PmemConfig,
|
||||
UserDeviceConfig, ValidationError, VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::config::{NumaConfig, PayloadConfig};
|
||||
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo};
|
||||
use std::cmp;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, Seek, SeekFrom, Write};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CpuElf64Writable, DumpState, Elf64Writable, GuestDebuggable, GuestDebuggableError, NoteDescType,
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{DeviceManager, DeviceManagerError};
|
||||
use crate::device_tree::DeviceTree;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{Debuggable, DebuggableError, GdbRequestPayload, GdbResponsePayload};
|
||||
#[cfg(feature = "igvm")]
|
||||
use crate::igvm::igvm_loader;
|
||||
use crate::landlock::LandlockError;
|
||||
use crate::memory_manager::{
|
||||
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
||||
};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::migration::get_vm_snapshot;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::migration::url_to_file;
|
||||
use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE};
|
||||
use crate::GuestMemoryMmap;
|
||||
use crate::{
|
||||
PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, MEMORY_MANAGER_SNAPSHOT_ID,
|
||||
};
|
||||
use std::mem::size_of;
|
||||
use std::num::Wrapping;
|
||||
use std::ops::Deref;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::time::Instant;
|
||||
use std::{result, str, thread};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use arch::get_host_cpu_phys_bits;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -72,19 +56,6 @@ use linux_loader::loader::pe::Error::InvalidImageMagicNumber;
|
||||
use linux_loader::loader::KernelLoader;
|
||||
use seccompiler::SeccompAction;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, Seek, SeekFrom, Write};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::mem::size_of;
|
||||
use std::num::Wrapping;
|
||||
use std::ops::Deref;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::time::Instant;
|
||||
use std::{result, str, thread};
|
||||
use thiserror::Error;
|
||||
use tracer::trace_scoped;
|
||||
use vm_device::Bus;
|
||||
@@ -101,6 +72,37 @@ use vm_migration::{
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::sock_ctrl_msg::ScmSocket;
|
||||
|
||||
use crate::config::{
|
||||
add_to_config, DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, PmemConfig,
|
||||
UserDeviceConfig, ValidationError, VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::config::{NumaConfig, PayloadConfig};
|
||||
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
CpuElf64Writable, DumpState, Elf64Writable, GuestDebuggable, GuestDebuggableError, NoteDescType,
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{DeviceManager, DeviceManagerError};
|
||||
use crate::device_tree::DeviceTree;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{Debuggable, DebuggableError, GdbRequestPayload, GdbResponsePayload};
|
||||
#[cfg(feature = "igvm")]
|
||||
use crate::igvm::igvm_loader;
|
||||
use crate::landlock::LandlockError;
|
||||
use crate::memory_manager::{
|
||||
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
||||
};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::migration::get_vm_snapshot;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::migration::url_to_file;
|
||||
use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE};
|
||||
use crate::GuestMemoryMmap;
|
||||
use crate::{
|
||||
PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, MEMORY_MANAGER_SNAPSHOT_ID,
|
||||
};
|
||||
|
||||
/// Errors associated with VM management
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
@@ -3124,12 +3126,13 @@ mod tests {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use arch::aarch64::fdt::create_fdt;
|
||||
use arch::aarch64::layout;
|
||||
use arch::{DeviceType, MmioDeviceInfo};
|
||||
use devices::gic::Gic;
|
||||
|
||||
use super::*;
|
||||
|
||||
const LEN: u64 = 4096;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use crate::{landlock::LandlockError, Landlock};
|
||||
use std::{fs, net::Ipv4Addr, path::PathBuf, result};
|
||||
|
||||
use net_util::MacAddr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fs, net::Ipv4Addr, path::PathBuf, result};
|
||||
use virtio_devices::RateLimiterConfig;
|
||||
|
||||
use crate::{landlock::LandlockError, Landlock};
|
||||
|
||||
pub type LandlockResult<T> = result::Result<T, LandlockError>;
|
||||
|
||||
/// Trait to apply Landlock on VmConfig elements
|
||||
|
||||
Reference in New Issue
Block a user