Skip to content

Commit a9dfb18

Browse files
author
David Scott
committed
If we aren't running xen, then we don't have I/O virtualisation
Signed-off-by: David Scott <[email protected]>
1 parent 901a644 commit a9dfb18

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

ocaml/xapi/create_misc.ml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -494,18 +494,23 @@ let create_chipset_info ~__context =
494494
let host = Helpers.get_localhost ~__context in
495495
let current_info = Db.Host.get_chipset_info ~__context ~self:host in
496496
let iommu =
497-
let open Xenops_client in
498-
let dbg = Context.string_of_task __context in
499-
let xen_dmesg = Client.HOST.get_console_data dbg in
500-
if String.has_substr xen_dmesg "I/O virtualisation enabled" then
501-
"true"
502-
else if String.has_substr xen_dmesg "I/O virtualisation disabled" then
503-
"false"
504-
else if List.mem_assoc "iommu" current_info then
505-
List.assoc "iommu" current_info
506-
else
507-
"false"
508-
in
497+
try
498+
let xc = Xenctrl.interface_open () in
499+
Xenctrl.interface_close xc;
500+
let open Xenops_client in
501+
let dbg = Context.string_of_task __context in
502+
let xen_dmesg = Client.HOST.get_console_data dbg in
503+
if String.has_substr xen_dmesg "I/O virtualisation enabled" then
504+
"true"
505+
else if String.has_substr xen_dmesg "I/O virtualisation disabled" then
506+
"false"
507+
else if List.mem_assoc "iommu" current_info then
508+
List.assoc "iommu" current_info
509+
else
510+
"false"
511+
with _ ->
512+
warn "Not running on xen; assuming I/O vierualization disabled";
513+
"false" in
509514
let info = ["iommu", iommu] in
510515
Db.Host.set_chipset_info ~__context ~self:host ~value:info
511516

0 commit comments

Comments
 (0)