Skip to content

Commit 4851cc6

Browse files
authored
Merge pull request xapi-project#3728 from edwintorok/uefi-merge
Uefi merge
2 parents d0990cf + 6609e66 commit 4851cc6

19 files changed

+218
-24
lines changed

ocaml/doc/vm-lifecycle.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ When using HVM booting, `HVM_boot_policy` and `HVM_boot_params` specify the boot
4444
handling. Only one policy is currently defined, "BIOS order". In this case,
4545
`HVM_boot_params` should contain one key-value pair "order" = "N" where N is the
4646
string that will be passed to QEMU.
47+
Optionally `HVM_boot_params` can contain another key-value pair "firmware"
48+
with values "bios" or "uefi" (default is "bios" if absent).
49+
By default Secure Boot is not enabled, it can be enabled when "uefi" is enabled by setting
50+
`VM.platform["secureboot"]` to true.

ocaml/idl/datamodel_common.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open Datamodel_roles
88
When introducing a new release, bump the schema minor version to the next hundred
99
to leave a gap for potential hotfixes needing to increment the schema version.*)
1010
let schema_major_vsn = 5
11-
let schema_minor_vsn = 203
11+
let schema_minor_vsn = 300
1212

1313
(* Historical schema versions just in case this is useful later *)
1414
let rio_schema_major_vsn = 5
@@ -86,6 +86,9 @@ let jura_release_schema_minor_vsn = 134
8686
let kolkata_release_schema_major_vsn = 5
8787
let kolkata_release_schema_minor_vsn = 142
8888

89+
let lima_release_schema_major_vsn = 5
90+
let lima_release_schema_minor_vsn = 203
91+
8992
(* List of tech-preview releases. Fields in these releases are not guaranteed to be retained when
9093
* upgrading to a full release. *)
9194
let tech_preview_releases = [

ocaml/idl/datamodel_types.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ let rel_inverness = "inverness"
6060
let rel_jura = "jura"
6161
let rel_kolkata = "kolkata"
6262
let rel_lima = "lima"
63+
let rel_naples = "naples"
6364

6465
type api_release = {
6566
code_name: string option;
@@ -210,6 +211,11 @@ let release_order_full = [{
210211
version_major = 2;
211212
version_minor = 11;
212213
branding = "XenServer 7.6";
214+
}; {
215+
code_name = Some rel_naples;
216+
version_major = 2;
217+
version_minor = 12;
218+
branding = "Unreleased"
213219
};
214220
]
215221
(* When you add a new release, use the version number of the latest release,

ocaml/idl/datamodel_vm.ml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,31 @@ let power_behaviour =
887887
~allowed_roles:_R_VM_ADMIN
888888
()
889889

890+
let remove_from_NVRAM = call ~flags:[`Session]
891+
~name:"remove_from_NVRAM"
892+
~lifecycle:[Prototyped, rel_naples, ""]
893+
~params:[Ref _vm, "self", "The VM";
894+
String, "key", "The key"]
895+
~allowed_roles:_R_VM_ADMIN
896+
()
897+
898+
let add_to_NVRAM = call ~flags:[`Session]
899+
~name:"add_to_NVRAM"
900+
~lifecycle:[Prototyped, rel_naples, ""]
901+
~params:[Ref _vm, "self", "The VM";
902+
String, "key", "The key";
903+
String, "value", "The value"]
904+
~allowed_roles:_R_VM_ADMIN
905+
()
906+
907+
let set_NVRAM = call ~flags:[`Session]
908+
~name:"set_NVRAM"
909+
~lifecycle:[Prototyped, rel_naples, ""]
910+
~params:[Ref _vm, "self", "The VM";
911+
Map(String, String), "value", "The value"]
912+
~allowed_roles:_R_VM_ADMIN
913+
()
914+
890915
let send_sysrq = call
891916
~name:"send_sysrq"
892917
~in_product_since:rel_rio
@@ -1164,6 +1189,7 @@ let power_behaviour =
11641189
"changing_shadow_memory_live", "Changing the shadow memory for a running VM.";
11651190
"changing_VCPUs", "Changing VCPU settings for a halted VM.";
11661191
"changing_VCPUs_live", "Changing VCPU settings for a running VM.";
1192+
"changing_NVRAM", "Changing NVRAM for a halted VM.";
11671193
"assert_operation_valid", "";
11681194
"data_source_op", "Add, remove, query or list data sources";
11691195
"update_allowed_operations", "";
@@ -1223,6 +1249,15 @@ let set_HVM_boot_policy = call ~flags:[`Session]
12231249
~allowed_roles:_R_VM_ADMIN
12241250
()
12251251

1252+
let set_NVRAM_EFI_variables = call ~flags:[`Session]
1253+
~name:"set_NVRAM_EFI_variables"
1254+
~lifecycle:[Prototyped, rel_naples, ""]
1255+
~params:[Ref _vm, "self", "The VM";
1256+
String, "value", "The value"]
1257+
~hide_from_docs:true
1258+
~allowed_roles:_R_LOCAL_ROOT_ONLY
1259+
()
1260+
12261261
(** VM (or 'guest') configuration: *)
12271262
let t =
12281263
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303 ~internal_deprecated_since:None ~persist:PersistEverything ~gen_constructor_destructor:true ~name:_vm ~descr:"A virtual machine (or 'guest')."
@@ -1243,6 +1278,9 @@ let set_HVM_boot_policy = call ~flags:[`Session]
12431278
pool_migrate; pool_migrate_complete;
12441279
set_vcpus_number_live;
12451280
add_to_VCPUs_params_live;
1281+
set_NVRAM;
1282+
add_to_NVRAM;
1283+
remove_from_NVRAM;
12461284
set_ha_restart_priority; (* updates the allowed-operations of the VM *)
12471285
set_ha_always_run; (* updates the allowed-operations of the VM *)
12481286
compute_memory_overhead;
@@ -1301,6 +1339,7 @@ let set_HVM_boot_policy = call ~flags:[`Session]
13011339
set_actions_after_crash;
13021340
set_domain_type;
13031341
set_HVM_boot_policy;
1342+
set_NVRAM_EFI_variables;
13041343
]
13051344
~contents:
13061345
([ uid _vm;
@@ -1400,6 +1439,10 @@ let set_HVM_boot_policy = call ~flags:[`Session]
14001439
Published, rel_kolkata, "The field is now valid"
14011440
]
14021441
~default_value:(Some (VEnum "unspecified")) "domain_type" "The type of domain that will be created when the VM is started";
1442+
1443+
field ~lifecycle:[Prototyped, rel_naples, ""] ~qualifier:StaticRO ~ty:(Map(String, String)) "NVRAM"
1444+
~default_value:(Some (VMap []))
1445+
"initial value for guest NVRAM (containing UEFI variables, etc). Cannot be changed while the VM is running";
14031446
])
14041447
()
14051448

