Skip to content

Commit 30a56a4

Browse files
simonjbeaumontKonstantina Chremmou
authored andcommitted
CP-17481: Add upgrade logic for new Host.control_domain
This needs to be done before the "hi-level" database upgrade because the code to ensure the VM record for dom0 exists is in the dbsync logic which is called as part of starting the database engine. This all happens before the DB upgrade, and therefore, the dbsync logic tries to create an additional dom0 record because it does not have the Host.control_domain link. This patch adds the Host.control_domain link during the dbsync if it finds a VM with the CONTROL_DOMAIN_UUID from the Xensource_inventory. Signed-off-by: Si Beaumont <[email protected]>
1 parent 54933c4 commit 30a56a4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ocaml/xapi/create_misc.ml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,21 @@ let (+++) = Int64.add
134134
(** It updates existing records if they are found, or else creates new *)
135135
(** records for any records that are missing. *)
136136
let rec ensure_domain_zero_records ~__context ~host (host_info: host_info) : unit =
137+
maybe_upgrade_domain_zero_record ~__context ~host host_info;
137138
let domain_zero_ref = ensure_domain_zero_record ~__context host_info in
138139
ensure_domain_zero_console_record ~__context ~domain_zero_ref;
139140
ensure_domain_zero_guest_metrics_record ~__context ~domain_zero_ref host_info;
140-
ensure_domain_zero_shadow_record ~__context ~domain_zero_ref;
141-
Db.Host.set_control_domain ~__context ~self:host ~value:domain_zero_ref
141+
ensure_domain_zero_shadow_record ~__context ~domain_zero_ref
142+
143+
and maybe_upgrade_domain_zero_record ~__context ~host (host_info: host_info) =
144+
try
145+
let control_domain = Db.VM.get_by_uuid ~__context ~uuid:host_info.dom0_uuid in
146+
if Db.Host.get_control_domain ~__context ~self:host = Ref.null then begin
147+
debug "Setting control domain for host %s to %s"
148+
(Ref.string_of host) (Ref.string_of control_domain);
149+
Db.Host.set_control_domain ~__context ~self:host ~value:control_domain;
150+
end
151+
with Db_exn.Read_missing_uuid(_) -> ()
142152

143153
and ensure_domain_zero_record ~__context (host_info: host_info): [`VM] Ref.t =
144154
let ref_lookup () = Helpers.get_domain_zero ~__context in
@@ -226,6 +236,7 @@ and create_domain_zero_record ~__context ~domain_zero_ref (host_info: host_info)
226236
~hardware_platform_version:0L
227237
~has_vendor_device:false
228238
;
239+
Db.Host.set_control_domain ~__context ~self:localhost ~value:domain_zero_ref;
229240
Xapi_vm_helpers.update_memory_overhead ~__context ~vm:domain_zero_ref
230241

231242
and create_domain_zero_console_record_with_protocol ~__context ~domain_zero_ref ~dom0_console_protocol =

0 commit comments

Comments
 (0)