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 <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2023-11-06 16:16:18 +00:00
parent bdb83f8282
commit 59d0d4caff
2 changed files with 6 additions and 11 deletions

View File

@ -99,11 +99,7 @@ impl TryFrom<NamedHypervisorConfig> 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,

View File

@ -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,