From 08d80c1aaad735ba617f88be6fa6f7c1f786e08e Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 8 Oct 2020 16:13:14 +1100 Subject: [PATCH] agent/device: update_spec_device_list() should error if dev not found If update_spec_device_list() is given a device that can't be found in the OCI spec, it currently does nothing, and returns Ok(()). That doesn't seem like what we'd expect and is not what the Go agent in Kata 1 does. Change it to return an error in that case, like Kata 1. Signed-off-by: David Gibson --- src/agent/src/device.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/agent/src/device.rs b/src/agent/src/device.rs index 5dbb166153..8b7e604126 100644 --- a/src/agent/src/device.rs +++ b/src/agent/src/device.rs @@ -262,10 +262,14 @@ fn update_spec_device_list(device: &Device, spec: &mut Spec) -> Result<()> { } } } + return Ok(()); } } - Ok(()) + Err(anyhow!( + "Should have found a matching device {} in the spec", + device.vm_path + )) } // device.Id should be the predicted device name (vda, vdb, ...)