From 3abc1e1e51e22c799ada7ea03ce07c4c5a083598 Mon Sep 17 00:00:00 2001 From: lizhaoxin1 Date: Thu, 4 Aug 2022 11:33:44 +0800 Subject: [PATCH] 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 --- src/main.rs | 2 +- vmm/src/config.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0e6d5e98b..890416c37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,7 +155,7 @@ fn create_app<'a>( Arg::new("platform") .long("platform") .help( - "num_pci_segments=,iommu_segments=,serial_number=<(DMI) device serial number>", + "num_pci_segments=,iommu_segments=,serial_number=,uuid=", ) .takes_value(true) .group("vm-config"), diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 1c8e93b24..d51b54b69 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -634,6 +634,8 @@ pub struct PlatformConfig { pub iommu_segments: Option>, #[serde(default)] pub serial_number: Option, + #[serde(default)] + pub uuid: Option, } 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, } } }