Skip to content

Commit 8bbde50

Browse files
author
Ben Anson
committed
XSI-804 ensure HVM boot params consistent
When the order parameter is the empty string, assume the user really wants "cd" Signed-off-by: Ben Anson <[email protected]> (cherry picked from commit 57e6f8b) Signed-off-by: Ben Anson <[email protected]>
1 parent 856f0f3 commit 8bbde50

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
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_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 *)

0 commit comments

Comments
 (0)