Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions xc/device.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ type disp_intf_opt =
(* Display output / keyboard input *)
type disp_opt =
| NONE
| VNC of disp_intf_opt * string option * bool * int * string (* IP address, auto-allocate, port if previous false, keymap *)
| VNC of disp_intf_opt * string option * bool * int * string option (* IP address, auto-allocate, port if previous false, keymap *)
| SDL of disp_intf_opt * string (* X11 display *)

type media = Disk | Cdrom
Expand Down Expand Up @@ -1528,40 +1528,42 @@ let cmdline_of_disp info =
match x with
| Vgpu [{implementation = Nvidia _}] -> ["-vgpu"]
| Vgpu [{implementation = GVT_g gvt_g}] ->
[
let base_opts = [
"-xengt";
"-vgt_low_gm_sz"; Int64.to_string gvt_g.low_gm_sz;
"-vgt_high_gm_sz"; Int64.to_string gvt_g.high_gm_sz;
"-vgt_fence_sz"; Int64.to_string gvt_g.fence_sz;
] @ (
match gvt_g.monitor_config_file with
| Some monitor_config_file ->
["-vgt_monitor_config_file"; monitor_config_file]
| None -> []
) @ [
"-priv"
]
and config_file_opt = match gvt_g.monitor_config_file with
| Some path -> ["-vgt_monitor_config_file"; path]
| None -> []
and priv_opt = ["-priv"] in
List.flatten [base_opts; config_file_opt; priv_opt]
| Vgpu _ -> failwith "Unsupported vGPU configuration"
| Std_vga -> ["-std-vga"]
| Cirrus -> []
| GVT_d -> ["-std-vga"; "-gfx_passthru"]
in
let videoram_opt = ["-videoram"; string_of_int info.video_mib] in
let vnc_opts_of ip_addr_opt auto port keymap =
let unused_opt = if auto then ["-vncunused"] else [] in
let vnc_opt =
let ip_addr = Opt.default "127.0.0.1" ip_addr_opt
and port = if auto then "1" else string_of_int port in
["-vnc"; ip_addr ^ ":" ^ port] in
let keymap_opt = match keymap with Some k -> ["-k"; k] | None -> [] in
List.flatten [unused_opt; vnc_opt; keymap_opt]
in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the same effect without needing the combine_opts function:

let vnc_opts_of ip_addr_opt auto port keymap =
    let ip_addr = Opt.default "127.0.0.1" ip_addr_opt in
    let port = if auto then "1" else string_of_int port in
    let unused_opt = if auto then ["-vncunused"] else [] in
    let vnc_opt = ["-vnc"; ip_addr ^ ":" ^ port] in
    let keymap_opt = ["-k"; keymap] in
    List.flatten [unused_opt; vnc_opt; keymap_opt]

You should be able to make similar changes in other functions which are using combine_opts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll do this, and for the vga opts too.

let disp_options, wait_for_port =
match info.disp with
| NONE ->
([], false)
| SDL (opts,x11name) ->
( [], false)
([], false)
| SDL (opts, x11name) ->
([], false)
| VNC (disp_intf, ip_addr_opt, auto, port, keymap) ->
let ip_addr = Opt.default "127.0.0.1" ip_addr_opt in
let vga_type_opts = vga_type_opts disp_intf in
let vnc_opts =
if auto
then [ "-vncunused"; "-k"; keymap; "-vnc"; ip_addr ^ ":1" ]
else [ "-vnc"; ip_addr ^ ":" ^ (string_of_int port); "-k"; keymap ]
in
(vga_type_opts @ videoram_opt @ vnc_opts), true
let vga_type_opts = vga_type_opts disp_intf in
let vnc_opts = vnc_opts_of ip_addr_opt auto port keymap in
(vga_type_opts @ videoram_opt @ vnc_opts), true
in
disp_options, wait_for_port

Expand Down
2 changes: 1 addition & 1 deletion xc/device.mli
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ sig

type disp_opt =
| NONE
| VNC of disp_intf_opt * string option * bool * int * string (* IP address, auto-allocate, port if previous false, keymap *)
| VNC of disp_intf_opt * string option * bool * int * string option (* IP address, auto-allocate, port if previous false, keymap *)
| SDL of disp_intf_opt * string (* X11 display *)

type media = Disk | Cdrom
Expand Down
2 changes: 1 addition & 1 deletion xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ module VM = struct
?(nics=[]) ?(disks=[]) ?(vgpus=[])
?(pci_emulations=[]) ?(usb=Device.Dm.Disabled)
?(parallel=None)
?(acpi=true) ?(video=Cirrus) ?(keymap="en-us")
?(acpi=true) ?(video=Cirrus) ?keymap
?vnc_ip ?(pci_passthrough=false) ?(hvm=true) ?(video_mib=4) () =
let video = match video, vgpus with
| Cirrus, [] -> Device.Dm.Cirrus
Expand Down