Skip to content

Commit 7dd54cb

Browse files
Merge pull request xapi-project#34 from koushikcgit/CA-141366
[HFX-1302] CA 141366: Xenopsd tries to build domain when it already knows it will fail (not enough memory)
2 parents 09854f4 + 1dc7157 commit 7dd54cb

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

ocaml/xenops/domain.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ let filtered_xsdata =
6969
List.filter allowed
7070

7171
exception Restore_signature_mismatch
72+
exception Not_enough_memory of int64
7273
exception Domain_build_failed
7374
exception Domain_restore_failed
7475
exception Domain_restore_truncated_hvmstate
@@ -465,7 +466,11 @@ let build_pre ~xc ~xs ~vcpus ~xen_max_mib ~shadow_mib ~required_host_free_mib do
465466
let uuid = get_uuid ~xc domid in
466467
debug "VM = %s; domid = %d; waiting for %Ld MiB of free host memory" (Uuid.to_string uuid) domid required_host_free_mib;
467468
(* CA-39743: Wait, if necessary, for the Xen scrubber to catch up. *)
468-
let (_: bool) = wait_xen_free_mem ~xc (Memory.kib_of_mib required_host_free_mib) in
469+
if not(wait_xen_free_mem ~xc (Memory.kib_of_mib required_host_free_mib)) then begin
470+
error "VM = %s; domid = %d; Failed waiting for Xen to free %Ld MiB"
471+
(Uuid.to_string uuid) domid required_host_free_mib;
472+
raise (Not_enough_memory (Memory.bytes_of_mib required_host_free_mib))
473+
end;
469474

470475
let shadow_mib = Int64.to_int shadow_mib in
471476

ocaml/xenops/domain.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ open Device_common
1818
type domid = Xenctrl.domid
1919

2020
exception Restore_signature_mismatch
21+
exception Not_enough_memory of int64
2122
exception Domain_build_failed
2223
exception Domain_restore_failed
2324
exception Xenguest_protocol_failure of string (* internal protocol failure *)

ocaml/xenops/xenops_server_xen.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,11 @@ module VM = struct
10791079
let m = Printf.sprintf "VM = %s; domid = %d; Bootloader.Error_from_bootloader %s" vm.Vm.id domid x in
10801080
debug "%s" m;
10811081
raise (Bootloader_error (vm.Vm.id, x))
1082+
| Domain.Not_enough_memory m ->
1083+
debug "VM = %s; domid = %d; Domain.Not_enough_memory. Needed: %Ld bytes" vm.Vm.id domid m;
1084+
raise (Not_enough_memory m)
10821085
| e ->
1083-
let m = Printf.sprintf "VM = %s; domid = %d; Bootloader error: %s" vm.Vm.id domid (Printexc.to_string e) in
1086+
let m = Printf.sprintf "VM = %s; domid = %d; Error: %s" vm.Vm.id domid (Printexc.to_string e) in
10841087
debug "%s" m;
10851088
raise e
10861089

0 commit comments

Comments
 (0)