1717
1818let 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
3026let 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
15443type 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-
17862let list_services () =
17963 with_lock service_to_queue_m (fun () ->
18064 Hashtbl. fold (fun service _ acc -> service :: acc) service_to_queue []
0 commit comments