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