From 29cf637f3f47ecec9688cec115e9c34a5e7dbd69 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 7 Oct 2022 08:41:11 -0700 Subject: [PATCH] vmm: Move 'default_serial/console()' to vm_config.rs In this way, we have all functions related to generate default values of vm-config structs in the same location. Signed-off-by: Bo Chen --- vmm/src/config.rs | 16 ---------------- vmm/src/vm_config.rs | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 2039eb335..4667599aa 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1414,22 +1414,6 @@ impl ConsoleConfig { Ok(Self { file, mode, iommu }) } - - pub fn default_serial() -> Self { - ConsoleConfig { - file: None, - mode: ConsoleOutputMode::Null, - iommu: false, - } - } - - pub fn default_console() -> Self { - ConsoleConfig { - file: None, - mode: ConsoleOutputMode::Tty, - iommu: false, - } - } } impl DeviceConfig { diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index a07a51922..e52c58eae 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -532,6 +532,22 @@ pub struct PayloadConfig { pub initramfs: Option, } +pub fn default_serial() -> ConsoleConfig { + ConsoleConfig { + file: None, + mode: ConsoleOutputMode::Null, + iommu: false, + } +} + +pub fn default_console() -> ConsoleConfig { + ConsoleConfig { + file: None, + mode: ConsoleOutputMode::Tty, + iommu: false, + } +} + #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct VmConfig { #[serde(default)] @@ -546,9 +562,9 @@ pub struct VmConfig { pub balloon: Option, pub fs: Option>, pub pmem: Option>, - #[serde(default = "ConsoleConfig::default_serial")] + #[serde(default = "default_serial")] pub serial: ConsoleConfig, - #[serde(default = "ConsoleConfig::default_console")] + #[serde(default = "default_console")] pub console: ConsoleConfig, pub devices: Option>, pub user_devices: Option>,