Skip to content

Commit 47a8ba2

Browse files
committed
CA-424473 Fix OpaqueRef:NULL in vm import
The `check_references` function needs to skip null reference before calling `get_snapshot`, or it will try to fetch a database record for Ref.null, leading to an exception. Signed-off-by: Changlei Li <changlei.li@cloud.com>
1 parent 1492ded commit 47a8ba2

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

ocaml/xapi/import.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,12 +2138,16 @@ let check_references ~__context (table : table) =
21382138
(Diagnostic.show_path path)
21392139
(Ref.string_of r)
21402140
in
2141-
let rec go (clazz, _, r) =
2142-
match get_snapshot ~clazz ~r with
2143-
| Some record ->
2144-
Diagnostic.visit_references check_reference clazz record
2145-
| _ ->
2146-
debug "Could not find imported object %s" r
2141+
let go (clazz, _, r) =
2142+
(* Ref.null will lead to a get_record failure *)
2143+
if Ref.of_string r = Ref.null then
2144+
()
2145+
else
2146+
match get_snapshot ~clazz ~r with
2147+
| Some record ->
2148+
Diagnostic.visit_references check_reference clazz record
2149+
| _ ->
2150+
debug "Could not find imported object %s" r
21472151
in
21482152
List.iter go table
21492153

0 commit comments

Comments
 (0)