From 95cdd18f44d183d4742192eb0f84d1eba9c4c59e Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Sat, 22 Sep 2018 00:26:52 +0200 Subject: [PATCH] . --- README.md | 2 +- app/vmm_console.ml | 8 +++++--- stats/vmm_stats_lwt.ml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b2985ec..9c7b89d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ DEV> cd mirage-skeleton/tutorial/hello DEV> mirage configure -t hvt DEV> mirage build DEV> mv solo5-hvt /tmp/solo5-hvt.none -DEV> cd ../device-usage/network +DEV> cd ../../device-usage/network DEV> mirage configure -t hvt DEV> mirage build DEV> mv solo5-hvt /tmp/solo5-hvt.net diff --git a/app/vmm_console.ml b/app/vmm_console.ml index ae2d781..6fb2197 100644 --- a/app/vmm_console.ml +++ b/app/vmm_console.ml @@ -33,7 +33,7 @@ let read_console name ring channel () = | Some fd -> Vmm_lwt.write_wire fd (Vmm_wire.Console.data my_version id t line) >>= function | Error _ -> - Lwt.catch (fun () -> Lwt_unix.close fd) (fun _ -> Lwt.return_unit) >|= fun () -> + Vmm_lwt.safe_close fd >|= fun () -> active := String.Map.remove name !active | Ok () -> Lwt.return_unit) >>= loop @@ -83,7 +83,9 @@ let attach s id = let name = Vmm_core.string_of_id id in Logs.debug (fun m -> m "attempting to attach %a" Vmm_core.pp_id id) ; match String.Map.find name !t with - | None -> Lwt.return (Error (`Msg "not found")) + | None -> + active := String.Map.add name s !active ; + Lwt.return (Ok "waiing for VM") | Some r -> let entries = Vmm_ring.read r in Logs.debug (fun m -> m "found %d history" (List.length entries)) ; @@ -131,7 +133,7 @@ let handle s addr () = Lwt.return_unit in loop () >>= fun () -> - Lwt.catch (fun () -> Lwt_unix.close s) (fun _ -> Lwt.return_unit) >|= fun () -> + Vmm_lwt.safe_close s >|= fun () -> Logs.warn (fun m -> m "disconnected") let jump _ file = diff --git a/stats/vmm_stats_lwt.ml b/stats/vmm_stats_lwt.ml index 642d4d0..04d754d 100644 --- a/stats/vmm_stats_lwt.ml +++ b/stats/vmm_stats_lwt.ml @@ -42,7 +42,7 @@ let handle s addr () = | Error _ -> Logs.err (fun m -> m "exception while writing") ; Lwt.return acc in loop [] >>= fun vmids -> - Lwt.catch (fun () -> Lwt_unix.close s) (fun _ -> Lwt.return_unit) >|= fun () -> + Vmm_lwt.safe_close s >|= fun () -> Logs.warn (fun m -> m "disconnect, dropping %d vms!" (List.length vmids)) ; let t' = Vmm_stats.remove_vmids !t vmids in t := t'