QEMU/KVM virtual machine management via QMP
0
fork

Configure Feed

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

wal, block, sse, zephyr: remove [mutable] from never-reassigned fields

Warning 69 (unused-field, mutable-never-assigned). Four independent
record fields were flagged as mutable but the code only mutates their
referents in place, never rebinds the record slot itself:

- ocaml-wal/lib/wal.ml: [t.file] (the Eio file resource; methods call
Eio.File.pwrite_all etc., the slot is set once at open time).
- ocaml-block/lib/block.ml: [Memory.state.data] (the backing bytes,
written via Bytes.blit_string; [Bytes.t] is already mutable).
- ocaml-sse/lib/sse.ml: [Parser.t.data_buf] (a Buffer.t, written via
Buffer.add_*; the slot never changes).
- ocaml-zephyr/lib/zephyr.ml: drop [mode : Read | Write] entirely —
set at open-time, read nowhere. The open_read / open_write
constructors already distinguish the two call shapes, so mode
tracking was redundant.

+103 -100
+1 -1
bin/main.ml
··· 376 376 Fmt.epr "QMP error: %a@." Qemu.Qmp.Error.pp e; 377 377 `Error (false, "QMP error") 378 378 | Ok (Ok json) -> 379 - (match Jsont_bytesrw.encode_string Jsont.json json with 379 + (match Json_bytesrw.encode_string Json.json json with 380 380 | Ok s -> Fmt.pr "%s@." s 381 381 | Error e -> Fmt.epr "JSON error: %s@." e); 382 382 `Ok ())))
+3
dune
··· 1 + (env 2 + (dev 3 + (flags :standard %{dune-warnings})))
+1 -1
dune-project
··· 23 23 (eio (>= 1.0)) 24 24 (eio_main (>= 1.0)) 25 25 (fmt (>= 0.9.0)) 26 - (jsont (>= 0.1.0)) 26 + (json (>= 0.1.0)) 27 27 (logs (>= 0.7.0)) 28 28 (bytesrw (>= 0.1.0)) 29 29 (vlog (>= 0.1.0))
+1 -1
lib/dune
··· 1 1 (library 2 2 (name qemu) 3 3 (public_name qemu) 4 - (libraries eio jsont jsont.bytesrw logs bytesrw vlog tty unix fmt)) 4 + (libraries eio json json.bytesrw logs bytesrw vlog tty unix fmt))
+61 -61
lib/qmp_protocol.ml
··· 22 22 { qemu = { major; minor; micro }; package } 23 23 24 24 let qemu_jsont = 25 - Jsont.Object.map ~kind:"qemu_version" (fun major minor micro -> 25 + Json.Object.map ~kind:"qemu_version" (fun major minor micro -> 26 26 { major; minor; micro }) 27 - |> Jsont.Object.mem "major" Jsont.int ~enc:(fun v -> v.major) 28 - |> Jsont.Object.mem "minor" Jsont.int ~enc:(fun v -> v.minor) 29 - |> Jsont.Object.mem "micro" Jsont.int ~enc:(fun v -> v.micro) 30 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 27 + |> Json.Object.mem "major" Json.int ~enc:(fun v -> v.major) 28 + |> Json.Object.mem "minor" Json.int ~enc:(fun v -> v.minor) 29 + |> Json.Object.mem "micro" Json.int ~enc:(fun v -> v.micro) 30 + |> Json.Object.skip_unknown |> Json.Object.finish 31 31 32 32 let jsont = 33 - Jsont.Object.map ~kind:"version" (fun qemu package -> { qemu; package }) 34 - |> Jsont.Object.mem "qemu" qemu_jsont ~enc:(fun v -> v.qemu) 35 - |> Jsont.Object.mem "package" Jsont.string ~enc:(fun v -> v.package) 36 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 33 + Json.Object.map ~kind:"version" (fun qemu package -> { qemu; package }) 34 + |> Json.Object.mem "qemu" qemu_jsont ~enc:(fun v -> v.qemu) 35 + |> Json.Object.mem "package" Json.string ~enc:(fun v -> v.package) 36 + |> Json.Object.skip_unknown |> Json.Object.finish 37 37 38 38 let pp ppf v = 39 39 Fmt.pf ppf "%d.%d.%d%s" v.qemu.major v.qemu.minor v.qemu.micro ··· 45 45 type t = { qmp : qmp_info } 46 46 47 47 let qmp_info_jsont = 48 - Jsont.Object.map ~kind:"qmp_info" (fun version capabilities -> 48 + Json.Object.map ~kind:"qmp_info" (fun version capabilities -> 49 49 { version; capabilities }) 50 - |> Jsont.Object.mem "version" Version.jsont ~enc:(fun q -> q.version) 51 - |> Jsont.Object.mem "capabilities" (Jsont.list Jsont.string) ~enc:(fun q -> 50 + |> Json.Object.mem "version" Version.jsont ~enc:(fun q -> q.version) 51 + |> Json.Object.mem "capabilities" (Json.list Json.string) ~enc:(fun q -> 52 52 q.capabilities) 53 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 53 + |> Json.Object.skip_unknown |> Json.Object.finish 54 54 55 55 let jsont = 56 - Jsont.Object.map ~kind:"greeting" (fun qmp -> { qmp }) 57 - |> Jsont.Object.mem "QMP" qmp_info_jsont ~enc:(fun g -> g.qmp) 58 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 56 + Json.Object.map ~kind:"greeting" (fun qmp -> { qmp }) 57 + |> Json.Object.mem "QMP" qmp_info_jsont ~enc:(fun g -> g.qmp) 58 + |> Json.Object.skip_unknown |> Json.Object.finish 59 59 60 60 let version t = t.qmp.version 61 61 let capabilities t = t.qmp.capabilities ··· 65 65 type t = { seconds : int; microseconds : int } 66 66 67 67 let jsont = 68 - Jsont.Object.map ~kind:"timestamp" (fun seconds microseconds -> 68 + Json.Object.map ~kind:"timestamp" (fun seconds microseconds -> 69 69 { seconds; microseconds }) 70 - |> Jsont.Object.mem "seconds" Jsont.int ~enc:(fun t -> t.seconds) 71 - |> Jsont.Object.mem "microseconds" Jsont.int ~enc:(fun t -> t.microseconds) 72 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 70 + |> Json.Object.mem "seconds" Json.int ~enc:(fun t -> t.seconds) 71 + |> Json.Object.mem "microseconds" Json.int ~enc:(fun t -> t.microseconds) 72 + |> Json.Object.skip_unknown |> Json.Object.finish 73 73 74 74 let to_float t = Float.of_int t.seconds +. (Float.of_int t.microseconds /. 1e6) 75 75 end ··· 78 78 type t = { class_ : string; desc : string } 79 79 80 80 let jsont = 81 - Jsont.Object.map ~kind:"qmp_error" (fun class_ desc -> { class_; desc }) 82 - |> Jsont.Object.mem "class" Jsont.string ~enc:(fun e -> e.class_) 83 - |> Jsont.Object.mem "desc" Jsont.string ~enc:(fun e -> e.desc) 84 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 81 + Json.Object.map ~kind:"qmp_error" (fun class_ desc -> { class_; desc }) 82 + |> Json.Object.mem "class" Json.string ~enc:(fun e -> e.class_) 83 + |> Json.Object.mem "desc" Json.string ~enc:(fun e -> e.desc) 84 + |> Json.Object.skip_unknown |> Json.Object.finish 85 85 86 86 let pp ppf e = Fmt.pf ppf "%s: %s" e.class_ e.desc 87 87 end 88 88 89 89 module Event = struct 90 - type t = { event : string; data : Jsont.json option; timestamp : Timestamp.t } 90 + type t = { event : string; data : Json.t option; timestamp : Timestamp.t } 91 91 92 92 let jsont = 93 - Jsont.Object.map ~kind:"event" (fun event data timestamp -> 93 + Json.Object.map ~kind:"event" (fun event data timestamp -> 94 94 { event; data; timestamp }) 95 - |> Jsont.Object.mem "event" Jsont.string ~enc:(fun e -> e.event) 96 - |> Jsont.Object.opt_mem "data" Jsont.json ~enc:(fun e -> e.data) 97 - |> Jsont.Object.mem "timestamp" Timestamp.jsont ~enc:(fun e -> e.timestamp) 98 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 95 + |> Json.Object.mem "event" Json.string ~enc:(fun e -> e.event) 96 + |> Json.Object.opt_mem "data" Json.json ~enc:(fun e -> e.data) 97 + |> Json.Object.mem "timestamp" Timestamp.jsont ~enc:(fun e -> e.timestamp) 98 + |> Json.Object.skip_unknown |> Json.Object.finish 99 99 100 100 let name t = t.event 101 101 let data t = t.data ··· 107 107 module Command = struct 108 108 type t = { 109 109 execute : string; 110 - arguments : Jsont.json option; 110 + arguments : Json.t option; 111 111 id : string option; 112 112 } 113 113 114 114 let make ?arguments ?id execute = { execute; arguments; id } 115 115 116 116 let jsont = 117 - Jsont.Object.map ~kind:"command" (fun execute arguments id -> 117 + Json.Object.map ~kind:"command" (fun execute arguments id -> 118 118 { execute; arguments; id }) 119 - |> Jsont.Object.mem "execute" Jsont.string ~enc:(fun c -> c.execute) 120 - |> Jsont.Object.opt_mem "arguments" Jsont.json ~enc:(fun c -> c.arguments) 121 - |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun c -> c.id) 122 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 119 + |> Json.Object.mem "execute" Json.string ~enc:(fun c -> c.execute) 120 + |> Json.Object.opt_mem "arguments" Json.json ~enc:(fun c -> c.arguments) 121 + |> Json.Object.opt_mem "id" Json.string ~enc:(fun c -> c.id) 122 + |> Json.Object.skip_unknown |> Json.Object.finish 123 123 124 124 let to_json t = 125 - match Jsont.Json.encode jsont t with 125 + match Json.Value.encode jsont t with 126 126 | Ok json -> json 127 127 | Error e -> Fmt.failwith "Failed to encode command: %s" e 128 128 ··· 142 142 end 143 143 144 144 module Response = struct 145 - type success = { return : Jsont.json; success_id : string option } 145 + type success = { return : Json.t; success_id : string option } 146 146 type error_response = { qmp_error : Error.t; error_id : string option } 147 147 type t = Success of success | Error of error_response 148 148 149 - let success_jsont : success Jsont.t = 150 - Jsont.Object.map ~kind:"success" (fun return success_id -> 149 + let success_jsont : success Json.codec = 150 + Json.Object.map ~kind:"success" (fun return success_id -> 151 151 { return; success_id }) 152 - |> Jsont.Object.mem "return" Jsont.json ~enc:(fun s -> s.return) 153 - |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun s -> s.success_id) 154 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 152 + |> Json.Object.mem "return" Json.json ~enc:(fun s -> s.return) 153 + |> Json.Object.opt_mem "id" Json.string ~enc:(fun s -> s.success_id) 154 + |> Json.Object.skip_unknown |> Json.Object.finish 155 155 156 - let error_jsont : error_response Jsont.t = 157 - Jsont.Object.map ~kind:"error_response" (fun qmp_error error_id -> 156 + let error_jsont : error_response Json.codec = 157 + Json.Object.map ~kind:"error_response" (fun qmp_error error_id -> 158 158 { qmp_error; error_id }) 159 - |> Jsont.Object.mem "error" Error.jsont ~enc:(fun e -> e.qmp_error) 160 - |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun e -> e.error_id) 161 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 159 + |> Json.Object.mem "error" Error.jsont ~enc:(fun e -> e.qmp_error) 160 + |> Json.Object.opt_mem "id" Json.string ~enc:(fun e -> e.error_id) 161 + |> Json.Object.skip_unknown |> Json.Object.finish 162 162 end 163 163 164 164 (** {1 Message parsing} *) ··· 172 172 173 173 (* Helper to check if an object has a member *) 174 174 let has_member name = function 175 - | Jsont.Object (mems, _) -> Option.is_some (Jsont.Json.find_mem name mems) 175 + | Json.Object (mems, _) -> Option.is_some (Json.Value.find_mem name mems) 176 176 | _ -> false 177 177 178 178 let err_invalid_greeting e = Result.error (Fmt.str "Invalid greeting: %s" e) ··· 184 184 let of_json json = 185 185 (* Try to detect message type by checking for key fields *) 186 186 if has_member "QMP" json then 187 - match Jsont.Json.decode Greeting.jsont json with 187 + match Json.Value.decode Greeting.jsont json with 188 188 | Ok g -> Ok (Greeting g) 189 189 | Error e -> err_invalid_greeting e 190 190 else if has_member "event" json then 191 - match Jsont.Json.decode Event.jsont json with 191 + match Json.Value.decode Event.jsont json with 192 192 | Ok e -> Ok (Event e) 193 193 | Error e -> err_invalid_event e 194 194 else if has_member "return" json then 195 - match Jsont.Json.decode Response.success_jsont json with 195 + match Json.Value.decode Response.success_jsont json with 196 196 | Ok s -> Ok (Success s) 197 197 | Error e -> err_invalid_success e 198 198 else if has_member "error" json then 199 - match Jsont.Json.decode Response.error_jsont json with 199 + match Json.Value.decode Response.error_jsont json with 200 200 | Ok e -> Ok (Error e) 201 201 | Error e -> err_invalid_error e 202 202 else Error "Unknown QMP message type" 203 203 204 204 let of_string s = 205 - match Jsont_bytesrw.decode_string Jsont.json s with 205 + match Json_bytesrw.decode_string Json.json s with 206 206 | Ok json -> of_json json 207 207 | Error e -> err_json_parse e 208 208 end ··· 268 268 type t = { running : bool; singlestep : bool; status : run_state } 269 269 270 270 let run_state_jsont = 271 - Jsont.enum ~kind:"run_state" 271 + Json.enum ~kind:"run_state" 272 272 [ 273 273 ("debug", Debug); 274 274 ("inmigrate", Inmigrate); ··· 289 289 ] 290 290 291 291 let jsont = 292 - Jsont.Object.map ~kind:"status" (fun running singlestep status -> 292 + Json.Object.map ~kind:"status" (fun running singlestep status -> 293 293 { running; singlestep; status }) 294 - |> Jsont.Object.mem "running" Jsont.bool ~enc:(fun s -> s.running) 295 - |> Jsont.Object.mem "singlestep" Jsont.bool ~enc:(fun s -> s.singlestep) 296 - |> Jsont.Object.mem "status" run_state_jsont ~enc:(fun s -> s.status) 297 - |> Jsont.Object.skip_unknown |> Jsont.Object.finish 294 + |> Json.Object.mem "running" Json.bool ~enc:(fun s -> s.running) 295 + |> Json.Object.mem "singlestep" Json.bool ~enc:(fun s -> s.singlestep) 296 + |> Json.Object.mem "status" run_state_jsont ~enc:(fun s -> s.status) 297 + |> Json.Object.skip_unknown |> Json.Object.finish 298 298 299 - let of_json json = Jsont.Json.decode jsont json 299 + let of_json json = Json.Value.decode jsont json 300 300 301 301 let pp ppf t = 302 302 Fmt.pf ppf "%s%s"
+15 -15
lib/qmp_protocol.mli
··· 13 13 val make : int -> int -> int -> string -> t 14 14 (** [make major minor micro package] creates a version. *) 15 15 16 - val jsont : t Jsont.t 16 + val jsont : t Json.codec 17 17 (** JSON codec. *) 18 18 19 19 val pp : Format.formatter -> t -> unit ··· 23 23 module Greeting : sig 24 24 type t 25 25 26 - val jsont : t Jsont.t 26 + val jsont : t Json.codec 27 27 (** JSON codec. *) 28 28 29 29 val version : t -> Version.t ··· 36 36 module Timestamp : sig 37 37 type t = { seconds : int; microseconds : int } 38 38 39 - val jsont : t Jsont.t 39 + val jsont : t Json.codec 40 40 (** JSON codec. *) 41 41 42 42 val to_float : t -> float ··· 46 46 module Error : sig 47 47 type t = { class_ : string; desc : string } 48 48 49 - val jsont : t Jsont.t 49 + val jsont : t Json.codec 50 50 (** JSON codec. *) 51 51 52 52 val pp : Format.formatter -> t -> unit ··· 56 56 module Event : sig 57 57 type t 58 58 59 - val jsont : t Jsont.t 59 + val jsont : t Json.codec 60 60 (** JSON codec. *) 61 61 62 62 val name : t -> string 63 63 (** Event name. *) 64 64 65 - val data : t -> Jsont.json option 65 + val data : t -> Json.t option 66 66 (** Event payload, if any. *) 67 67 68 68 val timestamp : t -> float ··· 74 74 module Command : sig 75 75 type t 76 76 77 - val make : ?arguments:Jsont.json -> ?id:string -> string -> t 77 + val make : ?arguments:Json.t -> ?id:string -> string -> t 78 78 (** [make ?arguments ?id name] creates a QMP command. *) 79 79 80 - val jsont : t Jsont.t 80 + val jsont : t Json.codec 81 81 (** JSON codec. *) 82 82 83 - val to_json : t -> Jsont.json 83 + val to_json : t -> Json.t 84 84 (** Encode command as JSON. *) 85 85 86 86 (** {2 Common Commands} *) ··· 122 122 end 123 123 124 124 module Response : sig 125 - type success = { return : Jsont.json; success_id : string option } 125 + type success = { return : Json.t; success_id : string option } 126 126 type error_response = { qmp_error : Error.t; error_id : string option } 127 127 type t = Success of success | Error of error_response 128 128 129 - val success_jsont : success Jsont.t 129 + val success_jsont : success Json.codec 130 130 (** JSON codec for success responses. *) 131 131 132 - val error_jsont : error_response Jsont.t 132 + val error_jsont : error_response Json.codec 133 133 (** JSON codec for error responses. *) 134 134 end 135 135 ··· 142 142 | Success of Response.success 143 143 | Error of Response.error_response 144 144 145 - val of_json : Jsont.json -> (t, string) result 145 + val of_json : Json.t -> (t, string) result 146 146 (** Parse a QMP message from JSON. *) 147 147 148 148 val of_string : string -> (t, string) result ··· 178 178 val string_of_run_state : run_state -> string 179 179 (** Convert a run state to its string representation. *) 180 180 181 - val jsont : t Jsont.t 181 + val jsont : t Json.codec 182 182 (** JSON codec. *) 183 183 184 - val of_json : Jsont.json -> (t, string) result 184 + val of_json : Json.t -> (t, string) result 185 185 (** Parse status from JSON. *) 186 186 187 187 val pp : Format.formatter -> t -> unit
+1 -1
lib/vm.ml
··· 264 264 265 265 let send_command t cmd = 266 266 let json = Qmp_protocol.Command.to_json cmd in 267 - match Jsont_bytesrw.encode_string Jsont.json json with 267 + match Json_bytesrw.encode_string Json.json json with 268 268 | Ok s -> 269 269 Log.debug (fun m -> m "Sending: %s" s); 270 270 write_line t s
+1 -1
lib/vm.mli
··· 127 127 val execute : 128 128 t -> 129 129 Qmp_protocol.Command.t -> 130 - ((Jsont.json, Qmp_protocol.Error.t) result, string) result 130 + ((Json.t, Qmp_protocol.Error.t) result, string) result 131 131 (** Execute a QMP command and return the result. *) 132 132 end 133 133
+1 -1
qemu.opam
··· 15 15 "eio" {>= "1.0"} 16 16 "eio_main" {>= "1.0"} 17 17 "fmt" {>= "0.9.0"} 18 - "jsont" {>= "0.1.0"} 18 + "json" {>= "0.1.0"} 19 19 "logs" {>= "0.7.0"} 20 20 "bytesrw" {>= "0.1.0"} 21 21 "vlog" {>= "0.1.0"}
+8 -8
test/test_qemu.ml
··· 11 11 module Qmp = Qemu.Qmp 12 12 13 13 let parse_json s = 14 - match Jsont_bytesrw.decode_string Jsont.json s with 14 + match Json_bytesrw.decode_string Json.json s with 15 15 | Ok json -> json 16 16 | Error e -> failwith e 17 17 ··· 70 70 match Qmp.Message.of_string json with 71 71 | Ok (Qmp.Message.Success s) -> ( 72 72 match s.return with 73 - | Jsont.Object _ -> () 73 + | Json.Object _ -> () 74 74 | _ -> Alcotest.fail "Expected JSON object") 75 75 | Ok _ -> Alcotest.fail "Expected Success" 76 76 | Error e -> Alcotest.fail e ··· 271 271 let test_command_encode () = 272 272 let cmd = Qmp.Command.query_status in 273 273 let json = Qmp.Command.to_json cmd in 274 - match Jsont_bytesrw.encode_string Jsont.json json with 274 + match Json_bytesrw.encode_string Json.json json with 275 275 | Ok s -> 276 276 Alcotest.(check bool) 277 277 "contains execute" true ··· 282 282 let cmd = Qmp.Command.make ~id:"cookie#1" "query-name" in 283 283 let json = Qmp.Command.to_json cmd in 284 284 (* Roundtrip through Command codec *) 285 - match Jsont_bytesrw.encode_string Jsont.json json with 285 + match Json_bytesrw.encode_string Json.json json with 286 286 | Ok s -> ( 287 - match Jsont_bytesrw.decode_string Qmp.Command.jsont s with 287 + match Json_bytesrw.decode_string Qmp.Command.jsont s with 288 288 | Ok cmd' -> 289 289 (* Encode again and check it still contains our id *) 290 290 let json' = Qmp.Command.to_json cmd' in 291 291 let s' = 292 - match Jsont_bytesrw.encode_string Jsont.json json' with 292 + match Json_bytesrw.encode_string Json.json json' with 293 293 | Ok s -> s 294 294 | Error e -> Alcotest.failf "re-encode: %s" e 295 295 in ··· 318 318 List.iter 319 319 (fun cmd -> 320 320 let json = Qmp.Command.to_json cmd in 321 - match Jsont_bytesrw.encode_string Jsont.json json with 321 + match Json_bytesrw.encode_string Json.json json with 322 322 | Ok s -> ( 323 - match Jsont_bytesrw.decode_string Qmp.Command.jsont s with 323 + match Json_bytesrw.decode_string Qmp.Command.jsont s with 324 324 | Ok _ -> () 325 325 | Error e -> Alcotest.failf "roundtrip decode: %s" e) 326 326 | Error e -> Alcotest.failf "roundtrip encode: %s" e)
+10 -10
test/test_qmp_protocol.ml
··· 18 18 module Qmp = Qemu.Qmp 19 19 20 20 let parse_json s = 21 - match Jsont_bytesrw.decode_string Jsont.json s with 21 + match Json_bytesrw.decode_string Json.json s with 22 22 | Ok json -> json 23 23 | Error e -> failwith e 24 24 25 25 let encode_json json = 26 - match Jsont_bytesrw.encode_string Jsont.json json with 26 + match Json_bytesrw.encode_string Json.json json with 27 27 | Ok s -> s 28 28 | Error e -> failwith e 29 29 ··· 32 32 let test_version_make_roundtrip () = 33 33 (* make -> jsont encode -> jsont decode -> check fields *) 34 34 let v = Qmp.Version.make 9 0 0 "v9.0.0" in 35 - let json = Jsont.Json.encode Qmp.Version.jsont v in 35 + let json = Json.Value.encode Qmp.Version.jsont v in 36 36 match json with 37 37 | Ok json -> ( 38 - match Jsont.Json.decode Qmp.Version.jsont json with 38 + match Json.Value.decode Qmp.Version.jsont json with 39 39 | Ok v' -> 40 40 Alcotest.(check int) "major" 9 v'.qemu.major; 41 41 Alcotest.(check int) "minor" 0 v'.qemu.minor; ··· 55 55 parse_json 56 56 {|{"qemu": {"major": 7, "minor": 2, "micro": 5}, "package": "Debian 1:7.2+dfsg-7"}|} 57 57 in 58 - match Jsont.Json.decode Qmp.Version.jsont json with 58 + match Json.Value.decode Qmp.Version.jsont json with 59 59 | Ok v -> 60 60 Alcotest.(check int) "major" 7 v.qemu.major; 61 61 Alcotest.(check int) "minor" 2 v.qemu.minor; ··· 69 69 parse_json 70 70 {|{"qemu": {"major": 8, "minor": 0, "micro": 0, "extra": true}, "package": "", "build-date": "2023-04"}|} 71 71 in 72 - match Jsont.Json.decode Qmp.Version.jsont json with 72 + match Json.Value.decode Qmp.Version.jsont json with 73 73 | Ok v -> 74 74 Alcotest.(check int) "major" 8 v.qemu.major; 75 75 Alcotest.(check string) "package" "" v.package ··· 163 163 (* The serialized form should contain "device_del" and the argument *) 164 164 Alcotest.(check bool) "has execute" true (String.length s > 0); 165 165 (* Roundtrip through codec *) 166 - match Jsont_bytesrw.decode_string Qmp.Command.jsont s with 166 + match Json_bytesrw.decode_string Qmp.Command.jsont s with 167 167 | Ok _ -> () 168 168 | Error e -> Alcotest.failf "roundtrip: %s" e 169 169 ··· 172 172 let cmd = Qmp.Command.make ~arguments:args ~id:"migrate-1" "migrate" in 173 173 let json = Qmp.Command.to_json cmd in 174 174 let s = encode_json json in 175 - match Jsont_bytesrw.decode_string Qmp.Command.jsont s with 175 + match Json_bytesrw.decode_string Qmp.Command.jsont s with 176 176 | Ok _ -> () 177 177 | Error e -> Alcotest.failf "roundtrip: %s" e 178 178 ··· 185 185 let cmd = Qmp.Command.make ~arguments:args "blockdev-add" in 186 186 let json = Qmp.Command.to_json cmd in 187 187 let s = encode_json json in 188 - match Jsont_bytesrw.decode_string Qmp.Command.jsont s with 188 + match Json_bytesrw.decode_string Qmp.Command.jsont s with 189 189 | Ok _ -> () 190 190 | Error e -> Alcotest.failf "roundtrip: %s" e 191 191 ··· 303 303 304 304 let test_timestamp_jsont_roundtrip () = 305 305 let json = parse_json {|{"seconds": 1267040730, "microseconds": 682951}|} in 306 - match Jsont.Json.decode Qmp.Timestamp.jsont json with 306 + match Json.Value.decode Qmp.Timestamp.jsont json with 307 307 | Ok ts -> 308 308 Alcotest.(check int) "seconds" 1267040730 ts.seconds; 309 309 Alcotest.(check int) "microseconds" 682951 ts.microseconds