Skip to content

Commit 75f8d27

Browse files
author
Ben Anson
authored
Merge pull request xapi-project#4469 from lippirk/private/bena/UPD-750
[stockholm] backports
2 parents 70b9344 + 8bbde50 commit 75f8d27

File tree

6 files changed

+69
-32
lines changed

6 files changed

+69
-32
lines changed

ocaml/xapi-consts/constants.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ let hvm_boot_policy_bios_order = "BIOS order"
181181
Value is the boot string we send to qemu-dm (eg cd, dc, dcn, etc) *)
182182
let hvm_boot_params_order = "order"
183183

184+
let hvm_default_boot_order = "cd"
185+
184186
(* Key we put in VM.other_config when we upgrade a VM from Zurich/Geneva to Rio *)
185187
let vm_upgrade_time = "upgraded at"
186188

ocaml/xapi/import_xva.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ let make __context rpc session_id srid (vms, vdis) =
7272
other_platform
7373
in
7474
let hVM_boot_policy = if vm.is_hvm then "BIOS order" else "" in
75-
let hVM_boot_params = if vm.is_hvm then [("order", "cd")] else [] in
75+
let hVM_boot_params =
76+
if vm.is_hvm then
77+
let open Constants in
78+
[(hvm_boot_params_order, hvm_default_boot_order)]
79+
else
80+
[]
81+
in
7682
let domain_type = Xapi_vm_helpers.derive_domain_type ~hVM_boot_policy in
7783
let vm_ref =
7884
Client.VM.create ~rpc ~session_id ~name_label:(vm.vm_name ^ " import")

ocaml/xapi/xapi_cluster.ml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
8484
set_ha_cluster_stack ~__context ;
8585
cluster_ref
8686
| Error error ->
87-
D.warn "Error occurred during Cluster.create" ;
87+
D.warn
88+
"Error occurred during Cluster.create. Shutting down cluster daemon" ;
89+
Xapi_clustering.Daemon.disable ~__context ;
8890
handle_error error)
8991

9092
let destroy ~__context ~self =
@@ -119,30 +121,6 @@ let get_network ~__context ~self = get_network_internal ~__context ~self
119121
(** Cluster.pool* functions are convenience wrappers for iterating low-level APIs over a pool.
120122
Concurrency checks are done in the implementation of these calls *)
121123

