Skip to content

Commit 9a34ddc

Browse files
authored
Do not recognise {VM;PBD}.other_config:storage_driver_domain (#7033)
This code is either obsolete or should use a first-class field (TBD). This is part of XSA-489 / CVE-2026-23561.
2 parents a2b1b5c + 65714e2 commit 9a34ddc

2 files changed

Lines changed: 13 additions & 143 deletions

File tree

ocaml/xapi/system_domains.ml

Lines changed: 13 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
let with_lock = Xapi_stdext_threads.Threadext.Mutex.execute
1919

20-
module D = Debug.Make (struct let name = "system_domains" end)
21-
22-
open D
23-
2420
(** If a VM is a system domain then xapi will perform lifecycle operations on demand,
2521
and will allow this VM to start even if a host is disabled. *)
2622

@@ -30,126 +26,19 @@ let is_system_domain snapshot = snapshot.API.vM_is_control_domain
3026
let get_is_system_domain ~__context ~self =
3127
is_system_domain (Db.VM.get_record ~__context ~self)
3228

33-
(* Notes on other_config keys: in the future these should become first-class fields.
34-
For now note that although two threads may attempt to update these keys in parallel,
35-
order shouldn't matter because everyone will always update them to the same value.
36-
It's therefore safe to throw away exceptions. *)
37-
38-
(** If a VM is a driver domain then it hosts backends for either disk or network
39-
devices. We link PBD.other_config:storage_driver_domain_key to
40-
VM.other_config:storage_driver_domain_key and we ensure the VM is marked as
41-
a system domain. *)
42-
let storage_driver_domain_key = "storage_driver_domain"
43-
44-
let pbd_set_storage_driver_domain ~__context ~self ~value =
45-
Helpers.log_exn_continue
46-
(Printf.sprintf "pbd_set_storage_driver_domain self = %s"
47-
(Ref.string_of self)
48-
)
49-
(fun () ->
50-
Db.PBD.remove_from_other_config ~__context ~self
51-
~key:storage_driver_domain_key ;
52-
Db.PBD.add_to_other_config ~__context ~self ~key:storage_driver_domain_key
53-
~value
54-
)
55-
()
56-
57-
let vm_set_storage_driver_domain ~__context ~self ~value =
58-
Helpers.log_exn_continue
59-
(Printf.sprintf "vm_set_storage_driver_domain self = %s" (Ref.string_of self)
60-
)
61-
(fun () ->
62-
Db.VM.remove_from_other_config ~__context ~self
63-
~key:storage_driver_domain_key ;
64-
Db.VM.add_to_other_config ~__context ~self ~key:storage_driver_domain_key
65-
~value
66-
)
67-
()
68-
69-
let record_pbd_storage_driver_domain ~__context ~pbd ~domain =
70-
(* set_is_system_domain ~__context ~self:domain ~value:"true" ; *)
71-
pbd_set_storage_driver_domain ~__context ~self:pbd
72-
~value:(Ref.string_of domain) ;
73-
vm_set_storage_driver_domain ~__context ~self:domain ~value:(Ref.string_of pbd)
74-
75-
let pbd_of_vm ~__context ~vm =
76-
let other_config = Db.VM.get_other_config ~__context ~self:vm in
77-
if List.mem_assoc storage_driver_domain_key other_config then
78-
Some (Ref.of_string (List.assoc storage_driver_domain_key other_config))
79-
else
80-
None
81-
82-
let storage_driver_domain_of_pbd ~__context ~pbd =
83-
let other_config = Db.PBD.get_other_config ~__context ~self:pbd in
84-
let dom0 = Helpers.get_domain_zero ~__context in
85-
if List.mem_assoc storage_driver_domain_key other_config then (
86-
let v = List.assoc storage_driver_domain_key other_config in
87-
if Db.is_valid_ref __context (Ref.of_string v) then
88-
Ref.of_string v
89-
else
90-
try Db.VM.get_by_uuid ~__context ~uuid:v
91-
with _ ->
92-
error "PBD %s has invalid %s key: falling back to dom0"
93-
(Ref.string_of pbd) storage_driver_domain_key ;
94-
dom0
95-
) else
96-
dom0
97-
98-
let storage_driver_domain_of_pbd ~__context ~pbd =
99-
let domain = storage_driver_domain_of_pbd ~__context ~pbd in
100-
(* set_is_system_domain ~__context ~self:domain ~value:"true" ; *)
101-
pbd_set_storage_driver_domain ~__context ~self:pbd
102-
~value:(Ref.string_of domain) ;
103-
vm_set_storage_driver_domain ~__context ~self:domain ~value:(Ref.string_of pbd) ;
104-
domain
105-
106-
let storage_driver_domain_of_vbd ~__context ~vbd =
107-
let dom0 = Helpers.get_domain_zero ~__context in
108-
let vdi = Db.VBD.get_VDI ~__context ~self:vbd in
109-
if Db.is_valid_ref __context vdi then
110-
let sr = Db.VDI.get_SR ~__context ~self:vdi in
111-
let sr_pbds = Db.SR.get_PBDs ~__context ~self:sr in
112-
let my_pbds = List.map fst (Helpers.get_my_pbds __context) in
113-
match Xapi_stdext_std.Listext.List.intersect sr_pbds my_pbds with
114-
| pbd :: _ ->
115-
storage_driver_domain_of_pbd ~__context ~pbd
116-
| _ ->
117-
dom0
118-
else
119-
dom0
120-
121-
let storage_driver_domain_of_sr_type ~__context ~_type =
122-
let dom0 = Helpers.get_domain_zero ~__context in
123-
dom0
124-
125-
let is_in_use ~__context ~self =
126-
let other_config = Db.VM.get_other_config ~__context ~self in
127-
List.mem_assoc storage_driver_domain_key other_config
128-
&&
129-
let pbd = Ref.of_string (List.assoc storage_driver_domain_key other_config) in
130-
if Db.is_valid_ref __context pbd then
131-
Db.PBD.get_currently_attached ~__context ~self:pbd
132-
else
133-
false
134-
135-
let queryable ~__context transport () =
136-
let open Xmlrpc_client in
137-
let tracing = Context.set_client_span __context in
138-
let http = xmlrpc ~version:"1.0" "/" in
139-
let http = Helpers.TraceHelper.inject_span_into_req tracing http in
140-
let rpc =
141-
XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"remote_smapiv2" ~transport ~http
142-
in
143-
let listMethods = Rpc.call "system.listMethods" [] in
144-
try
145-
let _ = rpc listMethods in
146-
info "XMLRPC service found at %s" (string_of_transport transport) ;
147-
true
148-
with e ->
149-
debug "Temporary failure querying storage service on %s: %s"
150-
(string_of_transport transport)
151-
(Printexc.to_string e) ;
152-
false
29+
(* NOTE: the storage domain functionality used to be based on
30+
other-config:storage_driver_domain, which has been dropped *)
31+
32+
let pbd_of_vm ~__context:_ ~vm:_ = None
33+
34+
let storage_driver_domain_of_pbd ~__context ~pbd:_ =
35+
Helpers.get_domain_zero ~__context
36+
37+
let storage_driver_domain_of_vbd ~__context ~vbd:_ =
38+
Helpers.get_domain_zero ~__context
39+
40+
let storage_driver_domain_of_sr_type ~__context ~_type:_ =
41+
Helpers.get_domain_zero ~__context
15342

15443
type service = {uuid: string; ty: string; instance: string; url: string}
15544
[@@deriving rpc]
@@ -170,11 +59,6 @@ let unregister_service service =
17059
Hashtbl.remove service_to_queue service
17160
)
17261

173-
let get_service service =
174-
with_lock service_to_queue_m (fun () ->
175-
Hashtbl.find_opt service_to_queue service
176-
)
177-
17862
let list_services () =
17963
with_lock service_to_queue_m (fun () ->
18064
Hashtbl.fold (fun service _ acc -> service :: acc) service_to_queue []

ocaml/xapi/system_domains.mli

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ val storage_driver_domain_of_vbd :
3131
(** [storage_driver_domain_of_vbd __context pbd] returns the VM which is hosting
3232
the storage backends for [vbd] on this host *)
3333

34-
val record_pbd_storage_driver_domain :
35-
__context:Context.t -> pbd:API.ref_PBD -> domain:API.ref_VM -> unit
36-
(** [record_pbd_storage_driver_domain __context pbd domain] persists [domain]
37-
as the driver domain for [pbd]. *)
38-
3934
val storage_driver_domain_of_sr_type :
4035
__context:Context.t -> _type:string -> API.ref_VM
4136
(** [storage_driver_domain_of_sr_type __context _type] returns the default VM which is hosting
@@ -45,12 +40,6 @@ val pbd_of_vm : __context:Context.t -> vm:API.ref_VM -> API.ref_PBD option
4540
(** [pbd_of_vm __context vm] returns (Some pbd) if [vm] is a driver domain
4641
for [pbd] and None otherwise. *)
4742

48-
val is_in_use : __context:Context.t -> self:API.ref_VM -> bool
49-
(** [is_in_use __context self] returns true if [self] is in use as a system domain *)
50-
51-
val queryable : __context:Context.t -> Xmlrpc_client.transport -> unit -> bool
52-
(** [queryable ip port ()] returns true if [ip]:[port] responsds to an XMLRPC query *)
53-
5443
(** One of many service running in a driver domain *)
5544
type service = {uuid: string; ty: string; instance: string; url: string}
5645

@@ -70,8 +59,5 @@ val register_service : service -> string -> unit
7059
val unregister_service : service -> unit
7160
(** [unregister_service service] forgets service [service] *)
7261

73-
val get_service : service -> string option
74-
(** [get_service_address service] returns the queue_name associated with [service] or None *)
75-
7662
val list_services : unit -> services
7763
(** [list_services ()] returns all the registered services *)

0 commit comments

Comments
 (0)