minor api cleanup

This commit is contained in:
Hannes Mehnert 2019-10-11 23:04:59 +02:00
parent 58c3490782
commit 520eab879e
3 changed files with 8 additions and 6 deletions

View File

@ -27,7 +27,7 @@ let rec create stat_out log_out cons_out data_out hdr name config =
| Error `Msg msg ->
Logs.err (fun m -> m "failed to create %a: %s" Name.pp name msg) ;
Lwt.return (None, (hdr, `Failure msg))
| Ok (state', `Create (cons, succ_cont, fail_cont)) ->
| Ok (state', (cons, succ_cont, fail_cont)) ->
state := state';
cons_out "create" cons >>= function
| Error () -> Lwt.return (None, fail_cont ())

View File

@ -179,12 +179,13 @@ let handle_create t hdr name vm_config =
(hdr, `Failure m)
in
Ok ({ t with console_counter = Int64.succ t.console_counter },
`Create (cons_out, success, fail))
(cons_out, success, fail))
let handle_shutdown t name vm r =
(match Vmm_unix.free_system_resources name vm.Unikernel.taps with
| Ok () -> ()
| Error (`Msg e) -> Logs.warn (fun m -> m "%s while shutdown vm %a" e Unikernel.pp vm)) ;
| Error (`Msg e) ->
Logs.err (fun m -> m "%s while shutdown vm %a" e Unikernel.pp vm));
let t, log_out = log t name (`Unikernel_stop (name, vm.Unikernel.pid, r)) in
let t, stat_out = remove_stats t name in
(t, stat_out, log_out)

View File

@ -8,13 +8,14 @@ val init : Vmm_commands.version -> 'a t
val waiter : 'a t -> Name.t -> 'a t * 'a option
val register : 'a t -> Name.t -> (unit -> 'b * 'a) -> ('a t * 'b)
val register : 'a t -> Name.t -> (unit -> 'b * 'a) -> 'a t * 'b
val register_restart : 'a t -> Name.t -> (unit -> 'b * 'a) -> ('a t * 'b) option
type 'a create =
Vmm_commands.wire *
('a t -> ('a t * Vmm_commands.wire * Vmm_commands.wire * Vmm_commands.wire * Name.t * Unikernel.t, [ `Msg of string ]) result) *
('a t -> ('a t * Vmm_commands.wire * Vmm_commands.wire * Vmm_commands.wire *
Name.t * Unikernel.t, [ `Msg of string ]) result) *
(unit -> Vmm_commands.wire)
val handle_shutdown : 'a t -> Name.t -> Unikernel.t ->
@ -22,7 +23,7 @@ val handle_shutdown : 'a t -> Name.t -> Unikernel.t ->
val handle_create : 'a t -> Vmm_commands.header ->
Name.t -> Unikernel.config ->
('a t * [ `Create of 'a create ], [> `Msg of string ]) result
('a t * 'a create, [> `Msg of string ]) result
val handle_command : 'a t -> Vmm_commands.wire ->
('a t *