122-
let pool_create ~__context ~network ~cluster_stack ~token_timeout
123-
~token_timeout_coefficient =
124-
validate_params ~token_timeout ~token_timeout_coefficient ;
125-
let master = Helpers.get_master ~__context in
126-
let slave_hosts = Xapi_pool_helpers.get_slaves_list ~__context in
127-
let pIF, _ = pif_of_host ~__context network master in
128-
let cluster =
129-
Helpers.call_api_functions ~__context (fun rpc session_id ->
130-
Client.Client.Cluster.create ~rpc ~session_id ~pIF ~cluster_stack
131-
~pool_auto_join:true ~token_timeout ~token_timeout_coefficient)
132-
in
133-
List.iter
134-
(fun host ->
135-
(* Cluster.create already created cluster_host on master, so we only iterate through slaves *)
136-
Helpers.call_api_functions ~__context (fun rpc session_id ->
137-
let pif, _ = pif_of_host ~__context network host in
138-
let cluster_host_ref =
139-
Client.Client.Cluster_host.create ~rpc ~session_id ~cluster ~host
140-
~pif
141-
in
142-
D.debug "Created Cluster_host: %s" (Ref.string_of cluster_host_ref)))
143-
slave_hosts ;
144-
cluster
145-
146124
let foreach_cluster_host ~__context ~self
147125
~(fn :
148126
rpc:(Rpc.call -> Rpc.response)
@@ -212,6 +190,42 @@ let pool_destroy ~__context ~self =
212190
Helpers.call_api_functions ~__context (fun rpc session_id ->
213191
Client.Client.Cluster.destroy ~rpc ~session_id ~self)
214192

193+
let pool_create ~__context ~network ~cluster_stack ~token_timeout
194+
~token_timeout_coefficient =
195+
validate_params ~token_timeout ~token_timeout_coefficient ;
196+
let master = Helpers.get_master ~__context in
197+
let slave_hosts = Xapi_pool_helpers.get_slaves_list ~__context in
198+
let pIF, _ = pif_of_host ~__context network master in
199+
let cluster =
200+
Helpers.call_api_functions ~__context (fun rpc session_id ->
201+
Client.Client.Cluster.create ~rpc ~session_id ~pIF ~cluster_stack
202+
~pool_auto_join:true ~token_timeout ~token_timeout_coefficient)
203+
in
204+
try
205+
List.iter
206+
(fun host ->
207+
(* Cluster.create already created cluster_host on master, so we only iterate through slaves *)
208+
Helpers.call_api_functions ~__context (fun rpc session_id ->
209+
let pif, _ = pif_of_host ~__context network host in
210+
let cluster_host_ref =
211+
Client.Client.Cluster_host.create ~rpc ~session_id ~cluster ~host
212+
~pif
213+
in
214+
D.debug "Created Cluster_host: %s" (Ref.string_of cluster_host_ref)))
215+
slave_hosts ;
216+
cluster
217+
with e ->
218+
error "pool_create failed. exception='%s'" (Printexc.to_string e) ;
219+
info "pool_create attempting cleanup of cluster=%s"
220+
(Ref.short_string_of cluster) ;
221+
( try pool_force_destroy ~__context ~self:cluster
222+
with e ->
223+
error "pool_create attempt to clean up cluster=%s failed. ex='%s'"
224+
(Ref.short_string_of cluster)
225+
(Printexc.to_string e)
226+
) ;
227+
raise e
228+
215229
let pool_resync ~__context ~(self : API.ref_Cluster) =
216230
List.iter
217231
(fun host ->

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,13 @@ let force_state_reset_keep_current_operations ~__context ~self ~value:state =
821821
Db.VGPU.set_scheduled_to_be_resident_on ~__context ~self:vgpu
822822
~value:Ref.null ;
823823
Db.VGPU.set_PCI ~__context ~self:vgpu ~value:Ref.null) ;
824-
(* release PCIs *)
825-
List.iter
826-
(fun pci -> Db.PCI.remove_attached_VMs ~__context ~self:pci ~value:self)
827-
(Db.VM.get_attached_PCIs ~__context ~self) ;
824+
Db.VM.get_attached_PCIs ~__context ~self
825+
|> List.iter (fun pci ->
826+
if Db.is_valid_ref __context pci then
827+
Db.PCI.remove_attached_VMs ~__context ~self:pci ~value:self
828+
else
829+
(* XSI-995 pci does not exist, so remove it from the vm record *)
830+
Db.VM.remove_attached_PCIs ~__context ~self ~value:pci) ;
828831
List.iter
829832
(fun pci ->
830833
(* The following should not be necessary if many-to-many relations in the DB

ocaml/xapi/xapi_xenops.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ let find f map default feature =
195195

196196
let string = find (fun x -> x)
197197

198+
let assume_default_if_null_empty map default feature =
199+
match List.assoc_opt feature map with
200+
| None | Some "" ->
201+
D.info "assuming default setting %s=%s" feature default ;
202+
default
203+
| Some x ->
204+
x
205+
198206
let int = find int_of_string
199207

200208
let bool = find (function "1" -> true | "0" -> false | x -> bool_of_string x)
@@ -398,7 +406,12 @@ let builder_of_vm ~__context (vmref, vm) timeoffset pci_passthrough vgpu =
398406
; vnc_ip= None (*None PR-1255*)
399407
; pci_emulations
400408
; pci_passthrough
401-
; boot_order= string vm.API.vM_HVM_boot_params "cd" "order"
409+
; boot_order=
410+
(* XSI-804 avoid boot orders which are the empty string, as qemu
411+
* will silently fail to start the VM *)
412+
(let open Constants in
413+
assume_default_if_null_empty vm.API.vM_HVM_boot_params
414+
hvm_default_boot_order hvm_boot_params_order)
402415
; qemu_disk_cmdline= bool vm.API.vM_platform false "qemu_disk_cmdline"
403416
; qemu_stubdom= false
404417
; (* Obsolete: implementation removed *)

scripts/bugtool-plugin/xapi/stuff.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
<command label="diagnostic_db_stats">@BINDIR@/xe diagnostic-db-stats</command>
77
<command label="diagnostic_net_stats">@BINDIR@/xe diagnostic-net-stats</command>
88
<command label="host_data_source_list">@BINDIR@/xe host-data-source-list host=$(@BINDIR@/xe pool-list params=master --minimal)</command>
9-
<command label="vm_data_source_list">@BINDIR@/xe vm-list power-state=running --minimal | tr , '\n' | xargs --verbose -n 1 -I {} @BINDIR@/xe vm-data-source-list uuid={} 2>&amp;1</command>
109
<command label="sr_data_source_list">@BINDIR@/xe sr-list --minimal | tr , '\n' | xargs --verbose -n 1 -I {} @BINDIR@/xe sr-data-source-list uuid={} 2>&amp;1</command>
1110
</collect>

0 commit comments

Comments
 (0)