From 59d0d4caffa15a6e91ceb91f076c056a3095afd3 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Mon, 6 Nov 2023 16:16:18 +0000 Subject: [PATCH] runtime-rs: ch: Simplify VSOCK error handling Remove the redundant `VmConfigError::EmptyVsockSocketPath` error from the Cloud Hypervisor config crate since this scenario is already handled by the `VsockConfigError::NoVsockSocketPath` error. Fixes: #8385. Signed-off-by: James O. D. Hunt --- .../crates/hypervisor/ch-config/src/convert.rs | 14 ++++++-------- .../crates/hypervisor/ch-config/src/errors.rs | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs b/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs index 89d97b0732..b322dfb80d 100644 --- a/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs +++ b/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs @@ -99,11 +99,7 @@ impl TryFrom for VmConfig { check_tdx_rootfs_settings(&cfg, &guest_protection_to_use)?; - let vsock_socket_path = if n.vsock_socket_path.is_empty() { - return Err(VmConfigError::EmptyVsockSocketPath); - } else { - n.vsock_socket_path - }; + let vsock_socket_path = n.vsock_socket_path; let sandbox_path = if n.sandbox_path.is_empty() { return Err(VmConfigError::EmptySandboxPath); @@ -1941,7 +1937,7 @@ mod tests { let tests = &[ TestData { cfg: NamedHypervisorConfig::default(), - result: Err(VmConfigError::EmptyVsockSocketPath), + result: Err(VmConfigError::EmptySandboxPath), }, TestData { cfg: NamedHypervisorConfig { @@ -1957,7 +1953,7 @@ mod tests { ..Default::default() }, - result: Err(VmConfigError::EmptyVsockSocketPath), + result: Err(VmConfigError::CPUError(CpusConfigError::BootVCPUsTooSmall)), }, TestData { cfg: NamedHypervisorConfig { @@ -2018,7 +2014,9 @@ mod tests { }, TestData { cfg: named_hypervisor_cfg_with_image_and_kernel_bad_vsock, - result: Err(VmConfigError::EmptyVsockSocketPath), + result: Err(VmConfigError::VsockError( + VsockConfigError::NoVsockSocketPath, + )), }, TestData { cfg: named_hypervisor_cfg_with_image_and_kernel, diff --git a/src/runtime-rs/crates/hypervisor/ch-config/src/errors.rs b/src/runtime-rs/crates/hypervisor/ch-config/src/errors.rs index 422d177d37..5fcb0c6e27 100644 --- a/src/runtime-rs/crates/hypervisor/ch-config/src/errors.rs +++ b/src/runtime-rs/crates/hypervisor/ch-config/src/errors.rs @@ -10,9 +10,6 @@ pub enum VmConfigError { #[error("empty sandbox path")] EmptySandboxPath, - #[error("empty VSOCK socket path")] - EmptyVsockSocketPath, - #[error("cannot specify image and initrd")] MultipleBootFiles,