diff --git a/vmm/src/config.rs b/vmm/src/config.rs index c2c147e2d..84d9c7b85 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -291,6 +291,22 @@ impl FromStr for HotplugMethod { } } +struct ByteSized(u64); + +enum ByteSizedParseError { + InvalidValue(String), +} + +impl FromStr for ByteSized { + type Err = ByteSizedParseError; + + fn from_str(s: &str) -> std::result::Result { + Ok(ByteSized(parse_size(s).map_err(|_| { + ByteSizedParseError::InvalidValue(s.to_owned()) + })?)) + } +} + fn parse_size(size: &str) -> Result { let s = size.trim();