From 9fe35c84efcee805d04250f4cc1491ca7d6879bc Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Tue, 11 Aug 2009 17:09:47 +0100 Subject: [PATCH] add display config option that permit to have vnc or others type of display. remove old vnc and vnckeymap config options, since they are superseded by the display config option. no display imply the same vnc port with en-us keymap that before this commit --- xenvm/vmact.ml | 9 ++++---- xenvm/vmconfig.ml | 52 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/xenvm/vmact.ml b/xenvm/vmact.ml index c3e9461..99cf255 100644 --- a/xenvm/vmact.ml +++ b/xenvm/vmact.ml @@ -186,10 +186,11 @@ let dm_info_of_cfg cfg = 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; diff --git a/xenvm/vmconfig.ml b/xenvm/vmconfig.ml index c6969f9..e4bf860 100644 --- a/xenvm/vmconfig.ml +++ b/xenvm/vmconfig.ml @@ -46,6 +46,21 @@ let snapshot_mode_of_string s = | "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; @@ -114,8 +129,7 @@ type config = { pcis: (int * config_pci) list; (* others *) boot: string; - vnc: int; - vnc_keymap: string; + display: display; cpuid: Domain.cpuid_config; datadir: string; notify: notify_ty; @@ -294,6 +308,31 @@ let config_notify_of_string s = | _ -> 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 @@ -328,11 +367,10 @@ let get cfg field = | "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 @@ -364,11 +402,10 @@ let set cfg field value = | "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 } @@ -441,13 +478,12 @@ let empty = 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; -- 2.39.5