mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add id field to --device through CLI
Add the ability to specify the "id" associated with a device, by adding an extra option to the parameter --device. This new option is not mandatory, and by default, the VMM will take care of finding a unique identifier. If the identifier provided by the user through this new option is not unique, an error will be thrown and the VM won't be started. Fixes #881 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
f4a956a60a
commit
9023444ad3
+10
-1
@@ -900,19 +900,28 @@ impl DeviceConfig {
|
||||
|
||||
let mut path_str: &str = "";
|
||||
let mut iommu_str: &str = "";
|
||||
let mut id_str: &str = "";
|
||||
|
||||
for param in params_list.iter() {
|
||||
if param.starts_with("path=") {
|
||||
path_str = ¶m[5..];
|
||||
} else if param.starts_with("iommu=") {
|
||||
iommu_str = ¶m[6..];
|
||||
} else if param.starts_with("id=") {
|
||||
id_str = ¶m[3..];
|
||||
}
|
||||
}
|
||||
|
||||
let id = if !id_str.is_empty() {
|
||||
Some(String::from(id_str))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(DeviceConfig {
|
||||
path: PathBuf::from(path_str),
|
||||
iommu: parse_on_off(iommu_str)?,
|
||||
id: None,
|
||||
id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user