Skip to content

Commit f1b9bfe

Browse files
committed
xapi_vm_snapshot: Fail VM.revert when a VDI.revert actually fails
In case where there's an error while reverting on the Storage Backend, the state of the SR might become unstable, and a recovery using the clone method for reverting might introduce bigger issues. Instead stop the revert immediately. The cases where ignoring the errors is acceptable is when either the SR does not advertise support for VDI_REVERT, and when the SR does not implement revert for a particular VDI. for example, if the SR implements the revert for only some of the formats it implements. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech> (cherry picked from commit f887de1)
1 parent 67d7c92 commit f1b9bfe

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

ocaml/xapi/storage_smapiv1.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,13 @@ module SMAPIv1 : Server_impl = struct
11361136
let revert _context ~dbg ~sr ~snapshot_info =
11371137
with_dbg ~name:"VDI.revert" ~dbg @@ fun di ->
11381138
let dbg = Debug_info.to_string di in
1139-
Server_helpers.exec_with_new_task "VDI.revert"
1140-
~subtask_of:(Ref.of_string dbg) (fun __context ->
1141-
call_revert ~__context ~dbg ~sr ~snapshot_info
1142-
)
1139+
try
1140+
Server_helpers.exec_with_new_task "VDI.revert"
1141+
~subtask_of:(Ref.of_string dbg) (fun __context ->
1142+
call_revert ~__context ~dbg ~sr ~snapshot_info
1143+
)
1144+
with Smint.Not_implemented_in_backend ->
1145+
raise (Storage_error (Unimplemented "VDI.revert"))
11431146
end
11441147

11451148
let get_by_name _context ~dbg:_ ~name:_ = assert false

ocaml/xapi/xapi_vdi.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,10 +1138,13 @@ let revert' ~__context ~snapshot =
11381138
C.VDI.revert (Ref.string_of task) sr' snapshot_info
11391139

11401140
let revert ~__context ~snapshot =
1141+
let __FUN = __FUNCTION__ in
11411142
Storage_utils.transform_storage_exn @@ fun () ->
11421143
try revert' ~__context ~snapshot
11431144
with Storage_interface.Storage_error (Unimplemented _) ->
11441145
let msg = [Ref.string_of (Db.VDI.get_SR ~__context ~self:snapshot)] in
1146+
debug "%s: Backend reported not implemented despite it offering the feature"
1147+
__FUN ;
11451148
raise Api_errors.(Server_error (unimplemented_in_sm_backend, msg))
11461149

11471150
let copy ~__context ~vdi ~sr ~base_vdi ~into_vdi =

ocaml/xapi/xapi_vm_snapshot.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,12 @@ let revert_vbds ~__context ~rpc ~session_id ~snapshot ~vm =
274274
try
275275
Client.VDI.revert ~rpc ~session_id ~snapshot ;
276276
true
277-
with _ -> false
277+
with
278+
| Api_errors.(Server_error (e, _))
279+
when e = Api_errors.sr_operation_not_supported
280+
|| e = Api_errors.unimplemented_in_sm_backend
281+
->
282+
false
278283
)
279284
snap_disks_all
280285
in

0 commit comments

Comments
 (0)