mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
vmm: remove pub use vm_config in config
This patch removes pub import vm_config in config.rs to eliminate the ambiguity of vm_comfig reference. Signed-off-by: Songqian Li <sionli@tencent.com>
This commit is contained in:
parent
61e57e1cb1
commit
33c15ca273
@ -19,7 +19,7 @@ const MEM_SIZE: usize = 256 * 1024 * 1024;
|
||||
const CMDLINE_START: GuestAddress = GuestAddress(0x20000);
|
||||
|
||||
fuzz_target!(|bytes| {
|
||||
let payload_config = vmm::config::PayloadConfig {
|
||||
let payload_config = vmm::vm_config::PayloadConfig {
|
||||
firmware: None,
|
||||
kernel: None,
|
||||
cmdline: Some(String::from_utf8_lossy(&bytes).to_string()),
|
||||
|
@ -14,6 +14,11 @@ use api_client::{
|
||||
};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use option_parser::{ByteSized, ByteSizedParseError};
|
||||
use vmm::config::RestoreConfig;
|
||||
use vmm::vm_config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig, VdpaConfig,
|
||||
VsockConfig,
|
||||
};
|
||||
#[cfg(feature = "dbus_api")]
|
||||
use zbus::{proxy, zvariant::Optional};
|
||||
|
||||
@ -773,15 +778,14 @@ fn resize_zone_config(id: &str, size: &str) -> Result<String, Error> {
|
||||
}
|
||||
|
||||
fn add_device_config(config: &str) -> Result<String, Error> {
|
||||
let device_config = vmm::config::DeviceConfig::parse(config).map_err(Error::AddDeviceConfig)?;
|
||||
let device_config = DeviceConfig::parse(config).map_err(Error::AddDeviceConfig)?;
|
||||
let device_config = serde_json::to_string(&device_config).unwrap();
|
||||
|
||||
Ok(device_config)
|
||||
}
|
||||
|
||||
fn add_user_device_config(config: &str) -> Result<String, Error> {
|
||||
let device_config =
|
||||
vmm::config::UserDeviceConfig::parse(config).map_err(Error::AddUserDeviceConfig)?;
|
||||
let device_config = UserDeviceConfig::parse(config).map_err(Error::AddUserDeviceConfig)?;
|
||||
let device_config = serde_json::to_string(&device_config).unwrap();
|
||||
|
||||
Ok(device_config)
|
||||
@ -794,28 +798,28 @@ fn remove_device_config(id: &str) -> String {
|
||||
}
|
||||
|
||||
fn add_disk_config(config: &str) -> Result<String, Error> {
|
||||
let disk_config = vmm::config::DiskConfig::parse(config).map_err(Error::AddDiskConfig)?;
|
||||
let disk_config = DiskConfig::parse(config).map_err(Error::AddDiskConfig)?;
|
||||
let disk_config = serde_json::to_string(&disk_config).unwrap();
|
||||
|
||||
Ok(disk_config)
|
||||
}
|
||||
|
||||
fn add_fs_config(config: &str) -> Result<String, Error> {
|
||||
let fs_config = vmm::config::FsConfig::parse(config).map_err(Error::AddFsConfig)?;
|
||||
let fs_config = FsConfig::parse(config).map_err(Error::AddFsConfig)?;
|
||||
let fs_config = serde_json::to_string(&fs_config).unwrap();
|
||||
|
||||
Ok(fs_config)
|
||||
}
|
||||
|
||||
fn add_pmem_config(config: &str) -> Result<String, Error> {
|
||||
let pmem_config = vmm::config::PmemConfig::parse(config).map_err(Error::AddPmemConfig)?;
|
||||
let pmem_config = PmemConfig::parse(config).map_err(Error::AddPmemConfig)?;
|
||||
let pmem_config = serde_json::to_string(&pmem_config).unwrap();
|
||||
|
||||
Ok(pmem_config)
|
||||
}
|
||||
|
||||
fn add_net_config(config: &str) -> Result<(String, Vec<i32>), Error> {
|
||||
let mut net_config = vmm::config::NetConfig::parse(config).map_err(Error::AddNetConfig)?;
|
||||
let mut net_config = NetConfig::parse(config).map_err(Error::AddNetConfig)?;
|
||||
|
||||
// NetConfig is modified on purpose here by taking the list of file
|
||||
// descriptors out. Keeping the list and send it to the server side
|
||||
@ -828,14 +832,14 @@ fn add_net_config(config: &str) -> Result<(String, Vec<i32>), Error> {
|
||||
}
|
||||
|
||||
fn add_vdpa_config(config: &str) -> Result<String, Error> {
|
||||
let vdpa_config = vmm::config::VdpaConfig::parse(config).map_err(Error::AddVdpaConfig)?;
|
||||
let vdpa_config = VdpaConfig::parse(config).map_err(Error::AddVdpaConfig)?;
|
||||
let vdpa_config = serde_json::to_string(&vdpa_config).unwrap();
|
||||
|
||||
Ok(vdpa_config)
|
||||
}
|
||||
|
||||
fn add_vsock_config(config: &str) -> Result<String, Error> {
|
||||
let vsock_config = vmm::config::VsockConfig::parse(config).map_err(Error::AddVsockConfig)?;
|
||||
let vsock_config = VsockConfig::parse(config).map_err(Error::AddVsockConfig)?;
|
||||
let vsock_config = serde_json::to_string(&vsock_config).unwrap();
|
||||
|
||||
Ok(vsock_config)
|
||||
@ -850,7 +854,7 @@ fn snapshot_config(url: &str) -> String {
|
||||
}
|
||||
|
||||
fn restore_config(config: &str) -> Result<(String, Vec<i32>), Error> {
|
||||
let mut restore_config = vmm::config::RestoreConfig::parse(config).map_err(Error::Restore)?;
|
||||
let mut restore_config = RestoreConfig::parse(config).map_err(Error::Restore)?;
|
||||
// RestoreConfig is modified on purpose to take out the file descriptors.
|
||||
// These fds are passed to the server side process via SCM_RIGHTS
|
||||
let fds = match &mut restore_config.net_fds {
|
||||
@ -936,15 +940,13 @@ fn main() {
|
||||
Command::new("add-device").about("Add VFIO device").arg(
|
||||
Arg::new("device_config")
|
||||
.index(1)
|
||||
.help(vmm::config::DeviceConfig::SYNTAX),
|
||||
.help(DeviceConfig::SYNTAX),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-disk").about("Add block device").arg(
|
||||
Arg::new("disk_config")
|
||||
.index(1)
|
||||
.help(vmm::config::DiskConfig::SYNTAX),
|
||||
),
|
||||
Command::new("add-disk")
|
||||
.about("Add block device")
|
||||
.arg(Arg::new("disk_config").index(1).help(DiskConfig::SYNTAX)),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-fs")
|
||||
@ -952,7 +954,7 @@ fn main() {
|
||||
.arg(
|
||||
Arg::new("fs_config")
|
||||
.index(1)
|
||||
.help(vmm::config::FsConfig::SYNTAX),
|
||||
.help(vmm::vm_config::FsConfig::SYNTAX),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
@ -961,15 +963,13 @@ fn main() {
|
||||
.arg(
|
||||
Arg::new("pmem_config")
|
||||
.index(1)
|
||||
.help(vmm::config::PmemConfig::SYNTAX),
|
||||
.help(vmm::vm_config::PmemConfig::SYNTAX),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-net").about("Add network device").arg(
|
||||
Arg::new("net_config")
|
||||
.index(1)
|
||||
.help(vmm::config::NetConfig::SYNTAX),
|
||||
),
|
||||
Command::new("add-net")
|
||||
.about("Add network device")
|
||||
.arg(Arg::new("net_config").index(1).help(NetConfig::SYNTAX)),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-user-device")
|
||||
@ -977,22 +977,18 @@ fn main() {
|
||||
.arg(
|
||||
Arg::new("device_config")
|
||||
.index(1)
|
||||
.help(vmm::config::UserDeviceConfig::SYNTAX),
|
||||
.help(UserDeviceConfig::SYNTAX),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-vdpa").about("Add vDPA device").arg(
|
||||
Arg::new("vdpa_config")
|
||||
.index(1)
|
||||
.help(vmm::config::VdpaConfig::SYNTAX),
|
||||
),
|
||||
Command::new("add-vdpa")
|
||||
.about("Add vDPA device")
|
||||
.arg(Arg::new("vdpa_config").index(1).help(VdpaConfig::SYNTAX)),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("add-vsock").about("Add vsock device").arg(
|
||||
Arg::new("vsock_config")
|
||||
.index(1)
|
||||
.help(vmm::config::VsockConfig::SYNTAX),
|
||||
),
|
||||
Command::new("add-vsock")
|
||||
.about("Add vsock device")
|
||||
.arg(Arg::new("vsock_config").index(1).help(VsockConfig::SYNTAX)),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("remove-device")
|
||||
@ -1061,7 +1057,7 @@ fn main() {
|
||||
.arg(
|
||||
Arg::new("restore_config")
|
||||
.index(1)
|
||||
.help(vmm::config::RestoreConfig::SYNTAX),
|
||||
.help(RestoreConfig::SYNTAX),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
|
70
src/main.rs
70
src/main.rs
@ -3,9 +3,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[macro_use]
|
||||
extern crate event_monitor;
|
||||
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||
use std::sync::mpsc::channel;
|
||||
@ -13,6 +10,7 @@ use std::sync::Mutex;
|
||||
use std::{env, io};
|
||||
|
||||
use clap::{Arg, ArgAction, ArgGroup, ArgMatches, Command};
|
||||
use event_monitor::event;
|
||||
use libc::EFD_NONBLOCK;
|
||||
use log::{warn, LevelFilter};
|
||||
use option_parser::OptionParser;
|
||||
@ -23,8 +21,16 @@ use thiserror::Error;
|
||||
use vmm::api::dbus::{dbus_api_graceful_shutdown, DBusApiOptions};
|
||||
use vmm::api::http::http_api_graceful_shutdown;
|
||||
use vmm::api::ApiAction;
|
||||
use vmm::config;
|
||||
use vmm::config::{RestoreConfig, VmParams};
|
||||
use vmm::landlock::{Landlock, LandlockError};
|
||||
use vmm::vm_config;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use vmm::vm_config::SgxEpcConfig;
|
||||
use vmm::vm_config::{
|
||||
BalloonConfig, DeviceConfig, DiskConfig, FsConfig, LandlockConfig, NetConfig, NumaConfig,
|
||||
PciSegmentConfig, PmemConfig, RateLimiterGroupConfig, TpmConfig, UserDeviceConfig, VdpaConfig,
|
||||
VmConfig, VsockConfig,
|
||||
};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::block_signal;
|
||||
|
||||
@ -157,17 +163,17 @@ fn prepare_default_values() -> (String, String, String) {
|
||||
fn default_vcpus() -> String {
|
||||
format!(
|
||||
"boot={},max_phys_bits={}",
|
||||
config::DEFAULT_VCPUS,
|
||||
config::DEFAULT_MAX_PHYS_BITS
|
||||
vm_config::DEFAULT_VCPUS,
|
||||
vm_config::DEFAULT_MAX_PHYS_BITS
|
||||
)
|
||||
}
|
||||
|
||||
fn default_memory() -> String {
|
||||
format!("size={}M", config::DEFAULT_MEMORY_MB)
|
||||
format!("size={}M", vm_config::DEFAULT_MEMORY_MB)
|
||||
}
|
||||
|
||||
fn default_rng() -> String {
|
||||
format!("src={}", config::DEFAULT_RNG_SOURCE)
|
||||
format!("src={}", vm_config::DEFAULT_RNG_SOURCE)
|
||||
}
|
||||
|
||||
fn create_app(default_vcpus: String, default_memory: String, default_rng: String) -> Command {
|
||||
@ -266,14 +272,14 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("rate-limit-group")
|
||||
.long("rate-limit-group")
|
||||
.help(config::RateLimiterGroupConfig::SYNTAX)
|
||||
.help(RateLimiterGroupConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("disk")
|
||||
.long("disk")
|
||||
.help(config::DiskConfig::SYNTAX)
|
||||
.help(DiskConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
@ -291,14 +297,14 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("landlock-rules")
|
||||
.long("landlock-rules")
|
||||
.help(config::LandlockConfig::SYNTAX)
|
||||
.help(LandlockConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("net")
|
||||
.long("net")
|
||||
.help(config::NetConfig::SYNTAX)
|
||||
.help(NetConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
@ -314,21 +320,21 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("balloon")
|
||||
.long("balloon")
|
||||
.help(config::BalloonConfig::SYNTAX)
|
||||
.help(BalloonConfig::SYNTAX)
|
||||
.num_args(1)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("fs")
|
||||
.long("fs")
|
||||
.help(config::FsConfig::SYNTAX)
|
||||
.help(FsConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("pmem")
|
||||
.long("pmem")
|
||||
.help(config::PmemConfig::SYNTAX)
|
||||
.help(PmemConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
@ -351,28 +357,28 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("device")
|
||||
.long("device")
|
||||
.help(config::DeviceConfig::SYNTAX)
|
||||
.help(DeviceConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("user-device")
|
||||
.long("user-device")
|
||||
.help(config::UserDeviceConfig::SYNTAX)
|
||||
.help(UserDeviceConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("vdpa")
|
||||
.long("vdpa")
|
||||
.help(config::VdpaConfig::SYNTAX)
|
||||
.help(VdpaConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("vsock")
|
||||
.long("vsock")
|
||||
.help(config::VsockConfig::SYNTAX)
|
||||
.help(VsockConfig::SYNTAX)
|
||||
.num_args(1)
|
||||
.group("vm-config"),
|
||||
)
|
||||
@ -387,14 +393,14 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("numa")
|
||||
.long("numa")
|
||||
.help(config::NumaConfig::SYNTAX)
|
||||
.help(NumaConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("pci-segment")
|
||||
.long("pci-segment")
|
||||
.help(config::PciSegmentConfig::SYNTAX)
|
||||
.help(PciSegmentConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
)
|
||||
@ -437,7 +443,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
.arg(
|
||||
Arg::new("restore")
|
||||
.long("restore")
|
||||
.help(config::RestoreConfig::SYNTAX)
|
||||
.help(RestoreConfig::SYNTAX)
|
||||
.num_args(1)
|
||||
.group("vmm-config"),
|
||||
)
|
||||
@ -452,7 +458,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
Arg::new("tpm")
|
||||
.long("tpm")
|
||||
.num_args(1)
|
||||
.help(config::TpmConfig::SYNTAX)
|
||||
.help(TpmConfig::SYNTAX)
|
||||
.group("vmm-config"),
|
||||
);
|
||||
|
||||
@ -460,7 +466,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String
|
||||
let app = app.arg(
|
||||
Arg::new("sgx-epc")
|
||||
.long("sgx-epc")
|
||||
.help(config::SgxEpcConfig::SYNTAX)
|
||||
.help(SgxEpcConfig::SYNTAX)
|
||||
.num_args(1..)
|
||||
.group("vm-config"),
|
||||
);
|
||||
@ -779,8 +785,8 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
cmd_arguments.contains_id("kernel") || cmd_arguments.contains_id("firmware");
|
||||
|
||||
if payload_present {
|
||||
let vm_params = config::VmParams::from_arg_matches(&cmd_arguments);
|
||||
let vm_config = config::VmConfig::parse(vm_params).map_err(Error::ParsingConfig)?;
|
||||
let vm_params = VmParams::from_arg_matches(&cmd_arguments);
|
||||
let vm_config = VmConfig::parse(vm_params).map_err(Error::ParsingConfig)?;
|
||||
|
||||
// Create and boot the VM based off the VM config we just built.
|
||||
let sender = api_request_sender.clone();
|
||||
@ -799,7 +805,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
.send(
|
||||
api_evt.try_clone().unwrap(),
|
||||
api_request_sender,
|
||||
config::RestoreConfig::parse(restore_params).map_err(Error::ParsingRestore)?,
|
||||
RestoreConfig::parse(restore_params).map_err(Error::ParsingRestore)?,
|
||||
)
|
||||
.map_err(Error::VmRestore)?;
|
||||
}
|
||||
@ -960,14 +966,14 @@ fn main() {
|
||||
mod unit_tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use vmm::config::{
|
||||
ConsoleConfig, ConsoleOutputMode, CpuFeatures, CpusConfig, MemoryConfig, PayloadConfig,
|
||||
RngConfig, VmConfig, VmParams,
|
||||
};
|
||||
use vmm::config::VmParams;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use vmm::vm_config::DebugConsoleConfig;
|
||||
use vmm::vm_config::{
|
||||
ConsoleConfig, ConsoleOutputMode, CpuFeatures, CpusConfig, HotplugMethod, MemoryConfig,
|
||||
PayloadConfig, RngConfig, VmConfig,
|
||||
};
|
||||
|
||||
use crate::config::HotplugMethod;
|
||||
use crate::{create_app, prepare_default_values};
|
||||
|
||||
fn get_vm_config_from_vec(args: &[&str]) -> VmConfig {
|
||||
|
@ -15,12 +15,12 @@ use crate::api::http::{error_response, EndpointHandler, HttpError};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::api::VmCoredump;
|
||||
use crate::api::{
|
||||
AddDisk, ApiAction, ApiRequest, VmAddDevice, VmAddFs, VmAddNet, VmAddPmem, VmAddUserDevice,
|
||||
VmAddVdpa, VmAddVsock, VmBoot, VmConfig, VmCounters, VmDelete, VmNmi, VmPause, VmPowerButton,
|
||||
VmReboot, VmReceiveMigration, VmRemoveDevice, VmResize, VmResizeZone, VmRestore, VmResume,
|
||||
VmSendMigration, VmShutdown, VmSnapshot,
|
||||
AddDisk, ApiAction, ApiRequest, NetConfig, VmAddDevice, VmAddFs, VmAddNet, VmAddPmem,
|
||||
VmAddUserDevice, VmAddVdpa, VmAddVsock, VmBoot, VmConfig, VmCounters, VmDelete, VmNmi, VmPause,
|
||||
VmPowerButton, VmReboot, VmReceiveMigration, VmRemoveDevice, VmResize, VmResizeZone, VmRestore,
|
||||
VmResume, VmSendMigration, VmShutdown, VmSnapshot,
|
||||
};
|
||||
use crate::config::{NetConfig, RestoreConfig};
|
||||
use crate::config::RestoreConfig;
|
||||
|
||||
// /api/v1/vm.create handler
|
||||
pub struct VmCreate {}
|
||||
|
@ -46,12 +46,13 @@ 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, start_http_path_thread};
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, UserDeviceConfig,
|
||||
VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::config::RestoreConfig;
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use crate::vm_config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig, VdpaConfig,
|
||||
VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::Error as VmmError;
|
||||
|
||||
/// API errors are sent back from the VMM API server through the ApiResponse.
|
||||
|
@ -17,7 +17,7 @@ use thiserror::Error;
|
||||
use virtio_devices::{RateLimiterConfig, TokenBucketConfig};
|
||||
|
||||
use crate::landlock::LandlockAccess;
|
||||
pub use crate::vm_config::*;
|
||||
use crate::vm_config::*;
|
||||
|
||||
const MAX_NUM_PCI_SEGMENTS: u16 = 96;
|
||||
|
||||
|
@ -77,7 +77,6 @@ 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,
|
||||
@ -91,7 +90,9 @@ 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::vm_config::CpusConfig;
|
||||
use crate::{GuestMemoryMmap, 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`,
|
||||
|
@ -91,10 +91,6 @@ 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};
|
||||
@ -102,7 +98,10 @@ use crate::interrupt::{LegacyUserspaceInterruptManager, 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::vm_config::{
|
||||
ConsoleOutputMode, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig,
|
||||
VdpaConfig, VhostMode, VmConfig, VsockConfig, DEFAULT_PCI_SEGMENT_APERTURE_WEIGHT,
|
||||
};
|
||||
use crate::{device_node, GuestRegionMmap, PciDeviceInfo, DEVICE_MANAGER_SNAPSHOT_ID};
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
|
@ -48,10 +48,7 @@ use crate::api::{
|
||||
ApiRequest, ApiResponse, RequestHandler, VmInfoResponse, VmReceiveMigrationData,
|
||||
VmSendMigrationData, VmmPingResponse,
|
||||
};
|
||||
use crate::config::{
|
||||
add_to_config, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig,
|
||||
UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::config::{add_to_config, RestoreConfig};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::GuestDebuggable;
|
||||
use crate::landlock::Landlock;
|
||||
@ -61,6 +58,10 @@ 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 crate::vm_config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig, VdpaConfig,
|
||||
VmConfig, VsockConfig,
|
||||
};
|
||||
|
||||
mod acpi;
|
||||
pub mod api;
|
||||
@ -2143,14 +2144,13 @@ const DEVICE_MANAGER_SNAPSHOT_ID: &str = "device-manager";
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_tests {
|
||||
use config::{
|
||||
ConsoleConfig, ConsoleOutputMode, CpusConfig, HotplugMethod, MemoryConfig, PayloadConfig,
|
||||
RngConfig,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::DebugConsoleConfig;
|
||||
use crate::vm_config::DebugConsoleConfig;
|
||||
use crate::vm_config::{
|
||||
ConsoleConfig, ConsoleOutputMode, CpuFeatures, CpusConfig, HotplugMethod, MemoryConfig,
|
||||
PayloadConfig, RngConfig,
|
||||
};
|
||||
|
||||
fn create_dummy_vmm() -> Vmm {
|
||||
Vmm::new(
|
||||
@ -2176,7 +2176,7 @@ mod unit_tests {
|
||||
kvm_hyperv: false,
|
||||
max_phys_bits: 46,
|
||||
affinity: None,
|
||||
features: config::CpuFeatures::default(),
|
||||
features: CpuFeatures::default(),
|
||||
},
|
||||
memory: MemoryConfig {
|
||||
size: 536_870_912,
|
||||
|
@ -2,6 +2,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
@ -46,14 +47,14 @@ use vm_migration::{
|
||||
Migratable, MigratableError, Pausable, 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;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::vm_config::SgxEpcConfig;
|
||||
use crate::vm_config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap, MEMORY_MANAGER_SNAPSHOT_ID};
|
||||
|
||||
pub const MEMORY_MANAGER_ACPI_SIZE: usize = 0x18;
|
||||
|
@ -9,10 +9,10 @@ use std::path::PathBuf;
|
||||
use anyhow::anyhow;
|
||||
use vm_migration::{MigratableError, Snapshot};
|
||||
|
||||
use crate::config::VmConfig;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::GuestDebuggableError;
|
||||
use crate::vm::VmSnapshot;
|
||||
use crate::vm_config::VmConfig;
|
||||
|
||||
pub const SNAPSHOT_STATE_FILE: &str = "state.json";
|
||||
pub const SNAPSHOT_CONFIG_FILE: &str = "config.json";
|
||||
|
@ -67,11 +67,7 @@ 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, NumaConfig,
|
||||
PayloadConfig, PmemConfig, UserDeviceConfig, ValidationError, VdpaConfig, VmConfig,
|
||||
VsockConfig,
|
||||
};
|
||||
use crate::config::{add_to_config, ValidationError};
|
||||
use crate::console_devices::{ConsoleDeviceError, ConsoleInfo};
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::{
|
||||
@ -92,6 +88,10 @@ 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::vm_config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, NumaConfig, PayloadConfig,
|
||||
PmemConfig, UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::{
|
||||
cpu, GuestMemoryMmap, PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID,
|
||||
MEMORY_MANAGER_SNAPSHOT_ID,
|
||||
|
Loading…
Reference in New Issue
Block a user