let nics = get_nics cfg in
let nics = List.map (fun nic -> nic.nic_mac_gen, nic.nic_bridge_gen, nic.nic_model) nics in
let disp =
- match cfg.vnc with
- | (-1) -> Device.Dm.NONE
- | 0 -> Device.Dm.VNC (true, "", 0, cfg.vnc_keymap)
- | _ -> Device.Dm.VNC (false, "", cfg.vnc, cfg.vnc_keymap)
+ match cfg.display with
+ | DisplayNone -> Device.Dm.NONE
+ | DisplaySDL _ -> Device.Dm.NONE
+ | DisplayIntel _ -> Device.Dm.NONE
+ | DisplayVNC (unused, port, keymap) -> Device.Dm.VNC (unused, "", port, keymap)
in
{
Device.Dm.hvm = cfg.hvm;
| "coalesce" -> Snapshot_coalesce
| _ -> failwith "unknown snapshot mode"
+type display =
+ | DisplayNone
+ | DisplaySDL of string option
+ | DisplayVNC of bool * int * string
+ | DisplayIntel of string option
+
+let string_of_display disp =
+ match disp with
+ | DisplayNone -> "none"
+ | DisplaySDL x -> String.concat ":" ([ "sdl" ] @ (match x with None -> [] | Some s -> [ s ]))
+ | DisplayIntel x -> String.concat ":" ([ "intel" ] @ (match x with None -> [] | Some s -> [ s ]))
+ | DisplayVNC (u, port, k) ->
+ let args = (if u then [ "use-port-unused" ] else []) @ [ "port=" ^ (string_of_int port) ] @ [ "keymap=" ^ k ] in
+ String.concat ":" ([ "vnc" ] @ [ String.concat "," args ])
+
type config_pci = {
pci_bind: bool;
pci_domain: int;
pcis: (int * config_pci) list;
(* others *)
boot: string;
- vnc: int;
- vnc_keymap: string;
+ display: display;
cpuid: Domain.cpuid_config;
datadir: string;
notify: notify_ty;
| _ ->
failwith "bah"
+let config_display_of_string s =
+ match String.split ~limit:2 ':' s with
+ | "vnc" :: options ->
+ let options = try List.hd options with _ -> "" in
+ let keymap = ref "en-us" in
+ let port = ref 0 in
+ let unused = ref false in
+ let opts = String.split ',' options in
+ List.iter (fun opt ->
+ match String.split '=' ~limit:2 opt with
+ | "use-port-unused" :: [] -> unused := true
+ | "keymap" :: s :: [] -> keymap := s
+ | "port" :: s :: [] -> port := int_of_string s
+ | _ -> ()
+ ) opts;
+ DisplayVNC (!unused, !port, !keymap)
+ | "sdl" :: options ->
+ DisplaySDL (try Some (List.hd options) with _ -> None)
+ | "intel" :: options ->
+ DisplayIntel (try Some (List.hd options) with _ -> None)
+ | "none" :: _ ->
+ DisplayNone
+ | _ ->
+ failwith "unknown display format"
+
exception Unknown_boolean of string
let string_of_string_option opt = match opt with None -> "" | Some v -> v
| "acpi-pt" -> string_of_bool cfg.acpi_pt
| "diskinfo-pt" -> string_of_bool cfg.diskinfo_pt
| "boot" -> cfg.boot
- | "vnc" -> string_of_int cfg.vnc
- | "vnc-keymap" -> cfg.vnc_keymap
| "timer-mode" -> string_of_int_option cfg.timer_mode
| "time-offset" -> string_of_string_option cfg.timeoffset
| "hpet" -> string_of_int_option cfg.hpet
+ | "display" -> string_of_display cfg.display
| "vpt-align" -> string_of_int_option cfg.vpt_align
| "power-management" -> string_of_int cfg.power_management
| "oem-features" -> string_of_int cfg.oem_features
| "acpi-pt" -> { cfg with acpi_pt = bool_of_string value }
| "diskinfo-pt" -> { cfg with diskinfo_pt = bool_of_string value }
| "boot" -> { cfg with boot = value }
- | "vnc" -> { cfg with vnc = int_of_string value }
- | "vnc-keymap" -> { cfg with vnc_keymap = value }
| "timer-mode" -> { cfg with timer_mode = int_option_of_string value }
| "time-offset" -> { cfg with timeoffset = string_option_of_string value }
| "hpet" -> { cfg with hpet = int_option_of_string value }
+ | "display" -> { cfg with display = config_display_of_string value }
| "vpt-align" -> { cfg with vpt_align = int_option_of_string value }
| "power-management" -> { cfg with power_management = int_of_string value }
| "oem-features" -> { cfg with oem_features = int_of_string value }
viridian = false;
videoram = None;
boot = "cd";
- vnc = 0;
- vnc_keymap = "en-us";
power_management = 0;
oem_features = 0;
timer_mode = None;
timeoffset = None;
hpet = None;
+ display = DisplayVNC (false, 0, "en-us");
vpt_align = None;
global_pci_msitranslate = 0;
global_pci_power_mgmt = 0;