QEMU/KVM virtual machine management via QMP
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-qemu: enable MDX on lib/qemu.mli

Run mdx on lib/qemu.mli so the {[ ... ]} odoc block now type-checks.

`Qemu.Vm.spawn` takes `~sw ~proc_mgr ...`; the example was missing
`~sw`. Wrapped the spawn + connect + query_status flow in
`let run () = ...` so the mdx test does not actually launch QEMU,
and switched the connect/query error paths from `failwith` /
`Fmt.pr` to `Fmt.epr` so errors land on stderr where they belong.

+14 -9
+4
lib/dune
··· 2 2 (name qemu) 3 3 (public_name qemu) 4 4 (libraries eio nox-json logs bytesrw vlog nox-tty unix fmt)) 5 + 6 + (mdx 7 + (files qemu.mli) 8 + (libraries qemu fmt eio eio.core eio.unix eio_main))
+10 -9
lib/qemu.mli
··· 13 13 {[ 14 14 open Eio.Std 15 15 16 - let () = 16 + let run () = 17 17 Eio_main.run @@ fun env -> 18 18 let net = Eio.Stdenv.net env in 19 19 let proc_mgr = Eio.Stdenv.process_mgr env in 20 20 Switch.run @@ fun sw -> 21 - (* Create VM configuration *) 21 + (* Create VM configuration. *) 22 22 let config = 23 23 Qemu.Vm.Config.default ~name:"test-vm" 24 24 |> Qemu.Vm.Config.with_memory_mb 1024 25 25 |> Qemu.Vm.Config.with_disk "/path/to/disk.img" 26 26 |> Qemu.Vm.Config.with_kernel "/path/to/vmlinuz" 27 27 in 28 - (* Spawn QEMU process *) 29 - let vm = Qemu.Vm.spawn ~proc_mgr config in 30 - (* Connect to QMP socket *) 28 + (* Spawn QEMU process. *) 29 + let vm = Qemu.Vm.spawn ~sw ~proc_mgr config in 30 + (* Connect to QMP socket. *) 31 31 match Qemu.Vm.connect ~sw ~net vm with 32 - | Error e -> failwith e 32 + | Error e -> Fmt.epr "connect: %s@." e 33 33 | Ok () -> ( 34 - (* Query status *) 34 + (* Query status. *) 35 35 match Qemu.Vm.query_status vm with 36 - | Ok status -> Fmt.pr "VM status: %a@." Qemu.Qmp.Status.pp status 37 - | Error e -> Fmt.pr "Error: %s@." e) 36 + | Ok status -> 37 + Fmt.pr "VM status: %a@." Qemu.Qmp.Status.pp status 38 + | Error e -> Fmt.epr "query_status: %s@." e) 38 39 ]} 39 40 40 41 {1 Architecture}