mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: Add iommu=on|off option for --rng
Having the virtual IOMMU created with --iommu is one thing, but we also need a way to decide if a virtio-rng device should be attached to this virtual IOMMU or not. That's why we introduce an extra option "iommu" with the value "on" or "off". By default, the device is not attached, which means "iommu=off". Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
20c4ed829a
commit
fb4769388b
10
src/main.rs
10
src/main.rs
@ -80,7 +80,8 @@ fn main() {
|
||||
}
|
||||
|
||||
let default_vcpus = format! {"{}", config::DEFAULT_VCPUS};
|
||||
let default_memory = &format! {"size={}M", config::DEFAULT_MEMORY_MB};
|
||||
let default_memory = format! {"size={}M", config::DEFAULT_MEMORY_MB};
|
||||
let default_rng = format! {"src={}", config::DEFAULT_RNG_SOURCE};
|
||||
|
||||
let cmd_arguments = App::new("cloud-hypervisor")
|
||||
.version(crate_version!())
|
||||
@ -145,8 +146,11 @@ fn main() {
|
||||
.arg(
|
||||
Arg::with_name("rng")
|
||||
.long("rng")
|
||||
.help("Path to entropy source")
|
||||
.default_value(config::DEFAULT_RNG_SOURCE)
|
||||
.help(
|
||||
"Random number generator parameters \
|
||||
\"src=<entropy_source_path>,iommu=on|off\"",
|
||||
)
|
||||
.default_value(&default_rng)
|
||||
.group("vm-config"),
|
||||
)
|
||||
.arg(
|
||||
|
@ -256,6 +256,9 @@ components:
|
||||
src:
|
||||
type: string
|
||||
default: "/dev/urandom"
|
||||
iommu:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
FsConfig:
|
||||
required:
|
||||
|
@ -320,12 +320,29 @@ impl NetConfig {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct RngConfig {
|
||||
pub src: PathBuf,
|
||||
#[serde(default)]
|
||||
pub iommu: bool,
|
||||
}
|
||||
|
||||
impl RngConfig {
|
||||
pub fn parse(rng: &str) -> Result<Self> {
|
||||
// Split the parameters based on the comma delimiter
|
||||
let params_list: Vec<&str> = rng.split(',').collect();
|
||||
|
||||
let mut src_str: &str = "";
|
||||
let mut iommu_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("src=") {
|
||||
src_str = ¶m[4..];
|
||||
} else if param.starts_with("iommu=") {
|
||||
iommu_str = ¶m[6..];
|
||||
}
|
||||
}
|
||||
|
||||
Ok(RngConfig {
|
||||
src: PathBuf::from(rng),
|
||||
src: PathBuf::from(src_str),
|
||||
iommu: parse_iommu(iommu_str)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -334,6 +351,7 @@ impl Default for RngConfig {
|
||||
fn default() -> Self {
|
||||
RngConfig {
|
||||
src: PathBuf::from(DEFAULT_RNG_SOURCE),
|
||||
iommu: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -752,6 +770,11 @@ impl VmConfig {
|
||||
net = Some(net_config_list);
|
||||
}
|
||||
|
||||
let rng = RngConfig::parse(vm_params.rng)?;
|
||||
if rng.iommu {
|
||||
iommu = true;
|
||||
}
|
||||
|
||||
let mut fs: Option<Vec<FsConfig>> = None;
|
||||
if let Some(fs_list) = &vm_params.fs {
|
||||
let mut fs_config_list = Vec::new();
|
||||
@ -826,7 +849,7 @@ impl VmConfig {
|
||||
cmdline: CmdlineConfig::parse(vm_params.cmdline)?,
|
||||
disks,
|
||||
net,
|
||||
rng: RngConfig::parse(vm_params.rng)?,
|
||||
rng,
|
||||
fs,
|
||||
pmem,
|
||||
serial,
|
||||
|
Loading…
Reference in New Issue
Block a user