Skip to content

Commit 470f36b

Browse files
mg12ctxlindig
authored andcommitted
CP-24361: improve abstraction for dmpath parameter from string to Profile.t
Passing dm:Profile.t parameter to device.ml instead of dmpath:string permits more type-safe choices to be made when starting the qemu daemon. This patch prepares the code for the next commit which will select the right qemu backend based on the profile received. Signed-off-by: Marcus Granado <marcus.granado@citrix.com>
1 parent 6f39be2 commit 470f36b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

xc/device.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ module Dm = struct
21672167
)
21682168
| _ -> failwith "Unsupported vGPU configuration"
21692169

2170-
let __start (task: Xenops_task.task_handle) ~xs ~dmpath ?(timeout = !Xenopsd.qemu_dm_ready_timeout) l info domid =
2170+
let __start (task: Xenops_task.task_handle) ~xs ~dm ?(timeout = !Xenopsd.qemu_dm_ready_timeout) l info domid =
21712171
debug "Device.Dm.start domid=%d args: [%s]" domid (String.concat " " l);
21722172

21732173
(* start vgpu emulation if appropriate *)
@@ -2185,7 +2185,7 @@ module Dm = struct
21852185
let ready_path =
21862186
Printf.sprintf "/local/domain/%d/device-model/%d/state" qemu_domid domid in
21872187
let cancel = Cancel_utils.Qemu (qemu_domid, domid) in
2188-
let qemu_pid = init_daemon ~task ~path:dmpath ~args ~name:"qemu-dm" ~domid
2188+
let qemu_pid = init_daemon ~task ~path:(Profile.wrapper_of dm) ~args ~name:"qemu-dm" ~domid
21892189
~xs ~ready_path ~ready_val:"running" ~timeout ~cancel () in
21902190
match !Xenopsd.action_after_qemu_crash with
21912191
| None ->
@@ -2221,17 +2221,17 @@ module Dm = struct
22212221
xs.Xs.write (Qemu.pid_path_signal domid) crash_reason
22222222
))
22232223

2224-
let start (task: Xenops_task.task_handle) ~xs ~dmpath ?timeout info domid =
2224+
let start (task: Xenops_task.task_handle) ~xs ~dm ?timeout info domid =
22252225
let l = cmdline_of_info info false domid in
2226-
__start task ~xs ~dmpath ?timeout l info domid
2226+
__start task ~xs ~dm ?timeout l info domid
22272227

2228-
let restore (task: Xenops_task.task_handle) ~xs ~dmpath ?timeout info domid =
2228+
let restore (task: Xenops_task.task_handle) ~xs ~dm ?timeout info domid =
22292229
let l = cmdline_of_info info true domid in
2230-
__start task ~xs ~dmpath ?timeout l info domid
2230+
__start task ~xs ~dm ?timeout l info domid
22312231

2232-
let start_vnconly (task: Xenops_task.task_handle) ~xs ~dmpath ?timeout info domid =
2232+
let start_vnconly (task: Xenops_task.task_handle) ~xs ~dm ?timeout info domid =
22332233
let l = vnconly_cmdline ~info domid in
2234-
__start task ~xs ~dmpath ?timeout l info domid
2234+
__start task ~xs ~dm ?timeout l info domid
22352235

22362236
end (* Dm *)
22372237

xc/device.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ sig
255255

256256
val cmdline_of_info: info -> bool -> int -> string list
257257

258-
val start : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dmpath:string -> ?timeout:float -> info -> Xenctrl.domid -> unit
259-
val start_vnconly : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dmpath:string -> ?timeout:float -> info -> Xenctrl.domid -> unit
260-
val restore : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dmpath:string -> ?timeout:float -> info -> Xenctrl.domid -> unit
258+
val start : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dm:Profile.t -> ?timeout:float -> info -> Xenctrl.domid -> unit
259+
val start_vnconly : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dm:Profile.t -> ?timeout:float -> info -> Xenctrl.domid -> unit
260+
val restore : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> dm:Profile.t -> ?timeout:float -> info -> Xenctrl.domid -> unit
261261
val suspend : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> qemu_domid:int -> Xenctrl.domid -> unit
262262
val resume : Xenops_task.task_handle -> xs:Xenstore.Xs.xsh -> qemu_domid:int -> Xenctrl.domid -> unit
263263
val stop : xs:Xenstore.Xs.xsh -> qemu_domid:int -> Xenctrl.domid -> unit

xc/xenops_server_xen.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ let choose_alternative kind default platformdata =
5757
end else default
5858

5959
(* We allow qemu-dm to be overriden via a platform flag *)
60-
let choose_qemu_dm x = Device.(Profile.wrapper_of (
60+
let choose_qemu_dm x = Device.(
6161
if List.mem_assoc _device_model x
6262
then Profile.of_string (List.assoc _device_model x)
6363
else Profile.fallback
64-
))
64+
)
6565

6666
(* We allow xenguest to be overriden via a platform flag *)
6767
let choose_xenguest x = choose_alternative _xenguest !Xc_resources.xenguest x
@@ -1334,7 +1334,7 @@ module VM = struct
13341334
let vmextra = DB.read_exn vm.Vm.id in
13351335
let qemu_dm = choose_qemu_dm vm.Vm.platformdata in
13361336
let xenguest = choose_xenguest vm.Vm.platformdata in
1337-
debug "chosen qemu_dm = %s" qemu_dm;
1337+
debug "chosen qemu_dm = %s" (Device.Profile.wrapper_of qemu_dm);
13381338
debug "chosen xenguest = %s" xenguest;
13391339
try
13401340
Opt.iter (fun info ->
@@ -1344,15 +1344,15 @@ module VM = struct
13441344
Opt.iter
13451345
(fun stubdom_domid ->
13461346
Stubdom.build task ~xc ~xs ~store_domid ~console_domid info xenguest di.Xenctrl.domid stubdom_domid;
1347-
Device.Dm.start_vnconly task ~xs ~dmpath:qemu_dm info stubdom_domid
1347+
Device.Dm.start_vnconly task ~xs ~dm:qemu_dm info stubdom_domid
13481348
) (get_stubdom ~xs di.Xenctrl.domid);
13491349
| Vm.HVM { Vm.qemu_stubdom = false } ->
13501350
(if saved_state then Device.Dm.restore else Device.Dm.start)
1351-
task ~xs ~dmpath:qemu_dm info di.Xenctrl.domid
1351+
task ~xs ~dm:qemu_dm info di.Xenctrl.domid
13521352
| Vm.PV _ ->
13531353
Device.Vfb.add ~xc ~xs di.Xenctrl.domid;
13541354
Device.Vkbd.add ~xc ~xs di.Xenctrl.domid;
1355-
Device.Dm.start_vnconly task ~xs ~dmpath:qemu_dm info di.Xenctrl.domid
1355+
Device.Dm.start_vnconly task ~xs ~dm:qemu_dm info di.Xenctrl.domid
13561356
) (create_device_model_config vm vmextra vbds vifs vgpus);
13571357
match vm.Vm.ty with
13581358
| Vm.PV { vncterm = true; vncterm_ip = ip } -> Device.PV_Vnc.start ~xs ?ip di.Xenctrl.domid

0 commit comments

Comments
 (0)