ocaml/tests/test_common.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ let make_vm ~__context ?(name_label="name_label") ?(name_description="descriptio
9494
?(shutdown_delay=0L) ?(order=0L) ?(suspend_SR=Ref.null) ?(version=0L)
9595
?(generation_id="0:0") ?(hardware_platform_version=0L)
9696
?(has_vendor_device=false) ?(has_vendor_device=false) ?(reference_label="")
97-
?(domain_type=`hvm) () =
97+
?(domain_type=`hvm) ?(nVRAM=[]) () =
9898
Xapi_vm.create ~__context ~name_label ~name_description ~user_version ~is_a_template
9999
~affinity ~memory_target ~memory_static_max ~memory_dynamic_max ~memory_dynamic_min
100100
~memory_static_min ~vCPUs_params ~vCPUs_max ~vCPUs_at_startup ~actions_after_shutdown
101101
~actions_after_reboot ~actions_after_crash ~pV_bootloader ~pV_kernel ~pV_ramdisk
102102
~pV_args ~pV_bootloader_args ~pV_legacy_args ~hVM_boot_policy ~hVM_boot_params
103-
~hVM_shadow_multiplier ~platform ~pCI_bus ~other_config ~xenstore_data ~recommendations
103+
~hVM_shadow_multiplier ~platform ~nVRAM ~pCI_bus ~other_config ~xenstore_data ~recommendations
104104
~ha_always_run ~ha_restart_priority ~tags ~blocked_operations ~protection_policy
105105
~is_snapshot_from_vmpp ~appliance ~start_delay ~shutdown_delay ~order ~suspend_SR
106106
~snapshot_schedule ~is_vmss_snapshot

ocaml/tests/test_platformdata.ml

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,29 @@ open Stdext
1616
open OUnit
1717
open Test_highlevel
1818

19+
let firmware_type_printer v =
20+
v |> Rpcmarshal.marshal Xenops_types.Vm.typ_of_firmware_type
21+
|> Jsonrpc.to_string
22+
23+
let uefi = Xenops_types.Vm.Uefi Xenops_types.Nvram_uefi_variables.default_t
24+
1925
module SanityCheck = Generic.Make(struct
2026
module Io = struct
21-
type input_t = ((string * string) list * bool * int64 * int64 * [ `hvm | `pv | `pv_in_pvh ])
27+
type input_t = ((string * string) list * Xenops_types.Vm.firmware_type option * bool * int64 * int64 * [ `hvm | `pv | `pv_in_pvh ])
2228
type output_t = (exn, (string * string) list) Either.t
2329

24-
let string_of_input_t (platformdata, filter, vcpu_max, vcpu_startup, domain_type) =
25-
Printf.sprintf "(platformdata = %s, filter_out_unknowns = %b, vcpu_max = %Ld,
30+
let string_of_input_t (platformdata, firmware, filter, vcpu_max, vcpu_startup, domain_type) =
31+
Printf.sprintf "(platformdata = %s, firmware = %s, filter_out_unknowns = %b, vcpu_max = %Ld,
2632
vcpu_at_startup = %Ld, domain_type = %s)"
2733
(platformdata |> Test_printers.(assoc_list string string))
34+
(firmware |> Test_printers.option firmware_type_printer)
2835
(filter) (vcpu_max) (vcpu_startup) (Record_util.domain_type_to_string domain_type)
2936

3037
let string_of_output_t = Test_printers.(either exn (assoc_list string string))
3138
end
3239

33-
let transform (platformdata, filter_out_unknowns, vcpu_max, vcpu_at_startup, domain_type) =
34-
try Either.Right (Vm_platform.sanity_check ~platformdata ~vcpu_max
40+
let transform (platformdata, firmware, filter_out_unknowns, vcpu_max, vcpu_at_startup, domain_type) =
41+
try Either.Right (Vm_platform.sanity_check ~platformdata ?firmware ~vcpu_max
3542
~vcpu_at_startup ~domain_type ~filter_out_unknowns)
3643
with e -> Either.Left e
3744

@@ -40,33 +47,38 @@ module SanityCheck = Generic.Make(struct
4047
"usb", "true";
4148
"usb_tablet", "true";
4249
] in
50+
let make_firmware_ok dm firmware =
51+
((["device-model", dm], firmware, false, 0L, 0L, `hvm),
52+
Either.Right (usb_defaults @ ["device-model", dm]))
53+
in
54+
let open Xenops_interface.Vm in
4355
[
4456
(* Check that we can filter out unknown platform flags. *)
4557
(([
4658
"nonsense", "abc";
4759
"pae", "true";
4860
"whatever", "def";
4961
"viridian", "true";
50-
], true, 0L, 0L, `pv),
62+
], None, true, 0L, 0L, `pv),
5163
Either.Right (usb_defaults @
5264
[
5365
"pae", "true";
5466
"viridian", "true";
5567
]));
5668
(* Check that usb and usb_tablet are turned on by default. *)
57-
(([], false, 0L, 0L, `pv),
69+
(([], None, false, 0L, 0L, `pv),
5870
Either.Right (usb_defaults));
5971
(* Check that an invalid tsc_mode gets filtered out. *)
60-
((["tsc_mode", "17";], false, 0L, 0L, `pv),
72+
((["tsc_mode", "17";], None, false, 0L, 0L, `pv),
6173
Either.right (usb_defaults));
6274
(* Check that an invalid parallel port gets filtered out. *)
63-
((["parallel", "/dev/random"], false, 0L, 0L, `pv),
75+
((["parallel", "/dev/random"], None, false, 0L, 0L, `pv),
6476
Either.Right (usb_defaults));
6577
(* Check that we can't set usb_tablet to true if usb is false. *)
6678
(([
6779
"usb", "false";
6880
"usb_tablet", "true";
69-
], false, 0L, 0L, `pv),
81+
], None, false, 0L, 0L, `pv),
7082
Either.Right ([
7183
"usb", "false";
7284
"usb_tablet", "false";
@@ -75,13 +87,13 @@ module SanityCheck = Generic.Make(struct
7587
(([
7688
"usb", "false";
7789
"usb_tablet", "false";
78-
], false, 0L, 0L, `pv),
90+
], None, false, 0L, 0L, `pv),
7991
Either.Right ([
8092
"usb", "false";
8193
"usb_tablet", "false";
8294
]));
8395
(* Check that we can disable the parallel port. *)
84-
((["parallel", "none"], false, 0L, 0L, `pv),
96+
((["parallel", "none"], None, false, 0L, 0L, `pv),
8597
Either.Right (usb_defaults @
8698
["parallel", "none"]));
8799
(* Check that a set of valid fields is unchanged (apart from
@@ -94,7 +106,7 @@ module SanityCheck = Generic.Make(struct
94106
"tsc_mode", "2";
95107
"viridian", "true";
96108
"usb", "true";
97-
], false, 0L, 0L, `pv),
109+
], None, false, 0L, 0L, `pv),
98110
Either.Right ([
99111
"usb", "true";
100112
"usb_tablet", "false";
@@ -109,7 +121,7 @@ module SanityCheck = Generic.Make(struct
109121
"pae", "true";
110122
"parallel", "/dev/parport0";
111123
"tsc_mode", "blah";
112-
], false, 0L, 0L, `pv),
124+
], None, false, 0L, 0L, `pv),
113125
Either.Right (usb_defaults @
114126
[
115127
"pae", "true";
@@ -118,33 +130,48 @@ module SanityCheck = Generic.Make(struct
118130
(* Check VCPUs configuration - hvm success scenario*)
119131
(([
120132
"cores-per-socket", "3";
121-
], false, 6L, 6L, `hvm),
133+
], None, false, 6L, 6L, `hvm),
122134
Either.Right (usb_defaults @
123135
[
124136
"cores-per-socket", "3";
125137
]));
126138
(* Check VCPUs configuration - pvm success scenario*)
127139
(([
128140
"cores-per-socket", "3";
129-
], false, 0L, 0L, `pv),
141+
], None, false, 0L, 0L, `pv),
130142
Either.Right (usb_defaults @
131143
[
132144
"cores-per-socket", "3";
133145
]));
134146
(* Check VCPUs configuration - hvm failure scenario*)
135147
(([
136148
"cores-per-socket", "4";
137-
], false, 6L, 6L, `hvm),
149+
], None, false, 6L, 6L, `hvm),
138150
Either.Left (Api_errors.Server_error(Api_errors.invalid_value,
139151
["platform:cores-per-socket";
140152
"VCPUs_max must be a multiple of this field"])));
141153
(* Check VCPUs configuration - hvm failure scenario*)
142154
(([
143155
"cores-per-socket", "abc";
144-
], false, 6L, 5L, `hvm),
156+
], None, false, 6L, 5L, `hvm),
145157
Either.Left(Api_errors.Server_error(Api_errors.invalid_value,
146158
["platform:cores-per-socket";
147159
"value = abc is not a valid int"])));
160+
161+
(* Check BIOS configuration - qemu trad *)
162+
make_firmware_ok "qemu-trad" (Some Bios);
163+
make_firmware_ok "qemu-upstream" (Some Bios);
164+
make_firmware_ok "qemu-upstream-compat" (Some Bios);
165+
166+
(* Check UEFI configuration - qemu upstream *)
167+
make_firmware_ok "qemu-upstream" (Some uefi);
168+
make_firmware_ok "qemu-upstream-compat" (Some uefi);
169+
170+
(* Check UEFI configuration - qemu-trad incompatibility *)
171+
(([ "device-model", "qemu-trad" ], Some uefi, false, 0L, 0L, `hvm),
172+
Either.Left(Api_errors.Server_error(Api_errors.invalid_value,
173+
["platform:device-model";
174+
"UEFI boot is not supported with qemu-trad"])));
148175
]
149176
end)
150177

