From a69d8c63b34c87e1227e1bab6601fbd209152c50 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 14 Nov 2023 15:41:18 +0800 Subject: [PATCH] vmm: speed up JSON load when reading snap files We found that it's slow to load JSON when reading snap files. As described in [1], using from_slice instead of from_reader can fix this. Also, fix the error type being returned. 1. https://github.com/serde-rs/json/issues/160 Signed-off-by: Yi Wang --- vmm/src/migration.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/vmm/src/migration.rs b/vmm/src/migration.rs index 1906d69fd..7e7b53770 100644 --- a/vmm/src/migration.rs +++ b/vmm/src/migration.rs @@ -7,7 +7,7 @@ use crate::coredump::GuestDebuggableError; use crate::{config::VmConfig, vm::VmSnapshot}; use anyhow::anyhow; use std::fs::File; -use std::io::BufReader; +use std::io::Read; use std::path::PathBuf; use vm_migration::{MigratableError, Snapshot}; @@ -49,10 +49,14 @@ pub fn recv_vm_config(source_url: &str) -> std::result::Result std::result::Result { @@ -61,10 +65,14 @@ pub fn recv_vm_state(source_url: &str) -> std::result::Result std::result::Result {