Skip to content

Commit bff6184

Browse files
author
Konstantina Chremmou
committed
CP-17481: expose the control domain id on the host so it is distinguishable from other control domains
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
1 parent 83169b4 commit bff6184

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

ocaml/client_records/records.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ let host_record rpc session_id host =
10961096
make_field ~name:"virtual-hardware-platform-versions"
10971097
~get:(fun () -> String.concat "; " (List.map Int64.to_string (x ()).API.host_virtual_hardware_platform_versions))
10981098
~get_set:(fun () -> List.map Int64.to_string (x ()).API.host_virtual_hardware_platform_versions) ();
1099+
make_field ~name:"control-domain-uuid" ~get:(fun () -> get_uuid_from_ref (x ()).API.host_control_domain) ();
10991100
]}
11001101

11011102
let vdi_record rpc session_id vdi =

ocaml/idl/datamodel.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4683,6 +4683,7 @@ let host =
46834683
field ~qualifier:RW ~in_product_since:rel_tampa ~default_value:(Some (VMap [])) ~ty:(Map (String, String)) "guest_VCPUs_params" "VCPUs params to apply to all resident guests";
46844684
field ~qualifier:RW ~in_product_since:rel_cream ~default_value:(Some (VEnum "enabled")) ~ty:host_display "display" "indicates whether the host is configured to output its console to a physical display device";
46854685
field ~qualifier:DynamicRO ~in_product_since:rel_cream ~default_value:(Some (VSet [VInt 0L])) ~ty:(Set (Int)) "virtual_hardware_platform_versions" "The set of versions of the virtual hardware platform that the host can offer to its guests";
4686+
field ~qualifier:DynamicRO ~default_value:(Some (VRef (Ref.string_of Ref.null))) ~in_product_since:rel_dundee_plus ~ty:(Ref _vm) "control_domain" "The control domain (domain 0)";
46864687
])
46874688
()
46884689

ocaml/xapi/create_misc.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ let (+++) = Int64.add
133133
(** This function makes sure there is exactly one record of each type. *)
134134
(** It updates existing records if they are found, or else creates new *)
135135
(** records for any records that are missing. *)
136-
let rec ensure_domain_zero_records ~__context (host_info: host_info) : unit =
136+
let rec ensure_domain_zero_records ~__context ~host (host_info: host_info) : unit =
137137
let domain_zero_ref = ensure_domain_zero_record ~__context host_info in
138138
ensure_domain_zero_console_record ~__context ~domain_zero_ref;
139139
ensure_domain_zero_guest_metrics_record ~__context ~domain_zero_ref host_info;
140-
ensure_domain_zero_shadow_record ~__context ~domain_zero_ref
140+
ensure_domain_zero_shadow_record ~__context ~domain_zero_ref;
141+
Db.Host.set_control_domain ~__context ~self:host ~value:domain_zero_ref
141142

142143
and ensure_domain_zero_record ~__context (host_info: host_info): [`VM] Ref.t =
143144
let ref_lookup () = Helpers.get_domain_zero ~__context in

ocaml/xapi/create_misc.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type host_info = {
3232
val read_dom0_memory_usage : unit -> int64 option
3333
val read_localhost_info : unit -> host_info
3434

35-
val ensure_domain_zero_records : __context:Context.t -> host_info -> unit
35+
val ensure_domain_zero_records : __context:Context.t -> host:[`host] Ref.t -> host_info -> unit
3636

3737
val create_root_user : __context:Context.t -> unit
3838

ocaml/xapi/dbsync_slave.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ let update_env __context sync_keys =
280280
Create_misc.create_host_cpu ~__context;
281281
);
282282

283+
let localhost = Helpers.get_localhost ~__context in
284+
283285
switched_sync Xapi_globs.sync_create_domain_zero (fun () ->
284286
debug "creating domain 0";
285-
Create_misc.ensure_domain_zero_records ~__context info;
287+
Create_misc.ensure_domain_zero_records ~__context ~host:localhost info;
286288
);
287289

288-
let localhost = Helpers.get_localhost ~__context in
289-
290290
switched_sync Xapi_globs.sync_crashdump_resynchronise (fun () ->
291291
debug "resynchronising host crashdumps";
292292
Xapi_host_crashdump.resynchronise ~__context ~host:localhost;

ocaml/xapi/xapi_host.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ let create ~__context ~uuid ~name_label ~name_description ~hostname ~address ~ex
617617
~guest_VCPUs_params:[]
618618
~display:`enabled
619619
~virtual_hardware_platform_versions:(if host_is_us then Xapi_globs.host_virtual_hardware_platform_versions else [0L])
620+
~control_domain:Ref.null
620621
;
621622
(* If the host we're creating is us, make sure its set to live *)
622623
Db.Host_metrics.set_last_updated ~__context ~self:metrics ~value:(Date.of_float (Unix.gettimeofday ()));

0 commit comments

Comments
 (0)