Skip to content

Commit 61b898e

Browse files
committed
Revert "CA-236863: division by 0 in VGPU-g detection"
1 parent c5c27fd commit 61b898e

File tree

1 file changed

+22
-41
lines changed

1 file changed

+22
-41
lines changed

ocaml/xapi/xapi_vgpu_type.ml

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -467,55 +467,36 @@ module Intel = struct
467467
List.nth device.Pci.Pci_dev.size 2
468468
|> Int64.of_nativeint
469469
in
470-
let rec collect acc = function
471-
| [] -> acc
472-
| Some v :: tail -> collect (v :: acc) tail
473-
| None :: tail -> collect acc tail
474-
in
475-
whitelist
476-
|> List.map
470+
List.map
477471
Identifier.(fun conf ->
478472
let vgpus_per_pgpu =
479473
bar_size /// 1024L /// 1024L
480474
/// conf.identifier.low_gm_sz
481475
--- 1L
482476
in
483-
if vgpus_per_pgpu <= 0L then
484-
begin
485-
warn "Not enough memory for Intel VGPUs. \
486-
If you intend to use them, increase the GPU \
487-
BAR size in the BIOS settings.";
488-
None
489-
end
490-
else
491-
let vgpu_size =
492-
Constants.pgpu_default_size /// vgpus_per_pgpu
493-
in
494-
let internal_config = let open Xapi_globs in
495-
List.concat [
496-
[ vgt_low_gm_sz, Int64.to_string conf.identifier.low_gm_sz
497-
; vgt_high_gm_sz, Int64.to_string conf.identifier.high_gm_sz
498-
; vgt_fence_sz, Int64.to_string conf.identifier.fence_sz
499-
]
500-
; match conf.identifier.monitor_config_file with
477+
let vgpu_size = Constants.pgpu_default_size /// vgpus_per_pgpu in
478+
{
479+
vendor_name;
480+
model_name = conf.model_name;
481+
framebuffer_size = conf.framebufferlength;
482+
max_heads = conf.num_heads;
483+
max_resolution_x = conf.max_x;
484+
max_resolution_y = conf.max_y;
485+
size = vgpu_size;
486+
internal_config = [
487+
Xapi_globs.vgt_low_gm_sz, Int64.to_string conf.identifier.low_gm_sz;
488+
Xapi_globs.vgt_high_gm_sz, Int64.to_string conf.identifier.high_gm_sz;
489+
Xapi_globs.vgt_fence_sz, Int64.to_string conf.identifier.fence_sz;
490+
] @ (
491+
match conf.identifier.monitor_config_file with
501492
| Some monitor_config_file ->
502-
[vgt_monitor_config_file, monitor_config_file]
493+
[Xapi_globs.vgt_monitor_config_file, monitor_config_file]
503494
| None -> []
504-
]
505-
in
506-
Some {
507-
vendor_name;
508-
model_name = conf.model_name;
509-
framebuffer_size = conf.framebufferlength;
510-
max_heads = conf.num_heads;
511-
max_resolution_x = conf.max_x;
512-
max_resolution_y = conf.max_y;
513-
size = vgpu_size;
514-
internal_config = internal_config;
515-
identifier = GVT_g conf.identifier;
516-
experimental = conf.experimental;
517-
})
518-
|> collect []
495+
);
496+
identifier = GVT_g conf.identifier;
497+
experimental = conf.experimental;
498+
})
499+
whitelist
519500

520501
let find_or_create_supported_types ~__context ~pci
521502
~is_system_display_device

0 commit comments

Comments
 (0)