From 2ae9939c0a0d346a94b991bbbbe5058ef6ec21cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 20 Nov 2024 09:42:30 +0100 Subject: [PATCH] On solo5 manifest mismatch print the manifest This makes it easier for users of the client to figure out what devices are expected without them having to know to query the solo5 manifest using solo5-elftool themselves. --- src/vmm_unix.ml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/vmm_unix.ml b/src/vmm_unix.ml index 89fb605..4ddf82e 100644 --- a/src/vmm_unix.ml +++ b/src/vmm_unix.ml @@ -252,13 +252,12 @@ let check_solo5_tender target version = Error (`Msg (Fmt.str "unexpected solo5 tender --version output, expected one line with 'ABI version %u', got %s" version (String.concat "\n" out))) -let solo5_image_devices image = - let* mft = Solo5_elftool.query_manifest (owee_buf_of_str image) in - Ok (List.fold_left - (fun (block_devices, networks) -> function - | Solo5_elftool.Dev_block_basic name -> name :: block_devices, networks - | Solo5_elftool.Dev_net_basic name -> block_devices, name :: networks) - ([], []) mft.entries) +let solo5_image_devices mft = + List.fold_left + (fun (block_devices, networks) -> function + | Solo5_elftool.Dev_block_basic name -> name :: block_devices, networks + | Solo5_elftool.Dev_net_basic name -> block_devices, name :: networks) + ([], []) mft.Solo5_elftool.entries let equal_string_lists b1 b2 err = if String_set.(equal (of_list b1) (of_list b2)) then @@ -266,20 +265,23 @@ let equal_string_lists b1 b2 err = else Error (`Msg err) -let devices_match ~bridges ~block_devices (manifest_block, manifest_net) = +let devices_match ~bridges ~block_devices mft = + let (manifest_block, manifest_net) = solo5_image_devices mft in let* () = equal_string_lists manifest_block block_devices - "specified block device(s) does not match with manifest" + (Format.asprintf "specified block device(s) does not match with manifest. Declared manifest: %a" + Solo5_elftool.pp_mft mft) in equal_string_lists manifest_net bridges - "specified bridge(s) does not match with the manifest" + (Format.asprintf "specified bridge(s) does not match with the manifest. Declared manifest: %a" + Solo5_elftool.pp_mft mft) let manifest_devices_match ~bridges ~block_devices image = - let* things = solo5_image_devices image in + let* mft = Solo5_elftool.query_manifest (owee_buf_of_str image) in let bridges = List.map (fun (b, _, _) -> b) bridges and block_devices = List.map (fun (b, _, _) -> b) block_devices in - devices_match ~bridges ~block_devices things + devices_match ~bridges ~block_devices mft let bridge_name (service, b, _mac) = match b with None -> service | Some b -> b