Merge pull request #910 from egernst/fix-parsing

agent: fix errorneous parsing for guest block size
This commit is contained in:
Eric Ernst 2020-10-12 12:40:02 -07:00 committed by GitHub
commit 2e72972cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1407,7 +1407,13 @@ fn get_memory_info(block_size: bool, hotplug: bool) -> Result<(u64, bool)> {
return Err(anyhow!("Invalid block size")); return Err(anyhow!("Invalid block size"));
} }
size = v.trim().parse::<u64>()?; size = match u64::from_str_radix(v.trim(), 16) {
Ok(h) => h,
Err(_) => {
warn!(sl!(), "failed to parse the str {} to hex", size);
return Err(anyhow!("Invalid block size"));
}
};
} }
Err(e) => { Err(e) => {
info!(sl!(), "memory block size error: {:?}", e.kind()); info!(sl!(), "memory block size error: {:?}", e.kind());