ocaml/tests/test_vm_check_operation_error.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ let all_vm_operations =
1111
; `changing_shadow_memory
1212
; `changing_shadow_memory_live
1313
; `changing_static_range
14+
; `changing_NVRAM
1415
; `checkpoint
1516
; `clean_reboot
1617
; `clean_shutdown

ocaml/xapi/cli_operations.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@ let vm_create printer rpc session_id params =
16941694
~hardware_platform_version:0L
16951695
~has_vendor_device:false ~reference_label:""
16961696
~domain_type:`unspecified
1697+
~nVRAM:[]
16971698
in
16981699
let uuid=Client.VM.get_uuid rpc session_id vm in
16991700
printer (Cli_printer.PList [uuid])

ocaml/xapi/create_misc.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ and create_domain_zero_record ~__context ~domain_zero_ref (host_info: host_info)
276276
~has_vendor_device:false
277277
~requires_reboot:false ~reference_label:""
278278
~domain_type:Xapi_globs.domain_zero_domain_type
279+
~nVRAM:[]
279280
;
280281
ensure_domain_zero_metrics_record ~__context ~domain_zero_ref host_info;
281282
Db.Host.set_control_domain ~__context ~self:localhost ~value:domain_zero_ref;

ocaml/xapi/import_xva.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ let make __context rpc session_id srid (vms, vdis) =
9999
~generation_id:""
100100
~hardware_platform_version:0L
101101
~has_vendor_device:false ~reference_label:""
102+
~nVRAM:[]
102103
in
103104

104105
TaskHelper.operate_on_db_task ~__context

0 commit comments

Comments
 (0)