Skip to content

Commit 8f63fb2

Browse files
committed
Revert "Update VDI snapshot and parent links after import"
This reverts commit adedd51. Signed-off-by: Changlei Li <changlei.li@cloud.com>
1 parent 7fe7c20 commit 8f63fb2

1 file changed

Lines changed: 2 additions & 33 deletions

File tree

ocaml/xapi/import.ml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,37 +2073,7 @@ let handlers =
20732073
; (Datamodel_common._vtpm, VTPMHandler.handle)
20742074
]
20752075

2076-
(* If snapshot_of(x) = y, and both x and y are freshly imported VDIs,
2077-
the field must be rewritten to a real database reference. The same
2078-
relationship formed by parental links must be preserved as well.
2079-
2080-
We can't do this on-the-fly during an import because we can't
2081-
guarantee that the VDIs will be imported in reverse topological
2082-
order of the relation induced by snapshot_of. *)
2083-
let update_vdi_links ~__context state =
2084-
(* Map an exported reference to a (freshly) imported reference, or
2085-
null if it's not present in the import. *)
2086-
let resolve_import =
2087-
let tbl = Hashtbl.create 16 in
2088-
let go (_, a, b) = Hashtbl.replace tbl a (Ref.of_string b) in
2089-
List.iter go state.table ;
2090-
fun r ->
2091-
Hashtbl.find_opt tbl (Ref.string_of r) |> Option.value ~default:Ref.null
2092-
in
2093-
let update x =
2094-
let x_r = Db.VDI.get_record ~__context ~self:x in
2095-
let parent = resolve_import x_r.API.vDI_parent in
2096-
let snapshot_of = resolve_import x_r.API.vDI_snapshot_of in
2097-
Db.VDI.set_parent ~__context ~self:x ~value:parent ;
2098-
Db.VDI.set_snapshot_of ~__context ~self:x ~value:snapshot_of ;
2099-
Db.VDI.set_is_a_snapshot ~__context ~self:x ~value:(snapshot_of <> Ref.null)
2100-
in
2101-
let go (cls, _, r) =
2102-
if cls = Datamodel_common._vdi then update (Ref.of_string r)
2103-
in
2104-
List.iter go state.table
2105-
2106-
let update_vm_links ~__context state =
2076+
let update_snapshot_and_parent_links ~__context state =
21072077
let aux (cls, _, ref) =
21082078
let ref = Ref.of_string ref in
21092079
( if
@@ -2181,8 +2151,7 @@ let handle_all __context config rpc session_id (xs : obj list) =
21812151
false
21822152
in
21832153
if not dry_run then (
2184-
update_vm_links ~__context state ;
2185-
update_vdi_links ~__context state ;
2154+
update_snapshot_and_parent_links ~__context state ;
21862155
check_references ~__context state.table
21872156
) ;
21882157
state

0 commit comments

Comments
 (0)