replace vmimage (Cstruct) with 0 after we wrote it to disk to avoid

the host process from referencing the whole vmimage
This commit is contained in:
Hannes Mehnert 2018-01-16 01:09:30 +01:00
parent 8807150c86
commit 0052c3dc84
1 changed files with 3 additions and 1 deletions

View File

@ -193,7 +193,9 @@ let exec dir vm tmpfile taps =
let dev = "/dev/vmm/ukvm" ^ string_of_int pid in
Bos.OS.Cmd.run Bos.Cmd.(v "chmod" % "g+rw" % dev)
| _ -> Ok ()) >>= fun () ->
Ok { config = vm ; cmd ; pid ; taps ; stdout ; tmpfile }
(* this should get rid of the vmimage from vmmd's memory! *)
let config = { vm with vmimage = (fst vm.vmimage, Cstruct.create 0) } in
Ok { config ; cmd ; pid ; taps ; stdout ; tmpfile }
with
Unix.Unix_error (e, _, _) ->
close_no_err stdout;