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

View file

@ -193,7 +193,9 @@ let exec dir vm tmpfile taps =
let dev = "/dev/vmm/ukvm" ^ string_of_int pid in let dev = "/dev/vmm/ukvm" ^ string_of_int pid in
Bos.OS.Cmd.run Bos.Cmd.(v "chmod" % "g+rw" % dev) Bos.OS.Cmd.run Bos.Cmd.(v "chmod" % "g+rw" % dev)
| _ -> Ok ()) >>= fun () -> | _ -> 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 with
Unix.Unix_error (e, _, _) -> Unix.Unix_error (e, _, _) ->
close_no_err stdout; close_no_err stdout;