Skip to content

Commit ca81f54

Browse files
CP-54217: Change wording.
Signed-off-by: Stephen Cheng <[email protected]>
1 parent 95fe296 commit ca81f54

File tree

5 files changed

+59
-58
lines changed

5 files changed

+59
-58
lines changed

ocaml/idl/datamodel_lifecycle.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ let prototyped_of_field = function
138138
| "VM", "actions__after_softreboot" ->
139139
Some "23.1.0"
140140
| "pool", "limit_console_sessions" ->
141-
Some "25.29.0"
141+
Some "25.30.0-next"
142142
| "pool", "ha_reboot_vm_on_internal_shutdown" ->
143143
Some "25.16.0"
144144
| "pool", "license_server" ->

ocaml/idl/datamodel_pool.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,10 @@ let t =
22522252
when HA is enabled"
22532253
; field ~writer_roles:_R_POOL_OP ~qualifier:RW ~lifecycle:[] ~ty:Bool
22542254
~default_value:(Some (VBool false)) "limit_console_sessions"
2255-
"Indicate whether the console concurrent limit is set for the pool \
2256-
(false means no limit)"
2255+
"When true, only one console connection per VM/host in the pool is \
2256+
accepted. Otherwise every connection for a VM/host's console is \
2257+
accepted. Note: when true, connection attempts via websocket will \
2258+
be rejected."
22572259
]
22582260
)
22592261
()

ocaml/idl/schematest.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
33
(* BEWARE: if this changes, check that schema has been bumped accordingly in
44
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)
55

6-
let last_known_schema_hash = "f546a0d01815608cbcf04cdb90c1be9f"
6+
let last_known_schema_hash = "cf1c1e26b4288dd53cf6da5a4d6ad13c"
77

88
let current_schema_hash : string =
99
let open Datamodel_types in

ocaml/xapi-cli-server/records.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ let pool_record rpc session_id pool =
15991599
~get:(fun () -> string_of_bool (x ()).API.pool_limit_console_sessions)
16001600
~set:(fun x ->
16011601
Client.Pool.set_limit_console_sessions ~rpc ~session_id ~self:pool
1602-
~value:(bool_of_string x)
1602+
~value:(safe_bool_of_string "limit-console-sessions" x)
16031603
)
16041604
()
16051605
]

ocaml/xapi/console.ml

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type address =
3434

3535
(* console is listening on a Unix domain socket *)
3636

37-
(* This module enforces connection limits for VM consoles.
38-
Depending on configuration, only one active connection per VM (including Dom0) is allowed,
39-
or that connections are unlimited. *)
37+
(* This module limits VNC console sessions to at most one per VM/host.
38+
Depending on configuration, either unlimited connections are allowed,
39+
or only a single active connection per VM/host is allowed. *)
4040
module Connection_limit = struct
4141
module VMSet = Set.Make (String)
4242

@@ -162,56 +162,55 @@ let ws_proxy __context _ req protocol address s =
162162
Db.Pool.get_limit_console_sessions ~__context ~self:pool
163163
in
164164
(* Disable connection via websocket if the limit is set *)
165-
if limit_console_sessions = true then (
166-
Http_svr.headers s (Http.http_503_service_unavailable ()) ;
167-
()
168-
) ;
169-
let addr = match address with Port p -> string_of_int p | Path p -> p in
170-
let protocol =
171-
match protocol with `rfb -> "rfb" | `vt100 -> "vt100" | `rdp -> "rdp"
172-
in
173-
let real_path = Filename.concat "/var/lib/xcp" "websockproxy" in
174-
let sock =
175-
try Some (Fecomms.open_unix_domain_sock_client real_path)
176-
with e ->
177-
debug "Error connecting to wsproxy (%s)" (Printexc.to_string e) ;
178-
Http_svr.headers s (Http.http_501_method_not_implemented ()) ;
179-
None
180-
in
181-
(* Ensure we always close the socket *)
182-
finally
183-
(fun () ->
184-
let upgrade_successful =
185-
Option.map
186-
(fun sock ->
187-
try
188-
let result = (sock, Some (Ws_helpers.upgrade req s)) in
189-
result
190-
with _ -> (sock, None)
191-
)
192-
sock
193-
in
194-
Option.iter
195-
(function
196-
| sock, Some ty ->
197-
let wsprotocol =
198-
match ty with
199-
| Ws_helpers.Hixie76 ->
200-
"hixie76"
201-
| Ws_helpers.Hybi10 ->
202-
"hybi10"
203-
in
204-
let message =
205-
Printf.sprintf "%s:%s:%s" wsprotocol protocol addr
206-
in
207-
let len = String.length message in
208-
ignore (Unixext.send_fd_substring sock message 0 len [] s)
209-
| _, None ->
210-
Http_svr.headers s (Http.http_501_method_not_implemented ())
211-
)
212-
upgrade_successful
213-
)
214-
(fun () -> Option.iter (fun sock -> Unix.close sock) sock)
165+
if limit_console_sessions = true then
166+
Http_svr.headers s (Http.http_503_service_unavailable ())
167+
else
168+
let addr = match address with Port p -> string_of_int p | Path p -> p in
169+
let protocol =
170+
match protocol with `rfb -> "rfb" | `vt100 -> "vt100" | `rdp -> "rdp"
171+
in
172+
let real_path = Filename.concat "/var/lib/xcp" "websockproxy" in
173+
let sock =
174+
try Some (Fecomms.open_unix_domain_sock_client real_path)
175+
with e ->
176+
debug "Error connecting to wsproxy (%s)" (Printexc.to_string e) ;
177+
Http_svr.headers s (Http.http_501_method_not_implemented ()) ;
178+
None
179+
in
180+
(* Ensure we always close the socket *)
181+
finally
182+
(fun () ->
183+
let upgrade_successful =
184+
Option.map
185+
(fun sock ->
186+
try
187+
let result = (sock, Some (Ws_helpers.upgrade req s)) in
188+
result
189+
with _ -> (sock, None)
190+
)
191+
sock
192+
in
193+
Option.iter
194+
(function
195+
| sock, Some ty ->
196+
let wsprotocol =
197+
match ty with
198+
| Ws_helpers.Hixie76 ->
199+
"hixie76"
200+
| Ws_helpers.Hybi10 ->
201+
"hybi10"
202+
in
203+
let message =
204+
Printf.sprintf "%s:%s:%s" wsprotocol protocol addr
205+
in
206+
let len = String.length message in
207+
ignore (Unixext.send_fd_substring sock message 0 len [] s)
208+
| _, None ->
209+
Http_svr.headers s (Http.http_501_method_not_implemented ())
210+
)
211+
upgrade_successful
212+
)
213+
(fun () -> Option.iter (fun sock -> Unix.close sock) sock)
215214

216215
let default_console_of_vm ~__context ~self =
217216
try

0 commit comments

Comments
 (0)