vmm: config: Add "uuid" option to "--platform"

The uuid indicates the unique ID of a virtual machine.
cloud-hypervisor takes the uuid passed by libvirt
and uses it to initialize cloud-init.

Signed-off-by: lizhaoxin1 <Lxiaoyouling@163.com>
This commit is contained in:
lizhaoxin1 2022-08-04 11:33:44 +08:00 committed by Sebastien Boeuf
parent 147e89f413
commit 3abc1e1e51
2 changed files with 7 additions and 1 deletions

View File

@ -155,7 +155,7 @@ fn create_app<'a>(
Arg::new("platform")
.long("platform")
.help(
"num_pci_segments=<num pci segments>,iommu_segments=<list_of_segments>,serial_number=<(DMI) device serial number>",
"num_pci_segments=<num_pci_segments>,iommu_segments=<list_of_segments>,serial_number=<dmi_device_serial_number>,uuid=<dmi_device_uuid>",
)
.takes_value(true)
.group("vm-config"),

View File

@ -634,6 +634,8 @@ pub struct PlatformConfig {
pub iommu_segments: Option<Vec<u16>>,
#[serde(default)]
pub serial_number: Option<String>,
#[serde(default)]
pub uuid: Option<String>,
}
impl PlatformConfig {
@ -642,6 +644,7 @@ impl PlatformConfig {
parser.add("num_pci_segments");
parser.add("iommu_segments");
parser.add("serial_number");
parser.add("uuid");
parser.parse(platform).map_err(Error::ParsePlatform)?;
let num_pci_segments: u16 = parser
@ -655,10 +658,12 @@ impl PlatformConfig {
let serial_number = parser
.convert("serial_number")
.map_err(Error::ParsePlatform)?;
let uuid = parser.convert("uuid").map_err(Error::ParsePlatform)?;
Ok(PlatformConfig {
num_pci_segments,
iommu_segments,
serial_number,
uuid,
})
}
@ -687,6 +692,7 @@ impl Default for PlatformConfig {
num_pci_segments: DEFAULT_NUM_PCI_SEGMENTS,
iommu_segments: None,
serial_number: None,
uuid: None,
}
}
}